23 #ifndef RestCore_TRestDetectorGas
24 #define RestCore_TRestDetectorGas
26 #include <TApplication.h>
33 #include <TRestMetadata.h>
42 #include "TRestDetectorDriftVolume.h"
44 #if defined USE_Garfield
45 #include <ComponentConstant.hh>
46 #include <GeometrySimple.hh>
47 #include <MediumMagboltz.hh>
49 #include <SolidBox.hh>
50 #include <TrackHeed.hh>
51 using namespace Garfield;
56 const int RESTGAS_ERROR = -1;
57 const int RESTGAS_INTITIALIZED = 0;
58 const int RESTGAS_CFG_LOADED = 1;
59 const int RESTGAS_GASFILE_LOADED = 2;
65 MediumMagboltz* fGasMedium;
75 Double_t fMaxElectronEnergy;
78 std::vector<TString> fGasComponentName;
80 std::vector<Double_t> fGasComponentFraction;
89 std::vector<Double_t> fEFields;
91 std::vector<Double_t> fBFields;
93 std::vector<Double_t> fAngles;
95 TString fGDMLMaterialRef;
111 Bool_t fTest =
false;
113 void InitFromConfigFile()
override;
114 std::string ConstructFilename();
116 void AddGasComponent(std::string gasName, Double_t fraction);
118 void GenerateGasFile();
120 void UploadGasToServer(std::string gasFilename);
122 Double_t GetDriftVelocity(Double_t E);
123 Double_t GetLongitudinalDiffusion(Double_t E);
124 Double_t GetTransversalDiffusion(Double_t E);
125 Double_t GetTownsendCoefficient(Double_t E);
126 Double_t GetAttachmentCoefficient(Double_t E);
130 TRestDetectorGas(
const char* configFilename, std::string name =
"",
bool gasGeneration =
false,
142 inline bool GasFileLoaded()
const {
return fStatus == RESTGAS_GASFILE_LOADED; }
144 void Initialize()
override;
148 std::string FindGasFile(std::string name);
150 void CalcGarField(
double Emin,
double Emax,
int n);
152 Int_t Write(
const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
override;
154 void InitFromRootFile()
override;
165 if (n >= GetNofGases()) {
166 std::cout <<
"REST WARNING. Gas name component n=" << n <<
" requested. But only "
167 << GetNofGases() <<
" component(s) in the mixture." << std::endl;
170 return fGasComponentName[n];
173 TString GetGasMixture();
176 if (fElectricField == 0) {
177 RESTWarning <<
"TRestDetectorGas::GetDriftVelocity. Warning fElectricField is zero!" << RESTendl;
178 RESTWarning <<
" - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
181 return GetDriftVelocity(fElectricField *
units(
"V/cm")) /
units(
"cm/us");
186 if (fElectricField == 0) {
187 RESTWarning <<
"TRestDetectorGas::GetLongitudinalDiffusion. Warning fElectricField is zero!"
189 RESTWarning <<
" - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
192 return GetLongitudinalDiffusion(fElectricField *
units(
"V/cm"));
197 if (fElectricField == 0) {
198 RESTWarning <<
"TRestDetectorGas::GetTransversalDiffusion. Warning fElectricField is zero!"
200 RESTWarning <<
" - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
203 return GetTransversalDiffusion(fElectricField *
units(
"V/cm"));
206 Double_t GetTownsendCoefficient()
override {
207 if (fElectricField == 0) {
208 RESTWarning <<
"TRestDetectorGas::GetTownsendCoefficient. Warning fElectricField is zero!"
210 RESTWarning <<
" - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
213 return GetTownsendCoefficient(fElectricField *
units(
"V/cm"));
216 Double_t GetAttachmentCoefficient()
override {
217 if (fElectricField == 0) {
218 RESTWarning <<
"TRestDetectorGas::GetAttachmentCoefficient. Warning fElectricField is zero!"
220 RESTWarning <<
" - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
223 return GetAttachmentCoefficient(fElectricField *
units(
"V/cm"));
226 void GetGasWorkFunction();
230 if (n >= GetNofGases()) {
231 std::cout <<
"REST WARNING. Gas fraction for component n=" << n <<
" requested. But only "
232 << GetNofGases() <<
" component(s) in the mixture." << std::endl;
236 return fGasComponentFraction[n];
245 void SetPressure(Double_t pressure)
override;
246 void SetTemperature(Double_t temperature)
override;
251 void PlotDriftVelocity(Double_t eMin, Double_t eMax, Int_t nSteps);
252 void PlotLongitudinalDiffusion(Double_t eMin, Double_t eMax, Int_t nSteps);
253 void PlotTransversalDiffusion(Double_t eMin, Double_t eMax, Int_t nSteps);
254 void PlotTownsendCoefficient(Double_t eMin, Double_t eMax, Int_t nSteps);
256 inline void PrintGasFileContent() { std::cout << fGasFileContent << std::endl; };
bool GasFileGenerationEnabled() const
Returns true if the file generation is enabled. False otherwise.
void EnableGasGeneration()
void PrintMetadata() override
Prints the metadata information from the gas.
TString GetGasComponentName(Int_t n)
Returns the gas component n.
Int_t GetNofGases() const
Returns the number of gas elements/compounds present in the gas mixture.
bool GasFileLoaded() const
Returns true if the gas file has been properly loaded. False otherwise.
Double_t GetTransversalDiffusion() override
Returns the transversal diffusion in (cm)^1/2.
Double_t GetMaxElectronEnergy() const
Double_t GetDriftVelocity() override
Returns the drift velocity in mm/us.
MediumMagboltz * GetGasMedium() const
Return pointer to Garfield::MediumGas for gas properties.
TString GetGDMLMaterialRef() const
Return reference name of the corresponding material in GDML file.
Double_t GetGasComponentFraction(Int_t n)
Returns the gas fraction in volume for component n.
void SetMaxElectronEnergy(Double_t energy)
Sets the maximum electron energy to be used in gas generation.
Double_t GetLongitudinalDiffusion() override
Returns the longitudinal diffusion in (cm)^1/2.