5#include "FairGeoMedia.h"
6#include "FairGeoRootBuilder.h"
7#include "FairRootManager.h"
16#include "TVirtualMC.h"
54 if (gMC->IsTrackEntering()) {
58 fTime = gMC->TrackTime() * 1.0e09;
65 gMC->TrackPosition(PosIn);
66 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
69 gMC->TrackMomentum(MomIn);
70 fMomIn.SetXYZ(MomIn.
X(), MomIn.
Y(), MomIn.
Z());
73 part = gMC->GetStack()->GetCurrentTrack();
82 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
89 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) &&
fELoss > 0) {
92 gMC->TrackPosition(PosOut);
93 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
96 gMC->TrackMomentum(MomOut);
97 fMomOut.SetXYZ(MomOut.
X(), MomOut.
Y(), MomOut.
Z());
102 if (diff_pos.
Mag() < 0.001)
114 Int_t stationNum = -1;
115 Int_t moduleNum = -1;
119 TRegexp expr =
"^SiBTSensor_module[0-9]+_station[0-9]+$";
120 if (currentVolumeName.
Contains(expr)) {
121 TRegexp mod_expt =
"module[0-9]+";
122 TRegexp stat_expt =
"station[0-9]+";
128 if (stationNum == -1 || moduleNum == -1)
163 cout <<
"-I- BmnSiBT: " << nHits <<
" points registered in this event." << endl;
165 if (fVerboseLevel > 1) {
167 (*fPointCollection)[
i]->Print();
181 cout <<
"-I- BmnSiBT: " << nEntries <<
" entries to add." << endl;
185 for (
Int_t i = 0;
i < nEntries;
i++) {
187 Int_t index = oldpoint->GetTrackID() + offset;
188 oldpoint->SetTrackID(index);
193 cout <<
"-I- BmnSiBT: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
198 TString fileName = GetGeometryFileName();
201 LOG(info) <<
"Constructing SiBT geometry from ROOT file " << fileName.
Data();
202 ConstructRootGeometry();
205 else if (fileName.
EndsWith(
".gdml"))
207 LOG(info) <<
"Constructing SiBT geometry from GDML file " << fileName.
Data();
213 LOG(fatal) <<
"Geometry format of SiBT file " << fileName.
Data() <<
" not supported.";
239 m->SetId(curId + maxInd);
249 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
252 for (
Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
254 LOG(debug) <<
" removing media " << medToDel->
GetName() <<
" with id " << medToDel->
GetId() <<
" (k=" << k
265 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->
GetName();
269 LOG(debug) <<
" volume: " << curVol->
GetName();
272 LOG(debug) <<
" skipping volume-assembly";
281 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->
GetName() <<
"\t" << curMed->
GetId();
282 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->
GetName() <<
"\t" << curMat->
GetIndex();
285 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->
GetName()
286 <<
"\t" << curMedInGeoManager->
GetId();
287 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
288 << curMatOfMedInGeoManager->
GetName() <<
"\t" << curMatOfMedInGeoManager->
GetIndex();
289 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->
GetName()
290 <<
"\t" << curMatInGeoManager->
GetIndex();
295 if (curMed->
GetId() != curMedInGeoManager->
GetId()) {
297 LOG(debug) <<
" Medium needs to be fixed";
301 LOG(debug) <<
" removing material " << curMat->
GetName() <<
" with index " << ind;
304 m->SetIndex(
m->GetIndex() - 1);
307 LOG(debug) <<
" Medium fixed";
309 LOG(debug) <<
" Already fixed medium found in the list ";
313 LOG(debug) <<
" There is no correct medium in the memory yet";
315 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
316 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
317 FairGeoMedia* geoMediaBase = geoFace->getMedia();
318 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
320 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
321 if (curMedInGeo == 0) {
322 LOG(fatal) <<
" Media not found in Geo file: " << medName;
327 LOG(debug) <<
" Found media in Geo file" << medName;
328 geobuild->createMedium(curMedInGeo);
331 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->
GetName() <<
" with index "
332 << curMatOfMedInGeoManager->
GetIndex();
337 m->SetIndex(
m->GetIndex() - 1);
341 if (curMedInGeo->getSensitivityFlag()) {
342 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
343 AddSensitiveVolume(curVol);
346 LOG(debug) <<
" Already fixed medium found in the list";
347 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
349 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
350 AddSensitiveVolume(curVol);
367 curNodeChild = (
TGeoNode*)NodeChildList->
At(j);
377 if (tsname.
Contains(
"SiBTSensor")) {
405 BmnSiBTPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss, isPrimary, charge, pdgId);
R__EXTERN TGeoManager * gGeoManager
void SetModule(Int_t module)
void SetStation(Int_t station)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
BmnSiBTPoint * AddHit(Int_t trackID, Int_t detID, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Int_t isPrimary, Double_t charge, Int_t pdgId, Int_t stationNum, Int_t moduleNum)
List of media "repaired" after importing GMDL.
std::map< TString, TGeoMedium * > fFixedMedia
Hit collection.
virtual Bool_t CheckIfSensitive(std::string name)
virtual Bool_t ProcessHits(FairVolume *vol=0)
Int_t fPosIndex
pdg id of particle
TVector3 fPosOut
position (in)
Double_t fCharge
is track primary?
Int_t fIsPrimary
energy loss
virtual void ConstructGDMLGeometry(TGeoMatrix *)
TVector3 fMomIn
position (out)
TClonesArray * fPointCollection
TVector3 fMomOut
momentum (in)
virtual TClonesArray * GetCollection(Int_t iColl) const
virtual void Print(Option_t *) const
void ExpandNodeForGdml(TGeoNode *node)
virtual void ConstructGeometry()
virtual void EndOfEvent()
Int_t fVolumeID
track index
Double32_t fTime
momentum (out)
TGeoVolume * GDMLReadFile(const char *filename="test.gdml")
TGeoMaterial * GetMaterial() const
TGeoVolume * GetVolume() const
TGeoMedium * GetMedium() const
TGeoMaterial * GetMaterial() const
Int_t GetNdaughters() const
virtual void SetMedium(TGeoMedium *medium)
virtual Bool_t IsAssembly() const
const char * GetName() const override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const 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