14 #include <FairLogger.h>
15 #include <FairRootManager.h>
16 #include <FairVolume.h>
18 #include <TClonesArray.h>
19 #include <TLorentzVector.h>
20 #include <TVirtualMC.h>
21 #include <TVirtualMCStack.h>
28 : FairDetector(
"AtSeGA", kTRUE,
kAtSeGA), fTrackID(-1), fVolumeID(-1), fDetCopyID(-1), fTime(-1.), fLength(-1.),
29 fELoss(-1), fAtSeGAPointCollection(new TClonesArray(
"AtMCPoint")), fELossAcc(-1)
34 : FairDetector(name, active,
kAtSeGA), fTrackID(-1), fVolumeID(-1), fDetCopyID(-1), fTime(-1.), fLength(-1.),
35 fELoss(-1), fAtSeGAPointCollection(new TClonesArray(
"AtMCPoint")), fELossAcc(-1)
41 if (fAtSeGAPointCollection) {
42 fAtSeGAPointCollection->Delete();
43 delete fAtSeGAPointCollection;
49 FairDetector::Initialize();
51 LOG(INFO) <<
"AtSeGA: initialisation";
58 auto *stack =
dynamic_cast<AtStack *
>(gMC->GetStack());
59 fVolName = gMC->CurrentVolName();
61 TLorentzVector fPosIn;
62 TLorentzVector fMomIn;
64 if (gMC->IsTrackEntering()) {
67 fTime = gMC->TrackTime() * 1.0e09;
75 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
76 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
77 fVolumeID = vol->getMCid();
78 fDetCopyID = vol->getCopyNo();
79 fLength = gMC->TrackLength();
80 gMC->TrackPosition(fPosIn);
81 gMC->TrackMomentum(fMomIn);
86 AddPoint(fTrackID, fVolumeID, TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()),
87 TVector3(fMomIn.X(), fMomIn.Y(), fMomIn.Z()), fTime, fLength, fELossAcc);
109 FairRootManager::Instance()->Register(
"AtMCPoint",
"AtSeGA", fAtSeGAPointCollection, kTRUE);
115 return fAtSeGAPointCollection;
123 fAtSeGAPointCollection->Clear();
128 Int_t nHits = fAtSeGAPointCollection->GetEntriesFast();
129 LOG(INFO) <<
"SEGA: " << nHits <<
" points registered in this event";
134 TString fileName = GetGeometryFileName();
135 if (fileName.EndsWith(
".geo")) {
136 LOG(INFO) <<
"Constructing SEGA geometry from ASCII file " << fileName;
138 }
else if (fileName.EndsWith(
".root")) {
139 LOG(INFO) <<
"Constructing SEGA geometry from ROOT file " << fileName;
140 ConstructRootGeometry();
142 std::cout <<
"Geometry format not supported." << std::endl;
148 TString tsname = name;
149 if (tsname.Contains(
"Crystal_")) {
150 LOG(INFO) <<
" SeGA geometry: Sensitive volume found: " << tsname;
158 AtSeGA::AddPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss)
160 TClonesArray &clref = *fAtSeGAPointCollection;
161 Int_t size = clref.GetEntriesFast();
162 if (fVerboseLevel > 1)
163 LOG(INFO) <<
"SEGA: Adding Point in detector " << detID <<
", track " << trackID <<
", energy loss "
164 << eLoss * 1e06 <<
" keV";
166 auto point =
new (clref[size])
AtMCPoint(trackID, detID, pos, mom, time, length, eLoss);
168 point->SetDetCopyID(fDetCopyID);