BOSS 7.0.8
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 G4Exception("BOOST environment not set!");
40 }
41 ReadData();
42 ReadBrData();
43 ReadMrpcData();
44}
45
47{
48}
49
50void BesTofGeoParameter::ReadBrData()
51{
52 // read file
53 const G4String pmtDataPath = m_dataPath + "/dat/TofBr.txt";
54
55 std::ifstream fin(pmtDataPath);
56 if (!fin) {
57 std::cerr << "cannot open " << pmtDataPath << " for initialization.";
58 exit(-1);
59 }
60
61 using std::string;
62 using std::vector;
63 string tempString;
64 string::size_type pre_position = 0;
65 string::size_type post_position = 0;
66 vector<string> stringVector;
67 while (getline(fin, tempString, '\n')){
68
69 // remove comments
70 pre_position = tempString.find_first_of("#");
71 if (pre_position != string::npos){ // there is no "#" in string
72 tempString.erase(tempString.begin() + pre_position, tempString.end());
73 }
74
75 // format string
76 pre_position = 0;
77 post_position = 0;
78 int size;
79 while (tempString.find_first_of(" ", pre_position) != string::npos){
80 pre_position = tempString.find_first_of(" ", pre_position);
81 post_position = tempString.find_first_not_of(" ", pre_position);
82 size = post_position - pre_position;
83 tempString.replace(pre_position, size, " ");
84 pre_position = post_position - size + 1;
85 }
86
87 // insert into string vector
88 if (tempString.size() > 10){
89 stringVector.push_back(tempString);
90 }
91 }
92
93 // for tests, read from string, write to variables
94 int scinNb;
95 double tempEPMTgain;
96 double tempERiseTime;
97 double tempWPMTgain;
98 double tempWRiseTime;
99 double tempAtten;
100 vector<string>::iterator it = stringVector.begin();
101 for (it; it != stringVector.end(); it++){
102 // string 2 buffer, buffer 2 temp Variables
103 std::istrstream buff((*it).c_str(), strlen((*it).c_str()));
104 buff >> scinNb >> tempEPMTgain >> tempERiseTime >> tempWPMTgain >> tempWRiseTime >> tempAtten;
105
106 m_BrEPMTgain[scinNb] = tempEPMTgain;
107 m_BrERiseTime[scinNb] = tempERiseTime;
108 m_BrWPMTgain[scinNb] = tempWPMTgain;
109 m_BrWRiseTime[scinNb] = tempWRiseTime;
110 m_atten[scinNb] = tempAtten;
111
112 }
113 fin.close();
114}
115
116void BesTofGeoParameter::ReadData()
117{
118 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
119 const G4String GeometryPath = m_dataPath + "/dat/BesTof.txt";
120
121 std::ifstream fin;
122 fin.open(GeometryPath);
123
124 const int maxCharOfOneLine=255;
125 char temp[maxCharOfOneLine],*p;
126 int lineNo=0,inputNo=0;
127 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.
128 {
129 fin.getline(temp,maxCharOfOneLine);
130 p=temp;
131 lineNo++;
132 while (*p!='\0')
133 {
134 if (*p=='#')
135 {
136 *p='\0'; //delete the comments.
137 break;
138 }
139 p++;
140 }
141 p=temp; //reset the pointer to the beginning of the string.
142 while (*p==' '||*p=='\t')p++;
143 if (*p=='\0')continue;
144 inputNo++;
145 switch (inputNo)
146 {
147 case 1:
148 std::istrstream(p)>>nScinBr>>br1L>>br1TrapW1>>br1TrapW2>>br1TrapH>>br1R1>>AlThickness>>PVFThickness;
149 break;
150 case 2:
151 std::istrstream(p)>>br2L>>br2TrapW1>>br2TrapW2>>br2TrapH>>br2R1;
152 break;
153 case 3:
154 std::istrstream(p)>>bucketDBr>>bucketLBr;
155 break;
156 case 4:
157 std::istrstream(p)>>nScinEc>>ecL>>ecTrapW1>>ecTrapW2>>ecTrapH>>ecTrapH1
158 >>zPosEastEc>>zPosWestEc>>ecR1>>ecR2;
159 break;
160 case 5:
161 std::istrstream(p)>>bucketDEc>>bucketLEc>>bucketPosR;
162 break;
163 case 6:
164 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;
165 case 7:
166 std::istrstream(p)>>m_ttsMean>>m_ttsSigma>>m_PMTgain>>m_Ce>>m_riseTime>>m_LLthresh>>m_HLthresh>>m_preGain>>m_noiseSigma;
167 case 8:
168 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;
169 case 9:
170 std::istrstream(p)>>m_ttsMeanEc>>m_ttsSigmaEc>>m_PMTgainEc>>m_CeEc>>m_riseTimeEc>>m_LLthreshEc>>m_HLthreshEc>>m_preGainEc>>m_noiseSigmaEc;
171 }
172 }
173
174 fin.close();
175}
176
177
178
179void BesTofGeoParameter::ReadMrpcData()
180{
181 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
182 G4String MrpcGeometryPath = m_dataPath + "/dat/BesTofMrpc.txt";
183 const int maxCharOfOneLine=255;
184 char temp[maxCharOfOneLine],*p;
185 container.clear();
186
187 std::string key;
188 double val;
189 std::string unit;
190 std::ifstream fin;
191 fin.open(MrpcGeometryPath);
192
193 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.
194 {
195 fin.getline(temp,maxCharOfOneLine);
196 p=temp;
197 while (*p!='\0')
198 {
199 if (*p=='#')
200 {
201 *p='\0'; //delete the comments.
202 break;
203 }
204 p++;
205 }
206 p=temp; //reset the pointer to the beginning of the string.
207 while (*p==' '||*p=='\t')p++;
208 if (*p=='\0')continue;
209
210 std::stringstream ss(temp);
211 ss >> key >> val>>unit;
212 container[key]=val*UNIT[unit];
213 }
214 fin.close();
215
216
217 //Adjusting parameters
218 container2.clear();
219 double rOffset, angle, angleOffset;
220 VEC v_rOffset, v_angle, v_angleOffset;
221 int lineNo = 0;
222 G4String MrpcGeometryPath1 = m_dataPath + "/dat/Mrpc_adjust.txt";
223 fin.open(MrpcGeometryPath1);
224
225 while (fin.peek()!=EOF)
226 {
227 fin.getline(temp,maxCharOfOneLine);
228 p=temp;
229 while (*p!='\0')
230 {
231 if (*p=='#')
232 {
233 *p='\0'; //delete the comments.
234 break;
235 }
236 p++;
237 }
238 p=temp; //reset the pointer to the beginning of the string.
239 while (*p==' '||*p=='\t')p++;
240 if (*p=='\0')continue;
241 lineNo++;
242
243 std::stringstream ss(temp);
244 std::stringstream name;
245 ss >> rOffset >> angle >> angleOffset;
246 if(lineNo==37)
247 {
248 container2["rOffset_east"] = v_rOffset;
249 container2["angle_east"] = v_angle;
250 container2["angleOffset_east"] = v_angleOffset;
251
252 v_rOffset.clear();
253 v_angle.clear();
254 v_angleOffset.clear();
255 }
256
257 v_rOffset.push_back(rOffset);
258 v_angle.push_back(angle);
259 v_angleOffset.push_back(angleOffset);
260 }
261 container2["rOffset_west"] = v_rOffset;
262 container2["angle_west"] = v_angle;
263 container2["angleOffset_west"] = v_angleOffset;
264
265 fin.close();
266
267
268 ////Print out the map
269 //for(CONTAINER::iterator it=container.begin(); it!=container.end(); ++it)
270 //{
271 // std::cout<<it->first<<" "<<it->second<<std::endl;
272 //}
273
274 //for(CONTAINER2::iterator it=container2.begin(); it!=container2.end(); ++it)
275 //{
276 // std::cout<<it->first<<": "<<std::endl;
277 // for(VEC::iterator it2 = (it->second).begin(); it2!=(it->second).end(); it2++)
278 // {
279 // std::cout << *it2 << std::endl;
280 // }
281 //}
282
283 int tofid, strip, end;
284 for(int i=0; i<72; i++)
285 {
286 for(int j=0; j<12; j++)
287 {
288 m_deadChannel[i][j] = -999;
289 }
290 }
291
292 G4String MrpcGeometryPath2 = m_dataPath + "/dat/BesTofMrpc_dead.txt";
293 fin.open(MrpcGeometryPath2);
294
295 while (fin.peek()!=EOF)
296 {
297 fin.getline(temp,maxCharOfOneLine);
298 p=temp;
299 while (*p!='\0')
300 {
301 if (*p=='#')
302 {
303 *p='\0'; //delete the comments.
304 break;
305 }
306 p++;
307 }
308 p=temp; //reset the pointer to the beginning of the string.
309 while (*p==' '||*p=='\t')p++;
310 if (*p=='\0')continue;
311
312 std::stringstream ss(temp);
313 ss >> tofid >> strip >> end;
314 m_deadChannel[tofid][strip] = end;
315 std::cout<<"deadC["<<tofid<<"]["<<strip<<"]= "<<m_deadChannel[tofid][strip]<<std::endl;
316 }
317
318 fin.close();
319
320
321}
322
323double BesTofGeoParameter::Get(std::string key)
324{
325 for(CONTAINER::iterator it=container.begin(); it!=container.end(); ++it)
326 {
327 if((it->first)==key)
328 {
329 double val = container[key];
330 return val;
331 }
332 }
333
334 std::cout<<"!!!! Wrong! Please check the value name !!!!"<<std::endl;
335 return -999.9;
336}
337
339{
340 VEC vec;
341 for(CONTAINER2::iterator it=container2.begin(); it!=container2.end(); ++it)
342 {
343 if((it->first)==key)
344 {
345 vec = container2[key];
346 return vec;
347 }
348 }
349
350 std::cout<<"!!!! Wrong! Please check the value name !!!!"<<std::endl;
351 return vec;
352}
353
354void BesTofGeoParameter::Get_deadChannel(int deadChannel[72][12])
355{
356 for(int i=0; i<72; i++)
357 {
358 for(int j=0; j<12; j++)
359 {
360 deadChannel[i][j] = m_deadChannel[i][j];
361 }
362 }
363}
364
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)