BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofGeoParameter.cc
Go to the documentation of this file.
1//This file reads the data from the TOF. For me the function ReadData is the important one. Here the standard data from the TOF is read
2
3// BOOST --- BESIII Object_Oriented Simulation Tool //
4//Description:
5//Author: Dengzy
6//Created: Mar, 2004
7//Modified:
8//Comment:
9//---------------------------------------------------------------------//
10//$ID: BesTofGeoParameter.cc
11
12#include "BesTofGeoParameter.hh"
13#include <fstream>
14#include <strstream>
15#include <string>
16#include <vector>
17#include "ReadBoostRoot.hh"
18
19BesTofGeoParameter* BesTofGeoParameter::m_instance = 0;
20
22{
23 if (m_instance == 0){
24 m_instance = new BesTofGeoParameter;
25 }
26 return m_instance;
27}
28
29//Construchttor --> Initialize the path, where data will be read from
31{
32 UNIT["mm"]=1.;
33 UNIT["cm"]=10.;
34 UNIT["rag"]=1.;
35 UNIT["deg"]=(acos(-1))/180.;
36
37 m_dataPath = getenv("TOFSIMROOT");
38 if (!m_dataPath){
39 G4cout<<"BOOST environment not set!"<<G4endl;
40 exit(-1);
41 }
42 ReadData();
43 ReadBrData();
44 ReadMrpcData();
45}
46
48{
49}
50
51void BesTofGeoParameter::ReadBrData()
52{
53 // read file
54 const G4String pmtDataPath = m_dataPath + "/dat/TofBr.txt";
55
56 std::ifstream fin(pmtDataPath);
57 if (!fin) {
58 std::cerr << "cannot open " << pmtDataPath << " for initialization.";
59 exit(-1);
60 }
61
62 using std::string;
63 using std::vector;
64 string tempString;
65 string::size_type pre_position = 0;
66 string::size_type post_position = 0;
67 vector<string> stringVector;
68 while (getline(fin, tempString, '\n')){
69
70 // remove comments
71 pre_position = tempString.find_first_of("#");
72 if (pre_position != string::npos){ // there is no "#" in string
73 tempString.erase(tempString.begin() + pre_position, tempString.end());
74 }
75
76 // format string
77 pre_position = 0;
78 post_position = 0;
79 int size;
80 while (tempString.find_first_of(" ", pre_position) != string::npos){
81 pre_position = tempString.find_first_of(" ", pre_position);
82 post_position = tempString.find_first_not_of(" ", pre_position);
83 size = post_position - pre_position;
84 tempString.replace(pre_position, size, " ");
85 pre_position = post_position - size + 1;
86 }
87
88 // insert into string vector
89 if (tempString.size() > 10){
90 stringVector.push_back(tempString);
91 }
92 }
93
94 // for tests, read from string, write to variables
95 int scinNb;
96 double tempEPMTgain;
97 double tempERiseTime;
98 double tempWPMTgain;
99 double tempWRiseTime;
100 double tempAtten;
101 vector<string>::iterator it = stringVector.begin();
102 for (it; it != stringVector.end(); it++){
103 // string 2 buffer, buffer 2 temp Variables
104 std::istrstream buff((*it).c_str(), strlen((*it).c_str()));
105 buff >> scinNb >> tempEPMTgain >> tempERiseTime >> tempWPMTgain >> tempWRiseTime >> tempAtten;
106
107 m_BrEPMTgain[scinNb] = tempEPMTgain;
108 m_BrERiseTime[scinNb] = tempERiseTime;
109 m_BrWPMTgain[scinNb] = tempWPMTgain;
110 m_BrWRiseTime[scinNb] = tempWRiseTime;
111 m_atten[scinNb] = tempAtten;
112
113 }
114 fin.close();
115}
116
117void BesTofGeoParameter::ReadData()
118{
119 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
120 const G4String GeometryPath = m_dataPath + "/dat/BesTof.txt";
121
122 std::ifstream fin;
123 fin.open(GeometryPath);
124
125 const int maxCharOfOneLine=255;
126 char temp[maxCharOfOneLine],*p;
127 int lineNo=0,inputNo=0;
128 while (fin.peek()!=EOF) //Peek: Reads and returns the next character without extracting it, i.e. leaving it as the next character to be extracted from the stream.
129 {
130 fin.getline(temp,maxCharOfOneLine);
131 p=temp;
132 lineNo++;
133 while (*p!='\0')
134 {
135 if (*p=='#')
136 {
137 *p='\0'; //delete the comments.
138 break;
139 }
140 p++;
141 }
142 p=temp; //reset the pointer to the beginning of the string.
143 while (*p==' '||*p=='\t')p++;
144 if (*p=='\0')continue;
145 inputNo++;
146 switch (inputNo)
147 {
148 case 1:
149 std::istrstream(p)>>nScinBr>>br1L>>br1TrapW1>>br1TrapW2>>br1TrapH>>br1R1>>AlThickness>>PVFThickness;
150 break;
151 case 2:
152 std::istrstream(p)>>br2L>>br2TrapW1>>br2TrapW2>>br2TrapH>>br2R1;
153 break;
154 case 3:
155 std::istrstream(p)>>bucketDBr>>bucketLBr;
156 break;
157 case 4:
158 std::istrstream(p)>>nScinEc>>ecL>>ecTrapW1>>ecTrapW2>>ecTrapH>>ecTrapH1
159 >>zPosEastEc>>zPosWestEc>>ecR1>>ecR2;
160 break;
161 case 5:
162 std::istrstream(p)>>bucketDEc>>bucketLEc>>bucketPosR;
163 break;
164 case 6:
165 std::istrstream(p)>>m_tau1>>m_tau2>>m_tau3>>m_tauRatio>>m_refIndex>>m_phNConst>>m_Cpe2pmt>>m_rAngle>>m_QE>>m_CE>>m_peCorFac;
166 case 7:
167 std::istrstream(p)>>m_ttsMean>>m_ttsSigma>>m_PMTgain>>m_Ce>>m_riseTime>>m_LLthresh>>m_HLthresh>>m_preGain>>m_noiseSigma;
168 case 8:
169 std::istrstream(p)>>m_tau1Ec>>m_tau2Ec>>m_tau3Ec>>m_tauRatioEc>>m_refIndexEc>>m_phNConstEc>>m_Cpe2pmtEc>>m_rAngleEc>>m_QEEc>>m_CEEc>>m_peCorFacEc>>m_attenEc;
170 case 9:
171 std::istrstream(p)>>m_ttsMeanEc>>m_ttsSigmaEc>>m_PMTgainEc>>m_CeEc>>m_riseTimeEc>>m_LLthreshEc>>m_HLthreshEc>>m_preGainEc>>m_noiseSigmaEc;
172 }
173 }
174
175 fin.close();
176}
177
178
179
180void BesTofGeoParameter::ReadMrpcData()
181{
182 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
183 G4String MrpcGeometryPath = m_dataPath + "/dat/BesTofMrpc.txt";
184 const int maxCharOfOneLine=255;
185 char temp[maxCharOfOneLine],*p;
186 container.clear();
187
188 std::string key;
189 double val;
190 std::string unit;
191 std::ifstream fin;
192 fin.open(MrpcGeometryPath);
193
194 while (fin.peek()!=EOF) //Peek: Reads and returns the next character without extracting it, i.e. leaving it as the next character to be extracted from the stream.
195 {
196 fin.getline(temp,maxCharOfOneLine);
197 p=temp;
198 while (*p!='\0')
199 {
200 if (*p=='#')
201 {
202 *p='\0'; //delete the comments.
203 break;
204 }
205 p++;
206 }
207 p=temp; //reset the pointer to the beginning of the string.
208 while (*p==' '||*p=='\t')p++;
209 if (*p=='\0')continue;
210
211 std::stringstream ss(temp);
212 ss >> key >> val>>unit;
213 container[key]=val*UNIT[unit];
214 }
215 fin.close();
216
217
218 //Adjusting parameters
219 container2.clear();
220 double rOffset, angle, angleOffset;
221 VEC v_rOffset, v_angle, v_angleOffset;
222 int lineNo = 0;
223 G4String MrpcGeometryPath1 = m_dataPath + "/dat/Mrpc_adjust.txt";
224 fin.open(MrpcGeometryPath1);
225
226 while (fin.peek()!=EOF)
227 {
228 fin.getline(temp,maxCharOfOneLine);
229 p=temp;
230 while (*p!='\0')
231 {
232 if (*p=='#')
233 {
234 *p='\0'; //delete the comments.
235 break;
236 }
237 p++;
238 }
239 p=temp; //reset the pointer to the beginning of the string.
240 while (*p==' '||*p=='\t')p++;
241 if (*p=='\0')continue;
242 lineNo++;
243
244 std::stringstream ss(temp);
245 std::stringstream name;
246 ss >> rOffset >> angle >> angleOffset;
247 if(lineNo==37)
248 {
249 container2["rOffset_east"] = v_rOffset;
250 container2["angle_east"] = v_angle;
251 container2["angleOffset_east"] = v_angleOffset;
252
253 v_rOffset.clear();
254 v_angle.clear();
255 v_angleOffset.clear();
256 }
257
258 v_rOffset.push_back(rOffset);
259 v_angle.push_back(angle);
260 v_angleOffset.push_back(angleOffset);
261 }
262 container2["rOffset_west"] = v_rOffset;
263 container2["angle_west"] = v_angle;
264 container2["angleOffset_west"] = v_angleOffset;
265
266 fin.close();
267
268
269 ////Print out the map
270 //for(CONTAINER::iterator it=container.begin(); it!=container.end(); ++it)
271 //{
272 // std::cout<<it->first<<" "<<it->second<<std::endl;
273 //}
274
275 //for(CONTAINER2::iterator it=container2.begin(); it!=container2.end(); ++it)
276 //{
277 // std::cout<<it->first<<": "<<std::endl;
278 // for(VEC::iterator it2 = (it->second).begin(); it2!=(it->second).end(); it2++)
279 // {
280 // std::cout << *it2 << std::endl;
281 // }
282 //}
283
284 int tofid, strip, end;
285 for(int i=0; i<72; i++)
286 {
287 for(int j=0; j<12; j++)
288 {
289 m_deadChannel[i][j] = -999;
290 }
291 }
292
293 G4String MrpcGeometryPath2 = m_dataPath + "/dat/BesTofMrpc_dead.txt";
294 fin.open(MrpcGeometryPath2);
295
296 while (fin.peek()!=EOF)
297 {
298 fin.getline(temp,maxCharOfOneLine);
299 p=temp;
300 while (*p!='\0')
301 {
302 if (*p=='#')
303 {
304 *p='\0'; //delete the comments.
305 break;
306 }
307 p++;
308 }
309 p=temp; //reset the pointer to the beginning of the string.
310 while (*p==' '||*p=='\t')p++;
311 if (*p=='\0')continue;
312
313 std::stringstream ss(temp);
314 ss >> tofid >> strip >> end;
315 m_deadChannel[tofid][strip] = end;
316 std::cout<<"deadC["<<tofid<<"]["<<strip<<"]= "<<m_deadChannel[tofid][strip]<<std::endl;
317 }
318
319 fin.close();
320
321
322}
323
324double BesTofGeoParameter::Get(std::string key)
325{
326 for(CONTAINER::iterator it=container.begin(); it!=container.end(); ++it)
327 {
328 if((it->first)==key)
329 {
330 double val = container[key];
331 return val;
332 }
333 }
334
335 std::cout<<"!!!! Wrong! Please check the value name !!!!"<<std::endl;
336 return -999.9;
337}
338
340{
341 VEC vec;
342 for(CONTAINER2::iterator it=container2.begin(); it!=container2.end(); ++it)
343 {
344 if((it->first)==key)
345 {
346 vec = container2[key];
347 return vec;
348 }
349 }
350
351 std::cout<<"!!!! Wrong! Please check the value name !!!!"<<std::endl;
352 return vec;
353}
354
355void BesTofGeoParameter::Get_deadChannel(int deadChannel[72][12])
356{
357 for(int i=0; i<72; i++)
358 {
359 for(int j=0; j<12; j++)
360 {
361 deadChannel[i][j] = m_deadChannel[i][j];
362 }
363 }
364}
365
std::vector< double > VEC
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
Definition: FoamA.h:90
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42
double Get(std::string key)
void Get_deadChannel(int deadChannel[72][12])
static BesTofGeoParameter * GetInstance()
VEC GetVec(std::string key)