216 #include "TRestDetectorGas.h"
218 #include <TRestDataBase.h>
234 fGasGeneration =
false;
252 fGasGeneration = gasGeneration;
256 if (strcmp(configFilename,
"server") == 0) {
271 RESTDebug <<
"Entering ... TRestDetectorGas() destructor." <<
RESTendl;
273 #if defined USE_Garfield
283 RESTDebug <<
"TRestDetectorGas. Entering ... Initialize()." <<
RESTendl;
289 fTemperatureInK = 300;
293 fGasComponentName.clear();
294 fGasComponentFraction.clear();
296 fStatus = RESTGAS_INTITIALIZED;
301 #if defined USE_Garfield
302 fGasMedium =
new Garfield::MediumMagboltz();
304 fGasMedium =
nullptr;
328 RESTDebug <<
"Entering ... TRestDetectorGas::LoadGasFile()." <<
RESTendl;
330 #if defined USE_Garfield
331 RESTDebug <<
"fGasFilename = " << fGasFilename <<
RESTendl;
333 RESTError << __PRETTY_FUNCTION__ <<
RESTendl;
334 RESTError <<
"The gas file does not exist. (name:" << fGasFilename <<
")" <<
RESTendl;
339 fGasMedium->LoadGasFile((
string)(fGasFilename));
344 fGasMedium->GetFieldGrid(fEFields, fBFields, fAngles);
346 fStatus = RESTGAS_GASFILE_LOADED;
347 RESTInfo <<
"TRestDetectorGas. Gas file loaded!" <<
RESTendl;
349 for (
unsigned int i = 0; i < fEFields.size(); i++)
350 RESTDebug <<
"node " << i <<
" Field : " << fEFields[i] <<
" V/cm" <<
RESTendl;
352 if (fGasMedium && fGasMedium->GetW() == 0.) {
353 fGasMedium->SetW(GetWvalue());
356 cout <<
"This REST is not complied with garfield, it cannot load any gas file!" << endl;
360 void TRestDetectorGas::CalcGarField(
double Emin,
double Emax,
int n) {
361 RESTDebug <<
"Entering ... TRestDetectorGas::CalcGarField( Emin=" << Emin <<
" , Emax=" << Emax <<
" )"
364 #if defined USE_Garfield
366 cout <<
"REST ERROR : The number of nodes is not a positive number!!. Gas "
367 "file generation cancelled."
372 if (fEmin >= fEmax) {
373 cout <<
"REST ERROR : The Electric field grid boundaries are not properly "
381 for (
int i = 0; i < fNofGases; i++) {
382 gasStr[i] = (string)fGasComponentName[i];
386 if (fNofGases == 1) fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100.);
389 fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100., gasStr[1],
390 fGasComponentFraction[1] * 100.);
393 fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100., gasStr[1],
394 fGasComponentFraction[1] * 100., gasStr[2],
395 fGasComponentFraction[2] * 100.);
398 cout <<
"REST ERROR : Number of gas components higher than 3 not allowed" << endl;
403 fGasMedium->SetTemperature(fTemperatureInK);
405 if (fPressureInAtm != 1)
406 RESTWarning <<
"-- Warning : The gas will be generated for gas pressure = 1atm" <<
RESTendl;
408 fGasMedium->SetPressure(1 * REST_Units::torr);
410 fGasMedium->SetFieldGrid(Emin, Emax, n, n > 1);
412 fGasMedium->SetMaxElectronEnergy(fMaxElectronEnergy);
414 cout <<
"Garfield: calculating..." << endl;
417 fGasMedium->Initialise();
420 fGasMedium->GenerateGasTable(fNCollisions,
true);
421 if (fPressureInAtm != 1) {
422 RESTWarning <<
"-- Warning : Restoring the gas pressure" <<
RESTendl;
423 fGasMedium->SetPressure(fPressureInAtm * 760.);
426 cout <<
"This REST is not complied with garfield, it cannot calculate "
442 RESTDebug <<
"Entering ... TRestDetectorGas::AddGasComponent( gasName=" << gasName
443 <<
" , fraction=" << fraction <<
" )" <<
RESTendl;
445 fGasComponentName.push_back(gasName);
446 fGasComponentFraction.push_back(fraction);
453 void TRestDetectorGas::GetGasWorkFunction() {
454 #if defined USE_Garfield
455 RESTEssential << __PRETTY_FUNCTION__ <<
RESTendl;
456 RESTEssential <<
"This method has never been validated to operate properly" <<
RESTendl;
457 RESTEssential <<
"If we manage to make it work we could use this method to "
458 "obtain the calculated W of the gas"
462 const double width = 1.;
463 SolidBox* box =
new SolidBox(width / 2., 0., 0., width / 2., 10., 10.);
464 GeometrySimple* geo =
new GeometrySimple();
465 geo->AddSolid(box, fGasMedium);
467 ComponentConstant* cmp =
new ComponentConstant();
468 cmp->SetGeometry(geo);
469 cmp->SetElectricField(100., 0., 0.);
471 Sensor* sensor =
new Sensor();
472 sensor->AddComponent(cmp);
474 TrackHeed* heed =
new TrackHeed();
475 heed->SetSensor(sensor);
477 heed->SetParticle(
"pi");
479 heed->SetMomentum(120.e9);
483 heed->EnableDebugging();
485 double x0 = 0., y0 = 0., z0 = 0., t0 = 0.;
487 double dx0 = 1., dy0 = 0., dz0 = 0.;
488 heed->NewTrack(x0, y0, z0, t0, dx0, dy0, dz0);
489 cout <<
"W : " << heed->GetW() << endl;
491 cout <<
"This REST is not complied with garfield, it cannot calculate "
508 RESTDebug <<
"Entering ... TRestDetectorGas::InitFromConfigFile()" <<
RESTendl;
514 cout <<
"Setting default W-value : " << fW << endl;
518 string _gasServer = gDataBase->
query_data(DBEntry(0,
"GAS_SERVER")).value;
519 if (_gasServer ==
"") _gasServer =
"none";
523 TiXmlElement* gasComponentDefinition =
GetElement(
"gasComponent");
524 while (gasComponentDefinition !=
nullptr) {
525 string gasName =
GetFieldValue(
"name", gasComponentDefinition);
530 if (fNofGases == 0 && fMaterial !=
"") {
531 vector<string> componentsdef =
Split(fMaterial,
" ");
532 for (
auto componentdef : componentsdef) {
533 vector<string> componentdefpair =
Split(componentdef,
":");
534 if (componentdefpair.size() != 2) {
540 if (fNofGases == 0) {
541 RESTError <<
"TRestDetectorGas: No gas components added!" <<
RESTendl;
548 RESTWarning <<
"TRestDetectorGas : The total gas fractions is NOT 1." <<
RESTendl;
554 TiXmlElement* eFieldDefinition =
GetElement(
"eField");
561 fGasGeneration =
true;
564 RESTWarning <<
"-- Warning : The specified gasOutputPath is not writable!" <<
RESTendl;
565 RESTWarning <<
"-- Warning : The output path will be changed to ./" <<
RESTendl;
572 RESTDebug <<
"TRestDetectorGas::InitFromConfigFile. ConstructFilename. fGasFilename = " << fGasFilename
575 RESTDebug <<
"TRestDetectorGas::InitFromConfigFile. FindGasFile. fGasFilename = " << fGasFilename
580 fGasGeneration =
false;
582 RESTWarning <<
"TRestDetectorGas gasFile generation is enabled, but the "
583 "gasFile already exists!!"
585 RESTWarning <<
"Filename : " << fGasFilename <<
RESTendl;
586 RESTWarning <<
"fGasGeneration should be disabled to remove this "
589 RESTWarning <<
"If you really want to re-generate the gas file you "
590 "will need to disable the gasServer."
592 RESTWarning <<
"And/or remove any local copies that are found by "
598 #if defined USE_Garfield
600 if (fGasGeneration) {
601 RESTEssential <<
"Starting gas generation" <<
RESTendl;
603 CalcGarField(fEmin, fEmax, fEnodes);
605 fStatus = RESTGAS_GASFILE_LOADED;
608 fGasMedium->SetPressure(fPressureInAtm * REST_Units::torr);
610 if (fGasMedium && fGasMedium->GetW() == 0.)
611 fGasMedium->SetW(fW);
618 RESTDebug <<
"Entering ... TRestDetectorGas::InitFromRootFile()" <<
RESTendl;
622 fGasFilename =
"/tmp/restGasFile_" + REST_USER +
".gas";
624 outf.open(fGasFilename, ios::ate);
628 int z = system(
"rm " + fGasFilename);
629 if (z != 0) RESTError <<
"Problem removing gas file: " << fGasFilename <<
RESTendl;
632 if (fGasFilename !=
"") {
638 void TRestDetectorGas::UploadGasToServer(
string absoluteGasFilename) {
639 RESTEssential <<
"uploading gas file and gas definition rmls" <<
RESTendl;
641 if (!fTest && (fMaxElectronEnergy < 400 || fNCollisions < 10 || fEnodes < 20)) {
642 RESTWarning <<
"-- Warning : The gas file does not fulfill the requirements "
643 "for being uploaded to the gasServer"
645 RESTWarning <<
"-- Warning : maxElectronEnergy >= 400. Number of collisions >= "
646 "10. Number of E nodes >= 20."
648 RESTWarning <<
"-- Warning : The generated file will NOT be uploaded to the "
649 "server but preserved locally."
660 string url = gDataBase->
query_data(DBEntry(0,
"META_RML",
"TRestDetectorGas")).value;
665 cmd =
"sed -i '' -e '$ d' " + fname;
667 cmd =
"sed -i '$ d' " + fname;
670 a = system(cmd.c_str());
673 RESTError <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
674 RESTError <<
"-- Error : problem removing last line from " << fname <<
RESTendl;
681 outf.open(fname, ios::app);
683 outf <<
"//------- User : " << REST_USER <<
" ---- REST version : " << REST_RELEASE
684 <<
" ---------------------------" << endl;
691 outf.open(fname, ios::app);
692 outf <<
"\n" << endl;
693 outf <<
"</gases>" << endl;
716 RESTSuccess <<
"-- Success : Gasfile server database was updated successfully!" <<
RESTendl;
734 RESTDebug <<
"Entering ... TRestDetectorGas::FindGasFile( name=" << name <<
" )" <<
RESTendl;
736 string absoluteName =
"";
738 if (!fGasGeneration &&
fGasServer !=
"none") {
742 if (absoluteName ==
"") {
743 RESTInfo <<
"Trying to find the gasFile locally" <<
RESTendl;
745 if (absoluteName ==
"") {
746 RESTWarning <<
"-- Warning : No sucess finding local gas file definition." <<
RESTendl;
747 RESTWarning <<
"-- Warning : Gas file definition does not exist." <<
RESTendl;
748 RESTInfo <<
"To generate a new gasFile enable gas generation in TRestDetectorGas "
751 RESTInfo <<
"TRestDetectorGas ( \"gasDefinition.rml\", \"gas Name\", true );" <<
RESTendl;
752 RESTInfo <<
"Further details can be found at TRestDetectorGas class definition and "
767 RESTDebug <<
"Entering ... TRestDetectorGas::GetGasMixture( )" <<
RESTendl;
771 for (
int n = 0; n < fNofGases; n++) {
772 if (n > 0) gasMixture +=
"-";
775 gasMixture += (TString)tmpStr;
787 RESTDebug <<
"Entering ... TRestDetectorGas::ConstructFilename( )" <<
RESTendl;
791 for (
int n = 0; n < fNofGases; n++) {
792 if (n > 0) name +=
"-";
799 name += (TString)tmpStr;
807 sprintf(tmpStr,
"%03.1lf", fEmin);
808 name += (TString)tmpStr;
811 sprintf(tmpStr,
"%03.1lf", fEmax);
812 name += (TString)tmpStr;
815 sprintf(tmpStr,
"%02d", fEnodes);
816 name += (TString)tmpStr;
819 sprintf(tmpStr,
"%02d", fNCollisions);
820 name += (TString)tmpStr;
823 sprintf(tmpStr,
"%03d", (Int_t)fMaxElectronEnergy);
824 name += (TString)tmpStr;
828 RESTDebug <<
"Constructed filename : " << name <<
RESTendl;
835 RESTDebug <<
"Entering ... TRestDetectorGas::GenerateGasFile( )" <<
RESTendl;
837 #if defined USE_Garfield
840 RESTDebug <<
" TRestDetectorGas::GenerateGasFile. fGasFilename = " << fGasFilename <<
RESTendl;
844 RESTWarning <<
"-- Warning: REST ERROR. TRestDetectorGas. Path is not writtable." <<
RESTendl;
846 RESTWarning <<
"-- Warning: Make sure the final data path is writtable before "
847 "proceed to gas generation."
849 RESTWarning <<
"-- Warning: or change the gas data path ... " <<
RESTendl;
855 cout <<
"Writing gas file : " << endl;
856 cout <<
"-----------------" << endl;
858 cout <<
"Filename : " << fGasFilename << endl;
860 fGasMedium->WriteGasFile((
string)(
fGasOutputPath +
"/" + fGasFilename));
865 cout <<
"This REST is not complied with garfield, it cannot save any gas file!" << endl;
879 RESTDebug <<
"Entering ... TRestDetectorGas::SetPressure( pressure=" << pressure <<
" )" <<
RESTendl;
881 fPressureInAtm = pressure;
882 #if defined USE_Garfield
883 fGasMedium->SetPressure(fPressureInAtm * REST_Units::torr);
890 RESTDebug <<
"Entering ... TRestDetectorGas::SetPressure( temperature=" << temperature <<
" )"
893 fTemperatureInK = temperature;
894 #if defined USE_Garfield
895 fGasMedium->SetTemperature(temperature);
908 RESTDebug <<
"Entering ... TRestDetectorGas::PlotDriftVelocity( eMin=" << eMin <<
" , eMax=" << eMax
909 <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
911 vector<Double_t> eField(nSteps), driftVel(nSteps);
913 for (
int i = 0; i < nSteps; i++) {
914 eField[i] = (eMin + (double)i * (eMax - eMin) / nSteps);
920 TCanvas* c =
new TCanvas(
"Drift velocity",
" ");
921 TGraph* fDriftVel =
new TGraph(nSteps, &eField[0], &driftVel[0]);
923 str.Form(
"Drift Velocity for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
924 fDriftVel->SetTitle(str);
925 fDriftVel->GetXaxis()->SetTitle(
"E [V/cm]");
926 fDriftVel->GetYaxis()->SetTitle(
"Drift velocity [cm/#mus]");
927 fDriftVel->GetYaxis()->SetTitleOffset(2);
941 RESTDebug <<
"Entering ... TRestDetectorGas::PlotLongitudinalDiffusion( eMin=" << eMin
942 <<
" , eMax=" << eMax <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
944 vector<Double_t> eField(nSteps), longDiff(nSteps);
946 for (
int i = 0; i < nSteps; i++) {
947 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
953 TCanvas* c =
new TCanvas(
"Longitudinal diffusion",
" ");
954 TGraph* fLongDiff =
new TGraph(nSteps, &eField[0], &longDiff[0]);
956 str.Form(
"Longitudinal diffusion for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
957 fLongDiff->SetTitle(str);
958 fLongDiff->GetXaxis()->SetTitle(
"E [V/cm]");
959 fLongDiff->GetYaxis()->SetTitle(
"Longitudinal diffusion [mm/#sqrt{cm}]");
960 fLongDiff->GetYaxis()->SetTitleOffset(2);
974 RESTDebug <<
"Entering ... TRestDetectorGas::PlotTransversalDiffusion( eMin=" << eMin
975 <<
" , eMax=" << eMax <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
977 vector<Double_t> eField(nSteps), transDiff(nSteps);
979 for (
int i = 0; i < nSteps; i++) {
980 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
986 TCanvas* c =
new TCanvas(
"Transitudinal diffusion",
" ");
987 TGraph* fTransDiff =
new TGraph(nSteps, &eField[0], &transDiff[0]);
989 str.Form(
"Transversal diffusion for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
990 fTransDiff->SetTitle(str);
991 fTransDiff->GetXaxis()->SetTitle(
"E [V/cm]");
992 fTransDiff->GetYaxis()->SetTitle(
"Transversal diffusion [mm/#sqrt{cm}]");
993 fTransDiff->GetYaxis()->SetTitleOffset(2);
994 fTransDiff->Draw(
"");
1007 RESTDebug <<
"Entering ... TRestDetectorGas::PlotTownsendCoefficient( eMin=" << eMin <<
" , eMax=" << eMax
1008 <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
1010 vector<Double_t> eField(nSteps), townsendCoeff(nSteps);
1012 for (
int i = 0; i < nSteps; i++) {
1013 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
1018 TCanvas* c =
new TCanvas(
"Townsend coefficient",
" ");
1019 TGraph* fTownsend =
new TGraph(nSteps, &eField[0], &townsendCoeff[0]);
1021 str.Form(
"Townsend coefficient for %s", GetName());
1022 fTownsend->SetTitle(str);
1023 fTownsend->GetXaxis()->SetTitle(
"E [V/cm]");
1024 fTownsend->GetYaxis()->SetTitle(
"Townsend coefficient [1/cm]");
1025 fTownsend->GetYaxis()->SetTitleOffset(2);
1026 fTownsend->Draw(
"");
1035 RESTDebug <<
"Entering ... TRestDetectorGas::GetDriftVelocity( E=" << E <<
" )" <<
RESTendl;
1039 #if defined USE_Garfield
1040 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1041 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1042 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1046 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1047 <<
"from REST standard unit. E is V/cm. The return is cm/us" <<
RESTendl;
1049 Double_t vx, vy, vz;
1050 fGasMedium->ElectronVelocity(0., 0, -E, 0, 0, 0, vx, vy, vz);
1053 std::cout <<
"This REST is not complied with garfield, Do not use Drift Velocity "
1054 "from TRestDetectorGas!"
1056 std::cout <<
"Please define the Drift Velocity in each process!" << std::endl;
1066 RESTDebug <<
"Entering ... TRestDetectorGas::GetLongitudinalDiffusion( E=" << E <<
" )" <<
RESTendl;
1070 #if defined USE_Garfield
1071 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1072 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1073 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1077 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1078 <<
"from REST standard unit. E is V/cm. The return is cm^1/2" <<
RESTendl;
1081 fGasMedium->ElectronDiffusion(0., 0, -E, 0, 0, 0, dl, dt);
1084 std::cout <<
"This REST is not compiled with garfield, Do not use Longitudinal "
1085 "Diffusion from TRestDetectorGas!"
1087 std::cout <<
"Please define the Longitudinal Diffusion in each process!" << std::endl;
1097 RESTDebug <<
"Entering ... TRestDetectorGas::GetTransversalDiffusion( E=" << E <<
" )" <<
RESTendl;
1100 #if defined USE_Garfield
1101 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1102 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1103 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1107 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1108 <<
"from REST standard unit. E is V/cm. The return is cm^1/2" <<
RESTendl;
1111 fGasMedium->ElectronDiffusion(0., 0, -E, 0, 0, 0, dl, dt);
1114 std::cout <<
"This REST is not complied with garfield, Do not use Transversal "
1115 "Diffusion from TRestDetectorGas!"
1117 std::cout <<
"Please define the Transversal Diffusion in each process!" << std::endl;
1127 RESTDebug <<
"Entering ... TRestDetectorGas::GetTownsendCoefficient( E=" << E <<
" )" <<
RESTendl;
1130 #if defined USE_Garfield
1131 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1132 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1133 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1137 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1138 <<
"from REST standard unit. E is V/cm. The return is V/cm" <<
RESTendl;
1141 fGasMedium->ElectronTownsend(0., 0, -E, 0, 0, 0, alpha);
1144 std::cout <<
"This REST is not complied with garfield, Do not use Townsend "
1145 "Coefficient from TRestDetectorGas!"
1147 std::cout <<
"Please define the Townsend Coefficient in each process!" << std::endl;
1157 RESTDebug <<
"Entering ... TRestDetectorGas::GetAttachmentCoefficient( E=" << E <<
" )" <<
RESTendl;
1160 #if defined USE_Garfield
1161 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1162 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1163 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1167 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1168 <<
"from REST standard unit. E is V/cm. The return is V/cm" <<
RESTendl;
1171 fGasMedium->ElectronAttachment(0., 0, -E, 0, 0, 0, eta);
1174 std::cout <<
"This REST is not complied with garfield, Do not use Attachment "
1175 "Coefficient from TRestDetectorGas!"
1177 std::cout <<
"Please define the Attachment Coefficient in each process!" << std::endl;
1186 RESTDebug <<
"Entering ... TRestDetectorGas::PrintGasInfo( )" <<
RESTendl;
1190 RESTMetadata <<
"Status : ";
1191 if (
fStatus == RESTGAS_INTITIALIZED) RESTMetadata <<
"Initialized";
1192 if (
fStatus == RESTGAS_CFG_LOADED) RESTMetadata <<
"Configuration loaded";
1193 if (
fStatus == RESTGAS_GASFILE_LOADED) RESTMetadata <<
"Gasfile loaded";
1194 if (
fStatus == RESTGAS_ERROR) RESTMetadata <<
"Error";
1198 RESTMetadata <<
"Pressure : " << fPressureInAtm <<
" atm" <<
RESTendl;
1199 RESTMetadata <<
"Temperature : " << fTemperatureInK <<
" K" <<
RESTendl;
1200 RESTMetadata <<
"Electric Field : " << fElectricField *
units(
"V/cm") <<
" V/cm " <<
RESTendl;
1201 RESTMetadata <<
"W-value : " << fW <<
" eV" <<
RESTendl;
1204 RESTMetadata <<
"Max. Electron energy : " << fMaxElectronEnergy <<
" eV" <<
RESTendl;
1205 RESTMetadata <<
"Field grid nodes : " << fEnodes <<
RESTendl;
1206 RESTMetadata <<
"Efield range : ( " << fEmin <<
" , " << fEmax <<
" ) V/cm " <<
RESTendl;
1207 RESTMetadata <<
"Number of Gases : " << fNofGases <<
RESTendl;
1208 for (
int i = 0; i < fNofGases; i++)
1209 RESTMetadata <<
"Gas id : " << i <<
", Name : " << fGasComponentName[i]
1210 <<
", Fraction : " << fGasComponentFraction[i] <<
RESTendl;
1211 RESTMetadata <<
"******************************************" <<
RESTendl;
1217 RESTDebug <<
"Entering ... TRestDetectorGas::Write( name=" << name <<
" option=" << option
1218 <<
" bufsize=" << bufsize <<
" )" <<
RESTendl;
1222 infile.open(fGasFilename);
1224 cout <<
"TRestDetectorGas: error reading gas file, gas file content won't be "
1229 while (getline(infile, str)) {
virtual DBEntry query_data(DBEntry info)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
virtual void SetElectricField(double value)
Sets the electric field. Must be given in V/mm.
std::string ConstructFilename()
Constructs the filename of the pre-generated gas file using the members defined in the RML file.
void InitFromConfigFile() override
Loads the gas parameters that define the gas calculation and properties.
void InitFromRootFile() override
Method called after the object is retrieved from root file.
TString GetGasComponentName(Int_t n)
Returns the gas component n.
void PrintGasInfo()
Prints the metadata information from the gas.
void PlotTransversalDiffusion(Double_t eMin, Double_t eMax, Int_t nSteps)
It creates a TCanvas where it plots the transversal diffusion as a function of the electric field.
bool GasFileLoaded() const
Returns true if the gas file has been properly loaded. False otherwise.
Double_t GetAttachmentCoefficient(Double_t E)
It returns the attachment coefficient for a given electric field in V/cm.
Double_t GetTransversalDiffusion() override
Returns the transversal diffusion in (cm)^1/2.
TString GetGasMixture()
Returns a string defining the gas components and fractions.
void SetPressure(Double_t pressure) override
Defines the pressure of the gas.
~TRestDetectorGas()
TRestDetectorGas default destructor.
void PlotTownsendCoefficient(Double_t eMin, Double_t eMax, Int_t nSteps)
It creates a TCanvas where it plots the townsend coefficient as a function of the electric field.
TRestDetectorGas()
TRestDetectorGas default constructor.
Double_t GetDriftVelocity() override
Returns the drift velocity in mm/us.
Double_t GetTownsendCoefficient(Double_t E)
It returns the townsend coefficient for a given electric field in V/cm.
void SetTemperature(Double_t temperature) override
Defines the temperature of the gas.
Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0) override
overwriting the write() method with fStore considered
void LoadGasFile()
It loads a pre-generated gas file corresponding to the gas defined using the RML TRestDetectorGas sec...
void Initialize() override
Defines the metadata section name and initalizes the TRestDetectorGas members.
void AddGasComponent(std::string gasName, Double_t fraction)
Adds a new element/compound to the gas.
std::string FindGasFile(std::string name)
This method tries to find the gas filename given in the argument.
void PlotDriftVelocity(Double_t eMin, Double_t eMax, Int_t nSteps)
It creates a TCanvas where it plots the drift velocity as a function of the electric field.
void PlotLongitudinalDiffusion(Double_t eMin, Double_t eMax, Int_t nSteps)
It creates a TCanvas where it plots the longitudinal diffusion as a function of the electric field.
void GenerateGasFile()
Save a gas file with a structured file name.
Double_t GetGasComponentFraction(Int_t n)
Returns the gas fraction in volume for component n.
Double_t GetLongitudinalDiffusion() override
Returns the longitudinal diffusion in (cm)^1/2.
@ REST_Info
+show most of the information for each steps
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.
Double_t StringToDouble(std::string in)
Gets a double from a string.
std::string ToUpper(std::string in)
Convert string to its upper case. Alternative of TString::ToUpper.
Int_t StringToInteger(std::string in)
Gets an integer from a string.