CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
BesRootIO Class Reference

#include <BesRootIO.hh>

Public Member Functions

 BesRootIO (G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4String)
 
 ~BesRootIO ()
 
void SetMdcDigiFlag (G4int flag)
 
void SetCgemDigiFlag (G4int flag)
 
void SaveEmcDigiRootEvent ()
 
void SaveHitRootEvent (G4int, const G4Event *)
 
void SaveMdcHitRoot ()
 
void SaveCgemHitRoot ()
 
void SaveTofHitRoot ()
 

Public Attributes

TFile * f
 
TTree * HitTree
 

Detailed Description

Definition at line 18 of file BesRootIO.hh.

Constructor & Destructor Documentation

◆ BesRootIO()

BesRootIO::BesRootIO ( G4int mdcTruFlag,
G4int mdcDigiFlag,
G4int cgemTruFlag,
G4int cgemDigiFlag,
G4int tofTruFlag,
G4int tofDigiFlag,
G4int emcTruFlag,
G4int emcDigiFlag,
G4int mucTruFlag,
G4int mucDigiFlag,
G4String name )

Definition at line 41 of file BesRootIO.cc.

47 :m_mdcTruFlag(mdcTruFlag),m_mdcDigiFlag(mdcDigiFlag),
48 m_cgemTruFlag(cgemTruFlag),m_cgemDigiFlag(cgemDigiFlag),
49 m_tofTruFlag(tofTruFlag),m_tofDigiFlag(tofDigiFlag),
50 m_emcTruFlag(emcTruFlag),m_emcDigiFlag(emcDigiFlag),
51 m_mucTruFlag(mucTruFlag),m_mucDigiFlag(mucDigiFlag),m_rootFile(name)
52{
53 m_DigiMan = G4DigiManager::GetDMpointer();
54
55 f = new TFile(m_rootFile,"RECREATE");
56 //create a MdcHit TTree
57 m_TMcHitEvent = new TMcHitEvent();
58 HitTree = new TTree("HitTree","staff data from HitCollection");
59
60 HitTree->Branch("TMcHitEvent", "TMcHitEvent", &m_TMcHitEvent, 32000, 99);
61}
TFile * f
Definition BesRootIO.hh:24
TTree * HitTree
Definition BesRootIO.hh:25

◆ ~BesRootIO()

BesRootIO::~BesRootIO ( )

Definition at line 63 of file BesRootIO.cc.

64{
65 f->Write();
66}

Member Function Documentation

◆ SaveCgemHitRoot()

void BesRootIO::SaveCgemHitRoot ( )

Definition at line 165 of file BesRootIO.cc.

166{
167 //std::cout << "SaveCgemHitRoot" << std::endl;
168 G4int THCID = -1;
169 THCID = m_DigiMan->GetHitsCollectionID("BesCgemHitsCollection");
170 if (THCID>=0)
171 {
172 BesCgemHitsCollection *cgemDC=(BesCgemHitsCollection*)(m_DigiMan->GetHitsCollection(THCID));
173 G4int nHits = cgemDC->entries();
174 //std::cout << "nHits: " << nHits << std::endl;
175 if (nHits>0)
176 {
177 BesCgemHit* cgemHit;
178 for (int i=0;i<nHits;i++)
179 {
180 cgemHit=(*cgemDC)[i];
181 TMcHitCgem* tCgemHit = new TMcHitCgem();
182
183 tCgemHit->SetTrackID (cgemHit->GetTrackID ());
184 tCgemHit->SetLayerID (cgemHit->GetLayerID ());
185 tCgemHit->SetPDGCode (cgemHit->GetPDGCode ());
186 tCgemHit->SetGlobalTime (cgemHit->GetGlobalTime ());
187 tCgemHit->SetTotalEnergyDeposit (cgemHit->GetTotalEnergyDeposit ());
188 tCgemHit->SetStepLength (cgemHit->GetStepLength ());
189
190 G4ThreeVector XYZ_pre = cgemHit->GetPositionOfPrePoint ();
191 G4ThreeVector XYZ_post = cgemHit->GetPositionOfPostPoint();
192 G4ThreeVector P_pre = cgemHit->GetMomentumOfPrePoint ();
193 G4ThreeVector P_post = cgemHit->GetMomentumOfPostPoint();
194
195 TVector3 tmp_XYZ_pre = TVector3(XYZ_pre.x() , XYZ_pre.y() , XYZ_pre.z() );
196 TVector3 tmp_XYZ_post = TVector3(XYZ_post.x() , XYZ_post.y() , XYZ_post.z() );
197 TVector3 tmp_P_pre = TVector3(P_pre.x() , P_pre.y() , P_pre.z() );
198 TVector3 tmp_P_post = TVector3(P_post.x() , P_post.y() , P_post.z() );
199
200 tCgemHit->SetPositionOfPrePoint ( tmp_XYZ_pre );
201 tCgemHit->SetPositionOfPostPoint ( tmp_XYZ_post );
202 tCgemHit->SetMomentumOfPrePoint ( tmp_P_pre );
203 tCgemHit->SetMomentumOfPostPoint ( tmp_P_post );
204 /*
205// ******************************************************************
206 G4ThreeVector Cu_pre = cgemHit->GetPrePositionInCu ();
207 G4ThreeVector Cu_post = cgemHit->GetPostPositionInCu();
208 G4ThreeVector P_Cu_pre = cgemHit->GetMomentumOfCuPre ();
209 G4ThreeVector P_Cu_post = cgemHit->GetMomentumOfCuPost();
210
211 TVector3 tmp_Cu_pre = TVector3(Cu_pre.x() , Cu_pre.y() , Cu_pre.z() );
212 TVector3 tmp_Cu_post = TVector3(Cu_post.x() , Cu_post.y() , Cu_post.z() );
213 TVector3 tmp_P_Cu_pre = TVector3(P_Cu_pre.x() ,P_Cu_pre.y() , P_Cu_pre.z() );
214 TVector3 tmp_P_Cu_post = TVector3(P_Cu_post.x() ,P_Cu_post.y() , P_Cu_post.z() );
215
216 tCgemHit->SetPrePositionInCu ( tmp_Cu_pre );
217 tCgemHit->SetPostPositionInCu ( tmp_Cu_post );
218 tCgemHit->SetMomentumOfCuPre ( tmp_P_Cu_pre );
219 tCgemHit->SetMomentumOfCuPost ( tmp_P_Cu_post );
220// ******************************************************************************************
221 */
222 //cgemHit->Print();
223 m_TMcHitEvent->addMcHitCgem(tCgemHit);
224
225 } /* End of 'for (int i=0;i<nHits;i++)' */
226 } /* End of 'if (nHits>0)' */
227 } /* End of 'if (THCID>=0)' */
228} /* End of 'void BesRootIO::SaveCgemHitRoot()' */
G4THitsCollection< BesCgemHit > BesCgemHitsCollection
G4ThreeVector GetPositionOfPrePoint() const
G4ThreeVector GetMomentumOfPostPoint() const
G4ThreeVector GetPositionOfPostPoint() const
G4ThreeVector GetMomentumOfPrePoint() const
void SetMomentumOfPrePoint(TVector3 f_P_pre)
Definition TMcHitCgem.h:27
void SetPositionOfPrePoint(TVector3 f_XYZ_pre)
Definition TMcHitCgem.h:25
void SetStepLength(Double_t f_L_step)
Definition TMcHitCgem.h:24
void SetGlobalTime(Double_t f_global_time)
Definition TMcHitCgem.h:22
void SetLayerID(Int_t f_ID_layer)
Definition TMcHitCgem.h:19
void SetPDGCode(Int_t f_pdg_code)
Definition TMcHitCgem.h:20
void SetTotalEnergyDeposit(Double_t f_E_deposit)
Definition TMcHitCgem.h:23
void SetPositionOfPostPoint(TVector3 f_XYZ_post)
Definition TMcHitCgem.h:26
void SetTrackID(Int_t f_ID_track)
Definition TMcHitCgem.h:18
void SetMomentumOfPostPoint(TVector3 f_P_post)
Definition TMcHitCgem.h:28
void addMcHitCgem(TMcHitCgem *hit)
Add a McHitCgem into the Cgem Data collection.

Referenced by SaveHitRootEvent().

◆ SaveEmcDigiRootEvent()

void BesRootIO::SaveEmcDigiRootEvent ( )

Definition at line 92 of file BesRootIO.cc.

92 {
93 //std::cout << "SaveEmcDigiRootEvent" << std::endl;
94 G4int emcDigiCollID = -1;
95 emcDigiCollID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
96 if(emcDigiCollID>=0)
97 {
98 BesEmcDigitsCollection* emcDC = (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection(emcDigiCollID);
99 G4int nHits = emcDC->entries();
100 //std::cout << "nHits: " << nHits << std::endl;
101
102 if(nHits>0){
103 BesEmcDigi* emcDigi;
104 for (int i = 0; i < nHits; i++) {
105 emcDigi=(*emcDC)[i];
106 TMcDigiEmc* tEmcDigi = new TMcDigiEmc();
107
108 tEmcDigi->SetPartId(emcDigi->GetPartId());
109 tEmcDigi->SetThetaNb(emcDigi->GetThetaNb());
110 tEmcDigi->SetPhiNb(emcDigi->GetPhiNb());
111 tEmcDigi->SetEnergy(emcDigi->GetEnergy());
112 tEmcDigi->SetTime(emcDigi->GetTime());
113 tEmcDigi->SetTrackIndex(emcDigi->GetTrackIndex());
114 //emcDigi->Print();
115 //std::cout << "SetEnergy" << emcDigi->GetEnergy() << std::endl;
116
117 m_TMcHitEvent->addMcDigiEmc(tEmcDigi);
118 //std::cout << "addMcDigiEmc" << std::endl;
119 }
120 }
121 }
122}
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
Definition BesEmcDigi.hh:69
G4int GetTrackIndex()
Definition BesEmcDigi.hh:54
G4int GetThetaNb()
Definition BesEmcDigi.hh:50
G4double GetEnergy()
Definition BesEmcDigi.hh:52
G4int GetPhiNb()
Definition BesEmcDigi.hh:51
G4double GetTime()
Definition BesEmcDigi.hh:53
G4int GetPartId()
Definition BesEmcDigi.hh:49
void SetThetaNb(Int_t nTheta)
Definition TMcDigiEmc.h:17
void SetPhiNb(Int_t nPhi)
Definition TMcDigiEmc.h:18
void SetPartId(Int_t id)
Definition TMcDigiEmc.h:16
void SetTime(Double_t time)
Definition TMcDigiEmc.h:20
void SetTrackIndex(Int_t index)
Definition TMcDigiEmc.h:21
void SetEnergy(Double_t energy)
Definition TMcDigiEmc.h:19
void addMcDigiEmc(TMcDigiEmc *digi)
Add a McHitMdc into the Mdc Data collection.

Referenced by SaveHitRootEvent().

◆ SaveHitRootEvent()

void BesRootIO::SaveHitRootEvent ( G4int runId,
const G4Event * evt )

Definition at line 68 of file BesRootIO.cc.

69{
70 //std::cout << "Save Hit Root Event" << std::endl;
71 if (m_mdcDigiFlag)
72 {
74 }
75 if (m_cgemDigiFlag)
76 {
78 }
79 if (m_tofDigiFlag)
80 {
82 }
83 if (m_emcDigiFlag){
85 }
86
87 HitTree->Fill();
88
89 m_TMcHitEvent->Clear();
90}
void SaveMdcHitRoot()
Definition BesRootIO.cc:124
void SaveCgemHitRoot()
Definition BesRootIO.cc:165
void SaveEmcDigiRootEvent()
Definition BesRootIO.cc:92
void SaveTofHitRoot()
Definition BesRootIO.cc:230
void Clear(Option_t *option="")

Referenced by BesEventAction::EndOfEventAction().

◆ SaveMdcHitRoot()

void BesRootIO::SaveMdcHitRoot ( )

Definition at line 124 of file BesRootIO.cc.

125{
126 //std::cout << "SaveMdcHitRoot" << std::endl;
127 G4int THCID = -1;
128 THCID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
129 if (THCID>=0)
130 {
131 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
132 G4int nHits = mdcDC->entries();
133 //std::cout << "nHits: " << nHits << std::endl;
134 if (nHits>0)
135 {
136 BesMdcHit* mdcHit;
137 for (int i=0;i<nHits;i++)
138 {
139 mdcHit=(*mdcDC)[i];
140 TMcHitMdc* tMdcHit = new TMcHitMdc();
141 tMdcHit->SetTrackID(mdcHit->GetTrackID());
142 tMdcHit->SetLayerNo(mdcHit->GetLayerNo());
143 tMdcHit->SetCellNo(mdcHit->GetCellNo());
144 tMdcHit->SetEdep(mdcHit->GetEdep());
145 tMdcHit->SetDriftD(mdcHit->GetDriftD());
146 tMdcHit->SetDriftT(mdcHit->GetDriftT());
147 tMdcHit->SetGlobalT(mdcHit->GetGlobalT());
148 tMdcHit->SetTheta(mdcHit->GetTheta());
149 tMdcHit->SetEnterAngle(mdcHit->GetEnterAngle());
150 tMdcHit->SetPosFlag(mdcHit->GetPosFlag());
151
152 G4ThreeVector gTemp = mdcHit->GetPos();
153 TVector3 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
154 tMdcHit->SetPos(tTemp);
155
156 //mdcHit->Print();
157 m_TMcHitEvent->addMcHitMdc(tMdcHit);
158 }
159 }
160 }
161
162
163}
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
Definition BesMdcHit.hh:97
G4double GetEdep()
Definition BesMdcHit.hh:59
G4double GetTheta()
Definition BesMdcHit.hh:64
G4int GetTrackID()
Definition BesMdcHit.hh:56
G4int GetPosFlag()
Definition BesMdcHit.hh:66
G4double GetGlobalT()
Definition BesMdcHit.hh:63
G4double GetEnterAngle()
Definition BesMdcHit.hh:65
G4int GetLayerNo()
Definition BesMdcHit.hh:57
G4double GetDriftD()
Definition BesMdcHit.hh:61
G4double GetDriftT()
Definition BesMdcHit.hh:62
G4ThreeVector GetPos()
Definition BesMdcHit.hh:60
G4int GetCellNo()
Definition BesMdcHit.hh:58
void addMcHitMdc(TMcHitMdc *hit)
Add a McHitMdc into the Mdc Data collection.
void SetDriftT(Double_t time)
Definition TMcHitMdc.h:22
void SetDriftD(Double_t distance)
Definition TMcHitMdc.h:21
void SetPosFlag(Int_t flag)
Definition TMcHitMdc.h:26
void SetGlobalT(Double_t time)
Definition TMcHitMdc.h:23
void SetTheta(Double_t angle)
Definition TMcHitMdc.h:24
void SetCellNo(Int_t cell)
Definition TMcHitMdc.h:18
void SetEnterAngle(Double_t angle)
Definition TMcHitMdc.h:25
void SetPos(TVector3 xyz)
Definition TMcHitMdc.h:20
void SetTrackID(Int_t track)
Definition TMcHitMdc.h:16
void SetEdep(Double_t de)
Definition TMcHitMdc.h:19
void SetLayerNo(Int_t layer)
Definition TMcHitMdc.h:17

Referenced by SaveHitRootEvent().

◆ SaveTofHitRoot()

void BesRootIO::SaveTofHitRoot ( )

Definition at line 230 of file BesRootIO.cc.

231{
232 //retrieve G4Svc
233 ISvcLocator* svcLocator = Gaudi::svcLocator();
234 IG4Svc* tmpSvc;
235 StatusCode sc = svcLocator->service("G4Svc", tmpSvc);
236 G4Svc* m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc);
237 double m_beamTime = m_G4Svc->GetBeamTime() * ns;
238 m_TMcHitEvent->setBeamTime(m_beamTime);
239 //std::cout << "beamtime: " << m_beamTime << std::endl;
240
241 G4int THCID = -1;
242 THCID = m_DigiMan->GetHitsCollectionID("BesTofHitsCollection");
243 if (THCID>=0)
244 {
245 BesTofHitsCollection* tofDC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
246 G4int nHits = tofDC->entries();
247 //std::cout << "nHits: " << nHits << std::endl;
248 if (nHits>0)
249 {
250 BesTofHit* tofHit;
251 for (int i=0;i<nHits;i++)
252 {
253 tofHit=(*tofDC)[i];
254 TMcHitTof* tTofHit = new TMcHitTof();
255 tTofHit->SetTrackIndex(tofHit->GetTrackIndex());
256 tTofHit->SetG4Index(tofHit->GetG4Index());
257 tTofHit->SetPartId(tofHit->GetPartId());
258 tTofHit->SetScinNb(tofHit->GetScinNb());
259 tTofHit->SetEdep(tofHit->GetEdep());
260 tTofHit->SetStepL(tofHit->GetStepL());
261 tTofHit->SetTrackL(tofHit->GetTrackL());
262 tTofHit->SetTime(tofHit->GetTime());
263 tTofHit->SetDeltaT(tofHit->GetDeltaT());
264 tTofHit->SetCharge(tofHit->GetCharge());
265
266 G4ThreeVector gTemp = tofHit->GetPos();
267 TVector3 tTemp(gTemp.x(), gTemp.y(), gTemp.z());
268 tTofHit->SetPos(tTemp);
269
270 gTemp = tofHit->GetPDirection();
271 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
272 tTofHit->SetPDirection(tTemp);
273
274 gTemp = tofHit->GetMomentum();
275 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
276 tTofHit->SetMomentum(tTemp);
277
278 //tofHit->Print();
279 m_TMcHitEvent->addMcHitTof(tTofHit);
280 }
281 }
282 }
283
284}
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition BesTofHit.hh:108
G4double GetDeltaT()
Definition BesTofHit.hh:67
G4ThreeVector GetPDirection()
Definition BesTofHit.hh:68
G4double GetStepL()
Definition BesTofHit.hh:63
G4double GetCharge()
Definition BesTofHit.hh:72
G4double GetTime()
Definition BesTofHit.hh:66
G4double GetEdep()
Definition BesTofHit.hh:62
G4ThreeVector GetPos()
Definition BesTofHit.hh:65
G4int GetScinNb()
Definition BesTofHit.hh:61
G4int GetPartId()
Definition BesTofHit.hh:60
G4double GetTrackL()
Definition BesTofHit.hh:64
G4int GetG4Index()
Definition BesTofHit.hh:59
G4ThreeVector GetMomentum()
Definition BesTofHit.hh:69
G4int GetTrackIndex()
Definition BesTofHit.hh:58
Definition G4Svc.h:32
double GetBeamTime()
Definition G4Svc.h:85
void addMcHitTof(TMcHitTof *hit)
Add a McHitTof into the TOF Data collection.
void setBeamTime(Double_t time)
Definition TMcHitEvent.h:59
void SetStepL(Double_t stepL)
Definition TMcHitTof.h:22
void SetTime(Double_t time)
Definition TMcHitTof.h:25
void SetTrackIndex(Int_t trackIndex)
Definition TMcHitTof.h:17
void SetG4Index(Int_t index)
Definition TMcHitTof.h:18
void SetPos(TVector3 pos)
Definition TMcHitTof.h:24
void SetMomentum(TVector3 momentum)
Definition TMcHitTof.h:28
void SetDeltaT(Double_t deltaT)
Definition TMcHitTof.h:26
void SetEdep(Double_t edep)
Definition TMcHitTof.h:21
void SetPartId(Int_t partId)
Definition TMcHitTof.h:19
void SetPDirection(TVector3 pDirection)
Definition TMcHitTof.h:27
void SetCharge(Int_t charge)
Definition TMcHitTof.h:29
void SetTrackL(Double_t length)
Definition TMcHitTof.h:23
void SetScinNb(Int_t scinNb)
Definition TMcHitTof.h:20
#define ns(x)
Definition xmltok.c:1504

Referenced by SaveHitRootEvent().

◆ SetCgemDigiFlag()

void BesRootIO::SetCgemDigiFlag ( G4int flag)
inline

Definition at line 31 of file BesRootIO.hh.

31{m_cgemDigiFlag=flag;}

◆ SetMdcDigiFlag()

void BesRootIO::SetMdcDigiFlag ( G4int flag)
inline

Definition at line 30 of file BesRootIO.hh.

30{m_mdcDigiFlag=flag;}

Member Data Documentation

◆ f

TFile* BesRootIO::f

Definition at line 24 of file BesRootIO.hh.

Referenced by BesRootIO(), and ~BesRootIO().

◆ HitTree

TTree* BesRootIO::HitTree

Definition at line 25 of file BesRootIO.hh.

Referenced by BesRootIO(), and SaveHitRootEvent().


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