BOSS 7.0.1
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, G4String)
 
 ~BesRootIO ()
 
void SetMdcDigiFlag (G4int flag)
 
void SaveEmcDigiRootEvent ()
 
void SaveHitRootEvent (G4int, const G4Event *)
 
void SaveMdcHitRoot ()
 
void SaveTofHitRoot ()
 
 BesRootIO (G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4int, G4String)
 
 ~BesRootIO ()
 
void SetMdcDigiFlag (G4int flag)
 
void SaveEmcDigiRootEvent ()
 
void SaveHitRootEvent (G4int, const G4Event *)
 
void SaveMdcHitRoot ()
 
void SaveTofHitRoot ()
 

Public Attributes

TFile * f
 
TTree * HitTree
 

Detailed Description

Constructor & Destructor Documentation

◆ BesRootIO() [1/2]

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

Definition at line 40 of file BesRootIO.cc.

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

◆ ~BesRootIO() [1/2]

BesRootIO::~BesRootIO ( )

Definition at line 60 of file BesRootIO.cc.

61{
62 f->Write();
63}

◆ BesRootIO() [2/2]

BesRootIO::BesRootIO ( G4int  ,
G4int  ,
G4int  ,
G4int  ,
G4int  ,
G4int  ,
G4int  ,
G4int  ,
G4String   
)

◆ ~BesRootIO() [2/2]

BesRootIO::~BesRootIO ( )

Member Function Documentation

◆ SaveEmcDigiRootEvent() [1/2]

void BesRootIO::SaveEmcDigiRootEvent ( )

Definition at line 85 of file BesRootIO.cc.

85 {
86 //std::cout << "SaveEmcDigiRootEvent" << std::endl;
87 G4int emcDigiCollID = -1;
88 emcDigiCollID = m_DigiMan->GetDigiCollectionID("BesEmcDigitsCollection");
89 if(emcDigiCollID>=0)
90 {
91 BesEmcDigitsCollection* emcDC = (BesEmcDigitsCollection*)m_DigiMan->GetDigiCollection(emcDigiCollID);
92 G4int nHits = emcDC->entries();
93 //std::cout << "nHits: " << nHits << std::endl;
94
95 if(nHits>0){
96 BesEmcDigi* emcDigi;
97 for (int i = 0; i < nHits; i++) {
98 emcDigi=(*emcDC)[i];
99 TMcDigiEmc* tEmcDigi = new TMcDigiEmc();
100
101 tEmcDigi->SetPartId(emcDigi->GetPartId());
102 tEmcDigi->SetThetaNb(emcDigi->GetThetaNb());
103 tEmcDigi->SetPhiNb(emcDigi->GetPhiNb());
104 tEmcDigi->SetEnergy(emcDigi->GetEnergy());
105 tEmcDigi->SetTime(emcDigi->GetTime());
106 tEmcDigi->SetTrackIndex(emcDigi->GetTrackIndex());
107 //emcDigi->Print();
108 //std::cout << "SetEnergy" << emcDigi->GetEnergy() << std::endl;
109
110 m_TMcHitEvent->addMcDigiEmc(tEmcDigi);
111 //std::cout << "addMcDigiEmc" << std::endl;
112 }
113 }
114 }
115}
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
void addMcDigiEmc(TMcDigiEmc *digi)
Add a McHitMdc into the Mdc Data collection.
Definition: TMcHitEvent.cxx:52

Referenced by SaveHitRootEvent().

◆ SaveEmcDigiRootEvent() [2/2]

void BesRootIO::SaveEmcDigiRootEvent ( )

◆ SaveHitRootEvent() [1/2]

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

Definition at line 65 of file BesRootIO.cc.

66{
67 //std::cout << "Save Hit Root Event" << std::endl;
68 if (m_mdcDigiFlag)
69 {
71 }
72 if (m_tofDigiFlag)
73 {
75 }
76 if (m_emcDigiFlag){
78 }
79
80 HitTree->Fill();
81
82 m_TMcHitEvent->Clear();
83}
void SaveMdcHitRoot()
Definition: BesRootIO.cc:117
void SaveEmcDigiRootEvent()
Definition: BesRootIO.cc:85
void SaveTofHitRoot()
Definition: BesRootIO.cc:158
void Clear(Option_t *option="")
Definition: TMcHitEvent.cxx:33

Referenced by BesEventAction::EndOfEventAction().

◆ SaveHitRootEvent() [2/2]

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

◆ SaveMdcHitRoot() [1/2]

void BesRootIO::SaveMdcHitRoot ( )

Definition at line 117 of file BesRootIO.cc.

118{
119 //std::cout << "SaveMdcHitRoot" << std::endl;
120 G4int THCID = -1;
121 THCID = m_DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
122 if (THCID>=0)
123 {
124 BesMdcHitsCollection* mdcDC = (BesMdcHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
125 G4int nHits = mdcDC->entries();
126 //std::cout << "nHits: " << nHits << std::endl;
127 if (nHits>0)
128 {
129 BesMdcHit* mdcHit;
130 for (int i=0;i<nHits;i++)
131 {
132 mdcHit=(*mdcDC)[i];
133 TMcHitMdc* tMdcHit = new TMcHitMdc();
134 tMdcHit->SetTrackID(mdcHit->GetTrackID());
135 tMdcHit->SetLayerNo(mdcHit->GetLayerNo());
136 tMdcHit->SetCellNo(mdcHit->GetCellNo());
137 tMdcHit->SetEdep(mdcHit->GetEdep());
138 tMdcHit->SetDriftD(mdcHit->GetDriftD());
139 tMdcHit->SetDriftT(mdcHit->GetDriftT());
140 tMdcHit->SetGlobalT(mdcHit->GetGlobalT());
141 tMdcHit->SetTheta(mdcHit->GetTheta());
142 tMdcHit->SetEnterAngle(mdcHit->GetEnterAngle());
143 tMdcHit->SetPosFlag(mdcHit->GetPosFlag());
144
145 G4ThreeVector gTemp = mdcHit->GetPos();
146 TVector3 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
147 tMdcHit->SetPos(tTemp);
148
149 //mdcHit->Print();
150 m_TMcHitEvent->addMcHitMdc(tMdcHit);
151 }
152 }
153 }
154
155
156}
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
void addMcHitMdc(TMcHitMdc *hit)
Add a McHitMdc into the Mdc Data collection.
Definition: TMcHitEvent.cxx:74

Referenced by SaveHitRootEvent().

◆ SaveMdcHitRoot() [2/2]

void BesRootIO::SaveMdcHitRoot ( )

◆ SaveTofHitRoot() [1/2]

void BesRootIO::SaveTofHitRoot ( )

Definition at line 158 of file BesRootIO.cc.

159{
160 //retrieve G4Svc
161 ISvcLocator* svcLocator = Gaudi::svcLocator();
162 IG4Svc* tmpSvc;
163 StatusCode sc = svcLocator->service("G4Svc", tmpSvc);
164 G4Svc* m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc);
165 double m_beamTime = m_G4Svc->GetBeamTime() * ns;
166 m_TMcHitEvent->setBeamTime(m_beamTime);
167 //std::cout << "beamtime: " << m_beamTime << std::endl;
168
169 G4int THCID = -1;
170 THCID = m_DigiMan->GetHitsCollectionID("BesTofHitsCollection");
171 if (THCID>=0)
172 {
173 BesTofHitsCollection* tofDC = (BesTofHitsCollection*) (m_DigiMan->GetHitsCollection(THCID));
174 G4int nHits = tofDC->entries();
175 //std::cout << "nHits: " << nHits << std::endl;
176 if (nHits>0)
177 {
178 BesTofHit* tofHit;
179 for (int i=0;i<nHits;i++)
180 {
181 tofHit=(*tofDC)[i];
182 TMcHitTof* tTofHit = new TMcHitTof();
183 tTofHit->SetTrackIndex(tofHit->GetTrackIndex());
184 tTofHit->SetG4Index(tofHit->GetG4Index());
185 tTofHit->SetPartId(tofHit->GetPartId());
186 tTofHit->SetScinNb(tofHit->GetScinNb());
187 tTofHit->SetEdep(tofHit->GetEdep());
188 tTofHit->SetStepL(tofHit->GetStepL());
189 tTofHit->SetTrackL(tofHit->GetTrackL());
190 tTofHit->SetTime(tofHit->GetTime());
191 tTofHit->SetDeltaT(tofHit->GetDeltaT());
192 tTofHit->SetCharge(tofHit->GetCharge());
193
194 G4ThreeVector gTemp = tofHit->GetPos();
195 TVector3 tTemp(gTemp.x(), gTemp.y(), gTemp.z());
196 tTofHit->SetPos(tTemp);
197
198 gTemp = tofHit->GetPDirection();
199 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
200 tTofHit->SetPDirection(tTemp);
201
202 gTemp = tofHit->GetMomentum();
203 tTemp = TVector3(gTemp.x(), gTemp.y(), gTemp.z());
204 tTofHit->SetMomentum(tTemp);
205
206 //tofHit->Print();
207 m_TMcHitEvent->addMcHitTof(tTofHit);
208 }
209 }
210 }
211
212}
G4THitsCollection< BesTofHit > BesTofHitsCollection
void addMcHitTof(TMcHitTof *hit)
Add a McHitTof into the TOF Data collection.
Definition: TMcHitEvent.cxx:63
#define ns(x)
Definition: xmltok.c:1504

Referenced by SaveHitRootEvent().

◆ SaveTofHitRoot() [2/2]

void BesRootIO::SaveTofHitRoot ( )

◆ SetMdcDigiFlag() [1/2]

void BesRootIO::SetMdcDigiFlag ( G4int  flag)
inline

Definition at line 29 of file InstallArea/include/BesSim/BesSim/BesRootIO.hh.

29{m_mdcDigiFlag=flag;}

◆ SetMdcDigiFlag() [2/2]

void BesRootIO::SetMdcDigiFlag ( G4int  flag)
inline

Definition at line 29 of file Simulation/BOOST/BesSim/BesSim-00-01-24/BesSim/BesRootIO.hh.

29{m_mdcDigiFlag=flag;}

Member Data Documentation

◆ f

TFile * BesRootIO::f

Definition at line 23 of file InstallArea/include/BesSim/BesSim/BesRootIO.hh.

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

◆ HitTree

TTree * BesRootIO::HitTree

Definition at line 24 of file InstallArea/include/BesSim/BesSim/BesRootIO.hh.

Referenced by BesRootIO(), and SaveHitRootEvent().


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