17 #include <FairLogger.h>
21 #include <TClonesArray.h>
25 #include <TGeoManager.h>
27 #include <TGeoVolume.h>
29 #include <TObjArray.h>
50 , fCurrentVolume(nullptr)
51 , fVolumeBoxShape(nullptr)
52 , fVolumeTrapShape(nullptr)
55 , fGlobalMatrix(nullptr)
66 , fAbsorbers(new TObjArray())
69 , fAcceptanceTanMin(0.)
70 , fAcceptanceTanMax(0.)
80 , fNSectorsPerLayer(0)
100 LOG(debug) <<
"CbmMuchGeoScheme created";
129 LOG(debug) <<
"CbmMuchGeoScheme init successful";
138 TFile* oldfile = gFile;
139 TFile* file =
new TFile(digiFileName);
140 TObjArray* stations = (TObjArray*) file->Get(
"stations");
144 Init(stations, flag);
155 if (!
fStations) Fatal(
"InitModules",
"No input array of stations.");
162 for (Int_t iStation = 0; iStation <
GetNStations(); iStation++) {
165 if (!station)
continue;
169 vector<CbmMuchLayerSide*> sides;
170 vector<CbmMuchModule*> modules;
172 for (Int_t iLayer = 0; iLayer < station->
GetNLayers(); iLayer++) {
174 if (!layer)
continue;
177 for (Int_t iSide = 0; iSide < 2; iSide++) {
184 sides.push_back(side);
186 for (Int_t iModule = 0; iModule < side->
GetNModules(); iModule++) {
195 modules.push_back(mod);
212 Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntries());
223 return station ? station->
GetLayer(iLayer) :
nullptr;
230 Bool_t iSide)
const {
233 return layer ? layer->
GetSide(iSide) :
nullptr;
241 Int_t iModule)
const {
244 return side ? side->
GetModule(iModule) :
nullptr;
262 assert(iLayer < station->GetNLayers());
263 return station ? station->
GetLayer(iLayer) :
nullptr;
273 return layer ? layer->
GetSide(iSide) :
nullptr;
282 assert(iModule < side->GetNModules());
283 return side ? side->
GetModule(iModule) :
nullptr;
290 vector<CbmMuchModule*> modules =
GetModules();
291 for (vector<CbmMuchModule*>::iterator it = modules.begin();
295 module->
SetPoints(
new TClonesArray(
"CbmVisPoint", 1));
303 vector<CbmMuchModule*> modules =
GetModules();
304 for (vector<CbmMuchModule*>::iterator it = modules.begin();
310 mod->
SetHits(
new TClonesArray(
"CbmVisPixelHit", 1));
324 vector<CbmMuchModule*> modules =
GetModules();
325 for (vector<CbmMuchModule*>::iterator it = modules.begin();
331 mod->
SetClusters(
new TClonesArray(
"CbmVisMuchCluster", 1));
339 vector<CbmMuchModule*> modules =
GetModules();
340 for (vector<CbmMuchModule*>::iterator it = modules.begin();
343 (*it)->GetPoints()->Clear();
352 vector<CbmMuchModule*> modules =
GetModules();
353 for (vector<CbmMuchModule*>::iterator it = modules.begin();
356 (*it)->GetHits()->Clear();
364 vector<CbmMuchModule*> modules =
GetModules();
365 for (vector<CbmMuchModule*>::iterator it = modules.begin();
377 vector<CbmMuchLayerSide*>
381 return fSides.at(iStation);
382 }
catch (std::out_of_range exc) {
383 Fatal(
"GetLayerSides",
"No input array of stations.");
385 return vector<CbmMuchLayerSide*>();
406 Fatal(
"GetLayerSideNr",
"Wrong side id or no modules in the layer side");
407 return fMapSides.find(sideId)->second + 1;
413 gGeoManager->cd(path.Data());
418 Double_t local[3] = {0., 0., 0.};
419 gGeoManager->LocalToMaster(local,
fGlobal);
464 const char* volumeName) {
466 TObjArray* caveArr = ncave->GetNodes();
468 for (
int iSystem = 0; iSystem < caveArr->GetEntriesFast(); iSystem++) {
469 TGeoNode* SystemNode =
static_cast<TGeoNode*
>(caveArr->At(iSystem));
471 if (!TString(SystemNode->GetName()).Contains(volumeName))
continue;
472 TObjArray* MuchObj = SystemNode->GetNodes();
474 for (Int_t iMuchObj = 0; iMuchObj < MuchObj->GetEntriesFast(); iMuchObj++) {
476 TGeoNode* MuchObjNode =
static_cast<TGeoNode*
>(MuchObj->At(iMuchObj));
479 if (!TString(MuchObjNode->GetName()).Contains(
"station"))
continue;
480 TString MuchObjPath = TString(
"/") + ncave->GetName() +
"/"
481 + SystemNode->GetName() +
"/"
482 + MuchObjNode->GetName();
493 TObjArray* stations = fSNode->GetNodes();
495 fNst = stations->GetEntriesFast();
508 for (Int_t iStation = 0; iStation <
fNst; iStation++) {
509 TGeoNode* station =
static_cast<TGeoNode*
>(stations->At(iStation));
510 TString StationPath = Path +
"/" + station->GetName();
511 TObjArray* layers = station->GetNodes();
512 fNlayers[iStation] = layers->GetEntriesFast();
520 static_cast<TGeoNode*
>(layers->At(0));
521 TString Layer1Path = StationPath +
"/" + layer1->GetName();
522 TObjArray* Supportlayer1 = layer1->GetNodes();
523 TGeoNode* Supportlayer1Node =
static_cast<TGeoNode*
>(Supportlayer1->At(0));
525 TString Supportlayer1Path = Layer1Path +
"/" + Supportlayer1Node->GetName();
531 fLayer1Z0 =
GetZ(Supportlayer1Path);
536 static_cast<TGeoNode*
>(layers->At(1));
537 TString Layer2Path = StationPath +
"/" + layer2->GetName();
539 TObjArray* Supportlayer2 = layer2->GetNodes();
540 TGeoNode* Supportlayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(0));
542 TString Supportlayer2Path = Layer2Path +
"/" + Supportlayer2Node->GetName();
549 fLayer2Z0 =
GetZ(Supportlayer2Path);
553 fLayersDz[iStation] = fLayer2Z0 - fLayer1Z0;
563 Double_t PosY = 0., Phi = 0., Dy = 0.;
567 TGeoNode* layer3 =
static_cast<TGeoNode*
>(layers->At(2));
568 TString Layer3Path = StationPath +
"/" + layer3->GetName();
570 TObjArray* Supportlayer3 = layer3->GetNodes();
571 TGeoNode* Supportlayer3Node =
572 static_cast<TGeoNode*
>(Supportlayer3->At(0));
573 TString Supportlayer3Path =
574 Layer3Path +
"/" + Supportlayer3Node->GetName();
580 TGeoNode* Activelayer3Node =
static_cast<TGeoNode*
>(Supportlayer3->At(1));
581 TString Activelayer3Path = Layer3Path +
"/" + Activelayer3Node->GetName();
590 TGeoNode* Activelayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(1));
591 TString Activelayer2Path = Layer2Path +
"/" + Activelayer2Node->GetName();
598 fStationZ0[iStation] = (fLayer2Z0 - fLayer1Z0) / 2.;
604 Double_t yMin = (PosY / TMath::Cos(Phi)) - Dy;
605 Double_t yMax = 2 * Dy + yMin;
606 LOG(info) <<
" Geo Scheme "
607 <<
" posY " << PosY <<
" phi " << Phi <<
" Dy " << Dy;
616 if (Supportlayer1->GetEntriesFast() > 0)
fModuleDesign[iStation] = 1;
620 LayerNode(station, iStation, StationPath);
640 TObjArray* layerArray = StNode->GetNodes();
641 for (Int_t iLayer = 0; iLayer < layerArray->GetEntriesFast(); iLayer++) {
642 TGeoNode* layerNode =
static_cast<TGeoNode*
>(layerArray->At(iLayer));
643 TString layerPath = StPath +
"/" + layerNode->GetName();
645 ModuleNode(layerNode, iStation, iLayer, layerPath);
664 TObjArray* moduleArray = layerNode->GetNodes();
665 for (Int_t iModule = 0; iModule < moduleArray->GetEntriesFast(); iModule++) {
666 TGeoNode* moduleNode =
static_cast<TGeoNode*
>(moduleArray->At(iModule));
668 TString modulePath = layerPath +
"/" + moduleNode->GetName();
682 TString modulePath) {
684 TString modName = moduleNode->GetName();
687 if (modName.Contains(
"support")) {
690 Double_t layerGlobalZ0;
695 layerGlobalZ0 =
GetZ(modulePath);
702 iStation, iLayer, layerGlobalZ0, layerZ0);
708 if (modName.Contains(
"active")) {
710 gGeoManager->cd(modulePath.Data());
712 moduleNode = gGeoManager->GetMother(0);
716 if (modName.Contains(
"factive")) iSide = 0;
717 if (modName.Contains(
"bactive")) iSide = 1;
740 if (modName.Contains(
"gasArgon")) DetType = 3;
741 if (modName.Contains(
"rpcgas")) DetType = 4;
765 gGeoManager->cd(path.Data());
770 Double_t local[3] = {0., 0., 0.};
839 Int_t nCornersInside = 0;
840 if (x1 * x1 + y1 * y1 < r * r) nCornersInside++;
841 if (x2 * x2 + y1 * y1 < r * r) nCornersInside++;
842 if (x1 * x1 + y2 * y2 < r * r) nCornersInside++;
843 if (x2 * x2 + y2 * y2 < r * r) nCornersInside++;
844 if (nCornersInside == 4)
return 2;
845 if (nCornersInside)
return 1;
846 if (!nCornersInside && x1 < r && y1 < 0 && y2 > 0)
return 1;
854 vector<CbmMuchModule*> modules;
855 for (Int_t iStation = 0; iStation <
GetNStations(); ++iStation) {
856 vector<CbmMuchModule*> stationModules =
GetModules(iStation);
857 for (vector<CbmMuchModule*>::iterator it = stationModules.begin();
858 it != stationModules.end();
861 modules.push_back(module);
874 vector<CbmMuchModuleGem*> modules;
875 for (Int_t iStation = 0; iStation <
GetNStations(); ++iStation) {
876 vector<CbmMuchModule*> stationModules =
GetModules(iStation);
877 for (vector<CbmMuchModule*>::iterator it = stationModules.begin();
878 it != stationModules.end();
898 }
catch (std::out_of_range exc) {
899 Fatal(
"GetModules",
"No input array of stations.");
901 return vector<CbmMuchModule*>();