#include <BesTuningIO.hh>
Public Member Functions | |
BesTuningIO (std::vector< std::string >) | |
BesTuningIO (std::vector< std::string >) | |
void | GetEmcDigi (void) |
void | GetEmcDigi (void) |
void | GetEmcRootDigi () |
void | GetEmcRootDigi () |
void | GetMdcHits (void) |
void | GetMdcHits (void) |
void | GetMdcRootHits () |
void | GetMdcRootHits () |
void | GetMucHits (void) |
void | GetMucHits (void) |
void | GetNextEvents (void) |
void | GetNextEvents (void) |
void | GetRootEvent (int evtID) |
void | GetRootEvent (int evtID) |
void | GetTofHits (void) |
void | GetTofHits (void) |
void | GetTofRootHits () |
void | GetTofRootHits () |
~BesTuningIO () | |
~BesTuningIO () | |
Public Attributes | |
TFile * | f |
TFile * | f |
TChain * | HitChain |
TChain * | HitChain |
TTree * | HitTree |
TTree * | HitTree |
Private Attributes | |
G4int | cellNo |
G4double | driftDistance |
G4double | energyDeposit |
G4double | enterAngle |
G4double | globalT |
G4int | layerNo |
G4DigiManager * | m_DigiMan |
G4DigiManager * | m_DigiMan |
HitEVENT * | m_evt |
HitEVENT * | m_evt |
std::ifstream * | m_inputFileStream |
std::ifstream * | m_inputFileStream |
const TMcDigiEmc * | m_TMcDigiEmc |
const TMcDigiEmc * | m_TMcDigiEmc |
const TMcHitEvent * | m_TMcHitEvent |
const TMcHitEvent * | m_TMcHitEvent |
const TMcHitMdc * | m_TMcHitMdc |
const TMcHitMdc * | m_TMcHitMdc |
const TMcHitTof * | m_TMcHitTof |
const TMcHitTof * | m_TMcHitTof |
std::vector< std::string > | m_tuningFile |
std::vector< std::string > | m_tuningFile |
FRMTVERSION | m_version |
G4double | posFlag |
G4double | posX |
G4double | posY |
G4double | posZ |
G4double | theta |
G4int | trackIndex |
|
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 }
|
|
00084 { 00085 if (m_inputFileStream) delete m_inputFileStream; 00086 if (m_evt) delete m_evt; 00087 }
|
|
|
|
|
|
|
|
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 }
|
|
|
|
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 }
|
|
|
|
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 }
|
|
|
|
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 }
|
|
00039 {};
|
|
00039 {};
|
|
|
|
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 }
|
|
|
|
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 }
|
|
00037 {};
|
|
00037 {};
|
|
|
|
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|