ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtGas.cxx
Go to the documentation of this file.
1 // This class header
2 #include "AtGas.h"
3 
4 #include <cstdlib>
5 #include <fstream> // IWYU pragma: keep
6 #include <iostream>
7 #include <sstream> // IWYU pragma: keep
8 #include <string>
9 #include <utility>
10 
11 // ROOT class headers
12 #include <Rtypes.h>
13 #include <TRandom.h>
14 #include <TString.h>
15 
16 using namespace std;
17 
19 
20  AtGas::AtGas(TString GasFileName)
21  : fGasFileName(std::move(GasFileName))
22 {
23  InitializeParameters();
24 }
25 
26 void AtGas::InitializeParameters()
27 {
28  ifstream gasFile(fGasFileName.Data(), std::fstream::in);
29  if (!gasFile)
30  cerr << "Gas file " << fGasFileName.Data() << " not found!!" << endl;
31 
32  string line;
33  string data;
34  string name;
35  string format;
36  string val;
37 
38  while (getline(gasFile, line)) {
39  istringstream ss_line(line);
40  if (ss_line >> data >> val && data[0] != '#' && data[0] != '[') {
41  name = data.substr(0, data.find(":"));
42  // name = strtok(data.c_str(),":");
43  // format = strtok(NULL,":");
44  if (name == "EIonizeP10")
45  fEIonize = atof(val.c_str());
46  if (name == "DriftVelocity")
47  fDriftVelocity = atof(val.c_str());
48  if (name == "CoefAttachment")
49  fCoefAttachment = atof(val.c_str());
50  if (name == "CoefDiffusionLong")
51  fCoefDiffusionLong = atof(val.c_str());
52  if (name == "CoefDiffusionTrans")
53  fCoefDiffusionTrans = atof(val.c_str());
54  if (name == "Gain")
55  fGain = atoi(val.c_str());
56  }
57  }
58 }
59 
60 void AtGas::operator=(const AtGas &GasToCopy)
61 {
62  fEIonize = GasToCopy.fEIonize;
63  fDriftVelocity = GasToCopy.fDriftVelocity;
64  fCoefAttachment = GasToCopy.fCoefAttachment;
65  fCoefDiffusionLong = GasToCopy.fCoefDiffusionLong;
66  fCoefDiffusionTrans = GasToCopy.fCoefDiffusionTrans;
67  fGain = GasToCopy.fGain;
68 }
69 
71 {
72  return fEIonize;
73 }
75 {
76  return fDriftVelocity;
77 }
79 {
80  return fCoefAttachment;
81 }
83 {
84  return fCoefDiffusionLong;
85 }
87 {
88  return fCoefDiffusionTrans;
89 }
91 {
92  return fGain;
93 }
95 {
96  auto CS = (UInt_t)(gRandom->Gaus(50, 20));
97  if (CS <= 0)
98  CS = 1;
99  return CS;
100 }
AtGas::GetGain
Int_t GetGain()
Definition: AtGas.cxx:90
AtGas::AtGas
AtGas(TString)
AtGas::GetCoefAttachment
Double_t GetCoefAttachment()
Definition: AtGas.cxx:78
AtGas::GetDriftVelocity
Double_t GetDriftVelocity()
Definition: AtGas.cxx:74
ClassImp
ClassImp(AtGas) AtGas
Definition: AtGas.cxx:18
AtGas::GetCoefDiffusionTrans
Double_t GetCoefDiffusionTrans()
Definition: AtGas.cxx:86
AtGas::GetRandomCS
UInt_t GetRandomCS()
Definition: AtGas.cxx:94
AtGas.h
AtGas::operator=
void operator=(const AtGas &GasToCopy)
Definition: AtGas.cxx:60
AtGas
Definition: AtGas.h:12
AtGas::GetCoefDiffusionLong
Double_t GetCoefDiffusionLong()
Definition: AtGas.cxx:82
AtGas::GetEIonize
Double_t GetEIonize()
Definition: AtGas.cxx:70