10#include "FairGeoBuilder.h"
11#include "FairGeoInterface.h"
12#include "FairGeoLoader.h"
13#include "FairGeoMedia.h"
14#include "FairGeoNode.h"
15#include "FairRootManager.h"
17#include "FairRuntimeDb.h"
18#include "FairVolume.h"
26#include "TVirtualMC.h"
75 gMC->Gmtod(globPos, localPos, 1);
86 gMC->Gdtom(localPos, globPos, 1);
98 if (gMC->IsTrackEntering()) {
102 fTime = gMC->TrackTime() * 1.0e09;
109 gMC->TrackPosition(PosIn);
110 fPosIn.SetXYZ(PosIn.
X(), PosIn.
Y(), PosIn.
Z());
111 gMC->TrackMomentum(
fMom);
113 TParticle* part = gMC->GetStack()->GetCurrentTrack();
122 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
129 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) &&
fELoss >= 0) {
131 gMC->TrackPosition(PosOut);
132 fPosOut.SetXYZ(PosOut.
X(), PosOut.
Y(), PosOut.
Z());
189 cout <<
"-I- BmnDch: " << nHits <<
" points registered in this event." << endl;
191 if (fVerboseLevel > 1)
207 cout <<
"-I- BmnDch: " << nEntries <<
" entries to add." << endl;
211 for (
Int_t i = 0;
i < nEntries;
i++) {
213 Int_t index = oldpoint->GetTrackID() + offset;
214 oldpoint->SetTrackID(index);
219 cout <<
"-I- BmnDch: " << cl2->
GetEntriesFast() <<
" merged entries." << endl;
225 TString fileName = GetGeometryFileName();
228 LOG(info) <<
"Constructing DCH geometry from ROOT file " << fileName.
Data();
229 ConstructRootGeometry();
230 }
else if (fileName.
EndsWith(
".geo")) {
231 LOG(info) <<
"Constructing DCH geometry from ASCII file " << fileName.
Data();
233 }
else if (fileName.
EndsWith(
".gdml")) {
234 LOG(info) <<
"Constructing DCH geometry from GDML file " << fileName.
Data();
237 LOG(fatal) <<
"Geometry format of DCH file " << fileName.
Data() <<
" not supported.";
244 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
245 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
247 DCHGeo->setGeomFile(GetGeometryFileName());
248 geoFace->addGeoModule(DCHGeo);
250 Bool_t rc = geoFace->readSet(DCHGeo);
252 DCHGeo->create(geoLoad->getGeoBuilder());
253 TList* volList = DCHGeo->getListOfVolumes();
255 FairRun* fRun = FairRun::Instance();
256 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
262 FairGeoNode* node = NULL;
263 FairGeoVolume* aVol = NULL;
265 while ((node = (FairGeoNode*)iter.
Next())) {
266 aVol =
dynamic_cast<FairGeoVolume*
>(node);
267 if (node->isSensitive()) {
274 par->setInputVersion(fRun->GetRunId(), 1);
275 ProcessNodes(volList);
401 m->SetId(curId + maxInd);
407 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
410 for (
Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
412 LOG(debug) <<
" removing media " << medToDel->
GetName() <<
" with id " << medToDel->
GetId() <<
" (k=" << k
423 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->
GetName();
426 LOG(debug) <<
" volume: " << curVol->
GetName();
429 LOG(debug) <<
" skipping volume-assembly";
438 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->
GetName() <<
"\t" << curMed->
GetId();
439 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->
GetName() <<
"\t" << curMat->
GetIndex();
442 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->
GetName()
443 <<
"\t" << curMedInGeoManager->
GetId();
444 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
445 << curMatOfMedInGeoManager->
GetName() <<
"\t" << curMatOfMedInGeoManager->
GetIndex();
446 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->
GetName()
447 <<
"\t" << curMatInGeoManager->
GetIndex();
452 if (curMed->
GetId() != curMedInGeoManager->
GetId()) {
454 LOG(debug) <<
" Medium needs to be fixed";
458 LOG(debug) <<
" removing material " << curMat->
GetName() <<
" with index " << ind;
461 m->SetIndex(
m->GetIndex() - 1);
464 LOG(debug) <<
" Medium fixed";
466 LOG(debug) <<
" Already fixed medium found in the list ";
470 LOG(debug) <<
" There is no correct medium in the memory yet";
472 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
473 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
474 FairGeoMedia* geoMediaBase = geoFace->getMedia();
475 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
477 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
478 if (curMedInGeo == 0) {
479 LOG(fatal) <<
" Media not found in Geo file: " << medName;
484 LOG(debug) <<
" Found media in Geo file" << medName;
485 geobuild->createMedium(curMedInGeo);
488 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->
GetName() <<
" with index "
489 << curMatOfMedInGeoManager->
GetIndex();
494 m->SetIndex(
m->GetIndex() - 1);
498 if (curMedInGeo->getSensitivityFlag()) {
499 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
500 AddSensitiveVolume(curVol);
503 LOG(debug) <<
" Already fixed medium found in the list";
504 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
506 LOG(debug) <<
" Adding sensitive " << curVol->
GetName();
507 AddSensitiveVolume(curVol);
524 curNodeChild = (
TGeoNode*)NodeChildList->
At(j);
562 return new (clref[size])
563 BmnDchPoint(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)
void SetPlaneNumber(Int_t plane_num)
TVector3 fPos
plane number
BmnDchPoint * 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)
TLorentzVector fMom
position local to gas chamber
virtual void Print(Option_t *) const
Int_t fVolumeID
track index
virtual TClonesArray * GetCollection(Int_t iColl) const
TVector3 LocalToGlobal(TVector3 &local)
Int_t fIsPrimary
energy loss
virtual void ConstructGeometry()
int DistAndPoints(TVector3 p3, TVector3 p4, TVector3 &pa, TVector3 &pb)
Hit collection.
Int_t fPlaneNumber
volume id
TVector3 GlobalToLocal(TVector3 &global)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
TVector3 fPosOut
entry position in global frame
virtual Bool_t CheckIfSensitive(std::string name)
virtual Bool_t ProcessHits(FairVolume *vol=0)
Double_t fCharge
is track primary?
void ExpandNodeForGdml(TGeoNode *node)
virtual void ConstructGDMLGeometry(TGeoMatrix *)
virtual void ConstructAsciiGeometry()
TClonesArray * fPointCollection
map< TString, TGeoMedium * > fFixedMedia
virtual void EndOfEvent()
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)