5#include "FairGeoMedia.h"
6#include "FairGeoRootBuilder.h"
7#include "FairRootManager.h"
15#include "TVirtualMC.h"
53 if (gMC->IsTrackEntering()) {
57 fTime = gMC->TrackTime() * 1.0e09;
64 gMC->TrackPosition(PosIn);
65 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
68 gMC->TrackMomentum(MomIn);
69 fMomIn.SetXYZ(MomIn.
X(), MomIn.
Y(), MomIn.
Z());
72 part = gMC->GetStack()->GetCurrentTrack();
81 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
88 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) &&
fELoss > 0) {
91 gMC->TrackPosition(PosOut);
92 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
95 gMC->TrackMomentum(MomOut);
96 fMomOut.SetXYZ(MomOut.
X(), MomOut.
Y(), MomOut.
Z());
101 if (diff_pos.
Mag() < 0.001)
113 Int_t stationNum = -1;
114 Int_t moduleNum = -1;
118 TRegexp expr =
"^CSCSensor_module[0-9]+_station[0-9]+.*";
119 if (currentVolumeName.
Contains(expr)) {
120 TRegexp mod_expt =
"module[0-9]+";
121 TRegexp stat_expt =
"station[0-9]+";
127 if (stationNum == -1 || moduleNum == -1)
162 cout <<
"-I- BmnCSC: " << nHits <<
" points registered in this event." << endl;
164 if (fVerboseLevel > 1) {
166 (*fPointCollection)[
i]->Print();
180 cout <<
"-I- BmnCSC: " << nEntries <<
" entries to add." << endl;
184 for (
Int_t i = 0;
i < nEntries;
i++) {
186 Int_t index = oldpoint->GetTrackID() + offset;
187 oldpoint->SetTrackID(index);
192 cout <<
"-I- BmnCSC: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
197 TString fileName = GetGeometryFileName();
200 LOG(info) <<
"Constructing CSC geometry from ROOT file " << fileName.
Data();
201 ConstructRootGeometry();
204 else if (fileName.
EndsWith(
".gdml"))
206 LOG(info) <<
"Constructing CSC geometry from GDML file " << fileName.
Data();
212 LOG(fatal) <<
"Geometry format of CSC file " << fileName.
Data() <<
" not supported.";
238 m->SetId(curId + maxInd);
248 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
251 for (
Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
253 LOG(debug) <<
" removing media " << medToDel->
GetName() <<
" with id " << medToDel->
GetId() <<
" (k=" << k
264 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->
GetName();
268 LOG(debug) <<
" volume: " << curVol->
GetName();
271 LOG(debug) <<
" skipping volume-assembly";
280 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->
GetName() <<
"\t" << curMed->
GetId();
281 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->
GetName() <<
"\t" << curMat->
GetIndex();
284 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->
GetName()
285 <<
"\t" << curMedInGeoManager->
GetId();
286 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
287 << curMatOfMedInGeoManager->
GetName() <<
"\t" << curMatOfMedInGeoManager->
GetIndex();
288 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->
GetName()
289 <<
"\t" << curMatInGeoManager->
GetIndex();
294 if (curMed->
GetId() != curMedInGeoManager->
GetId()) {
296 LOG(debug) <<
" Medium needs to be fixed";
300 LOG(debug) <<
" removing material " << curMat->
GetName() <<
" with index " << ind;
303 m->SetIndex(
m->GetIndex() - 1);
306 LOG(debug) <<
" Medium fixed";
308 LOG(debug) <<
" Already fixed medium found in the list ";
312 LOG(debug) <<
" There is no correct medium in the memory yet";
314 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
315 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
316 FairGeoMedia* geoMediaBase = geoFace->getMedia();
317 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
319 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
320 if (curMedInGeo == 0) {
321 LOG(fatal) <<
" Media not found in Geo file: " << medName;
326 LOG(debug) <<
" Found media in Geo file" << medName;
327 geobuild->createMedium(curMedInGeo);
330 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->
GetName() <<
" with index "
331 << curMatOfMedInGeoManager->
GetIndex();
336 m->SetIndex(
m->GetIndex() - 1);
340 if (curMedInGeo->getSensitivityFlag()) {
341 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
342 AddSensitiveVolume(curVol);
345 LOG(debug) <<
" Already fixed medium found in the list";
346 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
348 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
349 AddSensitiveVolume(curVol);
366 curNodeChild = (
TGeoNode*)NodeChildList->
At(j);
404 BmnCSCPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss, isPrimary, charge, pdgId);
R__EXTERN TGeoManager * gGeoManager
void SetStation(Int_t station)
void SetModule(Int_t module)
TVector3 fMomOut
momentum (in)
Int_t fVolumeID
track index
virtual Bool_t ProcessHits(FairVolume *vol=0)
Double_t fCharge
is track primary?
virtual void ConstructGeometry()
Int_t fPosIndex
pdg id of particle
TVector3 fPosOut
position (in)
BmnCSCPoint * 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)
virtual TClonesArray * GetCollection(Int_t iColl) const
Double32_t fTime
momentum (out)
void ExpandNodeForGdml(TGeoNode *node)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
std::map< TString, TGeoMedium * > fFixedMedia
Hit collection.
virtual void EndOfEvent()
TClonesArray * fPointCollection
TVector3 fMomIn
position (out)
virtual Bool_t CheckIfSensitive(std::string name)
virtual void Print(Option_t *) const
virtual void ConstructGDMLGeometry(TGeoMatrix *)
Int_t fIsPrimary
energy loss
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