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");
58 : FairDetector(
name, active) {
59 fZdcCollection =
new TClonesArray(
"BmnZdcPoint");
74 fZdcCollection->Delete();
75 delete fZdcCollection;
87 FairDetector::Initialize();
88 FairRun* sim = FairRun::Instance();
89 FairRuntimeDb* rtdb=sim->GetRuntimeDb();
104 Int_t ivol = vol->getMCid();
105 TLorentzVector tPos1, tMom1;
109 static Int_t lEDEBUGcounter=0;
110 if (lEDEBUGcounter<1)
111 std::cout <<
"EDEBUG-- BmnZdc::ProcessHits: entered" << gMC->CurrentVolPath() << endl;
114 if (gMC->IsTrackEntering()) {
119 gMC->TrackPosition(tPos1);
120 gMC->TrackMomentum(tMom1);
124 Double_t eLoss = gMC->Edep();
128 if ( gMC->IsTrackExiting() ||
129 gMC->IsTrackStop() ||
130 gMC->IsTrackDisappeared() ) {
133 if (fELoss == 0. )
return kFALSE;
135 if ((fELoss == 0. ) &&
136 (!((gMC->GetStack()->GetCurrentTrack()->GetPdgCode()==2112)&&(gMC->GetStack()->GetCurrentTrack()->GetMother(0)==-1)))
140 TParticle* part = gMC->GetStack()->GetCurrentTrack();
141 Double_t charge = part->GetPDG()->Charge() / 3. ;
144 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
145 Double_t time = gMC->TrackTime() * 1.0e09;
146 Double_t length = gMC->TrackLength();
147 TLorentzVector tPos, tMom;
148 gMC->TrackPosition(tPos);
149 gMC->TrackMomentum(tMom);
164 Int_t ivol1 = gMC->CurrentVolID(copyNo_slice);
166 Int_t iCell, iCell2 ;
167 gMC->CurrentVolOffID(1, copyNo);
171 static Bool_t already=0;
172 if (lEDEBUGcounter<200) {
173 std::cout <<
"EDEBUG-- BmnZdc::ProcessHits: TrackID:" << fTrackID <<
176 " " << gMC->CurrentVolPath() <<
" " << tPos.X()<<
" " << tPos.Y() <<
" " << tPos.Z() <<
" " << part->GetPDG()->PdgCode()<<
179 " " << ivol <<
" " << vol->getRealName() <<
" " <<
180 " " << gMC->CurrentVolOffID(1,iCell) <<
" " << gMC->CurrentVolOffName(1) <<
181 " " << iCell <<
" " << iCell2 <<
" "<< gMC->CurrentVolOffName(2) <<
182 " " << vol->getModId()<<
" " <<
194 if ((iCell==2)&&(lEDEBUGcounter>=100)&&(!already)) {
210 AddHit(fTrackID, ivol, copyNo_slice, copyNo, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
211 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
212 time, length, fELoss);
215 AddHit(fTrackID, ivol, copyNo_slice, copyNo, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
216 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
217 time, length, fELoss);
220 Int_t points = gMC->GetStack()->GetCurrentTrack()->GetMother(1);
225 points = ( points & ( ~ (1<<30) ) ) | (1 << 30);
226 gMC->GetStack()->GetCurrentTrack()->SetMother(1,points);
248 if (fVerboseLevel)
Print();
255 FairRootManager::Instance()->Register(
"ZdcPoint",
"Zdc", fZdcCollection, kTRUE);
261 if (iColl == 0)
return fZdcCollection;
269 Int_t nHits = fZdcCollection->GetEntriesFast();
270 cout <<
"-I- BmnZdc: " << nHits <<
" points registered in this event."
274 for (Int_t
i=0;
i<nHits;
i++) (*fZdcCollection)[
i]->Print();
282 fZdcCollection->Delete();
291 Int_t nEntries = cl1->GetEntriesFast();
293 TClonesArray& clref = *cl2;
295 for (Int_t
i=0;
i<nEntries;
i++) {
297 Int_t index = oldpoint->GetTrackID() + offset;
298 oldpoint->SetTrackID(index);
302 cout <<
" -I- BmnZdc: " << cl2->GetEntriesFast() <<
" merged entries."
310 TString fileName = GetGeometryFileName();
311 if(fileName.EndsWith(
".root"))
314 LOG(info) <<
"Constructing ZDC geometry from ROOT file" <<fileName.Data();
315 ConstructRootGeometry();
318 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
319 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
321 zdcGeo->setGeomFile(GetGeometryFileName());
322 geoFace->addGeoModule(zdcGeo);
324 Bool_t rc = geoFace->readSet(zdcGeo);
325 if (rc) zdcGeo->create(geoLoad->getGeoBuilder());
326 TList* volList = zdcGeo->getListOfVolumes();
329 FairRun *fRun = FairRun::Instance();
330 FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb();
335 TListIter iter(volList);
336 FairGeoNode* node = NULL;
337 FairGeoVolume *aVol=NULL;
339 while( (node = (FairGeoNode*)iter.Next()) ) {
340 aVol =
dynamic_cast<FairGeoVolume*
> ( node );
343 if ( node->isSensitive() ) {
344 fSensNodes->AddLast( aVol );
346 fPassNodes->AddLast( aVol );
350 par->setInputVersion(fRun->GetRunId(),1);
352 ProcessNodes ( volList );
357 TString tsname =
name;
358 if (tsname.Contains(
"zdc01s") || tsname.Contains(
"ScH")) {
368 TVector3 pos, TVector3 mom, Double_t time,
369 Double_t length, Double_t eLoss) {
370 TClonesArray& clref = *fZdcCollection;
371 Int_t size = clref.GetEntriesFast();
372 return new(clref[size])
BmnZdcPoint(trackID, detID, copyNo, copyNoMother,pos, mom,
373 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)