16#include "BesCgemHit.hh"
25#include "G4HCofThisEvent.hh"
26#include "G4SDManager.hh"
27#include "G4DigiManager.hh"
28#include "G4ThreeVector.hh"
30#include "GaudiKernel/ISvcLocator.h"
31#include "GaudiKernel/Bootstrap.h"
32#include "GaudiKernel/IDataProviderSvc.h"
42 :m_tuningFile(name),m_evt(0)
44 m_DigiMan = G4DigiManager::GetDMpointer();
45 m_inputFileStream =
new std::ifstream();
55 if (m_tuningFile.size()==0){
56 std::cout <<
"there is no tuning file" << std::endl;
58 std::cout <<
"file number: " << m_tuningFile.size() << std::endl;
59 for (
int i = 0 ; i < m_tuningFile.size(); i++){
63 HitChain->Add(m_tuningFile[i].c_str());
66 TBranch *branch =
HitChain->GetBranch(
"TMcHitEvent");
69 branch->SetAddress(&m_TMcHitEvent);
70 std::cout <<
"HitChain entries: " <<
HitChain->GetEntries() << std::endl;
87 if (m_inputFileStream)
delete m_inputFileStream;
88 if (m_evt)
delete m_evt;
92 if (m_evt)
delete m_evt;
96 (*m_inputFileStream) >> *m_evt;
98 std::cerr <<
"wrong tag, got " << ex.
got()
105 std::cerr<<
"BesTuningIO: Reach file end!"<<std::endl;
121 G4int mdcHitCollID = -1;
122 mdcHitCollID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
123 if (mdcHitCollID>=0){
126 G4int nHit = mdcDC->entries();
128 for (G4int i=0;i<nHit;i++)
132 mdcDC->GetVector()->clear();
135 std::vector<MdcHitType>::iterator
iter;
143 newHit->
SetEdep ((*iter).energyDeposit);
144 newHit->
SetPos (G4ThreeVector((*iter).posX,(*iter).posY,(*iter).posZ));
145 newHit->
SetDriftD ((*iter).driftDistance);
151 mdcDC->insert(newHit);
156 std::cerr <<
"BesTuningIO::can't get mdcHitsCollection"<<std::endl;
159 std::cerr <<
"BesTuningIO::can't get mdcHitCollID"<<std::endl;
165 G4int cgemHitCollID = -1;
166 cgemHitCollID = m_DigiMan->GetHitsCollectionID(
"BesCgemHitsCollection");
167 if (cgemHitCollID>=0)
172 G4int nHit = cgemDC->entries();
175 for (G4int i=0;i<nHit;i++)
179 cgemDC->GetVector()->clear();
182 std::vector<CgemHitType>::iterator
iter;
195 newHit->
SetPositionOfPrePoint (G4ThreeVector((*iter).m_XYZ_pre_x,(*iter).m_XYZ_pre_y,(*iter).m_XYZ_pre_z));
196 newHit->
SetPositionOfPostPoint(G4ThreeVector((*iter).m_XYZ_post_x,(*iter).m_XYZ_post_y,(*iter).m_XYZ_post_z));
197 newHit->
SetMomentumOfPrePoint (G4ThreeVector((*iter).m_P_pre_x,(*iter).m_P_pre_y,(*iter).m_P_pre_z));
206 cgemDC->insert(newHit);
212 std::cerr <<
"BesTuningIO::can't get cgemHitsCollection"<<std::endl;
217 std::cerr <<
"BesTuningIO::can't get cgemHitCollID"<<std::endl;
223 THCID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
226 m_DigiMan->SetDigiCollection(THCID,emcDC);
248 THCID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
255 int nHit = emcDC->entries();
258 for(
int i = 0; i < nHit; i++){
261 emcDC->GetVector()->clear();
267 for(
int i = 0; i < nHits; i++){
281 emcDC->insert(emcDigi);
287 m_DigiMan->SetDigiCollection(THCID,emcDC);
297 THCID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
301 int nHit = mdcDC->entries();
303 for(
int i = 0; i < nHit; i++){
306 mdcDC->GetVector()->clear();
312 for(
int i = 0; i < nHits; i++){
328 TVector3 tTemp = m_TMcHitMdc->
GetPos();
329 G4ThreeVector gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
333 mdcDC->insert(mdcHit);
347 THCID = m_DigiMan->GetHitsCollectionID(
"BesCgemHitsCollection");
353 int nHit = cgemDC->entries();
356 for(
int i = 0; i < nHit; i++)
360 cgemDC->GetVector()->clear();
366 for(
int i = 0; i < nHits; i++)
384 G4ThreeVector tmp_XYZ_pre = G4ThreeVector(XYZ_pre.x() , XYZ_pre.y() , XYZ_pre.z() );
385 G4ThreeVector tmp_XYZ_post = G4ThreeVector(XYZ_post.x() , XYZ_post.y() , XYZ_post.z());
386 G4ThreeVector tmp_P_pre = G4ThreeVector(P_pre.x() , P_pre.y() , P_pre.z() );
387 G4ThreeVector tmp_P_post = G4ThreeVector(P_post.x() , P_post.y() , P_post.z() );
414 cgemDC->insert(cgemHit);
423 ISvcLocator* svcLocator = Gaudi::svcLocator();
425 StatusCode sc = svcLocator->service(
"G4Svc", tmpSvc);
426 G4Svc* m_G4Svc =
dynamic_cast<G4Svc *
>(tmpSvc);
428 const double m_beamTime = m_TMcHitEvent->
getBeamTime();
433 THCID = m_DigiMan->GetHitsCollectionID(
"BesTofHitsCollection");
437 int nHit = tofDC->entries();
439 for(
int i = 0; i < nHit; i++){
442 tofDC->GetVector()->clear();
448 for(
int i = 0; i < nHits; i++){
464 TVector3 tTemp = m_TMcHitTof->
GetPos();
465 G4ThreeVector gTemp(tTemp.X(), tTemp.Y(), tTemp.Z());
469 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
473 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
478 tofDC->insert(tofHit);
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
G4THitsCollection< BesCgemHit > BesCgemHitsCollection
std::string expected() const
void SetTotalEnergyDeposit(G4double f_E_deposit)
void SetGlobalTime(G4double f_global_time)
void SetMomentumOfPostPoint(G4ThreeVector f_P_post)
void SetPDGCode(G4int f_pdg_code)
void SetLayerID(G4int f_ID_layer)
void SetParentID(G4int f_ID_parent)
void SetTrackID(G4int f_ID_track)
void SetPositionOfPrePoint(G4ThreeVector f_XYZ_pre)
void SetMomentumOfPrePoint(G4ThreeVector f_P_pre)
void SetPositionOfPostPoint(G4ThreeVector f_XYZ_post)
void SetStepLength(G4double f_L_step)
void SetTrackIndex(G4int index)
void SetTime(G4double time)
void SetEnergy(G4double energy)
void SetThetaNb(G4int nTheta)
void SetPhiNb(G4int nPhi)
void SetEdep(G4double de)
void SetDriftT(G4double time)
void SetEnterAngle(G4double angle)
void SetCellNo(G4int cell)
void SetPos(G4ThreeVector xyz)
void SetTrackID(G4int track)
void SetLayerNo(G4int layer)
void SetTheta(G4double angle)
void SetDriftD(G4double distance)
void SetGlobalT(G4double time)
void SetPosFlag(G4int flag)
void SetPos(G4ThreeVector pos)
void SetDeltaT(G4double deltaT)
void SetCharge(G4double charge)
void SetTrackIndex(G4int trackIndex)
void SetPDirection(G4ThreeVector pDirection)
void SetPartId(G4int partId)
void SetScinNb(G4int scinNb)
void SetStepL(G4double stepL)
void SetTrackL(G4double length)
void SetTime(G4double time)
void SetEdep(G4double edep)
void SetMomentum(G4ThreeVector momentum)
void SetG4Index(G4int index)
BesTuningIO(std::vector< std::string >)
void GetRootEvent(int evtID)
void SetBeamTime(double value)
static G4int GetFormatAR()
Int_t GetTrackIndex() const
Double_t GetEnergy() const
Int_t GetParentID() const
TVector3 GetPositionOfPostPoint() const
Double_t GetStepLength() const
Double_t GetGlobalTime() const
TVector3 GetMomentumOfPrePoint() const
Double_t GetTotalEnergyDeposit() const
TVector3 GetPositionOfPrePoint() const
TVector3 GetMomentumOfPostPoint() const
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
const TMcHitCgem * getMcHitCgem(Int_t i) const
retrieve a McHitCgem From the collection, using the index into the array
const TObjArray * getMcDigiEmcCol() const
retrieve the whole TObjArray of McHitMdc Data
const TMcHitMdc * getMcHitMdc(Int_t i) const
retrieve a McHitMdc From the collection, using the index into the array
const TObjArray * getMcHitCgemCol() const
retrieve the whole TObjArray of McHitCgem Data
const TMcDigiEmc * getMcDigiEmc(Int_t i) const
retrieve a McHitMdc From the collection, using the index into the array
const TObjArray * getMcHitMdcCol() const
retrieve the whole TObjArray of McHitMdc Data
Double_t getBeamTime() const
Double_t GetTheta() const
Double_t GetGlobalT() const
Double_t GetDriftT() const
Double_t GetEnterAngle() const
Double_t GetDriftD() const
Int_t GetTrackIndex() const
TVector3 GetPDirection() const
TVector3 GetMomentum() const
Double_t GetStepL() const
Double_t GetTrackL() const
Double_t GetDeltaT() const