216#include "TRestDetectorGas.h"
218#include <TRestDataBase.h>
234 fGasGeneration =
false;
251 : TRestDetectorDriftVolume() {
253 fGasGeneration = gasGeneration;
257 if (strcmp(configFilename,
"server") == 0) {
272 RESTDebug <<
"Entering ... TRestDetectorGas() destructor." <<
RESTendl;
274#if defined USE_Garfield
284 RESTDebug <<
"TRestDetectorGas. Entering ... Initialize()." <<
RESTendl;
290 fTemperatureInK = 300;
294 fGasComponentName.clear();
295 fGasComponentFraction.clear();
297 fStatus = RESTGAS_INTITIALIZED;
302#if defined USE_Garfield
303 fGasMedium =
new Garfield::MediumMagboltz();
305 fGasMedium =
nullptr;
329 RESTDebug <<
"Entering ... TRestDetectorGas::LoadGasFile()." <<
RESTendl;
331#if defined USE_Garfield
332 RESTDebug <<
"fGasFilename = " << fGasFilename <<
RESTendl;
334 RESTError << __PRETTY_FUNCTION__ <<
RESTendl;
335 RESTError <<
"The gas file does not exist. (name:" << fGasFilename <<
")" <<
RESTendl;
340 fGasMedium->LoadGasFile((
string)(fGasFilename));
345 fGasMedium->GetFieldGrid(fEFields, fBFields, fAngles);
347 fStatus = RESTGAS_GASFILE_LOADED;
348 RESTInfo <<
"TRestDetectorGas. Gas file loaded!" <<
RESTendl;
350 for (
unsigned int i = 0; i < fEFields.size(); i++)
351 RESTDebug <<
"node " << i <<
" Field : " << fEFields[i] <<
" V/cm" <<
RESTendl;
353 if (fGasMedium && fGasMedium->GetW() == 0.) {
354 fGasMedium->SetW(GetWvalue());
357 cout <<
"This REST is not complied with garfield, it cannot load any gas file!" << endl;
361void TRestDetectorGas::CalcGarField(
double Emin,
double Emax,
int n) {
362 RESTDebug <<
"Entering ... TRestDetectorGas::CalcGarField( Emin=" << Emin <<
" , Emax=" << Emax <<
" )"
365#if defined USE_Garfield
367 cout <<
"REST ERROR : The number of nodes is not a positive number!!. Gas "
368 "file generation cancelled."
373 if (fEmin >= fEmax) {
374 cout <<
"REST ERROR : The Electric field grid boundaries are not properly "
382 for (
int i = 0; i < fNofGases; i++) {
383 gasStr[i] = (string)fGasComponentName[i];
387 if (fNofGases == 1) fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100.);
390 fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100., gasStr[1],
391 fGasComponentFraction[1] * 100.);
394 fGasMedium->SetComposition(gasStr[0], fGasComponentFraction[0] * 100., gasStr[1],
395 fGasComponentFraction[1] * 100., gasStr[2],
396 fGasComponentFraction[2] * 100.);
399 cout <<
"REST ERROR : Number of gas components higher than 3 not allowed" << endl;
404 fGasMedium->SetTemperature(fTemperatureInK);
406 if (fPressureInAtm != 1)
407 RESTWarning <<
"-- Warning : The gas will be generated for gas pressure = 1atm" <<
RESTendl;
409 fGasMedium->SetPressure(1 * REST_Units::torr);
411 fGasMedium->SetFieldGrid(Emin, Emax, n, n > 1);
413 fGasMedium->SetMaxElectronEnergy(fMaxElectronEnergy);
415 cout <<
"Garfield: calculating..." << endl;
418 fGasMedium->Initialise();
421 fGasMedium->GenerateGasTable(fNCollisions,
true);
422 if (fPressureInAtm != 1) {
423 RESTWarning <<
"-- Warning : Restoring the gas pressure" <<
RESTendl;
424 fGasMedium->SetPressure(fPressureInAtm * 760.);
427 cout <<
"This REST is not complied with garfield, it cannot calculate "
443 RESTDebug <<
"Entering ... TRestDetectorGas::AddGasComponent( gasName=" << gasName
444 <<
" , fraction=" << fraction <<
" )" <<
RESTendl;
446 fGasComponentName.emplace_back(gasName);
447 fGasComponentFraction.push_back(fraction);
506#if defined USE_Garfield
507 if (
fStatus != RESTGAS_GASFILE_LOADED) {
508 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
509 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
513 RESTInfo <<
"Calling Garfield directly to fetch Fano factor" <<
RESTendl;
514 const auto fanoFactor = fGasMedium->GetFanoFactor();
516 if (fanoFactor == 0.) {
517 runtime_error(
"Fano Factor is 0! This REST is not compiled with the last version of Garfield");
521 cerr <<
"This REST is not compiled with garfield, Do not use Fano "
522 "Factor from TRestDetectorGas!"
524 <<
"Please define the Fano factor in each process!" << endl;
525 throw runtime_error(
"This REST is not compiled with garfield, cannot retrieve the Fano Factor");
530#if defined USE_Garfield
531 if (
fStatus != RESTGAS_GASFILE_LOADED) {
532 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
533 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
537 RESTInfo <<
"Calling Garfield directly to fetch the work function" <<
RESTendl;
538 const auto workFunction = fGasMedium->GetW();
540 if (workFunction == 0.) {
541 throw runtime_error(
"Work Function is 0! This should never happen");
546 "This REST is not compiled with garfield, cannot retrieve the work function from the gas");
561 RESTDebug <<
"Entering ... TRestDetectorGas::InitFromConfigFile()" <<
RESTendl;
567 cout <<
"Setting default W-value : " << fW << endl;
571 string _gasServer = gDataBase->query_data(DBEntry(0,
"GAS_SERVER")).value;
572 if (_gasServer ==
"") _gasServer =
"none";
576 TiXmlElement* gasComponentDefinition =
GetElement(
"gasComponent");
577 while (gasComponentDefinition !=
nullptr) {
578 string gasName =
GetFieldValue(
"name", gasComponentDefinition);
583 if (fNofGases == 0 && !fMaterial.empty()) {
584 vector<string> componentsdef =
Split(fMaterial,
" ");
585 for (
const auto& componentdef : componentsdef) {
586 vector<string> componentdefpair =
Split(componentdef,
":");
587 if (componentdefpair.size() != 2) {
593 if (fNofGases == 0) {
594 RESTError <<
"TRestDetectorGas: No gas components added!" <<
RESTendl;
601 RESTWarning <<
"TRestDetectorGas : The total gas fractions is NOT 1." <<
RESTendl;
607 TiXmlElement* eFieldDefinition =
GetElement(
"eField");
614 fGasGeneration =
true;
617 RESTWarning <<
"-- Warning : The specified gasOutputPath is not writable!" <<
RESTendl;
618 RESTWarning <<
"-- Warning : The output path will be changed to ./" <<
RESTendl;
625 RESTDebug <<
"TRestDetectorGas::InitFromConfigFile. ConstructFilename. fGasFilename = " << fGasFilename
628 RESTDebug <<
"TRestDetectorGas::InitFromConfigFile. FindGasFile. fGasFilename = " << fGasFilename
633 fGasGeneration =
false;
635 RESTWarning <<
"TRestDetectorGas gasFile generation is enabled, but the "
636 "gasFile already exists!!"
638 RESTWarning <<
"Filename : " << fGasFilename <<
RESTendl;
639 RESTWarning <<
"fGasGeneration should be disabled to remove this "
642 RESTWarning <<
"If you really want to re-generate the gas file you "
643 "will need to disable the gasServer."
645 RESTWarning <<
"And/or remove any local copies that are found by "
651#if defined USE_Garfield
653 if (fGasGeneration) {
654 RESTEssential <<
"Starting gas generation" <<
RESTendl;
656 CalcGarField(fEmin, fEmax, fEnodes);
658 fStatus = RESTGAS_GASFILE_LOADED;
661 fGasMedium->SetPressure(fPressureInAtm * REST_Units::torr);
663 if (fGasMedium && fGasMedium->GetW() == 0.)
664 fGasMedium->SetW(fW);
671 RESTDebug <<
"Entering ... TRestDetectorGas::InitFromRootFile()" <<
RESTendl;
675 fGasFilename =
"/tmp/restGasFile_" + REST_USER +
".gas";
677 outf.open(fGasFilename, ios::ate);
681 int z = system(
"rm " + fGasFilename);
682 if (z != 0) RESTError <<
"Problem removing gas file: " << fGasFilename <<
RESTendl;
685 if (fGasFilename !=
"") {
691void TRestDetectorGas::UploadGasToServer(
string absoluteGasFilename) {
692 RESTEssential <<
"uploading gas file and gas definition rmls" << RESTendl;
694 if (!fTest && (fMaxElectronEnergy < 400 || fNCollisions < 10 || fEnodes < 20)) {
695 RESTWarning <<
"-- Warning : The gas file does not fulfill the requirements "
696 "for being uploaded to the gasServer"
698 RESTWarning <<
"-- Warning : maxElectronEnergy >= 400. Number of collisions >= "
699 "10. Number of E nodes >= 20."
701 RESTWarning <<
"-- Warning : The generated file will NOT be uploaded to the "
702 "server but preserved locally."
713 string url = gDataBase->
query_data(DBEntry(0,
"META_RML",
"TRestDetectorGas")).value;
718 cmd =
"sed -i '' -e '$ d' " + fname;
720 cmd =
"sed -i '$ d' " + fname;
723 a = system(cmd.c_str());
726 RESTError <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
727 RESTError <<
"-- Error : problem removing last line from " << fname <<
RESTendl;
734 outf.open(fname, ios::app);
736 outf <<
"//------- User : " << REST_USER <<
" ---- REST version : " << REST_RELEASE
737 <<
" ---------------------------" << endl;
744 outf.open(fname, ios::app);
745 outf <<
"\n" << endl;
746 outf <<
"</gases>" << endl;
769 RESTSuccess <<
"-- Success : Gasfile server database was updated successfully!" <<
RESTendl;
787 RESTDebug <<
"Entering ... TRestDetectorGas::FindGasFile( name=" << name <<
" )" <<
RESTendl;
789 string absoluteName =
"";
791 if (!fGasGeneration &&
fGasServer !=
"none") {
795 if (absoluteName.empty()) {
796 RESTInfo <<
"Trying to find the gasFile locally" <<
RESTendl;
798 if (absoluteName.empty()) {
799 RESTWarning <<
"-- Warning : No sucess finding local gas file definition." <<
RESTendl;
800 RESTWarning <<
"-- Warning : Gas file definition does not exist." <<
RESTendl;
801 RESTInfo <<
"To generate a new gasFile enable gas generation in TRestDetectorGas "
804 RESTInfo << R
"(TRestDetectorGas ( "gasDefinition.rml", "gas Name", true );)" << RESTendl;
805 RESTInfo << "Further details can be found at TRestDetectorGas class definition and "
820 RESTDebug <<
"Entering ... TRestDetectorGas::GetGasMixture( )" <<
RESTendl;
824 for (
int n = 0; n < fNofGases; n++) {
825 if (n > 0) gasMixture +=
"-";
828 gasMixture += (TString)tmpStr;
840 RESTDebug <<
"Entering ... TRestDetectorGas::ConstructFilename( )" <<
RESTendl;
844 for (
int n = 0; n < fNofGases; n++) {
845 if (n > 0) name +=
"-";
852 name += (TString)tmpStr;
860 sprintf(tmpStr,
"%03.1lf", fEmin);
861 name += (TString)tmpStr;
864 sprintf(tmpStr,
"%03.1lf", fEmax);
865 name += (TString)tmpStr;
868 sprintf(tmpStr,
"%02d", fEnodes);
869 name += (TString)tmpStr;
872 sprintf(tmpStr,
"%02d", fNCollisions);
873 name += (TString)tmpStr;
876 sprintf(tmpStr,
"%03d", (Int_t)fMaxElectronEnergy);
877 name += (TString)tmpStr;
881 RESTDebug <<
"Constructed filename : " << name <<
RESTendl;
888 RESTDebug <<
"Entering ... TRestDetectorGas::GenerateGasFile( )" <<
RESTendl;
890#if defined USE_Garfield
893 RESTDebug <<
" TRestDetectorGas::GenerateGasFile. fGasFilename = " << fGasFilename <<
RESTendl;
897 RESTWarning <<
"-- Warning: REST ERROR. TRestDetectorGas. Path is not writtable." <<
RESTendl;
899 RESTWarning <<
"-- Warning: Make sure the final data path is writtable before "
900 "proceed to gas generation."
902 RESTWarning <<
"-- Warning: or change the gas data path ... " <<
RESTendl;
908 cout <<
"Writing gas file : " << endl;
909 cout <<
"-----------------" << endl;
911 cout <<
"Filename : " << fGasFilename << endl;
913 fGasMedium->WriteGasFile((
string)(
fGasOutputPath +
"/" + fGasFilename));
918 cout <<
"This REST is not complied with garfield, it cannot save any gas file!" << endl;
932 RESTDebug <<
"Entering ... TRestDetectorGas::SetPressure( pressure=" << pressure <<
" )" <<
RESTendl;
934 fPressureInAtm = pressure;
935#if defined USE_Garfield
936 fGasMedium->SetPressure(fPressureInAtm * REST_Units::torr);
943 RESTDebug <<
"Entering ... TRestDetectorGas::SetPressure( temperature=" << temperature <<
" )"
946 fTemperatureInK = temperature;
947#if defined USE_Garfield
948 fGasMedium->SetTemperature(temperature);
961 RESTDebug <<
"Entering ... TRestDetectorGas::PlotDriftVelocity( eMin=" << eMin <<
" , eMax=" << eMax
962 <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
964 vector<Double_t> eField(nSteps), driftVel(nSteps);
966 for (
int i = 0; i < nSteps; i++) {
967 eField[i] = (eMin + (double)i * (eMax - eMin) / nSteps);
973 auto c =
new TCanvas(
"Drift velocity",
" ");
974 auto fDriftVel =
new TGraph(nSteps, &eField[0], &driftVel[0]);
976 str.Form(
"Drift Velocity for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
977 fDriftVel->SetTitle(str);
978 fDriftVel->GetXaxis()->SetTitle(
"E [V/cm]");
979 fDriftVel->GetYaxis()->SetTitle(
"Drift velocity [cm/#mus]");
980 fDriftVel->GetYaxis()->SetTitleOffset(2);
994 RESTDebug <<
"Entering ... TRestDetectorGas::PlotLongitudinalDiffusion( eMin=" << eMin
995 <<
" , eMax=" << eMax <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
997 vector<Double_t> eField(nSteps), longDiff(nSteps);
999 for (
int i = 0; i < nSteps; i++) {
1000 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
1006 auto c =
new TCanvas(
"Longitudinal diffusion",
" ");
1007 auto fLongDiff =
new TGraph(nSteps, &eField[0], &longDiff[0]);
1009 str.Form(
"Longitudinal diffusion for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
1010 fLongDiff->SetTitle(str);
1011 fLongDiff->GetXaxis()->SetTitle(
"E [V/cm]");
1012 fLongDiff->GetYaxis()->SetTitle(
"Longitudinal diffusion [mm/#sqrt{cm}]");
1013 fLongDiff->GetYaxis()->SetTitleOffset(2);
1014 fLongDiff->Draw(
"");
1027 RESTDebug <<
"Entering ... TRestDetectorGas::PlotTransversalDiffusion( eMin=" << eMin
1028 <<
" , eMax=" << eMax <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
1030 vector<Double_t> eField(nSteps), transDiff(nSteps);
1032 for (
int i = 0; i < nSteps; i++) {
1033 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
1039 auto c =
new TCanvas(
"Transitudinal diffusion",
" ");
1040 auto fTransDiff =
new TGraph(nSteps, &eField[0], &transDiff[0]);
1042 str.Form(
"Transversal diffusion for %s (Pressure: %3.1lf bar)", GetName(), this->GetPressure());
1043 fTransDiff->SetTitle(str);
1044 fTransDiff->GetXaxis()->SetTitle(
"E [V/cm]");
1045 fTransDiff->GetYaxis()->SetTitle(
"Transversal diffusion [mm/#sqrt{cm}]");
1046 fTransDiff->GetYaxis()->SetTitleOffset(2);
1047 fTransDiff->Draw(
"");
1060 RESTDebug <<
"Entering ... TRestDetectorGas::PlotTownsendCoefficient( eMin=" << eMin <<
" , eMax=" << eMax
1061 <<
", nSteps=" << nSteps <<
" )" <<
RESTendl;
1063 vector<Double_t> eField(nSteps), townsendCoeff(nSteps);
1065 for (
int i = 0; i < nSteps; i++) {
1066 eField[i] = eMin + (double)i * (eMax - eMin) / nSteps;
1071 auto c =
new TCanvas(
"Townsend coefficient",
" ");
1072 auto fTownsend =
new TGraph(nSteps, &eField[0], &townsendCoeff[0]);
1074 str.Form(
"Townsend coefficient for %s", GetName());
1075 fTownsend->SetTitle(str);
1076 fTownsend->GetXaxis()->SetTitle(
"E [V/cm]");
1077 fTownsend->GetYaxis()->SetTitle(
"Townsend coefficient [1/cm]");
1078 fTownsend->GetYaxis()->SetTitleOffset(2);
1079 fTownsend->Draw(
"");
1088 RESTDebug <<
"Entering ... TRestDetectorGas::GetDriftVelocity( E=" << E <<
" )" <<
RESTendl;
1092#if defined USE_Garfield
1093 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1094 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1095 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1099 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1100 <<
"from REST standard unit. E is V/cm. The return is cm/us" <<
RESTendl;
1102 Double_t vx, vy, vz;
1103 fGasMedium->ElectronVelocity(0., 0, -E, 0, 0, 0, vx, vy, vz);
1106 std::cout <<
"This REST is not complied with garfield, Do not use Drift Velocity "
1107 "from TRestDetectorGas!"
1109 std::cout <<
"Please define the Drift Velocity in each process!" << std::endl;
1119 RESTDebug <<
"Entering ... TRestDetectorGas::GetLongitudinalDiffusion( E=" << E <<
" )" <<
RESTendl;
1123#if defined USE_Garfield
1124 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1125 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1126 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1130 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1131 <<
"from REST standard unit. E is V/cm. The return is cm^1/2" <<
RESTendl;
1134 fGasMedium->ElectronDiffusion(0., 0, -E, 0, 0, 0, dl, dt);
1137 std::cout <<
"This REST is not compiled with garfield, Do not use Longitudinal "
1138 "Diffusion from TRestDetectorGas!"
1140 std::cout <<
"Please define the Longitudinal Diffusion in each process!" << std::endl;
1150 RESTDebug <<
"Entering ... TRestDetectorGas::GetTransversalDiffusion( E=" << E <<
" )" <<
RESTendl;
1153#if defined USE_Garfield
1154 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1155 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1156 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1160 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1161 <<
"from REST standard unit. E is V/cm. The return is cm^1/2" <<
RESTendl;
1164 fGasMedium->ElectronDiffusion(0., 0, -E, 0, 0, 0, dl, dt);
1167 std::cout <<
"This REST is not complied with garfield, Do not use Transversal "
1168 "Diffusion from TRestDetectorGas!"
1170 std::cout <<
"Please define the Transversal Diffusion in each process!" << std::endl;
1180 RESTDebug <<
"Entering ... TRestDetectorGas::GetTownsendCoefficient( E=" << E <<
" )" <<
RESTendl;
1183#if defined USE_Garfield
1184 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1185 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1186 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1190 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1191 <<
"from REST standard unit. E is V/cm. The return is V/cm" <<
RESTendl;
1194 fGasMedium->ElectronTownsend(0., 0, -E, 0, 0, 0, alpha);
1197 std::cout <<
"This REST is not complied with garfield, Do not use Townsend "
1198 "Coefficient from TRestDetectorGas!"
1200 std::cout <<
"Please define the Townsend Coefficient in each process!" << std::endl;
1210 RESTDebug <<
"Entering ... TRestDetectorGas::GetAttachmentCoefficient( E=" << E <<
" )" <<
RESTendl;
1213#if defined USE_Garfield
1214 if (
fStatus != RESTGAS_GASFILE_LOADED) {
1215 RESTDebug <<
"-- Error : " << __PRETTY_FUNCTION__ <<
RESTendl;
1216 RESTDebug <<
"-- Error : Gas file was not loaded!" <<
RESTendl;
1220 RESTInfo <<
"Calling Garfield directly. Please be aware that the unit is different "
1221 <<
"from REST standard unit. E is V/cm. The return is V/cm" <<
RESTendl;
1224 fGasMedium->ElectronAttachment(0., 0, -E, 0, 0, 0, eta);
1227 std::cout <<
"This REST is not complied with garfield, Do not use Attachment "
1228 "Coefficient from TRestDetectorGas!"
1230 std::cout <<
"Please define the Attachment Coefficient in each process!" << std::endl;
1239 RESTDebug <<
"Entering ... TRestDetectorGas::PrintGasInfo( )" <<
RESTendl;
1243 RESTMetadata <<
"Status : ";
1244 if (
fStatus == RESTGAS_INTITIALIZED) RESTMetadata <<
"Initialized";
1245 if (
fStatus == RESTGAS_CFG_LOADED) RESTMetadata <<
"Configuration loaded";
1246 if (
fStatus == RESTGAS_GASFILE_LOADED) RESTMetadata <<
"Gasfile loaded";
1247 if (
fStatus == RESTGAS_ERROR) RESTMetadata <<
"Error";
1251 RESTMetadata <<
"Pressure : " << fPressureInAtm <<
" atm" <<
RESTendl;
1252 RESTMetadata <<
"Temperature : " << fTemperatureInK <<
" K" <<
RESTendl;
1253 RESTMetadata <<
"Electric Field : " << fElectricField * units(
"V/cm") <<
" V/cm " <<
RESTendl;
1254 RESTMetadata <<
"W-value : " << fW <<
" eV" <<
RESTendl;
1255 RESTMetadata <<
"Drift velocity : " <<
GetDriftVelocity(fElectricField * units(
"V/cm")) / units(
"cm/us")
1257 RESTMetadata <<
"Max. Electron energy : " << fMaxElectronEnergy <<
" eV" <<
RESTendl;
1258 RESTMetadata <<
"Field grid nodes : " << fEnodes <<
RESTendl;
1259 RESTMetadata <<
"Efield range : ( " << fEmin <<
" , " << fEmax <<
" ) V/cm " <<
RESTendl;
1260 RESTMetadata <<
"Number of Gases : " << fNofGases <<
RESTendl;
1261 for (
int i = 0; i < fNofGases; i++)
1262 RESTMetadata <<
"Gas id : " << i <<
", Name : " << fGasComponentName[i]
1263 <<
", Fraction : " << fGasComponentFraction[i] <<
RESTendl;
1264 RESTMetadata <<
"******************************************" <<
RESTendl;
1270 RESTDebug <<
"Entering ... TRestDetectorGas::Write( name=" << name <<
" option=" << option
1271 <<
" bufsize=" << bufsize <<
" )" <<
RESTendl;
1275 infile.open(fGasFilename);
1277 cout <<
"TRestDetectorGas: error reading gas file, gas file content won't be "
1282 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.
Double_t GetGasFanoFactor() const
Returns the gas fano factor.
void InitFromConfigFile() override
Loads the gas parameters that define the gas calculation and properties.
void AddGasComponent(const std::string &gasName, Double_t fraction)
Adds a new element/compound to the gas.
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=nullptr, 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.
Double_t GetGasWorkFunction() const
Returns the gas work function in eV.
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.