24#include <TClonesArray.h>
28#include <TGeoManager.h>
30#include <TGeoVolume.h>
103 LOG(debug) <<
"CbmMuchGeoScheme created";
135 LOG(debug) <<
"CbmMuchGeoScheme init successful";
146 TFile* oldFile = gFile;
147 TDirectory* oldDir = gDirectory;
149 TFile* file =
new TFile(digiFileName);
150 LOG_IF(fatal, !file) <<
"File " << digiFileName <<
" does not exist";
151 TObjArray* stations = file->Get<TObjArray>(
"stations");
152 LOG_IF(fatal, !stations) <<
"No TObjArray stations found in file " << digiFileName;
160 Init(stations, flag);
172 if (!
fStations) Fatal(
"InitModules",
"No input array of stations.");
182 if (!station)
continue;
190 if (!layer)
continue;
193 for (
Int_t iSide = 0; iSide < 2; iSide++) {
198 sides.push_back(side);
207 modules.push_back(mod);
225 Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast());
237 return station ? station->
GetLayer(iLayer) :
nullptr;
246 return layer ? layer->
GetSide(iSide) :
nullptr;
255 return side ? side->
GetModule(iModule) :
nullptr;
275 assert(iLayer < station->GetNLayers());
276 return station ? station->
GetLayer(iLayer) :
nullptr;
287 return layer ? layer->
GetSide(iSide) :
nullptr;
297 assert(iModule < side->GetNModules());
298 return side ? side->
GetModule(iModule) :
nullptr;
309 module->SetPoints(new TClonesArray("CbmVisPoint", 1));
323 mod->
SetHits(
new TClonesArray(
"CbmVisPixelHit", 1));
343 mod->
SetClusters(
new TClonesArray(
"CbmVisMuchCluster", 1));
354 (*it)->GetPoints()->Clear();
366 (*it)->GetHits()->Clear();
390 return fSides.at(iStation);
392 catch (
const std::out_of_range& exc) {
393 Fatal(
"GetLayerSides",
"No input array of stations.");
417 Fatal(
"GetLayerSideNr",
"Wrong side id or no modules in the layer side");
418 return fMapSides.find(sideId)->second + 1;
425 gGeoManager->cd(path.Data());
430 Double_t local[3] = {0., 0., 0.};
431 gGeoManager->LocalToMaster(local,
fGlobal);
484 TObjArray* caveArr = ncave->GetNodes();
486 for (
int iSystem = 0; iSystem < caveArr->GetEntriesFast(); iSystem++) {
487 TGeoNode* SystemNode =
static_cast<TGeoNode*
>(caveArr->At(iSystem));
489 if (!TString(SystemNode->GetName()).Contains(volumeName))
continue;
490 TObjArray* MuchObj = SystemNode->GetNodes();
492 for (
Int_t iMuchObj = 0; iMuchObj < MuchObj->GetEntriesFast(); iMuchObj++) {
494 TGeoNode* MuchObjNode =
static_cast<TGeoNode*
>(MuchObj->At(iMuchObj));
497 if (!TString(MuchObjNode->GetName()).Contains(
"station"))
continue;
498 TString MuchObjPath =
499 TString(
"/") + ncave->GetName() +
"/" + SystemNode->GetName() +
"/" + MuchObjNode->GetName();
511 TObjArray* stations = fSNode->GetNodes();
513 fNst = stations->GetEntriesFast();
525 for (
Int_t iStation = 0; iStation <
fNst; iStation++) {
526 TGeoNode* station =
static_cast<TGeoNode*
>(stations->At(iStation));
527 TString StationPath = Path +
"/" + station->GetName();
528 TObjArray* layers = station->GetNodes();
529 fNlayers[iStation] = layers->GetEntriesFast();
536 TGeoNode* layer1 =
static_cast<TGeoNode*
>(layers->At(0));
537 TString Layer1Path = StationPath +
"/" + layer1->GetName();
538 TObjArray* Supportlayer1 = layer1->GetNodes();
539 TGeoNode* Supportlayer1Node =
static_cast<TGeoNode*
>(Supportlayer1->At(0));
541 TString Supportlayer1Path = Layer1Path +
"/" + Supportlayer1Node->GetName();
546 fLayer1Z0 =
GetZ(Supportlayer1Path);
550 TGeoNode* layer2 =
static_cast<TGeoNode*
>(layers->At(1));
551 TString Layer2Path = StationPath +
"/" + layer2->GetName();
553 TObjArray* Supportlayer2 = layer2->GetNodes();
554 TGeoNode* Supportlayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(0));
556 TString Supportlayer2Path = Layer2Path +
"/" + Supportlayer2Node->GetName();
562 fLayer2Z0 =
GetZ(Supportlayer2Path);
566 fLayersDz[iStation] = fLayer2Z0 - fLayer1Z0;
575 Double_t PosY = 0.,
Phi = 0., Dy = 0.;
579 TGeoNode* layer3 =
static_cast<TGeoNode*
>(layers->At(2));
580 TString Layer3Path = StationPath +
"/" + layer3->GetName();
582 TObjArray* Supportlayer3 = layer3->GetNodes();
583 TGeoNode* Supportlayer3Node =
static_cast<TGeoNode*
>(Supportlayer3->At(0));
584 TString Supportlayer3Path = Layer3Path +
"/" + Supportlayer3Node->GetName();
590 TGeoNode* Activelayer3Node =
static_cast<TGeoNode*
>(Supportlayer3->At(1));
591 TString Activelayer3Path = Layer3Path +
"/" + Activelayer3Node->GetName();
601 TGeoNode* Activelayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(1));
602 TString Activelayer2Path = Layer2Path +
"/" + Activelayer2Node->GetName();
609 fStationZ0[iStation] = (fLayer2Z0 - fLayer1Z0) / 2.;
615 Double_t yMin = (PosY / TMath::Cos(
Phi)) - Dy;
616 Double_t yMax = 2 * Dy + yMin;
617 LOG(info) <<
" Geo Scheme "
618 <<
" posY " << PosY <<
" phi " <<
Phi <<
" Dy " << Dy;
627 if (Supportlayer1->GetEntriesFast() > 0)
fModuleDesign[iStation] = 1;
631 LayerNode(station, iStation, StationPath);
635 Double_t supDx =
muchLy->GetSupportDx();
636 Double_t supDy =
muchLy->GetSupportDy();
639 muchSt->SetTubeRmax(TMath::Sqrt(supDx * supDx + supDy * supDy) + 10);
650 TObjArray* layerArray = StNode->GetNodes();
651 for (
Int_t iLayer = 0; iLayer < layerArray->GetEntriesFast(); iLayer++) {
652 TGeoNode* layerNode =
static_cast<TGeoNode*
>(layerArray->At(iLayer));
653 TString layerPath = StPath +
"/" + layerNode->GetName();
655 ModuleNode(layerNode, iStation, iLayer, layerPath);
672 TObjArray* moduleArray = layerNode->GetNodes();
673 for (
Int_t iModule = 0; iModule < moduleArray->GetEntriesFast(); iModule++) {
674 TGeoNode* moduleNode =
static_cast<TGeoNode*
>(moduleArray->At(iModule));
676 TString modulePath = layerPath +
"/" + moduleNode->GetName();
690 TString modName = moduleNode->GetName();
693 if (modName.Contains(
"support")) {
696 Double_t layerGlobalZ0;
700 layerGlobalZ0 =
GetZ(modulePath);
702 Double_t layerZ0 = (iLayer - (
fNlayers[iStation] - 1) / 2.) *
fLayersDz[iStation];
706 muchLy->GetSideB()->SetZ(layerGlobalZ0 + sideDz);
707 muchLy->GetSideF()->SetZ(layerGlobalZ0 - sideDz);
711 if (modName.Contains(
"active")) {
713 gGeoManager->cd(modulePath.Data());
715 moduleNode = gGeoManager->GetMother(0);
719 if (modName.Contains(
"factive")) iSide = 0;
720 if (modName.Contains(
"bactive")) iSide = 1;
743 if (modName.Contains(
"gasArgon")) DetType = 3;
744 if (modName.Contains(
"rpcgas")) DetType = 4;
749 new CbmMuchModuleGemRadial(DetType, iStation, iLayer, iSide,
muchLySd->GetNModules(),
pos, Dx1,
Dx2, Dy, Dz,
760 gGeoManager->cd(path.Data());
765 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;
860 modules.push_back(module);
895 catch (
const std::out_of_range& exc) {
896 Fatal(
"GetModules",
"No input array of stations.");
ClassImp(CbmConverterManager)
friend fvec sqrt(const fvec &a)
static int32_t GetModuleIndex(int32_t address)
static int32_t GetLayerIndex(int32_t address)
static int32_t GetLayerSideIndex(int32_t address)
static int32_t GetStationIndex(int32_t address)
Int_t GetLayerSideNr(Int_t detId) const
std::vector< CbmMuchLayerSide * > GetLayerSides(Int_t iStation) const
Int_t fLayer
StationTypeID, 1..3.
std::vector< CbmMuchModuleGem * > GetGemModules() const
Double_t GetModuleY(const TString &path)
void ExtractGeoParameter(TGeoNode *muchNode, const char *volumeName)
Int_t fActive
LayerID within station, 1..4.
CbmMuchLayer * GetLayerByDetId(Int_t detId) const
Double_t GetZ(const TString &path)
TGeoHMatrix * fGlobalMatrix
Global center of volume.
std::map< Int_t, Int_t > fMapSides
Double_t GetModuleBl1(const TString &path)
Double_t GetModuleH1(const TString &path)
std::vector< std::vector< CbmMuchModule * > > fModules
void StationNode(TGeoNode *MuchObjNode, TString MuchObjPath)
CbmMuchStation * GetStationByDetId(Int_t detId) const
std::vector< std::vector< CbmMuchLayerSide * > > fSides
void ActiveModuleNode(TGeoNode *moduleNode, Int_t iStation, Int_t iLayer, Int_t iModule, TString modulePath)
Double_t GetSizeY(const TString &path)
Double_t GetModuleTl1(const TString &path)
CbmMuchStation * GetStation(Int_t iStation) const
std::vector< CbmMuchModule * > GetModules() const
void CreateClusterArrays()
static CbmMuchGeoScheme * Instance()
void Init(TObjArray *stations, Int_t flag)
static CbmMuchGeoScheme * fInstance
TGeoVolume * fCurrentVolume
void NavigateModule(const TString &path)
Double_t GetY(const TString &path)
Double_t GetModulePhi(const TString &path)
void ModuleNode(TGeoNode *layerNode, Int_t iStation, Int_t iLayer, TString layerPath)
static Bool_t fModulesInitialized
void ClearClusterArrays()
CbmMuchLayerSide * GetLayerSideByDetId(Int_t detId) const
CbmMuchLayerSide * GetLayerSide(Int_t iStation, Int_t iLayer, Bool_t iSide) const
CbmMuchLayer * GetLayer(Int_t iStation, Int_t iLayer) const
Double_t GetModuleX(const TString &path)
Double_t fAcceptanceTanMin
Double_t GetSizeX(const TString &path)
Int_t GetNStations() const
TArrayI fNSectorsPerLayer
void NavigateTo(const TString &path)
CbmMuchLayerSide * muchLySd
Double_t GetModuleDZ(const TString &path)
static Bool_t fInitialized
Double_t GetX(const TString &path)
Int_t fGeoID
ModuleCopyID with module type.
CbmMuchModule * GetModuleByDetId(Int_t detId) const
Double_t GetSizeZ(const TString &path)
Double_t fAcceptanceTanMax
CbmMuchModule * GetModule(Int_t iStation, Int_t iLayer, Bool_t iSide, Int_t iModule) const
TGeoBBox * fVolumeBoxShape
void LayerNode(TGeoNode *StNode, Int_t iStation, TString StPath)
Double_t GetModuleZ(const TString &path)
TGeoTrap * fVolumeTrapShape
Int_t Intersect(Float_t x, Float_t y, Float_t dx, Float_t dy, Float_t r)
Int_t GetNModules() const
CbmMuchModule * GetModule(Int_t iModule) const
Int_t GetDetectorId() const
CbmMuchLayerSide * GetSide(Bool_t side)
Int_t GetDetectorId() const
Int_t GetDetectorId() const
void SetClusters(TClonesArray *clusters)
void SetHits(TClonesArray *hits)
virtual Bool_t InitModule()
TClonesArray * GetClusters() const
Int_t GetDetectorType() const
CbmMuchLayer * GetLayer(Int_t iLayer) const
Int_t GetDetectorId() const