1 #include "ERGadastSetup.h" 4 #include "TGeoManager.h" 5 #include "TGeoMatrix.h" 10 #include "FairRuntimeDb.h" 12 #include "ERDetectorList.h" 18 TGeoPhysicalNode* ERGadastSetup::fGadastNode;
21 if (fInstance == NULL)
27 ERGadastSetup::ERGadastSetup()
30 FairRun* run = FairRun::Instance();
31 if ( ! run ) Fatal(
"ERGadastSetup",
"No analysis run");
33 FairRuntimeDb* rtdb = run->GetRuntimeDb();
34 if ( ! rtdb ) Fatal(
"ERGadastSetup",
"No runtime database");
37 if ( ! fDigiPar ) Fatal(
"ERGadastSetup`",
"No ERNeuRadDigiPar in runtime");
40 int ERGadastSetup::GetMeshElement(TVector3* pos, SensetiveType detType){
41 TGeoNode* node = gGeoManager->FindNode(pos->X(), pos->Y(), pos->Z());
42 TGeoMatrix* gm = node->GetMatrix();
44 Double_t posMaster[3];
45 posMaster[0] = pos->X(); posMaster[1] = pos->Y(); posMaster[2] = pos->Z();
47 gm->MasterToLocal(posMaster,posLocal);
49 Int_t xCount=4,yCount=4,zCount=4;
50 Double_t dX = 72.8/(double)xCount;
51 Double_t dY = 41.5/(double)yCount;
52 Double_t dZ = 150.1/(double)zCount;
53 posLocal[0] += 72.8/2;
54 posLocal[1] += 41.5/2;
57 Int_t x = (Int_t)(posLocal[0]/dX);
58 Int_t y = (Int_t)(posLocal[1]/dY);
59 Int_t z = (Int_t)(posLocal[2]/dZ);
61 Int_t MeshElement = z*xCount*yCount + y*xCount + x;
66 Double_t dZ = 50.8/(double)zCount;
67 posLocal[2] += 50.8/2;
69 Int_t z = (Int_t)(posLocal[2]/dZ);
74 Bool_t ERGadastSetup::Init(){
76 TGeoManager* geo = gGeoManager;
78 Fatal(
"ERGadastSetup",
"Can`t find gGeoManager!");
81 cout <<
"Reading geometry from TGeoManager " << geo->GetName() << endl;
83 TGeoNode* cave = geo->GetCurrentNode();
85 TGeoNode* gadast = NULL;
86 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
87 TString name = cave->GetDaughter(iNode)->GetName();
88 if ( name.Contains(
"Gadast", TString::kIgnoreCase) ) {
89 gadast = cave->GetDaughter(iNode);
91 cout <<
"Gadast top node is " << gadast->GetName() << endl;
97 cout <<
"No top Gadast node found in geometry!" << endl;
102 TString path = cave->GetName();
103 path = path +
"/" + gadast->GetName();
104 fGadastNode =
new TGeoPhysicalNode(path);
110 Float_t ERGadastSetup::CsILC(TVector3* pos){
111 return fDigiPar->CsILC(fInstance->GetMeshElement(pos, CsI));
114 Float_t ERGadastSetup::LaBrLC(TVector3* pos){
115 return fDigiPar->LaBrLC(fInstance->GetMeshElement(pos, LaBr));
118 Float_t ERGadastSetup::CsIDispA(TVector3* pos){
119 return fDigiPar->CsIDispA(fInstance->GetMeshElement(pos, CsI));
122 Float_t ERGadastSetup::LaBrDispA(TVector3* pos){
123 return fDigiPar->LaBrDispA(fInstance->GetMeshElement(pos, LaBr));
126 Float_t ERGadastSetup::CsIDispB(TVector3* pos){
127 return fDigiPar->CsIDispB(fInstance->GetMeshElement(pos, CsI));
130 Float_t ERGadastSetup::LaBrDispB(TVector3* pos){
131 return fDigiPar->LaBrDispB(fInstance->GetMeshElement(pos, LaBr));