REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDetectorSetup.cxx
1
16
17#include "TRestDetectorSetup.h"
18
19#include "TRestManager.h"
20#include "TRestRun.h"
21
22using namespace std;
23
24ClassImp(TRestDetectorSetup);
25
26TRestDetectorSetup::TRestDetectorSetup() : TRestMetadata() { Initialize(); }
27
28TRestDetectorSetup::TRestDetectorSetup(const char* configFilename, const string& name)
29 : TRestMetadata(configFilename) {
30 Initialize();
31
32 LoadConfigFromFile(fConfigFileName, name);
33
34 PrintMetadata();
35}
36
37TRestDetectorSetup::~TRestDetectorSetup() {
38 // TRestDetectorSetup destructor
39}
40
42 SetSectionName(this->ClassName());
43 SetLibraryVersion(LIBRARY_VERSION);
44
45 fRunNumber = 0;
46 fSubRunNumber = 0;
47 fRunTag = "";
48
49 fMeshVoltage = 0;
50 fDriftField = 0;
51 fDetectorPressure = 0;
52
53 fElectronicsGain = "";
54 fSamplingTime = "";
55 fShapingTime = "";
56
57 fSamplingInMicroSec = 0;
58}
59
61 this->Initialize();
62
63 // Initialize the metadata members from a configfile
64 fRunNumber = StringToInteger(GetParameter("runNumber"));
65 fSubRunNumber = StringToInteger(GetParameter("subRunNumber"));
66 if (fHostmgr != nullptr && fHostmgr->GetRunInfo() != nullptr) {
67 TRestRun* r = fHostmgr->GetRunInfo();
68 if (r->GetInputFileNumber() > 0) InitFromFileName(r->GetInputFileName(0));
69 }
70 // TOBE implemented if needed
71}
72
73void TRestDetectorSetup::InitFromFileName(TString fName) {
74 string fullName = (string)fName;
75
76 unsigned int startPos = fullName.find_last_of("/") + 1;
77 unsigned int length = fullName.length();
78 string name = fullName.substr(startPos, length - startPos);
79
80 fRunNumber = StringToInteger(name.substr(1, 5));
81
82 unsigned int pos = name.find("_") + 1;
83 unsigned int len = name.find("_Vm") - pos;
84 fRunTag = (TString)name.substr(pos, len);
85
86 pos = name.find("Vm_") + 3;
87 len = name.find("_Vd") - pos;
88 fMeshVoltage = StringToDouble(name.substr(pos, len));
89
90 pos = name.find("Vd_") + 3;
91 len = name.find("_Pr") - pos;
92 fDriftField = StringToDouble(name.substr(pos, len));
93
94 pos = name.find("Pr_") + 3;
95 len = name.find("_Gain") - pos;
96 fDetectorPressure = StringToDouble(name.substr(pos, len));
97
98 pos = name.find("Gain_") + 5;
99 len = name.find("_Shape") - pos;
100 fElectronicsGain = name.substr(pos, len);
101
102 pos = name.find("Shape_") + 6;
103 len = name.find("_Clock") - pos;
104 fShapingTime = name.substr(pos, len);
105
106 pos = name.find("Clock_") + 6;
107 len = name.find("-") - pos;
108 fSamplingTime = name.substr(pos, len);
109
110 TString samplingReduced = fSamplingTime(2, fSamplingTime.Length());
111 fSamplingInMicroSec =
112 (Double_t)strtol(samplingReduced.Data(), nullptr, 16) / 100.; // This is only for AGET
113
114 pos = name.find("-") + 1;
115 len = name.find(".aqs") - pos;
116 fSubRunNumber = StringToInteger(name.substr(pos, len));
117}
118
120 cout << endl;
121 cout << "+++++++++++++++++++++++++++++++++++++++++++++" << endl;
122 cout << "TRestDetectorSetup content" << endl;
123 cout << "+++++++++++++++++++++++++++++++++++++++++++++" << endl;
124 cout << " Run number : " << fRunNumber << endl;
125 cout << " Run sub number : " << fSubRunNumber << endl;
126 cout << " Run tag : " << fRunTag << endl;
127 cout << " --------------------------------------------" << endl;
128 cout << " Mesh voltage : " << fMeshVoltage << " V" << endl;
129 cout << " Drift field : " << fDriftField << " V/cm/bar" << endl;
130 cout << " Detector pressure : " << fDetectorPressure << " bar" << endl;
131 cout << " --------------------------------------------" << endl;
132 cout << " Electronics gain register : " << fElectronicsGain << endl;
133 cout << " Shaping time register : " << fShapingTime << endl;
134 cout << " Sampling rate register : " << fSamplingTime << endl;
135 cout << " Sampling rate : " << fSamplingInMicroSec << " us " << endl;
136 cout << " --------------------------------------------" << endl;
137}
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize() override
Making default settings.
A base class for any REST metadata class.
Definition: TRestMetadata.h:74
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
TRestManager * fHostmgr
All metadata classes can be initialized and managed by TRestManager.
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
Data provider and manager in REST.
Definition: TRestRun.h:18
Double_t StringToDouble(std::string in)
Gets a double from a string.
Int_t StringToInteger(std::string in)
Gets an integer from a string.