11#include "TVirtualMC.h"
21#include "FairGeoInterface.h"
22#include "FairGeoLoader.h"
23#include "FairGeoMedia.h"
24#include "FairGeoNode.h"
25#include "FairGeoRootBuilder.h"
26#include "FairRootManager.h"
28#include "FairRuntimeDb.h"
29#include "FairVolume.h"
78 gMC->Gmtod(globPos, localPos, 1);
87 gMC->Gdtom(localPos, globPos, 1);
94 if (gMC->IsTrackEntering()) {
98 fTime = gMC->TrackTime() * 1.0e09;
105 gMC->TrackPosition(PosIn);
106 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
107 gMC->TrackMomentum(
fMom);
109 part = gMC->GetStack()->GetCurrentTrack();
118 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
125 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) &&
fELoss > 0) {
127 gMC->TrackPosition(PosOut);
128 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
181 cout <<
"-I- BmnMwpc: " << nHits <<
" points registered in this event." << endl;
183 if (fVerboseLevel > 1)
197 cout <<
"-I- BmnMwpc: " << nEntries <<
" entries to add." << endl;
201 for (
Int_t i = 0;
i < nEntries;
i++) {
203 Int_t index = oldpoint->GetTrackID() + offset;
204 oldpoint->SetTrackID(index);
209 cout <<
"-I- BmnMwpc: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
214 TString fileName = GetGeometryFileName();
217 LOG(info) <<
"Constructing MWPC geometry from ROOT file " << fileName.
Data();
218 ConstructRootGeometry();
219 }
else if (fileName.
EndsWith(
".geo")) {
220 LOG(info) <<
"Constructing MWPC geometry from ASCII file " << fileName.
Data();
222 }
else if (fileName.
EndsWith(
".gdml")) {
223 LOG(info) <<
"Constructing MWPC geometry from GDML file " << fileName.
Data();
226 LOG(fatal) <<
"Geometry format of MWPC file " << fileName.
Data() <<
" not supported.";
234 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
235 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
237 MWPCGeo->setGeomFile(GetGeometryFileName());
238 geoFace->addGeoModule(MWPCGeo);
240 Bool_t rc = geoFace->readSet(MWPCGeo);
242 MWPCGeo->create(geoLoad->getGeoBuilder());
243 TList* volList = MWPCGeo->getListOfVolumes();
245 FairRun* fRun = FairRun::Instance();
246 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
252 FairGeoNode* node = NULL;
253 FairGeoVolume* aVol = NULL;
255 while ((node = (FairGeoNode*)iter.
Next())) {
256 aVol =
dynamic_cast<FairGeoVolume*
>(node);
257 if (node->isSensitive()) {
264 par->setInputVersion(fRun->GetRunId(), 1);
265 ProcessNodes(volList);
392 m->SetId(curId + maxInd);
401 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
404 for (
Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
406 LOG(debug) <<
" removing media " << medToDel->
GetName() <<
" with id " << medToDel->
GetId() <<
" (k=" << k
417 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->
GetName();
421 LOG(debug) <<
" volume: " << curVol->
GetName();
424 LOG(debug) <<
" skipping volume-assembly";
433 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->
GetName() <<
"\t" << curMed->
GetId();
434 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->
GetName() <<
"\t" << curMat->
GetIndex();
437 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->
GetName()
438 <<
"\t" << curMedInGeoManager->
GetId();
439 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
440 << curMatOfMedInGeoManager->
GetName() <<
"\t" << curMatOfMedInGeoManager->
GetIndex();
441 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->
GetName()
442 <<
"\t" << curMatInGeoManager->
GetIndex();
447 if (curMed->
GetId() != curMedInGeoManager->
GetId()) {
449 LOG(debug) <<
" Medium needs to be fixed";
453 LOG(debug) <<
" removing material " << curMat->
GetName() <<
" with index " << ind;
456 m->SetIndex(
m->GetIndex() - 1);
459 LOG(debug) <<
" Medium fixed";
461 LOG(debug) <<
" Already fixed medium found in the list ";
465 LOG(debug) <<
" There is no correct medium in the memory yet";
467 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
468 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
469 FairGeoMedia* geoMediaBase = geoFace->getMedia();
470 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
472 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
473 if (curMedInGeo == 0) {
474 LOG(fatal) <<
" Media not found in Geo file: " << medName;
479 LOG(debug) <<
" Found media in Geo file" << medName;
480 geobuild->createMedium(curMedInGeo);
483 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->
GetName() <<
" with index "
484 << curMatOfMedInGeoManager->
GetIndex();
489 m->SetIndex(
m->GetIndex() - 1);
493 if (curMedInGeo->getSensitivityFlag()) {
494 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
495 AddSensitiveVolume(curVol);
498 LOG(debug) <<
" Already fixed medium found in the list";
499 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
501 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
502 AddSensitiveVolume(curVol);
519 curNodeChild = (
TGeoNode*)NodeChildList->
At(j);
558 return new (clref[size])
559 BmnMwpcPoint(trackID, detID, pos, radius, mom, time, length, eLoss, isPrimary, charge, pdgId, trackPos);
R__EXTERN TGeoManager * gGeoManager
TObjArray * GetGeoSensitiveNodes()
TObjArray * GetGeoPassiveNodes()
void SetPhi(Double_t phi)
Int_t fIsPrimary
energy loss
TVector3 fPosOut
entry position in global frame
int DistAndPoints(TVector3 p3, TVector3 p4, TVector3 &pa, TVector3 &pb)
Hit collection.
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
TVector3 GlobalToLocal(TVector3 &global)
TLorentzVector fMom
position local to gas chamber
TClonesArray * fPointCollection
virtual void ConstructGDMLGeometry(TGeoMatrix *)
Double_t fCharge
is track primary?
virtual TClonesArray * GetCollection(Int_t iColl) const
virtual void Print(Option_t *) const
Int_t fVolumeID
track index
virtual Bool_t ProcessHits(FairVolume *vol=0)
TVector3 LocalToGlobal(TVector3 &local)
virtual Bool_t CheckIfSensitive(std::string name)
void ExpandNodeForGdml(TGeoNode *node)
virtual void ConstructAsciiGeometry()
virtual void EndOfEvent()
map< TString, TGeoMedium * > fFixedMedia
BmnMwpcPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, Double_t radius, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t isPrimary, Double_t charge, Int_t fPdgId, TVector3 trackPos)
virtual void ConstructGeometry()
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
TObject * Next() override
const char * GetName() const 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
void GetXYZ(Double_t *carray) const
Double_t ATan2(Double_t y, Double_t x)