11#include "CbmStsPoint.h"
12#include "FairGeoInterface.h"
13#include "FairGeoLoader.h"
14#include "FairGeoMedia.h"
15#include "FairGeoNode.h"
16#include "FairGeoRootBuilder.h"
17#include "FairRootManager.h"
19#include "FairRuntimeDb.h"
20#include "FairVolume.h"
24#include "TGeoMCGeometry.h"
30#include "TVirtualMC.h"
102 if (gMC->IsTrackEntering()) {
104 fTime = gMC->TrackTime() * 1.0e09;
108 gMC->TrackPosition(PosIn);
109 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
112 gMC->TrackMomentum(MomIn);
113 fMomIn.SetXYZ(MomIn.
X(), MomIn.
Y(), MomIn.
Z());
120 if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) {
122 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
126 gMC->TrackPosition(PosOut);
127 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
130 gMC->TrackMomentum(MomOut);
131 fMomOut.SetXYZ(MomOut.
X(), MomOut.
Y(), MomOut.
Z());
139 if (diff_pos.
Mag() < 0.001)
151 Int_t stationNum = -1;
152 Int_t moduleNum = -1;
157 TRegexp expr =
"^Sensor_module[0-9]+_station[0-9]+_GEM$";
158 if (currentVolumeName.
Contains(expr)) {
159 TRegexp mod_expr =
"module[0-9]+";
160 TRegexp stat_expr =
"station[0-9]+";
170 if (stationNum == -1 || moduleNum == -1)
174 AddHit(
fTrackID,
fDetectorId,
fPosIn,
fPosOut,
fMomIn,
fMomOut,
fTime,
fLength,
fELoss, stationNum, moduleNum);
222 cout <<
"-I- CbmSts: " << nHits <<
" points registered in this event." << endl;
239 cout <<
"-I- CbmSts: " << nEntries <<
" entries to add." << endl;
242 for (
Int_t i = 0;
i < nEntries;
i++) {
244 Int_t index = oldpoint->GetTrackID() + offset;
249 cout <<
" -I- CbmSts: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
256 TString fileName = GetGeometryFileName();
258 LOG(info) <<
"Constructing STS geometry from ROOT file " << fileName.
Data();
259 ConstructRootGeometry();
260 }
else if (fileName.
EndsWith(
".geo")) {
261 LOG(info) <<
"Constructing STS geometry from ASCII file " << fileName.
Data();
263 }
else if (fileName.
EndsWith(
".gdml")) {
264 LOG(info) <<
"Constructing STS geometry from GDML file " << fileName.
Data();
267 LOG(fatal) <<
"Geometry format of STS file " << fileName.
Data() <<
" not supported";
275 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
276 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
278 stsGeo->setGeomFile(GetGeometryFileName());
279 geoFace->addGeoModule(stsGeo);
281 Bool_t rc = geoFace->readSet(stsGeo);
283 stsGeo->create(geoLoad->getGeoBuilder());
284 TList* volList = stsGeo->getListOfVolumes();
286 FairRun* fRun = FairRun::Instance();
287 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
293 FairGeoNode* node = NULL;
294 FairGeoVolume* aVol = NULL;
296 while ((node = (FairGeoNode*)iter.
Next())) {
297 aVol =
dynamic_cast<FairGeoVolume*
>(node);
298 if (node->isSensitive()) {
305 par->setInputVersion(fRun->GetRunId(), 1);
306 ProcessNodes(volList);
318 <<
"\033[5m\033[31mFairModule::ConstructGDMLGeometry(): could construct geometry from GDML File!! \033[0m"
319 << GetGeometryFileName().Data();
398 TFile* outfile =
new TFile(
"sts.root",
"RECREATE");
430 if (fVerboseLevel > 1)
431 cout <<
"-I- CbmSts: Adding Point at (" << posIn.
X() <<
", " << posIn.
Y() <<
", " << posIn.
Z()
432 <<
") cm, detector " << detID <<
", track " << trackID <<
", energy loss " << eLoss * 1e06 <<
" keV"
437 new (clref[size])
CbmStsPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss);
R__EXTERN TGeoManager * gGeoManager
TObjArray * GetGeoPassiveNodes()
TObjArray * GetGeoSensitiveNodes()
void AddPoint(DetectorId iDet)
Increment number of points for the current track in a given detector.
void SetStation(Int_t station)
void SetModule(Int_t module)
virtual void SetTrackID(Int_t id)
virtual void Reset()
Virtual method Reset.
CbmSts()
Default constructor.
virtual void ConstructAsciiGeometry()
Construct the geometry from an ASCII geometry file.
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
virtual void Print(Option_t *) const
Virtual method Print.
virtual Bool_t ProcessHits(FairVolume *vol=0)
Virtual method ProcessHits.
Int_t fVolumeID
track index
virtual void ConstructGDMLGeometry(TGeoMatrix *)
Construct the geometry from a GDML geometry file.
virtual void Register()
Virtual method Register.
Int_t fPosIndex
energy loss
virtual void ConstructGeometry()
Construct the STS geometry.
Int_t fDetectorId
volume id
virtual void BeginEvent()
Virtual method BeginEvent.
CbmStsPoint * AddHit(Int_t trackID, Int_t detID, TVector3 posIn, TVector3 pos_out, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Int_t stationNum, Int_t moduleNum)
The hit collection.
Int_t fTrackID
Track information to be stored until the track leaves the active volume.
virtual Bool_t CheckIfSensitive(std::string name)
Check whether a volume is sensitive.
virtual ~CbmSts()
Destructor.
virtual void EndOfEvent()
Virtual method EndOfEvent.
void ResetParameters()
Private method ResetParameters.
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Virtual method CopyClones.
TClonesArray * fStsCollection
void Close(Option_t *option="") override
TGeoVolume * GDMLReadFile(const char *filename="test.gdml")
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
TGeoNode * GetNode(const char *name) const
TGeoVoxelFinder * GetVoxels() const
void SetNeedRebuild(Bool_t flag=kTRUE)
TObject * Next() override
const char * GetName() const override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
void AddLast(TObject *obj) override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
*brief user defined string literal for JSON values *sa std::size_t n