#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 () |
Public Attributes | |
TFile * | f |
TTree * | HitTree |
TChain * | HitChain |
Private Attributes | |
std::vector< std::string > | m_tuningFile |
std::ifstream * | m_inputFileStream |
FRMTVERSION | m_version |
HitEVENT * | m_evt |
G4DigiManager * | m_DigiMan |
const TMcHitEvent * | m_TMcHitEvent |
const TMcHitTof * | m_TMcHitTof |
const TMcHitMdc * | m_TMcHitMdc |
const TMcDigiEmc * | m_TMcDigiEmc |
G4int | trackIndex |
G4int | layerNo |
G4int | cellNo |
G4double | posX |
G4double | posY |
G4double | posZ |
G4double | energyDeposit |
G4double | driftDistance |
G4double | globalT |
G4double | theta |
G4double | enterAngle |
G4double | posFlag |
Definition at line 26 of file BesTuningIO.hh.
BesTuningIO::BesTuningIO | ( | std::vector< std::string > | ) |
Definition at line 39 of file BesTuningIO.cc.
References ReadBoostRoot::GetFormatAR(), HitChain, genRecEmupikp::i, m_DigiMan, m_inputFileStream, m_TMcHitEvent, and m_tuningFile.
00040 :m_tuningFile(name),m_evt(0) 00041 { 00042 m_DigiMan = G4DigiManager::GetDMpointer(); 00043 m_inputFileStream = new std::ifstream(); 00044 00045 if (ReadBoostRoot::GetFormatAR()){ 00046 //tuning input root file 00047 //TFile *f = new TFile(m_tuningFile); 00048 //HitTree = (TTree*)f->Get("HitTree"); 00049 //m_TMcHitEvent = new TMcHitEvent(); 00050 //TBranch *branch = HitTree->GetBranch("TMcHitEvent"); 00051 // begin change from TTree to TChain 00052 HitChain = new TChain("HitTree"); 00053 if (m_tuningFile.size()==0){ 00054 std::cout << "there is no tuning file" << std::endl; 00055 } 00056 std::cout << "file number: " << m_tuningFile.size() << std::endl; 00057 for (int i = 0 ; i < m_tuningFile.size(); i++){ 00058 00059 //std::cout << "________________________________________________________________________________fileName : " << m_tuningFile[i] << std::endl; 00060 //HitChain->Add(&m_tuningFile[i]); 00061 HitChain->Add(m_tuningFile[i].c_str()); 00062 } 00063 m_TMcHitEvent = new TMcHitEvent(); 00064 TBranch *branch = HitChain->GetBranch("TMcHitEvent"); 00065 00066 // end change from TTree to TChain 00067 branch->SetAddress(&m_TMcHitEvent); 00068 std::cout << "HitChain entries: " << HitChain->GetEntries() << std::endl; 00069 } 00070 else{// tuning input ascii file 00071 //m_inputFileStream->open(m_tuningFile.c_str()); 00072 //if ((*m_inputFileStream).good()) { 00073 // try { 00074 // (*m_inputFileStream) >> m_version; 00075 // } catch (AsciiDumpException& ) { 00076 // std::cerr << "BesTuningIO::Got AsciiDumpException eror while reading VERSION block !!!" << std::endl; 00077 // } 00078 //}else{ 00079 // std::cerr << "BesTuningIO::Open tuning input file error!!!" << std::endl; 00080 //} 00081 } 00082 }
BesTuningIO::~BesTuningIO | ( | ) |
Definition at line 84 of file BesTuningIO.cc.
References m_evt, and m_inputFileStream.
00084 { 00085 if (m_inputFileStream) delete m_inputFileStream; 00086 if (m_evt) delete m_evt; 00087 }
void BesTuningIO::GetEmcDigi | ( | void | ) |
Definition at line 161 of file BesTuningIO.cc.
References m_DigiMan.
Referenced by GetNextEvents().
00161 { 00162 G4int THCID = -1; 00163 THCID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection"); 00164 if (THCID>=0) { 00165 BesEmcDigitsCollection* emcDC = new BesEmcDigitsCollection("BesEmcDigitizer","BesEmcDigitsCollection"); 00166 m_DigiMan->SetDigiCollection(THCID,emcDC); 00167 } 00168 }
void BesTuningIO::GetEmcRootDigi | ( | ) |
Definition at line 185 of file BesTuningIO.cc.
References TMcDigiEmc::GetEnergy(), TMcHitEvent::getMcDigiEmc(), TMcHitEvent::getMcDigiEmcCol(), TMcDigiEmc::GetPartId(), TMcDigiEmc::GetPhiNb(), TMcDigiEmc::GetThetaNb(), TMcDigiEmc::GetTime(), TMcDigiEmc::GetTrackIndex(), genRecEmupikp::i, m_DigiMan, m_TMcDigiEmc, m_TMcHitEvent, BesEmcDigi::SetEnergy(), BesEmcDigi::SetPartId(), BesEmcDigi::SetPhiNb(), BesEmcDigi::SetThetaNb(), BesEmcDigi::SetTime(), and BesEmcDigi::SetTrackIndex().
Referenced by GetRootEvent().
00185 { 00186 G4int THCID = -1; 00187 THCID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection"); 00188 //cout << "THCID " << THCID << endl; 00189 if (THCID>=0) { 00190 BesEmcDigitsCollection* emcDC = new BesEmcDigitsCollection("BesEmcDigitizer","BesEmcDigitsCollection"); 00191 00192 //std::cout << "GetEmcRootDigi " << emcDC << std::endl; 00193 if(emcDC){ 00194 int nHit = emcDC->entries(); 00195 //std::cout << "nHit: " << nHit << std::endl; 00196 if(nHit > 0){ 00197 for(int i = 0; i < nHit; i++){ 00198 delete (*emcDC)[i]; 00199 } 00200 emcDC->GetVector()->clear(); 00201 } 00202 } 00203 00204 int nHits = m_TMcHitEvent->getMcDigiEmcCol()->GetEntries(); 00205 //std::cout << "nHits: " << nHits << std::endl; 00206 for(int i = 0; i < nHits; i++){ 00207 m_TMcDigiEmc = m_TMcHitEvent->getMcDigiEmc(i); 00208 00209 BesEmcDigi* emcDigi = new BesEmcDigi(); 00210 00211 emcDigi->SetPartId(m_TMcDigiEmc->GetPartId()); 00212 emcDigi->SetThetaNb(m_TMcDigiEmc->GetThetaNb()); 00213 emcDigi->SetPhiNb(m_TMcDigiEmc->GetPhiNb()); 00214 emcDigi->SetEnergy(m_TMcDigiEmc->GetEnergy()); 00215 emcDigi->SetTime(m_TMcDigiEmc->GetTime()); 00216 emcDigi->SetTrackIndex(m_TMcDigiEmc->GetTrackIndex()); 00217 //emcDigi->Print(); 00218 //std::cout << "SetEnergy" << emcDigi->GetEnergy() << std::endl; 00219 00220 emcDC->insert(emcDigi); 00221 delete m_TMcDigiEmc; 00222 00223 } 00224 00225 //std::cout << "insert" << std::endl; 00226 m_DigiMan->SetDigiCollection(THCID,emcDC); 00227 00228 00229 } 00230 00231 }
void BesTuningIO::GetMdcHits | ( | void | ) |
Definition at line 118 of file BesTuningIO.cc.
References genRecEmupikp::i, iter(), m_DigiMan, m_evt, and HitEVENT::mdcHit.
Referenced by GetNextEvents().
00118 { 00119 G4int mdcHitCollID = -1; 00120 mdcHitCollID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection"); 00121 if (mdcHitCollID>=0){ 00122 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*)m_DigiMan->GetHitsCollection(mdcHitCollID); 00123 if (mdcDC){ 00124 G4int nHit = mdcDC->entries(); 00125 if (nHit>0){ 00126 for (G4int i=0;i<nHit;i++) 00127 { 00128 delete (*mdcDC)[i]; 00129 } 00130 mdcDC->GetVector()->clear(); 00131 } 00132 00133 std::vector<MdcHitType>::iterator iter; 00134 iter = (m_evt->mdcHit).hitCol.begin(); 00135 // Loop over mdc hits 00136 for (; iter != (m_evt->mdcHit).hitCol.end(); iter++) { 00137 BesMdcHit* newHit = new BesMdcHit(); 00138 newHit->SetTrackID ((*iter).trackIndex); 00139 newHit->SetLayerNo ((*iter).layerNo); 00140 newHit->SetCellNo ((*iter).cellNo); 00141 newHit->SetEdep ((*iter).energyDeposit); 00142 newHit->SetPos (G4ThreeVector((*iter).posX,(*iter).posY,(*iter).posZ)); 00143 newHit->SetDriftD ((*iter).driftDistance); 00144 newHit->SetTheta((*iter).theta); 00145 newHit->SetPosFlag((*iter).posFlag); 00146 newHit->SetEnterAngle((*iter).enterAngle); 00147 newHit->SetDriftT (0.); 00148 newHit->SetGlobalT((*iter).globalT); 00149 mdcDC->insert(newHit); 00150 00151 } 00152 //mdcDC->PrintAllHits(); 00153 }else{ 00154 std::cerr << "BesTuningIO::can't get mdcHitsCollection"<<std::endl; 00155 } 00156 }else{ 00157 std::cerr << "BesTuningIO::can't get mdcHitCollID"<<std::endl; 00158 } 00159 }
void BesTuningIO::GetMdcRootHits | ( | ) |
Definition at line 233 of file BesTuningIO.cc.
References TMcHitMdc::GetCellNo(), TMcHitMdc::GetDriftD(), TMcHitMdc::GetDriftT(), TMcHitMdc::GetEdep(), TMcHitMdc::GetEnterAngle(), TMcHitMdc::GetGlobalT(), TMcHitMdc::GetLayerNo(), TMcHitEvent::getMcHitMdc(), TMcHitEvent::getMcHitMdcCol(), TMcHitMdc::GetPos(), TMcHitMdc::GetPosFlag(), TMcHitMdc::GetTheta(), TMcHitMdc::GetTrackID(), genRecEmupikp::i, m_DigiMan, m_TMcHitEvent, m_TMcHitMdc, BesMdcHit::SetCellNo(), BesMdcHit::SetDriftD(), BesMdcHit::SetDriftT(), BesMdcHit::SetEdep(), BesMdcHit::SetEnterAngle(), BesMdcHit::SetGlobalT(), BesMdcHit::SetLayerNo(), BesMdcHit::SetPos(), BesMdcHit::SetPosFlag(), BesMdcHit::SetTheta(), and BesMdcHit::SetTrackID().
Referenced by GetRootEvent().
00233 { 00234 00235 G4int THCID = -1; 00236 THCID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection"); 00237 if (THCID>=0) { 00238 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(THCID)); 00239 if(mdcDC){ 00240 int nHit = mdcDC->entries(); 00241 if(nHit > 0){ 00242 for(int i = 0; i < nHit; i++){ 00243 delete (*mdcDC)[i]; 00244 } 00245 mdcDC->GetVector()->clear(); 00246 } 00247 } 00248 00249 int nHits = m_TMcHitEvent->getMcHitMdcCol()->GetEntries(); 00250 //std::cout << "nHits: " << nHits << std::endl; 00251 for(int i = 0; i < nHits; i++){ 00252 m_TMcHitMdc = m_TMcHitEvent->getMcHitMdc(i); 00253 00254 BesMdcHit* mdcHit = new BesMdcHit(); 00255 00256 mdcHit->SetTrackID(m_TMcHitMdc->GetTrackID()); 00257 mdcHit->SetLayerNo(m_TMcHitMdc->GetLayerNo()); 00258 mdcHit->SetCellNo(m_TMcHitMdc->GetCellNo()); 00259 mdcHit->SetEdep(m_TMcHitMdc->GetEdep()); 00260 mdcHit->SetDriftD(m_TMcHitMdc->GetDriftD()); 00261 mdcHit->SetDriftT(m_TMcHitMdc->GetDriftT()); 00262 mdcHit->SetGlobalT(m_TMcHitMdc->GetGlobalT()); 00263 mdcHit->SetTheta(m_TMcHitMdc->GetTheta()); 00264 mdcHit->SetEnterAngle(m_TMcHitMdc->GetEnterAngle()); 00265 mdcHit->SetPosFlag(m_TMcHitMdc->GetPosFlag()); 00266 00267 TVector3 tTemp = m_TMcHitMdc->GetPos(); 00268 G4ThreeVector gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z()); 00269 mdcHit->SetPos(gTemp); 00270 //mdcHit->Print(); 00271 00272 mdcDC->insert(mdcHit); 00273 delete m_TMcHitMdc; 00274 00275 } 00276 00277 00278 } 00279 00280 }
void BesTuningIO::GetMucHits | ( | void | ) | [inline] |
void BesTuningIO::GetNextEvents | ( | void | ) |
Definition at line 89 of file BesTuningIO.cc.
References AsciiWrongTag::expected(), ReadBoostRoot::GetEmc(), GetEmcDigi(), ReadBoostRoot::GetMdc(), GetMdcHits(), ReadBoostRoot::GetMuc(), GetMucHits(), ReadBoostRoot::GetTof(), GetTofHits(), AsciiWrongTag::got(), and m_evt.
Referenced by BesEventAction::EndOfEventAction().
00089 { 00090 if (m_evt) delete m_evt; 00091 00092 m_evt = new HitEVENT; 00093 try { 00094 (*m_inputFileStream) >> *m_evt; 00095 } catch (AsciiWrongTag& ex) { 00096 std::cerr << "wrong tag, got " << ex.got() 00097 << " expected: " << ex.expected() 00098 << std::endl; 00099 delete m_evt; 00100 m_evt=0; 00101 return; 00102 } catch (AsciiDumpException&) { 00103 std::cerr<<"BesTuningIO: Reach file end!"<<std::endl; 00104 delete m_evt; 00105 m_evt=0; 00106 return; 00107 } 00108 00109 if (ReadBoostRoot::GetMdc())GetMdcHits(); 00110 00111 if (ReadBoostRoot::GetTof())GetTofHits(); 00112 00113 if (ReadBoostRoot::GetEmc())GetEmcDigi(); 00114 00115 if (ReadBoostRoot::GetMuc())GetMucHits(); 00116 }
void BesTuningIO::GetRootEvent | ( | int | evtID | ) |
Definition at line 173 of file BesTuningIO.cc.
References ReadBoostRoot::GetEmc(), GetEmcRootDigi(), ReadBoostRoot::GetMdc(), GetMdcRootHits(), ReadBoostRoot::GetMuc(), GetMucHits(), ReadBoostRoot::GetTof(), GetTofRootHits(), and HitChain.
Referenced by BesEventAction::EndOfEventAction().
00173 { 00174 //std::cout << "evtID: " << evtID << std::endl; 00175 //HitTree->GetEntry(evtID); 00176 HitChain->GetEntry(evtID); 00177 //std::cout << "HitChain" << std::endl; 00178 if (ReadBoostRoot::GetMdc())GetMdcRootHits(); 00179 if (ReadBoostRoot::GetTof())GetTofRootHits(); 00180 if (ReadBoostRoot::GetEmc())GetEmcRootDigi(); 00181 if (ReadBoostRoot::GetMuc())GetMucHits(); 00182 }
void BesTuningIO::GetTofHits | ( | void | ) | [inline] |
void BesTuningIO::GetTofRootHits | ( | ) |
Definition at line 282 of file BesTuningIO.cc.
References TMcHitEvent::getBeamTime(), TMcHitTof::GetCharge(), TMcHitTof::GetDeltaT(), TMcHitTof::GetEdep(), TMcHitTof::GetG4Index(), TMcHitEvent::getMcHitTof(), TMcHitEvent::getMcHitTofCol(), TMcHitTof::GetMomentum(), TMcHitTof::GetPartId(), TMcHitTof::GetPDirection(), TMcHitTof::GetPos(), TMcHitTof::GetScinNb(), TMcHitTof::GetStepL(), TMcHitTof::GetTime(), TMcHitTof::GetTrackIndex(), TMcHitTof::GetTrackL(), genRecEmupikp::i, m_DigiMan, m_TMcHitEvent, m_TMcHitTof, G4Svc::SetBeamTime(), BesTofHit::SetCharge(), BesTofHit::SetDeltaT(), BesTofHit::SetEdep(), BesTofHit::SetG4Index(), BesTofHit::SetMomentum(), BesTofHit::SetPartId(), BesTofHit::SetPDirection(), BesTofHit::SetPos(), BesTofHit::SetScinNb(), BesTofHit::SetStepL(), BesTofHit::SetTime(), BesTofHit::SetTrackIndex(), and BesTofHit::SetTrackL().
Referenced by GetRootEvent().
00282 { 00283 00284 //retrieve G4Svc 00285 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00286 IG4Svc* tmpSvc; 00287 StatusCode sc = svcLocator->service("G4Svc", tmpSvc); 00288 G4Svc* m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc); 00289 00290 const double m_beamTime = m_TMcHitEvent->getBeamTime(); 00291 m_G4Svc->SetBeamTime(m_beamTime); 00292 //std::cout << "beamtime: " << m_beamTime << std::endl; 00293 00294 G4int THCID = -1; 00295 THCID = m_DigiMan->GetHitsCollectionID("BesTofHitsCollection"); 00296 if (THCID>=0) { 00297 BesTofHitsCollection* tofDC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(THCID)); 00298 if(tofDC){ 00299 int nHit = tofDC->entries(); 00300 if(nHit > 0){ 00301 for(int i = 0; i < nHit; i++){ 00302 delete (*tofDC)[i]; 00303 } 00304 tofDC->GetVector()->clear(); 00305 } 00306 } 00307 00308 int nHits = m_TMcHitEvent->getMcHitTofCol()->GetEntries(); 00309 //std::cout << "nHits: " << nHits << std::endl; 00310 for(int i = 0; i < nHits; i++){ 00311 m_TMcHitTof = m_TMcHitEvent->getMcHitTof(i); 00312 00313 BesTofHit* tofHit = new BesTofHit(); 00314 00315 tofHit->SetTrackIndex(m_TMcHitTof->GetTrackIndex()); 00316 tofHit->SetG4Index(m_TMcHitTof->GetG4Index()); 00317 tofHit->SetPartId(m_TMcHitTof->GetPartId()); 00318 tofHit->SetScinNb(m_TMcHitTof->GetScinNb()); 00319 tofHit->SetEdep(m_TMcHitTof->GetEdep()); 00320 tofHit->SetStepL(m_TMcHitTof->GetStepL()); 00321 tofHit->SetTrackL(m_TMcHitTof->GetTrackL()); 00322 tofHit->SetTime(m_TMcHitTof->GetTime()); 00323 tofHit->SetDeltaT(m_TMcHitTof->GetDeltaT()); 00324 tofHit->SetCharge(m_TMcHitTof->GetCharge()); 00325 00326 TVector3 tTemp = m_TMcHitTof->GetPos(); 00327 G4ThreeVector gTemp(tTemp.X(), tTemp.Y(), tTemp.Z()); 00328 tofHit->SetPos(gTemp); 00329 00330 tTemp = m_TMcHitTof->GetPDirection(); 00331 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z()); 00332 tofHit->SetPDirection(gTemp); 00333 00334 tTemp = m_TMcHitTof->GetMomentum(); 00335 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z()); 00336 tofHit->SetMomentum(gTemp); 00337 00338 //tofHit->Print(); 00339 00340 tofDC->insert(tofHit); 00341 delete m_TMcHitTof; 00342 00343 } 00344 00345 //std::cout << "tofDC: " << tofDC->entries() << std::endl; 00346 00347 } 00348 00349 }
G4int BesTuningIO::cellNo [private] |
Definition at line 66 of file BesTuningIO.hh.
G4double BesTuningIO::driftDistance [private] |
Definition at line 71 of file BesTuningIO.hh.
G4double BesTuningIO::energyDeposit [private] |
Definition at line 70 of file BesTuningIO.hh.
G4double BesTuningIO::enterAngle [private] |
Definition at line 74 of file BesTuningIO.hh.
TFile* BesTuningIO::f |
Definition at line 39 of file BesTuningIO.hh.
G4double BesTuningIO::globalT [private] |
Definition at line 72 of file BesTuningIO.hh.
TChain* BesTuningIO::HitChain |
TTree* BesTuningIO::HitTree |
Definition at line 43 of file BesTuningIO.hh.
G4int BesTuningIO::layerNo [private] |
Definition at line 65 of file BesTuningIO.hh.
G4DigiManager* BesTuningIO::m_DigiMan [private] |
Definition at line 56 of file BesTuningIO.hh.
Referenced by BesTuningIO(), GetEmcDigi(), GetEmcRootDigi(), GetMdcHits(), GetMdcRootHits(), and GetTofRootHits().
HitEVENT* BesTuningIO::m_evt [private] |
Definition at line 55 of file BesTuningIO.hh.
Referenced by GetMdcHits(), GetNextEvents(), and ~BesTuningIO().
std::ifstream* BesTuningIO::m_inputFileStream [private] |
const TMcDigiEmc* BesTuningIO::m_TMcDigiEmc [private] |
const TMcHitEvent* BesTuningIO::m_TMcHitEvent [private] |
Definition at line 58 of file BesTuningIO.hh.
Referenced by BesTuningIO(), GetEmcRootDigi(), GetMdcRootHits(), and GetTofRootHits().
const TMcHitMdc* BesTuningIO::m_TMcHitMdc [private] |
const TMcHitTof* BesTuningIO::m_TMcHitTof [private] |
std::vector<std::string> BesTuningIO::m_tuningFile [private] |
FRMTVERSION BesTuningIO::m_version [private] |
Definition at line 54 of file BesTuningIO.hh.
G4double BesTuningIO::posFlag [private] |
Definition at line 75 of file BesTuningIO.hh.
G4double BesTuningIO::posX [private] |
Definition at line 67 of file BesTuningIO.hh.
G4double BesTuningIO::posY [private] |
Definition at line 68 of file BesTuningIO.hh.
G4double BesTuningIO::posZ [private] |
Definition at line 69 of file BesTuningIO.hh.
G4double BesTuningIO::theta [private] |
Definition at line 73 of file BesTuningIO.hh.
G4int BesTuningIO::trackIndex [private] |
Definition at line 64 of file BesTuningIO.hh.