14 #include <FairDetector.h>
15 #include <FairLogger.h>
16 #include <FairRootManager.h>
17 #include <FairVolume.h>
19 #include <TClonesArray.h>
20 #include <TLorentzVector.h>
22 #include <TVirtualMC.h>
23 #include <TVirtualMCStack.h>
31 : FairDetector(
"AtApollo", kTRUE,
kAtApollo), fTrackID(-1), fVolumeID(-1), fDetCopyID(-1), fTime(-1.), fLength(-1.),
32 fELoss(-1), fAtApolloPointCollection(new TClonesArray(
"AtApolloPoint")), fELossAcc(-1)
37 : FairDetector(name, active,
kAtApollo), fTrackID(-1), fVolumeID(-1), fDetCopyID(-1), fTime(-1.), fLength(-1.),
38 fELoss(-1), fAtApolloPointCollection(new TClonesArray(
"AtApolloPoint")), fELossAcc(-1)
44 if (fAtApolloPointCollection) {
45 fAtApolloPointCollection->Delete();
46 delete fAtApolloPointCollection;
52 FairDetector::Initialize();
55 LOG(INFO) <<
"AtApollo: initialisation";
62 auto *stack =
dynamic_cast<AtStack *
>(gMC->GetStack());
63 fVolName = gMC->CurrentVolName();
65 TLorentzVector fPosIn;
66 TLorentzVector fMomIn;
68 if (gMC->IsTrackEntering()) {
71 fTime = gMC->TrackTime() * 1.0e09;
79 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
80 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
81 fVolumeID = vol->getMCid();
82 fDetCopyID = vol->getCopyNo();
83 fLength = gMC->TrackLength();
84 gMC->TrackPosition(fPosIn);
85 gMC->TrackMomentum(fMomIn);
90 AddPoint(fTrackID, fVolumeID, TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()),
91 TVector3(fMomIn.X(), fMomIn.Y(), fMomIn.Z()), fDetCopyID, fTime, fLength, fELossAcc);
113 FairRootManager::Instance()->Register(
"AtApolloPoint",
"AtApollo", fAtApolloPointCollection, kTRUE);
119 return fAtApolloPointCollection;
127 fAtApolloPointCollection->Clear();
132 Int_t nHits = fAtApolloPointCollection->GetEntriesFast();
133 LOG(INFO) <<
"APOLLO: " << nHits <<
" points registered in this event";
138 TString fileName = GetGeometryFileName();
139 if (fileName.EndsWith(
".geo")) {
140 LOG(INFO) <<
"Constructing APOLLO geometry from ASCII file " << fileName;
142 }
else if (fileName.EndsWith(
".root")) {
143 LOG(INFO) <<
"Constructing APOLLO geometry from ROOT file " << fileName;
144 ConstructRootGeometry();
146 std::cout <<
"Geometry format not supported." << std::endl;
152 TString tsname = name;
153 if (tsname.Contains(
"Crystal_")) {
154 LOG(INFO) <<
" APOLLO geometry: Sensitive volume found: " << tsname;
161 AtApolloPoint *AtApollo::AddPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Int_t crystalID,
162 Double_t time, Double_t length, Double_t eLoss)
164 TClonesArray &clref = *fAtApolloPointCollection;
165 Int_t size = clref.GetEntriesFast();
166 if (fVerboseLevel > 1)
167 LOG(INFO) <<
"APOLLO: Adding Point in detector " << detID <<
", track " << trackID <<
", energy loss "
168 << eLoss * 1e06 <<
" keV";
170 return new (clref[size])
AtApolloPoint(trackID, detID, pos, mom, crystalID, time, length, eLoss);