er  dev
ERNeuRadSetup.cxx
1 #include "ERNeuRadSetup.h"
2 
3 #include <iostream>
4 
5 #include "TGeoBBox.h"
6 #include "TError.h"
7 #include "TMath.h"
8 #include "TGeoManager.h"
9 
10 #include "FairRootManager.h"
11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
13 
14 ERNeuRadSetup* ERNeuRadSetup::fInstance = NULL;
15 ERNeuRadDigiPar* ERNeuRadSetup::fDigiPar;
16 Float_t ERNeuRadSetup::fZ;
17 Float_t ERNeuRadSetup::fLength;
18 Float_t ERNeuRadSetup::fFiberWidth;
19 Int_t ERNeuRadSetup::fRowNofFibers;
20 Int_t ERNeuRadSetup::fRowNofModules;
21 Int_t ERNeuRadSetup::fRowNofPixels;
22 
23 std::vector<ERNeuRadModule*> ERNeuRadSetup::fModules;
24 std::vector<std::vector<ERNeuRadFiber*> > ERNeuRadSetup::fFibers;
25 
26 ERNeuRadSetup::ERNeuRadSetup(){
27  // --- Catch absence of TGeoManager
28  if ( ! gGeoManager ) {
29  std::cerr << "ERNeuRadSetup: cannot initialise without TGeoManager!"<< std::endl;
30  }
31  gGeoManager->CdTop();
32  TGeoNode* cave = gGeoManager->GetCurrentNode();
33  TGeoNode* neuRad = NULL;
34  for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
35  TString name = cave->GetDaughter(iNode)->GetName();
36  if ( name.Contains("NeuRad", TString::kIgnoreCase) ) {
37  neuRad = cave->GetDaughter(iNode);
38  }
39  }
40  fZ = neuRad->GetMatrix()->GetTranslation()[2];
41  std::cout << "NeuRad Z position:" << fZ << std::endl;
42 
43  TGeoNode* module = neuRad->GetDaughter(0);
44  TGeoBBox* module_box = (TGeoBBox*)module->GetVolume()->GetShape();
45  fLength = module_box->GetDZ()*2;
46  std::cout << "NeuRad length:" << fLength << std::endl;
47 
48  TGeoNode* pixel = module->GetDaughter(0);
49  TGeoNode* fiber = pixel->GetDaughter(0); // fiber with clading and dead zone
50  TGeoBBox* fiber_box = (TGeoBBox*)fiber->GetVolume()->GetShape();
51  fFiberWidth = fiber_box->GetDX()*2;
52  std::cout << "NeuRad fiber width:" << fFiberWidth << std::endl;
53 
54  fRowNofModules = Int_t(TMath::Sqrt(neuRad->GetNdaughters()));
55  fRowNofPixels = Int_t(TMath::Sqrt(module->GetNdaughters()));
56  fRowNofFibers = Int_t(TMath::Sqrt(pixel->GetNdaughters()));
57 
58  //Обработка субмодулей в новой геометрии
59  Int_t iSubm = -1; //Любой subm
60  Int_t nSubm = 0;
61  for (Int_t iNode = 0; iNode < module->GetNdaughters(); iNode++){
62  if (TString(module->GetDaughter(iNode)->GetName()).Contains("submodul")){
63  iSubm = iNode;
64  nSubm++;
65  }
66  }
67  Int_t nPixel_in_subm = 0;
68  if (iSubm > -1){
69  std::cout << "Submodules in geometry!" << std::endl;
70  TGeoNode* subm = module->GetDaughter(iSubm);
71  for (Int_t iNode = 0; iNode < subm->GetNdaughters(); iNode++){
72  if (TString(subm->GetDaughter(iNode)->GetName()).Contains("pixel")){
73  pixel = subm->GetDaughter(iNode);
74  nPixel_in_subm++;
75  }
76  }
77  fRowNofPixels = Int_t(TMath::Sqrt(nSubm))*Int_t(TMath::Sqrt(nPixel_in_subm));
78  fRowNofFibers = Int_t(TMath::Sqrt(pixel->GetNdaughters()));
79  }
80 
81  std::cout << "NeuRad modules in row count:" << fRowNofModules << std::endl;
82  std::cout << "NeuRad pixels in row count:" << fRowNofPixels << std::endl;
83  std::cout << "NeuRad fibers in row count:" << fRowNofFibers << std::endl;
84 
85  std::cout << "ERNeuRadSetup initialized! "<< std::endl;
86 }
87 
88 ERNeuRadSetup* ERNeuRadSetup::Instance(){
89  if (fInstance == NULL)
90  return new ERNeuRadSetup();
91  else
92  return fInstance;
93 }
94 
95 Int_t ERNeuRadSetup::SetParContainers(){
96  // Get run and runtime database
97  FairRunAna* run = FairRunAna::Instance();
98  if ( ! run ) Fatal("SetParContainers", "No analysis run");
99 
100  FairRuntimeDb* rtdb = run->GetRuntimeDb();
101  if ( ! rtdb ) Fatal("SetParContainers", "No runtime database");
102  fDigiPar = (ERNeuRadDigiPar*)
103  (rtdb->getContainer("ERNeuRadDigiPar"));
104  if (fDigiPar) {
105  std::cout << "ERNeuRadSetup::SetParContainers() "<< std::endl;
106  std::cout << "ERNeuRadDigiPar initialized! "<< std::endl;
107  return 0;
108  }
109  return 1;
110 }
111 
112 Int_t ERNeuRadSetup::NofFibers() {
113  return fRowNofFibers*fRowNofFibers;
114 }
115 
116 Int_t ERNeuRadSetup::NofPixels(){
117  return fRowNofPixels*fRowNofPixels;
118 }
119 
120 Int_t ERNeuRadSetup::NofModules() {
121  return fRowNofModules*fRowNofModules;
122 }
123 
124 Float_t ERNeuRadSetup::FiberLength() {
125  return fLength;
126 }
127 
128 Float_t ERNeuRadSetup::FiberWidth() {
129  return fFiberWidth;
130 }
131 
132 Float_t ERNeuRadSetup::ModuleX(Int_t iModule){
133  return fModules[iModule]->fX;
134 }
135 
136 Float_t ERNeuRadSetup::ModuleY(Int_t iModule){
137  return fModules[iModule]->fY;
138 }
139 
140 Float_t ERNeuRadSetup::FiberX(Int_t iModule, Int_t iFiber){
141  return fFibers[iModule][iFiber]->fX;
142 }
143 
144 Float_t ERNeuRadSetup::FiberY(Int_t iModule, Int_t iFiber){
145  return fFibers[iModule][iFiber]->fY;
146 }
147 
148 Float_t ERNeuRadSetup::PixelQuantumEfficiency(Int_t iModule, Int_t iFiber){
149  return fDigiPar->PixelQuantumEfficiency(iFiber);
150 }
151 
152 Float_t ERNeuRadSetup::PixelGain(Int_t iModule, Int_t iFiber){
153  return fDigiPar->PixelGain(iFiber);
154 }
155 
156 Float_t ERNeuRadSetup::PixelSigma(Int_t iModule, Int_t iFiber){
157  return fDigiPar->PixelSigma(iFiber);
158 }
159 
160 void ERNeuRadSetup::Print(){
161  fDigiPar->print();
162 }
163 
164 void ERNeuRadSetup::Crosstalks(Int_t iFiber, TArrayF& crosstalks){
165  return fDigiPar->Crosstalks(iFiber, crosstalks);
166 }
167 
168 Int_t ERNeuRadSetup::RowNofFibers(){
169  return fRowNofFibers;
170 }
171 
172 Int_t ERNeuRadSetup::RowNofPixels(){
173  return fRowNofPixels;
174 }
175 
176 Int_t ERNeuRadSetup::RowNofModules(){
177  return fRowNofModules;
178 }
179 
180 Bool_t ERNeuRadSetup::UseCrosstalks(){
181  return fDigiPar->UseCrosstalks();
182 }
183 
184 ClassImp(ERNeuRadSetup)
virtual void print()