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();
106 Int_t ivol = vol->getMCid();
107 TLorentzVector tPos1, tMom1;
111 static Int_t lEDEBUGcounter=0;
112 if (lEDEBUGcounter<1)
113 std::cout <<
"EDEBUG-- BmnZdc::ProcessHits: entered" << gMC->CurrentVolPath() << endl;
116 if (gMC->IsTrackEntering()) {
121 gMC->TrackPosition(tPos1);
122 gMC->TrackMomentum(tMom1);
126 Double_t eLoss = gMC->Edep();
130 if ( gMC->IsTrackExiting() ||
131 gMC->IsTrackStop() ||
132 gMC->IsTrackDisappeared() ) {
146 TParticle* part = gMC->GetStack()->GetCurrentTrack();
147 Double_t charge = part->GetPDG()->Charge() / 3. ;
150 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
151 Double_t time = gMC->TrackTime() * 1.0e09;
152 Double_t length = gMC->TrackLength();
153 TLorentzVector tPos, tMom;
154 gMC->TrackPosition(tPos);
155 gMC->TrackMomentum(tMom);
170 Int_t ivol1 = gMC->CurrentVolID(copyNo_slice);
172 Int_t iCell, iCell2 ;
173 gMC->CurrentVolOffID(1, copyNo);
177 static Bool_t already=0;
178 if (lEDEBUGcounter<200) {
179 std::cout <<
"EDEBUG-- BmnZdc::ProcessHits: TrackID:" << fTrackID <<
182 " " << gMC->CurrentVolPath() <<
" " << tPos.X()<<
" " << tPos.Y() <<
" " << tPos.Z() <<
" " << part->GetPDG()->PdgCode()<<
185 " " << ivol <<
" " << vol->getRealName() <<
" " <<
186 " " << gMC->CurrentVolOffID(1,iCell) <<
" " << gMC->CurrentVolOffName(1) <<
187 " " << iCell <<
" " << iCell2 <<
" "<< gMC->CurrentVolOffName(2) <<
188 " " << vol->getModId()<<
" " <<
200 if ((iCell==2)&&(lEDEBUGcounter>=100)&&(!already)) {
216 AddHit(fTrackID, ivol, copyNo_slice, copyNo, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
217 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
218 time, length, fELoss);
221 AddHit(fTrackID, ivol, copyNo_slice, copyNo, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
222 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
223 time, length, fELoss);
226 Int_t points = gMC->GetStack()->GetCurrentTrack()->GetMother(1);
231 points = ( points & ( ~ (1<<30) ) ) | (1 << 30);
232 gMC->GetStack()->GetCurrentTrack()->SetMother(1,points);
254 if (fVerboseLevel)
Print();
261 FairRootManager::Instance()->Register(
"ZdcPoint",
"Zdc", fZdcCollection, kTRUE);
267 if (iColl == 0)
return fZdcCollection;
275 Int_t nHits = fZdcCollection->GetEntriesFast();
276 cout <<
"-I- BmnZdc: " << nHits <<
" points registered in this event."
280 for (Int_t
i=0;
i<nHits;
i++) (*fZdcCollection)[
i]->Print();
288 fZdcCollection->Delete();
297 Int_t nEntries = cl1->GetEntriesFast();
299 TClonesArray& clref = *cl2;
301 for (Int_t
i=0;
i<nEntries;
i++) {
303 Int_t index = oldpoint->GetTrackID() + offset;
304 oldpoint->SetTrackID(index);
308 cout <<
" -I- BmnZdc: " << cl2->GetEntriesFast() <<
" merged entries."
316 TString fileName = GetGeometryFileName();
317 if(fileName.EndsWith(
".root"))
320 LOG(info) <<
"Constructing ZDC geometry from ROOT file" <<fileName.Data();
321 ConstructRootGeometry();
324 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
325 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
327 zdcGeo->setGeomFile(GetGeometryFileName());
328 geoFace->addGeoModule(zdcGeo);
330 Bool_t rc = geoFace->readSet(zdcGeo);
331 if (rc) zdcGeo->create(geoLoad->getGeoBuilder());
332 TList* volList = zdcGeo->getListOfVolumes();
335 FairRun *fRun = FairRun::Instance();
336 FairRuntimeDb *rtdb= FairRun::Instance()->GetRuntimeDb();
341 TListIter iter(volList);
342 FairGeoNode* node = NULL;
343 FairGeoVolume *aVol=NULL;
345 while( (node = (FairGeoNode*)iter.Next()) ) {
346 aVol =
dynamic_cast<FairGeoVolume*
> ( node );
349 if ( node->isSensitive() ) {
350 fSensNodes->AddLast( aVol );
352 fPassNodes->AddLast( aVol );
356 par->setInputVersion(fRun->GetRunId(),1);
358 ProcessNodes ( volList );
363 TString tsname =
name;
364 if (tsname.Contains(
"zdc01s") || tsname.Contains(
"ScH")) {
374 TVector3 pos, TVector3 mom, Double_t time,
375 Double_t length, Double_t eLoss) {
376 TClonesArray& clref = *fZdcCollection;
377 Int_t size = clref.GetEntriesFast();
378 return new(clref[size])
BmnZdcPoint(trackID, detID, copyNo, copyNoMother,pos, mom,
379 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)