BOSS 6.6.4.p01
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//using namespace std;
19
20BesTofGeoParameter* BesTofGeoParameter::m_instance = 0;
21
23{
24 if (m_instance == 0){
25 m_instance = new BesTofGeoParameter;
26 }
27 return m_instance;
28}
29
30//Construchttor --> Initialize the path, where data will be read from
32{
33 m_dataPath = getenv("TOFSIMROOT");
34 if (!m_dataPath){
35 G4Exception("BOOST environment not set!");
36 }
37 //fot test
38 ReadData();
39 ReadBrData();
40 //ReadMrpcData();
41}
42
44{
45}
46
47void BesTofGeoParameter::ReadBrData()
48{
49 // read file
50 const G4String pmtDataPath = m_dataPath + "/dat/TofBr.txt";
51
52 std::ifstream fin(pmtDataPath);
53 if (!fin) {
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 // remove comments
67 pre_position = tempString.find_first_of("#");
68 if (pre_position != string::npos){ // there is no "#" in string
69 tempString.erase(tempString.begin() + pre_position, tempString.end());
70 }
71
72 // format string
73 pre_position = 0;
74 post_position = 0;
75 int size;
76 while (tempString.find_first_of(" ", pre_position) != string::npos){
77 pre_position = tempString.find_first_of(" ", pre_position);
78 post_position = tempString.find_first_not_of(" ", pre_position);
79 size = post_position - pre_position;
80 tempString.replace(pre_position, size, " ");
81 pre_position = post_position - size + 1;
82 }
83
84 // insert into string vector
85 if (tempString.size() > 10){
86 stringVector.push_back(tempString);
87 }
88 }
89
90 // for tests, read from string, write to variables
91 int scinNb;
92 double tempEPMTgain;
93 double tempERiseTime;
94 double tempWPMTgain;
95 double tempWRiseTime;
96 double tempAtten;
97 vector<string>::iterator it = stringVector.begin();
98 for (it; it != stringVector.end(); it++){
99 // string 2 buffer, buffer 2 temp Variables
100 std::istrstream buff((*it).c_str(), strlen((*it).c_str()));
101 buff >> scinNb >> tempEPMTgain >> tempERiseTime >> tempWPMTgain >> tempWRiseTime >> tempAtten;
102
103 m_BrEPMTgain[scinNb] = tempEPMTgain;
104 m_BrERiseTime[scinNb] = tempERiseTime;
105 m_BrWPMTgain[scinNb] = tempWPMTgain;
106 m_BrWRiseTime[scinNb] = tempWRiseTime;
107 m_atten[scinNb] = tempAtten;
108
109 }
110
111
112 fin.close();
113}
114
115void BesTofGeoParameter::ReadData()
116{
117 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
118 const G4String GeometryPath = m_dataPath + "/dat/BesTof.txt";
119
120 std::ifstream fin;
121 fin.open(GeometryPath);
122
123 const int maxCharOfOneLine=255;
124 char temp[maxCharOfOneLine],*p;
125 int lineNo=0,inputNo=0;
126 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.
127 {
128 fin.getline(temp,maxCharOfOneLine);
129 p=temp;
130 lineNo++;
131 while (*p!='\0')
132 {
133 if (*p=='#')
134 {
135 *p='\0'; //delete the comments.
136 break;
137 }
138 p++;
139 }
140 p=temp; //reset the pointer to the beginning of the string.
141 while (*p==' '||*p=='\t')p++;
142 if (*p=='\0')continue;
143 inputNo++;
144 switch (inputNo)
145 {
146 case 1:
147 std::istrstream(p)>>nScinBr>>br1L>>br1TrapW1>>br1TrapW2>>br1TrapH>>br1R1>>AlThickness>>PVFThickness;
148 break;
149 case 2:
150 std::istrstream(p)>>br2L>>br2TrapW1>>br2TrapW2>>br2TrapH>>br2R1;
151 break;
152 case 3:
153 std::istrstream(p)>>bucketDBr>>bucketLBr;
154 break;
155 case 4:
156 std::istrstream(p)>>nScinEc>>ecL>>ecTrapW1>>ecTrapW2>>ecTrapH>>ecTrapH1
157 >>zPosEastEc>>zPosWestEc>>ecR1>>ecR2;
158 break;
159 case 5:
160 std::istrstream(p)>>bucketDEc>>bucketLEc>>bucketPosR;
161 break;
162 case 6:
163 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;
164 case 7:
165 std::istrstream(p)>>m_ttsMean>>m_ttsSigma>>m_PMTgain>>m_Ce>>m_riseTime>>m_LLthresh>>m_HLthresh>>m_preGain>>m_noiseSigma;
166 case 8:
167 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;
168 case 9:
169 std::istrstream(p)>>m_ttsMeanEc>>m_ttsSigmaEc>>m_PMTgainEc>>m_CeEc>>m_riseTimeEc>>m_LLthreshEc>>m_HLthreshEc>>m_preGainEc>>m_noiseSigmaEc;
170 }
171 }
172}
173
174
175/*
176void BesTofGeoParameter::ReadMrpcData()
177{
178 //G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
179 const G4String GeometryPath = m_dataPath + "/dat/BesTofMrpc.txt";
180
181 std::ifstream fin;
182 fin.open(GeometryPath);
183
184 const int maxCharOfOneLine=255;
185 char temp[maxCharOfOneLine],*p;
186 int lineNo=0,inputNo=0;
187 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.
188 {
189 fin.getline(temp,maxCharOfOneLine);
190 p=temp;
191 lineNo++;
192 while (*p!='\0')
193 {
194 if (*p=='#')
195 {
196 *p='\0'; //delete the comments.
197 break;
198 }
199 p++;
200 }
201 p=temp; //reset the pointer to the beginning of the string.
202 while (*p==' '||*p=='\t')p++;
203 if (*p=='\0')continue;
204 inputNo++;
205 switch (inputNo)
206 {
207 case 1:
208 std::istrstream(p)>>nScinBr>>br1L>>br1TrapW1>>br1TrapW2>>br1TrapH>>br1R1>>AlThickness>>PVFThickness;
209 break;
210 case 2:
211 std::istrstream(p)>>br2L>>br2TrapW1>>br2TrapW2>>br2TrapH>>br2R1;
212 break;
213
214 }
215 }
216}
217*/
static BesTofGeoParameter * GetInstance()