10#include "RootEventData/TMcHitTof.h"
11#include "RootEventData/TMcHitEvent.h"
12#include "RootEventData/TMcHitMdc.h"
13#include "RootEventData/TMcDigiEmc.h"
14#include "BesMdcHit.hh"
15#include "BesTofHit.hh"
16#include "BesEmcHit.hh"
17#include "BesEmcDigi.hh"
18#include "BesMucHit.hh"
19#include "ReadBoostRoot.hh"
20#include "BesTuningIO.hh"
21#include "AsciiDmp/AsciiData.hh"
23#include "G4HCofThisEvent.hh"
24#include "G4SDManager.hh"
25#include "G4DigiManager.hh"
26#include "G4ThreeVector.hh"
28#include "GaudiKernel/ISvcLocator.h"
29#include "GaudiKernel/Bootstrap.h"
30#include "GaudiKernel/IDataProviderSvc.h"
32#include "G4Svc/IG4Svc.h"
33#include "G4Svc/G4Svc.h"
35#include "ReadBoostRoot.hh"
40 :m_tuningFile(name),m_evt(0)
42 m_DigiMan = G4DigiManager::GetDMpointer();
43 m_inputFileStream =
new std::ifstream();
53 if (m_tuningFile.size()==0){
54 std::cout <<
"there is no tuning file" << std::endl;
56 std::cout <<
"file number: " << m_tuningFile.size() << std::endl;
57 for (
int i = 0 ; i < m_tuningFile.size(); i++){
61 HitChain->Add(m_tuningFile[i].c_str());
64 TBranch *branch =
HitChain->GetBranch(
"TMcHitEvent");
67 branch->SetAddress(&m_TMcHitEvent);
68 std::cout <<
"HitChain entries: " <<
HitChain->GetEntries() << std::endl;
85 if (m_inputFileStream)
delete m_inputFileStream;
86 if (m_evt)
delete m_evt;
90 if (m_evt)
delete m_evt;
94 (*m_inputFileStream) >> *m_evt;
96 std::cerr <<
"wrong tag, got " << ex.
got()
103 std::cerr<<
"BesTuningIO: Reach file end!"<<std::endl;
119 G4int mdcHitCollID = -1;
120 mdcHitCollID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
121 if (mdcHitCollID>=0){
124 G4int nHit = mdcDC->entries();
126 for (G4int i=0;i<nHit;i++)
130 mdcDC->GetVector()->clear();
133 std::vector<MdcHitType>::iterator
iter;
141 newHit->
SetEdep ((*iter).energyDeposit);
142 newHit->
SetPos (G4ThreeVector((*iter).posX,(*iter).posY,(*iter).posZ));
143 newHit->
SetDriftD ((*iter).driftDistance);
149 mdcDC->insert(newHit);
154 std::cerr <<
"BesTuningIO::can't get mdcHitsCollection"<<std::endl;
157 std::cerr <<
"BesTuningIO::can't get mdcHitCollID"<<std::endl;
163 THCID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
166 m_DigiMan->SetDigiCollection(THCID,emcDC);
187 THCID = m_DigiMan->GetDigiCollectionID(
"BesEmcDigitsCollection");
194 int nHit = emcDC->entries();
197 for(
int i = 0; i < nHit; i++){
200 emcDC->GetVector()->clear();
206 for(
int i = 0; i < nHits; i++){
220 emcDC->insert(emcDigi);
226 m_DigiMan->SetDigiCollection(THCID,emcDC);
236 THCID = m_DigiMan->GetHitsCollectionID(
"BesMdcHitsCollection");
240 int nHit = mdcDC->entries();
242 for(
int i = 0; i < nHit; i++){
245 mdcDC->GetVector()->clear();
251 for(
int i = 0; i < nHits; i++){
267 TVector3 tTemp = m_TMcHitMdc->
GetPos();
268 G4ThreeVector gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
272 mdcDC->insert(mdcHit);
285 ISvcLocator* svcLocator = Gaudi::svcLocator();
287 StatusCode sc = svcLocator->service(
"G4Svc", tmpSvc);
288 G4Svc* m_G4Svc =
dynamic_cast<G4Svc *
>(tmpSvc);
290 const double m_beamTime = m_TMcHitEvent->
getBeamTime();
295 THCID = m_DigiMan->GetHitsCollectionID(
"BesTofHitsCollection");
299 int nHit = tofDC->entries();
301 for(
int i = 0; i < nHit; i++){
304 tofDC->GetVector()->clear();
310 for(
int i = 0; i < nHits; i++){
326 TVector3 tTemp = m_TMcHitTof->
GetPos();
327 G4ThreeVector gTemp(tTemp.X(), tTemp.Y(), tTemp.Z());
331 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
335 gTemp = G4ThreeVector(tTemp.X(), tTemp.Y(), tTemp.Z());
340 tofDC->insert(tofHit);
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
std::string expected() const
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
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 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 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