16#include "TClonesArray.h"
17#include "TGeoMCGeometry.h"
18#include "TGeoManager.h"
19#include "TLorentzVector.h"
21#include "TVirtualMC.h"
24#include "FairGeoInterface.h"
25#include "FairGeoLoader.h"
26#include "FairGeoNode.h"
28#include "FairGeoRootBuilder.h"
33#include "FairRootManager.h"
34#include "FairVolume.h"
37#include "FairRuntimeDb.h"
41#include "TParticlePDG.h"
45 fZdcCollection =
new TClonesArray(
"BmnZdcPoint");
60 : FairDetector(
name, active) {
61 fZdcCollection =
new TClonesArray(
"BmnZdcPoint");
78 fZdcCollection->Delete();
79 delete fZdcCollection;
91 FairDetector::Initialize();
92 FairRun* sim = FairRun::Instance();
93 FairRuntimeDb* rtdb=sim->GetRuntimeDb();
95 fVSCVolId = gMC->VolId(
"zdc01s");
96 fVSCVolId_after = gMC->VolId(
"zdc01s_after");
111 Int_t copyNoVSC,copyNoVTYVEC,copyNoVMOD,copyNoVZDC;
113 Int_t copyNoVSC_after,copyNoVTYVECNICA,copyNoVMODNICA,copyNoVZDCNICA;
114 Int_t copyNoVSCVETO,copyNoVTYVECVETO,copyNoVMODVETO,copyNoVZDCVETO;
115 Int_t copyNoVSCCom,copyNoVTYVECCom,copyNoVMODCom,copyNoVZDCCom;
118 TLorentzVector tPos1, tMom1;
120 Int_t module, module_nica;
121 Int_t slice, slice_nica;
124 TLorentzVector tPos, tMom;
136 Double_t timeCut = 55;
138 Double_t BirkConst = 12.6;
142 if (gMC->CurrentVolID(copyNoVSC) != fVSCVolId &&
143 gMC->CurrentVolID(copyNoVSC_after) != fVSCVolId_after)
148 ivol = vol->getMCid();
149 fEventID = gMC->CurrentEvent();
151 if (gMC->CurrentVolID(copyNoVSC) == fVSCVolId || gMC->CurrentVolID(copyNoVSC_after) == fVSCVolId_after) {
154 gMC->CurrentVolOffID(0, copyNo);
155 gMC->CurrentVolOffID(1, copyNo_slice);
159 if (gMC->IsTrackEntering()) {
165 gMC->TrackPosition(tPos);
166 gMC->TrackMomentum(tMom);
168 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
169 part = gMC->GetStack()->GetCurrentTrack();
174 if ( gMC->IsTrackExiting()) {
176 gMC->TrackPosition(tPos);
177 gMC->TrackMomentum(tMom);
178 part = gMC->GetStack()->GetCurrentTrack();
182 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
183 time = gMC->TrackTime() * 1.0e09;
191 AddHit(fTrackID, ivol, copyNo_slice, copyNo, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
192 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
193 time, length, fELoss);
409 if (fVerboseLevel)
Print();
416 FairRootManager::Instance()->Register(
"ZdcPoint",
"Zdc", fZdcCollection, kTRUE);
422 if (iColl == 0)
return fZdcCollection;
430 Int_t nHits = fZdcCollection->GetEntriesFast();
431 cout <<
"-I- BmnZdc: " << nHits <<
" points registered in this event."
435 for (Int_t
i=0;
i<nHits;
i++) (*fZdcCollection)[
i]->Print();
443 fZdcCollection->Delete();
452 Int_t nEntries = cl1->GetEntriesFast();
454 TClonesArray& clref = *cl2;
456 for (Int_t
i=0;
i<nEntries;
i++) {
458 Int_t index = oldpoint->GetTrackID() + offset;
459 oldpoint->SetTrackID(index);
463 cout <<
" -I- BmnZdc: " << cl2->GetEntriesFast() <<
" merged entries."
471 TString fileName = GetGeometryFileName();
472 if(fileName.EndsWith(
".root"))
475 LOG(info) <<
"Constructing ZDC geometry from ROOT file" <<fileName.Data();
476 ConstructRootGeometry();
479 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
480 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
482 zdcGeo->setGeomFile(GetGeometryFileName());
483 geoFace->addGeoModule(zdcGeo);
485 Bool_t rc = geoFace->readSet(zdcGeo);
486 if (rc) zdcGeo->create(geoLoad->getGeoBuilder());
487 TList* volList = zdcGeo->getListOfVolumes();
490 FairRun *fRun = FairRun::Instance();
491 FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb();
496 TListIter iter(volList);
497 FairGeoNode* node = NULL;
498 FairGeoVolume *aVol=NULL;
500 while( (node = (FairGeoNode*)iter.Next()) ) {
501 aVol =
dynamic_cast<FairGeoVolume*
> ( node );
504 if ( node->isSensitive() ) {
505 fSensNodes->AddLast( aVol );
507 fPassNodes->AddLast( aVol );
511 par->setInputVersion(fRun->GetRunId(),1);
513 ProcessNodes ( volList );
518 TString tsname =
name;
520 if (tsname.Contains(
"zdc01s") || tsname.Contains(
"zdc01s_after") || tsname.Contains(
"ScH")) {
530 TVector3 pos, TVector3 mom, Double_t time,
531 Double_t length, Double_t eLoss) {
532 TClonesArray& clref = *fZdcCollection;
533 Int_t size = clref.GetEntriesFast();
534 return new(clref[size])
BmnZdcPoint(trackID, detID, copyNo, copyNoMother,pos, mom,
535 time, length, eLoss);
TObjArray * GetGeoPassiveNodes()
TObjArray * GetGeoSensitiveNodes()
virtual void Print() const
virtual void EndOfEvent()
virtual void ConstructGeometry()
virtual Bool_t CheckIfSensitive(std::string name)
BmnZdcPoint * AddHit(Int_t trackID, Int_t detID, Int_t copyNo, Int_t copyNoMother, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
virtual void BeginEvent()
virtual TClonesArray * GetCollection(Int_t iColl) const
virtual void Initialize()
virtual Bool_t ProcessHits(FairVolume *vol=0)