1#include "FairGeoInterface.h"
2#include "FairGeoLoader.h"
3#include "FairGeoNode.h"
4#include "FairGeoRootBuilder.h"
5#include "FairMCPoint.h"
6#include "FairRootManager.h"
9#include "TGeoMCGeometry.h"
21#include "FairRuntimeDb.h"
62 FairDetector::Initialize();
88 Int_t ivol = vol->getMCid();
94 static Int_t lEDEBUGcounter = 0;
95 if (lEDEBUGcounter < 1)
96 std::cout <<
"EDEBUG-- BmnSiMD::ProcessHits: entered" << gMC->CurrentVolPath() << endl;
99 if (gMC->IsTrackEntering()) {
111 gMC->TrackPosition(PosIn);
112 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
115 gMC->TrackMomentum(MomIn);
118 timeIn = gMC->TrackTime() * 1.0e09;
126 part = gMC->GetStack()->GetCurrentTrack();
139 Double_t slengthtrack = gMC->TrackStep();
140 lengthtrack += slengthtrack;
142 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && (
fELoss > 0)) {
144 gMC->TrackPosition(PosOut);
145 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
148 gMC->TrackMomentum(MomOut);
151 timeOut = gMC->TrackTime() * 1.0e09;
178 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
180 Double_t time = gMC->TrackTime() * 1.0e09;
181 Double_t length = gMC->TrackLength();
184 gMC->CurrentVolID(copyNo);
187 gMC->CurrentVolOffID(1, iCell);
190 if (lEDEBUGcounter < 100) {
191 std::cout <<
"EDEBUG-- BmnSiMD::ProcessHits: TrackID:" <<
fTrackID <<
194 " " << gMC->CurrentVolPath() <<
" " << tPos.Z() <<
196 " " << ivol <<
"==" << gMC->CurrentVolID(copyNo) <<
"," << copyNo <<
" "
197 << gMC->CurrentVolOffID(1, iCell) <<
" " << iCell <<
" " << gMC->CurrentVolOffName(1) <<
" "
198 << gMC->CurrentVolOffName(0) <<
208 AddHit(
fTrackID, ivol, copyNo,
fPosIn,
fPosOut,
fMomIn,
fMomOut, time, length,
fELoss,
fIsPrimary,
fCharge,
209 fPdgId, timeIn, timeOut, lengthtrack);
212 AddHit(
fTrackID, ivol, copyNo,
fPosIn,
fPosOut,
fMomIn,
fMomOut, time, length,
fELoss,
fIsPrimary,
fCharge,
213 fPdgId, timeIn, timeOut, lengthtrack);
259 cout <<
"-I- BmnSiMD: " << nHits <<
" points registered in this event." << endl;
261 if (fVerboseLevel > 1)
282 for (
Int_t i = 0;
i < nEntries;
i++) {
284 Int_t index = oldpoint->GetTrackID() + offset;
285 oldpoint->SetTrackID(index);
289 cout <<
" -I- BmnSiMD: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
295 TString fileName = GetGeometryFileName();
297 LOG(info) <<
"Constructing SiMD geometry from ROOT file " << fileName.
Data();
298 ConstructRootGeometry();
299 }
else if (fileName.
EndsWith(
".geo")) {
300 LOG(info) <<
"Constructing SiMD geometry from ASCII file " << fileName.
Data();
303 LOG(fatal) <<
"Geometry format of SiMD file " << fileName.
Data() <<
" not supported.";
308 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
309 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
311 SiMDGeo->setGeomFile(GetGeometryFileName());
312 geoFace->addGeoModule(SiMDGeo);
314 Bool_t rc = geoFace->readSet(SiMDGeo);
316 SiMDGeo->create(geoLoad->getGeoBuilder());
317 TList* volList = SiMDGeo->getListOfVolumes();
320 FairRun* fRun = FairRun::Instance();
321 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
327 FairGeoNode* node =
nullptr;
328 FairGeoVolume* aVol =
nullptr;
330 while ((node = (FairGeoNode*)iter.
Next())) {
331 aVol =
dynamic_cast<FairGeoVolume*
>(node);
333 if (node->isSensitive())
340 par->setInputVersion(fRun->GetRunId(), 1);
341 ProcessNodes(volList);
375 return new (clref[size])
BmnSiMDPoint(trackID, detID, copyNo, posIn, posOut, momIn, momOut, time, length, eLoss,
376 isPrimary, charge, pdgId, timeIn, timeOut, lengthtrack);
TObjArray * GetGeoSensitiveNodes()
TObjArray * GetGeoPassiveNodes()
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Virtual method CopyClones.
BmnSiMDPoint * AddHit(Int_t trackID, Int_t detID, Int_t copyNo, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Bool_t isPrimary, Double_t charge, Int_t pdgId, Double_t timeIn, Double_t timeOut, Double_t lengthtrack)
TVector3 fMomOut
momentum (in)
virtual void Print(Option_t *) const
Virtual method Print.
void ResetParameters()
length
virtual void Reset()
Virtual method Reset.
virtual Bool_t CheckIfSensitive(std::string name)
BmnSiMD()
Default constructor.
virtual ~BmnSiMD()
Destructor.
virtual void ConstructAsciiGeometry()
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
virtual void Initialize()
Virtual method Initialize Initialises detector.
virtual void EndOfEvent()
Virtual method EndOfEvent.
TClonesArray * fSiMDCollection
Int_t fPosIndex
energy loss
virtual void ConstructGeometry()
Virtual method Construct geometry.
virtual void BeginEvent()
virtual Bool_t ProcessHits(FairVolume *vol=0)
Virtual method ProcessHits.
TVector3 fPosOut
position (in)
Double_t fCharge
is track primary?
virtual void Register()
Virtual method Register.
Int_t fIsPrimary
MC volume ID of MUO.
TVector3 fMomIn
position (out)
TObject * Next() override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
void AddLast(TObject *obj) override
TParticlePDG * GetPDG(Int_t mode=0) const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const