BOSS 8.0.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.
2// Here the standard data from the TOF is read
3
4// BOOST --- BESIII Object_Oriented Simulation Tool //
5// Description:
6// Author: Dengzy
7// Created: Mar, 2004
8// Modified:
9// Comment:
10//---------------------------------------------------------------------//
11//$ID: BesTofGeoParameter.cc
12
13#include "TofSim/BesTofGeoParameter.hh"
14#include "SimUtil/ReadBoostRoot.hh"
15#include <fstream>
16#include <string>
17#include <strstream>
18#include <vector>
19
20BesTofGeoParameter* BesTofGeoParameter::m_instance = 0;
21
23 if ( m_instance == 0 ) { m_instance = new BesTofGeoParameter; }
24 return m_instance;
25}
26
27// Construchttor --> Initialize the path, where data will be read from
29 UNIT["mm"] = 1.;
30 UNIT["cm"] = 10.;
31 UNIT["rag"] = 1.;
32 UNIT["deg"] = ( acos( -1 ) ) / 180.;
33
34 m_dataPath = getenv( "TOFSIMROOT" );
35 if ( !m_dataPath )
36 {
37 G4cout << "BOOST environment not set!" << G4endl;
38 exit( -1 );
39 }
40 ReadData();
41 ReadBrData();
42 ReadMrpcData();
43}
44
46
47void BesTofGeoParameter::ReadBrData() {
48 // read file
49 const G4String pmtDataPath = m_dataPath + "/dat/TofBr.txt";
50
51 std::ifstream fin( pmtDataPath );
52 if ( !fin )
53 {
54 std::cerr << "cannot open " << pmtDataPath << " for initialization.";
55 exit( -1 );
56 }
57
58 using std::string;
59 using std::vector;
60 string tempString;
61 string::size_type pre_position = 0;
62 string::size_type post_position = 0;
63 vector<string> stringVector;
64 while ( getline( fin, tempString, '\n' ) )
65 {
66
67 // remove comments
68 pre_position = tempString.find_first_of( "#" );
69 if ( pre_position != string::npos )
70 { // there is no "#" in string
71 tempString.erase( tempString.begin() + pre_position, tempString.end() );
72 }
73
74 // format string
75 pre_position = 0;
76 post_position = 0;
77 int size;
78 while ( tempString.find_first_of( " ", pre_position ) != string::npos )
79 {
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 ) { stringVector.push_back( tempString ); }
89 }
90
91 // for tests, read from string, write to variables
92 int scinNb;
93 double tempEPMTgain;
94 double tempERiseTime;
95 double tempWPMTgain;
96 double tempWRiseTime;
97 double tempAtten;
98 vector<string>::iterator it = stringVector.begin();
99 for ( it; it != stringVector.end(); it++ )
100 {
101 // string 2 buffer, buffer 2 temp Variables
102 std::istrstream buff( ( *it ).c_str(), strlen( ( *it ).c_str() ) );
103 buff >> scinNb >> tempEPMTgain >> tempERiseTime >> tempWPMTgain >> tempWRiseTime >>
104 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 fin.close();
113}
114
115void BesTofGeoParameter::ReadData() {
116 // G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
117 const G4String GeometryPath = m_dataPath + "/dat/BesTof.txt";
118
119 std::ifstream fin;
120 fin.open( GeometryPath );
121
122 const int maxCharOfOneLine = 255;
123 char temp[maxCharOfOneLine], *p;
124 int lineNo = 0, inputNo = 0;
125 while ( fin.peek() != EOF ) // Peek: Reads and returns the next character without extracting
126 // it, i.e. leaving it as the next character to be extracted from
127 // 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 >>
149 AlThickness >> PVFThickness;
150 break;
151 case 2: std::istrstream( p ) >> br2L >> br2TrapW1 >> br2TrapW2 >> br2TrapH >> br2R1; break;
152 case 3: std::istrstream( p ) >> bucketDBr >> bucketLBr; break;
153 case 4:
154 std::istrstream( p ) >> nScinEc >> ecL >> ecTrapW1 >> ecTrapW2 >> ecTrapH >> ecTrapH1 >>
155 zPosEastEc >> zPosWestEc >> ecR1 >> ecR2;
156 break;
157 case 5: std::istrstream( p ) >> bucketDEc >> bucketLEc >> bucketPosR; break;
158 case 6:
159 std::istrstream( p ) >> m_tau1 >> m_tau2 >> m_tau3 >> m_tauRatio >> m_refIndex >>
160 m_phNConst >> m_Cpe2pmt >> m_rAngle >> m_QE >> m_CE >> m_peCorFac;
161 case 7:
162 std::istrstream( p ) >> m_ttsMean >> m_ttsSigma >> m_PMTgain >> m_Ce >> m_riseTime >>
163 m_LLthresh >> m_HLthresh >> m_preGain >> m_noiseSigma;
164 case 8:
165 std::istrstream( p ) >> m_tau1Ec >> m_tau2Ec >> m_tau3Ec >> m_tauRatioEc >>
166 m_refIndexEc >> m_phNConstEc >> m_Cpe2pmtEc >> m_rAngleEc >> m_QEEc >> m_CEEc >>
167 m_peCorFacEc >> m_attenEc;
168 case 9:
169 std::istrstream( p ) >> m_ttsMeanEc >> m_ttsSigmaEc >> m_PMTgainEc >> m_CeEc >>
170 m_riseTimeEc >> m_LLthreshEc >> m_HLthreshEc >> m_preGainEc >> m_noiseSigmaEc;
171 }
172 }
173
174 fin.close();
175}
176
177void BesTofGeoParameter::ReadMrpcData() {
178 // G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
179 G4String MrpcGeometryPath = m_dataPath + "/dat/BesTofMrpc.txt";
180 const int maxCharOfOneLine = 255;
181 char temp[maxCharOfOneLine], *p;
182 container.clear();
183
184 std::string key;
185 double val;
186 std::string unit;
187 std::ifstream fin;
188 fin.open( MrpcGeometryPath );
189
190 while ( fin.peek() != EOF ) // Peek: Reads and returns the next character without extracting
191 // it, i.e. leaving it as the next character to be extracted from
192 // the stream.
193 {
194 fin.getline( temp, maxCharOfOneLine );
195 p = temp;
196 while ( *p != '\0' )
197 {
198 if ( *p == '#' )
199 {
200 *p = '\0'; // delete the comments.
201 break;
202 }
203 p++;
204 }
205 p = temp; // reset the pointer to the beginning of the string.
206 while ( *p == ' ' || *p == '\t' ) p++;
207 if ( *p == '\0' ) continue;
208
209 std::stringstream ss( temp );
210 ss >> key >> val >> unit;
211 container[key] = val * UNIT[unit];
212 }
213 fin.close();
214
215 // Adjusting parameters
216 container2.clear();
217 double rOffset, angle, angleOffset;
218 VEC v_rOffset, v_angle, v_angleOffset;
219 int lineNo = 0;
220 G4String MrpcGeometryPath1 = m_dataPath + "/dat/Mrpc_adjust.txt";
221 fin.open( MrpcGeometryPath1 );
222
223 while ( fin.peek() != EOF )
224 {
225 fin.getline( temp, maxCharOfOneLine );
226 p = temp;
227 while ( *p != '\0' )
228 {
229 if ( *p == '#' )
230 {
231 *p = '\0'; // delete the comments.
232 break;
233 }
234 p++;
235 }
236 p = temp; // reset the pointer to the beginning of the string.
237 while ( *p == ' ' || *p == '\t' ) p++;
238 if ( *p == '\0' ) continue;
239 lineNo++;
240
241 std::stringstream ss( temp );
242 std::stringstream name;
243 ss >> rOffset >> angle >> angleOffset;
244 if ( lineNo == 37 )
245 {
246 container2["rOffset_east"] = v_rOffset;
247 container2["angle_east"] = v_angle;
248 container2["angleOffset_east"] = v_angleOffset;
249
250 v_rOffset.clear();
251 v_angle.clear();
252 v_angleOffset.clear();
253 }
254
255 v_rOffset.push_back( rOffset );
256 v_angle.push_back( angle );
257 v_angleOffset.push_back( angleOffset );
258 }
259 container2["rOffset_west"] = v_rOffset;
260 container2["angle_west"] = v_angle;
261 container2["angleOffset_west"] = v_angleOffset;
262
263 fin.close();
264
265 ////Print out the map
266 // for(CONTAINER::iterator it=container.begin(); it!=container.end(); ++it)
267 //{
268 // std::cout<<it->first<<" "<<it->second<<std::endl;
269 // }
270
271 // for(CONTAINER2::iterator it=container2.begin(); it!=container2.end(); ++it)
272 //{
273 // std::cout<<it->first<<": "<<std::endl;
274 // for(VEC::iterator it2 = (it->second).begin(); it2!=(it->second).end(); it2++)
275 // {
276 // std::cout << *it2 << std::endl;
277 // }
278 // }
279
280 int tofid, strip, end;
281 for ( int i = 0; i < 72; i++ )
282 {
283 for ( int j = 0; j < 12; j++ ) { m_deadChannel[i][j] = -999; }
284 }
285
286 G4String MrpcGeometryPath2 = m_dataPath + "/dat/BesTofMrpc_dead.txt";
287 fin.open( MrpcGeometryPath2 );
288
289 while ( fin.peek() != EOF )
290 {
291 fin.getline( temp, maxCharOfOneLine );
292 p = temp;
293 while ( *p != '\0' )
294 {
295 if ( *p == '#' )
296 {
297 *p = '\0'; // delete the comments.
298 break;
299 }
300 p++;
301 }
302 p = temp; // reset the pointer to the beginning of the string.
303 while ( *p == ' ' || *p == '\t' ) p++;
304 if ( *p == '\0' ) continue;
305
306 std::stringstream ss( temp );
307 ss >> tofid >> strip >> end;
308 m_deadChannel[tofid][strip] = end;
309 std::cout << "deadC[" << tofid << "][" << strip << "]= " << m_deadChannel[tofid][strip]
310 << std::endl;
311 }
312
313 fin.close();
314}
315
316double BesTofGeoParameter::Get( std::string key ) {
317 for ( CONTAINER::iterator it = container.begin(); it != container.end(); ++it )
318 {
319 if ( ( it->first ) == key )
320 {
321 double val = container[key];
322 return val;
323 }
324 }
325
326 std::cout << "!!!! Wrong! Please check the value name !!!!" << std::endl;
327 return -999.9;
328}
329
331 VEC vec;
332 for ( CONTAINER2::iterator it = container2.begin(); it != container2.end(); ++it )
333 {
334 if ( ( it->first ) == key )
335 {
336 vec = container2[key];
337 return vec;
338 }
339 }
340
341 std::cout << "!!!! Wrong! Please check the value name !!!!" << std::endl;
342 return vec;
343}
344
345void BesTofGeoParameter::Get_deadChannel( int deadChannel[72][12] ) {
346 for ( int i = 0; i < 72; i++ )
347 {
348 for ( int j = 0; j < 12; j++ ) { deadChannel[i][j] = m_deadChannel[i][j]; }
349 }
350}
dble_vec_t vec[12]
*******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)