BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTuningIO Class Reference

#include <BesTuningIO.hh>

Public Member Functions

 BesTuningIO (std::vector< std::string >)
 
 ~BesTuningIO ()
 
void GetNextEvents (void)
 
void GetMdcHits (void)
 
void GetTofHits (void)
 
void GetEmcDigi (void)
 
void GetMucHits (void)
 
void GetRootEvent (int evtID)
 
void GetMdcRootHits ()
 
void GetTofRootHits ()
 
void GetEmcRootDigi ()
 
 BesTuningIO (std::vector< std::string >)
 
 ~BesTuningIO ()
 
void GetNextEvents (void)
 
void GetMdcHits (void)
 
void GetTofHits (void)
 
void GetEmcDigi (void)
 
void GetMucHits (void)
 
void GetRootEvent (int evtID)
 
void GetMdcRootHits ()
 
void GetTofRootHits ()
 
void GetEmcRootDigi ()
 

Public Attributes

TFile * f
 
TTree * HitTree
 
TChain * HitChain
 

Detailed Description

Constructor & Destructor Documentation

◆ BesTuningIO() [1/2]

BesTuningIO::BesTuningIO ( std::vector< std::string >  name)

Definition at line 39 of file BesTuningIO.cc.

40 :m_tuningFile(name),m_evt(0)
41{
42 m_DigiMan = G4DigiManager::GetDMpointer();
43 m_inputFileStream = new std::ifstream();
44
46 //tuning input root file
47 //TFile *f = new TFile(m_tuningFile);
48 //HitTree = (TTree*)f->Get("HitTree");
49 //m_TMcHitEvent = new TMcHitEvent();
50 //TBranch *branch = HitTree->GetBranch("TMcHitEvent");
51 // begin change from TTree to TChain
52 HitChain = new TChain("HitTree");
53 if (m_tuningFile.size()==0){
54 std::cout << "there is no tuning file" << std::endl;
55 }
56 std::cout << "file number: " << m_tuningFile.size() << std::endl;
57 for (int i = 0 ; i < m_tuningFile.size(); i++){
58
59 //std::cout << "________________________________________________________________________________fileName : " << m_tuningFile[i] << std::endl;
60 //HitChain->Add(&m_tuningFile[i]);
61 HitChain->Add(m_tuningFile[i].c_str());
62 }
63 m_TMcHitEvent = new TMcHitEvent();
64 TBranch *branch = HitChain->GetBranch("TMcHitEvent");
65
66 // end change from TTree to TChain
67 branch->SetAddress(&m_TMcHitEvent);
68 std::cout << "HitChain entries: " << HitChain->GetEntries() << std::endl;
69 }
70 else{// tuning input ascii file
71 //m_inputFileStream->open(m_tuningFile.c_str());
72 //if ((*m_inputFileStream).good()) {
73 // try {
74 // (*m_inputFileStream) >> m_version;
75 // } catch (AsciiDumpException& ) {
76 // std::cerr << "BesTuningIO::Got AsciiDumpException eror while reading VERSION block !!!" << std::endl;
77 // }
78 //}else{
79 // std::cerr << "BesTuningIO::Open tuning input file error!!!" << std::endl;
80 //}
81 }
82}
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ ~BesTuningIO() [1/2]

BesTuningIO::~BesTuningIO ( )

Definition at line 84 of file BesTuningIO.cc.

84 {
85 if (m_inputFileStream) delete m_inputFileStream;
86 if (m_evt) delete m_evt;
87}

◆ BesTuningIO() [2/2]

BesTuningIO::BesTuningIO ( std::vector< std::string >  )

◆ ~BesTuningIO() [2/2]

BesTuningIO::~BesTuningIO ( )

Member Function Documentation

◆ GetEmcDigi() [1/2]

void BesTuningIO::GetEmcDigi ( void  )

Definition at line 161 of file BesTuningIO.cc.

161 {
162 G4int THCID = -1;
163 THCID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
164 if (THCID>=0) {
165 BesEmcDigitsCollection* emcDC = new BesEmcDigitsCollection("BesEmcDigitizer","BesEmcDigitsCollection");
166 m_DigiMan->SetDigiCollection(THCID,emcDC);
167 }
168}
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection

Referenced by GetNextEvents().

◆ GetEmcDigi() [2/2]

void BesTuningIO::GetEmcDigi ( void  )

◆ GetEmcRootDigi() [1/2]

void BesTuningIO::GetEmcRootDigi ( )

Definition at line 185 of file BesTuningIO.cc.

185 {
186 G4int THCID = -1;
187 THCID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
188 //cout << "THCID " << THCID << endl;
189 if (THCID>=0) {
190 BesEmcDigitsCollection* emcDC = new BesEmcDigitsCollection("BesEmcDigitizer","BesEmcDigitsCollection");
191
192 //std::cout << "GetEmcRootDigi " << emcDC << std::endl;
193 if(emcDC){
194 int nHit = emcDC->entries();
195 //std::cout << "nHit: " << nHit << std::endl;
196 if(nHit > 0){
197 for(int i = 0; i < nHit; i++){
198 delete (*emcDC)[i];
199 }
200 emcDC->GetVector()->clear();
201 }
202 }
203
204 int nHits = m_TMcHitEvent->getMcDigiEmcCol()->GetEntries();
205 //std::cout << "nHits: " << nHits << std::endl;
206 for(int i = 0; i < nHits; i++){
207 m_TMcDigiEmc = m_TMcHitEvent->getMcDigiEmc(i);
208
209 BesEmcDigi* emcDigi = new BesEmcDigi();
210
211 emcDigi->SetPartId(m_TMcDigiEmc->GetPartId());
212 emcDigi->SetThetaNb(m_TMcDigiEmc->GetThetaNb());
213 emcDigi->SetPhiNb(m_TMcDigiEmc->GetPhiNb());
214 emcDigi->SetEnergy(m_TMcDigiEmc->GetEnergy());
215 emcDigi->SetTime(m_TMcDigiEmc->GetTime());
216 emcDigi->SetTrackIndex(m_TMcDigiEmc->GetTrackIndex());
217 //emcDigi->Print();
218 //std::cout << "SetEnergy" << emcDigi->GetEnergy() << std::endl;
219
220 emcDC->insert(emcDigi);
221 delete m_TMcDigiEmc;
222
223 }
224
225 //std::cout << "insert" << std::endl;
226 m_DigiMan->SetDigiCollection(THCID,emcDC);
227
228
229 }
230
231}
const TObjArray * getMcDigiEmcCol() const
retrieve the whole TObjArray of McHitMdc Data
const TMcDigiEmc * getMcDigiEmc(Int_t i) const
retrieve a McHitMdc From the collection, using the index into the array
Definition: TMcHitEvent.cxx:57

Referenced by GetRootEvent().

◆ GetEmcRootDigi() [2/2]

void BesTuningIO::GetEmcRootDigi ( )

◆ GetMdcHits() [1/2]

void BesTuningIO::GetMdcHits ( void  )

Definition at line 118 of file BesTuningIO.cc.

118 {
119 G4int mdcHitCollID = -1;
120 mdcHitCollID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
121 if (mdcHitCollID>=0){
122 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*)m_DigiMan->GetHitsCollection(mdcHitCollID);
123 if (mdcDC){
124 G4int nHit = mdcDC->entries();
125 if (nHit>0){
126 for (G4int i=0;i<nHit;i++)
127 {
128 delete (*mdcDC)[i];
129 }
130 mdcDC->GetVector()->clear();
131 }
132
133 std::vector<MdcHitType>::iterator iter;
134 iter = (m_evt->mdcHit).hitCol.begin();
135 // Loop over mdc hits
136 for (; iter != (m_evt->mdcHit).hitCol.end(); iter++) {
137 BesMdcHit* newHit = new BesMdcHit();
138 newHit->SetTrackID ((*iter).trackIndex);
139 newHit->SetLayerNo ((*iter).layerNo);
140 newHit->SetCellNo ((*iter).cellNo);
141 newHit->SetEdep ((*iter).energyDeposit);
142 newHit->SetPos (G4ThreeVector((*iter).posX,(*iter).posY,(*iter).posZ));
143 newHit->SetDriftD ((*iter).driftDistance);
144 newHit->SetTheta((*iter).theta);
145 newHit->SetPosFlag((*iter).posFlag);
146 newHit->SetEnterAngle((*iter).enterAngle);
147 newHit->SetDriftT (0.);
148 newHit->SetGlobalT((*iter).globalT);
149 mdcDC->insert(newHit);
150
151 }
152 //mdcDC->PrintAllHits();
153 }else{
154 std::cerr << "BesTuningIO::can't get mdcHitsCollection"<<std::endl;
155 }
156 }else{
157 std::cerr << "BesTuningIO::can't get mdcHitCollID"<<std::endl;
158 }
159}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
G4THitsCollection< BesMdcHit > BesMdcHitsCollection

Referenced by GetNextEvents().

◆ GetMdcHits() [2/2]

void BesTuningIO::GetMdcHits ( void  )

◆ GetMdcRootHits() [1/2]

void BesTuningIO::GetMdcRootHits ( )

Definition at line 233 of file BesTuningIO.cc.

233 {
234
235 G4int THCID = -1;
236 THCID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
237 if (THCID>=0) {
238 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
239 if(mdcDC){
240 int nHit = mdcDC->entries();
241 if(nHit > 0){
242 for(int i = 0; i < nHit; i++){
243 delete (*mdcDC)[i];
244 }
245 mdcDC->GetVector()->clear();
246 }
247 }
248
249 int nHits = m_TMcHitEvent->getMcHitMdcCol()->GetEntries();
250 //std::cout << "nHits: " << nHits << std::endl;
251 for(int i = 0; i < nHits; i++){
252 m_TMcHitMdc = m_TMcHitEvent->getMcHitMdc(i);
253
254 BesMdcHit* mdcHit = new BesMdcHit();
255
256 mdcHit->SetTrackID(m_TMcHitMdc->GetTrackID());
257 mdcHit->SetLayerNo(m_TMcHitMdc->GetLayerNo());
258 mdcHit->SetCellNo(m_TMcHitMdc->GetCellNo());
259 mdcHit->SetEdep(m_TMcHitMdc->GetEdep());
260 mdcHit->SetDriftD(m_TMcHitMdc->GetDriftD());
261 mdcHit->SetDriftT(m_TMcHitMdc->GetDriftT());
262 mdcHit->SetGlobalT(m_TMcHitMdc->GetGlobalT());
263 mdcHit->SetTheta(m_TMcHitMdc->GetTheta());
264 mdcHit->SetEnterAngle(m_TMcHitMdc->GetEnterAngle());
265 mdcHit->SetPosFlag(m_TMcHitMdc->GetPosFlag());
266
267 TVector3 tTemp = m_TMcHitMdc->GetPos();
268 G4ThreeVector gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
269 mdcHit->SetPos(gTemp);
270 //mdcHit->Print();
271
272 mdcDC->insert(mdcHit);
273 delete m_TMcHitMdc;
274
275 }
276
277
278 }
279
280}
const TMcHitMdc * getMcHitMdc(Int_t i) const
retrieve a McHitMdc From the collection, using the index into the array
Definition: TMcHitEvent.cxx:79
const TObjArray * getMcHitMdcCol() const
retrieve the whole TObjArray of McHitMdc Data

Referenced by GetRootEvent().

◆ GetMdcRootHits() [2/2]

void BesTuningIO::GetMdcRootHits ( )

◆ GetMucHits() [1/2]

void BesTuningIO::GetMucHits ( void  )
inline

Definition at line 39 of file InstallArea/include/BesSim/BesSim/BesTuningIO.hh.

39{};

Referenced by GetNextEvents(), and GetRootEvent().

◆ GetMucHits() [2/2]

void BesTuningIO::GetMucHits ( void  )
inline

◆ GetNextEvents() [1/2]

void BesTuningIO::GetNextEvents ( void  )

Definition at line 89 of file BesTuningIO.cc.

89 {
90 if (m_evt) delete m_evt;
91
92 m_evt = new HitEVENT;
93 try {
94 (*m_inputFileStream) >> *m_evt;
95 } catch (AsciiWrongTag& ex) {
96 std::cerr << "wrong tag, got " << ex.got()
97 << " expected: " << ex.expected()
98 << std::endl;
99 delete m_evt;
100 m_evt=0;
101 return;
102 } catch (AsciiDumpException&) {
103 std::cerr<<"BesTuningIO: Reach file end!"<<std::endl;
104 delete m_evt;
105 m_evt=0;
106 return;
107 }
108
110
112
114
116}
void GetMdcHits(void)
Definition: BesTuningIO.cc:118
void GetEmcDigi(void)
Definition: BesTuningIO.cc:161

Referenced by BesEventAction::EndOfEventAction().

◆ GetNextEvents() [2/2]

void BesTuningIO::GetNextEvents ( void  )

◆ GetRootEvent() [1/2]

void BesTuningIO::GetRootEvent ( int  evtID)

Definition at line 173 of file BesTuningIO.cc.

173 {
174 //std::cout << "evtID: " << evtID << std::endl;
175 //HitTree->GetEntry(evtID);
176 HitChain->GetEntry(evtID);
177 //std::cout << "HitChain" << std::endl;
182}
void GetEmcRootDigi()
Definition: BesTuningIO.cc:185
void GetTofRootHits()
Definition: BesTuningIO.cc:282
void GetMdcRootHits()
Definition: BesTuningIO.cc:233

Referenced by BesEventAction::EndOfEventAction().

◆ GetRootEvent() [2/2]

void BesTuningIO::GetRootEvent ( int  evtID)

◆ GetTofHits() [1/2]

void BesTuningIO::GetTofHits ( void  )
inline

Definition at line 37 of file InstallArea/include/BesSim/BesSim/BesTuningIO.hh.

37{};

Referenced by GetNextEvents().

◆ GetTofHits() [2/2]

void BesTuningIO::GetTofHits ( void  )
inline

◆ GetTofRootHits() [1/2]

void BesTuningIO::GetTofRootHits ( )

Definition at line 282 of file BesTuningIO.cc.

282 {
283
284 //retrieve G4Svc
285 ISvcLocator* svcLocator = Gaudi::svcLocator();
286 IG4Svc* tmpSvc;
287 StatusCode sc = svcLocator->service("G4Svc", tmpSvc);
288 G4Svc* m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc);
289
290 const double m_beamTime = m_TMcHitEvent->getBeamTime();
291 m_G4Svc->SetBeamTime(m_beamTime);
292 //std::cout << "beamtime: " << m_beamTime << std::endl;
293
294 G4int THCID = -1;
295 THCID = m_DigiMan->GetHitsCollectionID("BesTofHitsCollection");
296 if (THCID>=0) {
297 BesTofHitsCollection* tofDC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
298 if(tofDC){
299 int nHit = tofDC->entries();
300 if(nHit > 0){
301 for(int i = 0; i < nHit; i++){
302 delete (*tofDC)[i];
303 }
304 tofDC->GetVector()->clear();
305 }
306 }
307
308 int nHits = m_TMcHitEvent->getMcHitTofCol()->GetEntries();
309 //std::cout << "nHits: " << nHits << std::endl;
310 for(int i = 0; i < nHits; i++){
311 m_TMcHitTof = m_TMcHitEvent->getMcHitTof(i);
312
313 BesTofHit* tofHit = new BesTofHit();
314
315 tofHit->SetTrackIndex(m_TMcHitTof->GetTrackIndex());
316 tofHit->SetG4Index(m_TMcHitTof->GetG4Index());
317 tofHit->SetPartId(m_TMcHitTof->GetPartId());
318 tofHit->SetScinNb(m_TMcHitTof->GetScinNb());
319 tofHit->SetEdep(m_TMcHitTof->GetEdep());
320 tofHit->SetStepL(m_TMcHitTof->GetStepL());
321 tofHit->SetTrackL(m_TMcHitTof->GetTrackL());
322 tofHit->SetTime(m_TMcHitTof->GetTime());
323 tofHit->SetDeltaT(m_TMcHitTof->GetDeltaT());
324 tofHit->SetCharge(m_TMcHitTof->GetCharge());
325
326 TVector3 tTemp = m_TMcHitTof->GetPos();
327 G4ThreeVector gTemp(tTemp.X(), tTemp.Y(), tTemp.Z());
328 tofHit->SetPos(gTemp);
329
330 tTemp = m_TMcHitTof->GetPDirection();
331 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
332 tofHit->SetPDirection(gTemp);
333
334 tTemp = m_TMcHitTof->GetMomentum();
335 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
336 tofHit->SetMomentum(gTemp);
337
338 //tofHit->Print();
339
340 tofDC->insert(tofHit);
341 delete m_TMcHitTof;
342
343 }
344
345 //std::cout << "tofDC: " << tofDC->entries() << std::endl;
346
347 }
348
349}
G4THitsCollection< BesTofHit > BesTofHitsCollection
void SetPDirection(G4ThreeVector pDirection)
void SetMomentum(G4ThreeVector momentum)
void SetBeamTime(double value)
const TObjArray * getMcHitTofCol() const
retrieve the whole TObjArray of McHitTof Data
const TMcHitTof * getMcHitTof(Int_t i) const
retrieve a McHitTof From the collection, using the index into the array
Definition: TMcHitEvent.cxx:68

Referenced by GetRootEvent().

◆ GetTofRootHits() [2/2]

void BesTuningIO::GetTofRootHits ( )

Member Data Documentation

◆ f

TFile * BesTuningIO::f

◆ HitChain

TChain * BesTuningIO::HitChain

Definition at line 44 of file InstallArea/include/BesSim/BesSim/BesTuningIO.hh.

Referenced by BesTuningIO(), and GetRootEvent().

◆ HitTree

TTree * BesTuningIO::HitTree

The documentation for this class was generated from the following files: