24#include <TClonesArray.h>
28#include <TGeoManager.h>
30#include <TGeoVolume.h>
53 , fCurrentVolume(nullptr)
54 , fVolumeBoxShape(nullptr)
55 , fVolumeTrapShape(nullptr)
58 , fGlobalMatrix(nullptr)
69 , fAbsorbers(new TObjArray())
72 , fAcceptanceTanMin(0.)
73 , fAcceptanceTanMax(0.)
83 , fNSectorsPerLayer(0)
104 LOG(debug) <<
"CbmMuchGeoScheme created";
136 LOG(debug) <<
"CbmMuchGeoScheme init successful";
147 TFile* oldFile = gFile;
148 TDirectory* oldDir = gDirectory;
150 TFile* file =
new TFile(digiFileName);
151 LOG_IF(fatal, !file) <<
"File " << digiFileName <<
" does not exist";
152 TObjArray* stations = file->Get<TObjArray>(
"stations");
153 LOG_IF(fatal, !stations) <<
"No TObjArray stations found in file " << digiFileName;
161 Init(stations, flag);
173 if (!
fStations) Fatal(
"InitModules",
"No input array of stations.");
180 for (Int_t iStation = 0; iStation <
GetNStations(); iStation++) {
183 if (!station)
continue;
186 vector<CbmMuchLayerSide*> sides;
187 vector<CbmMuchModule*> modules;
189 for (Int_t iLayer = 0; iLayer < station->
GetNLayers(); iLayer++) {
191 if (!layer)
continue;
194 for (Int_t iSide = 0; iSide < 2; iSide++) {
199 sides.push_back(side);
201 for (Int_t iModule = 0; iModule < side->
GetNModules(); iModule++) {
208 modules.push_back(mod);
226 Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast());
238 return station ? station->
GetLayer(iLayer) :
nullptr;
247 return layer ? layer->
GetSide(iSide) :
nullptr;
256 return side ? side->
GetModule(iModule) :
nullptr;
276 assert(iLayer < station->GetNLayers());
277 return station ? station->
GetLayer(iLayer) :
nullptr;
288 return layer ? layer->
GetSide(iSide) :
nullptr;
298 assert(iModule < side->GetNModules());
299 return side ? side->
GetModule(iModule) :
nullptr;
307 vector<CbmMuchModule*> modules =
GetModules();
308 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
310 module->SetPoints(new TClonesArray("CbmVisPoint", 1));
319 vector<CbmMuchModule*> modules =
GetModules();
320 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
324 mod->
SetHits(
new TClonesArray(
"CbmVisPixelHit", 1));
339 vector<CbmMuchModule*> modules =
GetModules();
340 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
344 mod->
SetClusters(
new TClonesArray(
"CbmVisMuchCluster", 1));
353 vector<CbmMuchModule*> modules =
GetModules();
354 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
355 (*it)->GetPoints()->Clear();
365 vector<CbmMuchModule*> modules =
GetModules();
366 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
367 (*it)->GetHits()->Clear();
376 vector<CbmMuchModule*> modules =
GetModules();
377 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
391 return fSides.at(iStation);
393 catch (
const std::out_of_range& exc) {
394 Fatal(
"GetLayerSides",
"No input array of stations.");
396 return vector<CbmMuchLayerSide*>();
418 Fatal(
"GetLayerSideNr",
"Wrong side id or no modules in the layer side");
419 return fMapSides.find(sideId)->second + 1;
426 gGeoManager->cd(path.Data());
431 Double_t local[3] = {0., 0., 0.};
432 gGeoManager->LocalToMaster(local,
fGlobal);
485 TObjArray* caveArr = ncave->GetNodes();
487 for (
int iSystem = 0; iSystem < caveArr->GetEntriesFast(); iSystem++) {
488 TGeoNode* SystemNode =
static_cast<TGeoNode*
>(caveArr->At(iSystem));
490 if (!TString(SystemNode->GetName()).Contains(volumeName))
continue;
491 TObjArray* MuchObj = SystemNode->GetNodes();
493 for (Int_t iMuchObj = 0; iMuchObj < MuchObj->GetEntriesFast(); iMuchObj++) {
495 TGeoNode* MuchObjNode =
static_cast<TGeoNode*
>(MuchObj->At(iMuchObj));
498 if (!TString(MuchObjNode->GetName()).Contains(
"station"))
continue;
499 TString MuchObjPath =
500 TString(
"/") + ncave->GetName() +
"/" + SystemNode->GetName() +
"/" + MuchObjNode->GetName();
512 TObjArray* stations = fSNode->GetNodes();
514 fNst = stations->GetEntriesFast();
526 for (Int_t iStation = 0; iStation <
fNst; iStation++) {
527 TGeoNode* station =
static_cast<TGeoNode*
>(stations->At(iStation));
528 TString StationPath = Path +
"/" + station->GetName();
529 TObjArray* layers = station->GetNodes();
530 fNlayers[iStation] = layers->GetEntriesFast();
537 TGeoNode* layer1 =
static_cast<TGeoNode*
>(layers->At(0));
538 TString Layer1Path = StationPath +
"/" + layer1->GetName();
539 TObjArray* Supportlayer1 = layer1->GetNodes();
540 TGeoNode* Supportlayer1Node =
static_cast<TGeoNode*
>(Supportlayer1->At(0));
542 TString Supportlayer1Path = Layer1Path +
"/" + Supportlayer1Node->GetName();
547 fLayer1Z0 =
GetZ(Supportlayer1Path);
551 TGeoNode* layer2 =
static_cast<TGeoNode*
>(layers->At(1));
552 TString Layer2Path = StationPath +
"/" + layer2->GetName();
554 TObjArray* Supportlayer2 = layer2->GetNodes();
555 TGeoNode* Supportlayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(0));
557 TString Supportlayer2Path = Layer2Path +
"/" + Supportlayer2Node->GetName();
563 fLayer2Z0 =
GetZ(Supportlayer2Path);
567 fLayersDz[iStation] = fLayer2Z0 - fLayer1Z0;
576 Double_t PosY = 0.,
Phi = 0., Dy = 0.;
580 TGeoNode* layer3 =
static_cast<TGeoNode*
>(layers->At(2));
581 TString Layer3Path = StationPath +
"/" + layer3->GetName();
583 TObjArray* Supportlayer3 = layer3->GetNodes();
584 TGeoNode* Supportlayer3Node =
static_cast<TGeoNode*
>(Supportlayer3->At(0));
585 TString Supportlayer3Path = Layer3Path +
"/" + Supportlayer3Node->GetName();
591 TGeoNode* Activelayer3Node =
static_cast<TGeoNode*
>(Supportlayer3->At(1));
592 TString Activelayer3Path = Layer3Path +
"/" + Activelayer3Node->GetName();
602 TGeoNode* Activelayer2Node =
static_cast<TGeoNode*
>(Supportlayer2->At(1));
603 TString Activelayer2Path = Layer2Path +
"/" + Activelayer2Node->GetName();
610 fStationZ0[iStation] = (fLayer2Z0 - fLayer1Z0) / 2.;
616 Double_t yMin = (PosY / TMath::Cos(
Phi)) - Dy;
617 Double_t yMax = 2 * Dy + yMin;
618 LOG(info) <<
" Geo Scheme "
619 <<
" posY " << PosY <<
" phi " <<
Phi <<
" Dy " << Dy;
628 if (Supportlayer1->GetEntriesFast() > 0)
fModuleDesign[iStation] = 1;
632 LayerNode(station, iStation, StationPath);
651 TObjArray* layerArray = StNode->GetNodes();
652 for (Int_t iLayer = 0; iLayer < layerArray->GetEntriesFast(); iLayer++) {
653 TGeoNode* layerNode =
static_cast<TGeoNode*
>(layerArray->At(iLayer));
654 TString layerPath = StPath +
"/" + layerNode->GetName();
656 ModuleNode(layerNode, iStation, iLayer, layerPath);
673 TObjArray* moduleArray = layerNode->GetNodes();
674 for (Int_t iModule = 0; iModule < moduleArray->GetEntriesFast(); iModule++) {
675 TGeoNode* moduleNode =
static_cast<TGeoNode*
>(moduleArray->At(iModule));
677 TString modulePath = layerPath +
"/" + moduleNode->GetName();
691 TString modName = moduleNode->GetName();
694 if (modName.Contains(
"support")) {
697 Double_t layerGlobalZ0;
701 layerGlobalZ0 =
GetZ(modulePath);
703 Double_t layerZ0 = (iLayer - (
fNlayers[iStation] - 1) / 2.) *
fLayersDz[iStation];
712 if (modName.Contains(
"active")) {
714 gGeoManager->cd(modulePath.Data());
716 moduleNode = gGeoManager->GetMother(0);
720 if (modName.Contains(
"factive")) iSide = 0;
721 if (modName.Contains(
"bactive")) iSide = 1;
744 if (modName.Contains(
"gasArgon")) DetType = 3;
745 if (modName.Contains(
"rpcgas")) DetType = 4;
750 new CbmMuchModuleGemRadial(DetType, iStation, iLayer, iSide,
muchLySd->
GetNModules(),
pos, Dx1,
Dx2, Dy, Dz,
761 gGeoManager->cd(path.Data());
766 Double_t local[3] = {0., 0., 0.};
840 Int_t nCornersInside = 0;
841 if (x1 * x1 + y1 * y1 < r * r) nCornersInside++;
842 if (x2 * x2 + y1 * y1 < r * r) nCornersInside++;
843 if (x1 * x1 + y2 * y2 < r * r) nCornersInside++;
844 if (x2 * x2 + y2 * y2 < r * r) nCornersInside++;
845 if (nCornersInside == 4)
return 2;
846 if (nCornersInside)
return 1;
847 if (!nCornersInside && x1 < r && y1 < 0 && y2 > 0)
return 1;
856 vector<CbmMuchModule*> modules;
857 for (Int_t iStation = 0; iStation <
GetNStations(); ++iStation) {
858 vector<CbmMuchModule*> stationModules =
GetModules(iStation);
859 for (vector<CbmMuchModule*>::iterator it = stationModules.begin(); it != stationModules.end(); it++) {
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(); it != stationModules.end(); it++) {
896 catch (
const std::out_of_range& exc) {
897 Fatal(
"GetModules",
"No input array of stations.");
899 return vector<CbmMuchModule*>();
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
std::vector< CbmMuchModuleGem * > GetGemModules() const
Double_t GetModuleY(const TString &path)
void ExtractGeoParameter(TGeoNode *muchNode, const char *volumeName)
CbmMuchLayer * GetLayerByDetId(Int_t detId) const
Double_t GetZ(const TString &path)
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 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)
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
void AddModule(CbmMuchModule *module)
CbmMuchModule * GetModule(Int_t iModule) const
Int_t GetDetectorId() const
Double_t GetSupportDx() const
void SetSupportDx(Double_t supDx)
CbmMuchLayerSide * GetSide(Bool_t side)
CbmMuchLayerSide * GetSideF()
CbmMuchLayerSide * GetSideB()
Double_t GetSupportDy() const
Int_t GetDetectorId() const
void SetSupportDy(Double_t supDy)
void SetSupportDz(Double_t supDz)
Int_t GetDetectorId() const
void SetClusters(TClonesArray *clusters)
void SetHits(TClonesArray *hits)
virtual Bool_t InitModule()
TClonesArray * GetClusters() const
Int_t GetDetectorType() const
void SetRmin(Double_t rMin)
CbmMuchLayer * GetLayer(Int_t iLayer) const
void SetTubeRmin(Double_t rMin)
void AddLayer(CbmMuchLayer *layer)
void SetTubeRmax(Double_t rMax)
void SetModuleDesign(Bool_t on)
void SetRmax(Double_t rMax)
Int_t GetDetectorId() const