CbmRoot
Loading...
Searching...
No Matches
CbmMuchGeoScheme.cxx
Go to the documentation of this file.
1/* Copyright (C) 2008-2021 St. Petersburg Polytechnic University, St. Petersburg
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Vikas Singhal, Mikhail Ryzhinskiy [committer], Florian Uhlig, Evgeny Kryshen */
4// -------------------------------------------------------------------------
5// ----- CbmMuchGeoScheme source file -----
6//------ Modilfied 21/06/2019 by Ekata Nandy(Detector type for GEM & RPC included) -----
7//------ Modilfied 18/10/2017 by Omveer Singh -----
8// ----- Created 18/02/08 by E. Kryshen
9// -------------------------------------------------------------------------
10#include "CbmMuchGeoScheme.h"
11
12#include "CbmMuchAddress.h" // for CbmMuchAddress
13#include "CbmMuchLayer.h" // for CbmMuchLayer
14#include "CbmMuchLayerSide.h" // for CbmMuchLayerSide
15#include "CbmMuchModule.h" // for CbmMuchModule
16#include "CbmMuchModuleGem.h" // for CbmMuchModuleGem
17#include "CbmMuchModuleGemRadial.h" // for CbmMuchModuleGemRadial
18#include "CbmMuchStation.h" // for CbmMuchStation
19
20#include <Logger.h> // for LOG
21
22#include <TArrayD.h> // for TArrayD
23#include <TArrayI.h> // for TArrayI
24#include <TClonesArray.h> // for TClonesArray
25#include <TFile.h> // for TFile, gFile
26#include <TGeoArb8.h> // for TGeoTrap
27#include <TGeoBBox.h> // for TGeoBBox
28#include <TGeoManager.h> // for TGeoManager, gGeoManager
29#include <TGeoNode.h> // for TGeoNode
30#include <TGeoVolume.h> // for TGeoVolume
31#include <TMath.h> // for Cos, Sqrt
32#include <TObjArray.h> // for TObjArray
33#include <TObject.h> // for TObject
34#include <TVector3.h> // for TVector3
35
36#include <cassert> // for assert
37#include <cmath> // for sqrt
38#include <stdexcept> // for out_of_range
39#include <utility> // for pair
40#include <vector>
41
42using std::vector;
43
47
48// -------------------------------------------------------------------------
50 : TObject()
51 , fGeoPathHash(0)
52 , fCurrentVolume(nullptr)
53 , fVolumeBoxShape(nullptr)
54 , fVolumeTrapShape(nullptr)
55 , fGlobal()
56 , fGlobalTrap()
57 , fGlobalMatrix(nullptr)
58 , fStation(0)
59 , fLayer(0)
60 , fActive(0)
61 , fGeoID(0)
62 ,
63 //fIsSimulation(kFALSE),
64 fModules()
65 , fSides()
66 , fMapSides()
67 , fStations(nullptr)
68 , fAbsorbers(new TObjArray())
69 , fMuchCave(nullptr)
70 , fMuchZ1(0.)
73 , fNabs(0)
74 , fNst(0)
75 , fActiveLx(0.)
76 , fActiveLy(0.)
77 , fActiveLz(0.)
78 , fSpacerLx(0.)
79 , fSpacerLy(0.)
80 , fOverlapY(0.)
81 , fStrawLz(0.)
83 , fActiveLzSector(0.)
84 , fSpacerR(0.)
85 , fSpacerPhi(0)
86 , fOverlapR(0.)
87 , fAbsorberZ1(0)
88 , fAbsorberLz(0)
89 , fAbsorberMat(0)
90 , fStationZ0(0)
91 , fNlayers(0)
92 , fDetType(0)
93 , fLayersDz(0)
94 , fSupportLz(0)
95 , fModuleDesign(0)
96 , muchSt(nullptr)
97 , muchLy(nullptr)
98 , muchLySd(nullptr)
99 , Rmin(-1.)
100 , Rmax(-1.)
101 , Dx2(-1.)
102{
103 LOG(debug) << "CbmMuchGeoScheme created";
104}
105// -------------------------------------------------------------------------
106
107// -------------------------------------------------------------------------
109{
110
111 if (fInstance != nullptr) delete fInstance;
112}
113// -------------------------------------------------------------------------
114
115
116// -------------------------------------------------------------------------
123// -------------------------------------------------------------------------
124
125// -------------------------------------------------------------------------
126void CbmMuchGeoScheme::Init(TObjArray* stations, Int_t flag)
127{
128
129 if (!fInitialized) {
130 fStations = stations;
131 //LOG(info) <<" enter ini loop check"<<fStations->GetEntriesFast()<<" "<<stations->GetEntriesFast();
132 fGeoID = flag;
133 fInitialized = kTRUE;
134 }
135 LOG(debug) << "CbmMuchGeoScheme init successful";
136 InitModules();
137}
138// -------------------------------------------------------------------------
139
140
141// -------------------------------------------------------------------------
142void CbmMuchGeoScheme::Init(TString digiFileName, Int_t flag)
143{
144
146 TFile* oldFile = gFile;
147 TDirectory* oldDir = gDirectory;
148
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;
153 file->Close();
154 file->Delete();
155
157 gFile = oldFile;
158 gDirectory = oldDir;
159
160 Init(stations, flag);
161}
162// -------------------------------------------------------------------------
163
164
165// -------------------------------------------------------------------------
167{
168
169 if (!fModulesInitialized) {
170
171
172 if (!fStations) Fatal("InitModules", "No input array of stations.");
173 Int_t incSides = 0;
174 fMapSides.clear();
175 fSides.clear();
176 fModules.clear();
177
178 //LOG(info) <<"Total No. of Stations "<<" "<<GetNStations()<<" absorbers "<<GetNAbsorbers();
179 for (Int_t iStation = 0; iStation < GetNStations(); iStation++) {
180
181 const CbmMuchStation* station = GetStation(iStation);
182 if (!station) continue;
183
184 assert(iStation == CbmMuchAddress::GetStationIndex(station->GetDetectorId()));
187
188 for (Int_t iLayer = 0; iLayer < station->GetNLayers(); iLayer++) {
189 CbmMuchLayer* layer = station->GetLayer(iLayer);
190 if (!layer) continue;
191
192 assert(iLayer == CbmMuchAddress::GetLayerIndex(layer->GetDetectorId()));
193 for (Int_t iSide = 0; iSide < 2; iSide++) {
194 CbmMuchLayerSide* side = (CbmMuchLayerSide*) layer->GetSide(iSide);
195 if (!side) continue;
196 assert(iSide == CbmMuchAddress::GetLayerSideIndex(side->GetDetectorId()));
197 if (side->GetNModules() != 0) fMapSides[side->GetDetectorId()] = incSides++;
198 sides.push_back(side);
199
200 for (Int_t iModule = 0; iModule < side->GetNModules(); iModule++) {
201 CbmMuchModule* mod = side->GetModule(iModule);
202 if (!mod) continue;
203
204 assert(iModule == CbmMuchAddress::GetModuleIndex(mod->GetDetectorId()));
205 assert(iStation == CbmMuchAddress::GetStationIndex(mod->GetDetectorId()));
206 if (!mod->InitModule()) continue;
207 modules.push_back(mod);
208 } // Modules
209 } // Sides
210 } // Layers
211 fSides.push_back(sides);
212 fModules.push_back(modules);
213 } // Stations
214
215 fModulesInitialized = kTRUE;
216 }
217}
218// -------------------------------------------------------------------------
219
220// -------------------------------------------------------------------------
222{
223
224 if (!fStations) return nullptr;
225 Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast());
226
227 return result ? (CbmMuchStation*) fStations->At(iStation) : nullptr;
228}
229// -------------------------------------------------------------------------
230
231
232// -------------------------------------------------------------------------
234{
235
236 CbmMuchStation* station = GetStation(iStation);
237 return station ? station->GetLayer(iLayer) : nullptr;
238}
239// -------------------------------------------------------------------------
240
241// -------------------------------------------------------------------------
243{
244
245 CbmMuchLayer* layer = GetLayer(iStation, iLayer);
246 return layer ? layer->GetSide(iSide) : nullptr;
247}
248// -------------------------------------------------------------------------
249
250// -------------------------------------------------------------------------
251CbmMuchModule* CbmMuchGeoScheme::GetModule(Int_t iStation, Int_t iLayer, Bool_t iSide, Int_t iModule) const
252{
253
254 CbmMuchLayerSide* side = GetLayerSide(iStation, iLayer, iSide);
255 return side ? side->GetModule(iModule) : nullptr;
256}
257// -------------------------------------------------------------------------
258
259// -------------------------------------------------------------------------
261{
262
263 Int_t iStation = CbmMuchAddress::GetStationIndex(detId);
264 assert(iStation < GetNStations());
265 return GetStation(iStation);
266}
267// -------------------------------------------------------------------------
268
269// -------------------------------------------------------------------------
271{
272
273 CbmMuchStation* station = GetStationByDetId(detId);
274 Int_t iLayer = CbmMuchAddress::GetLayerIndex(detId);
275 assert(iLayer < station->GetNLayers());
276 return station ? station->GetLayer(iLayer) : nullptr;
277}
278// -------------------------------------------------------------------------
279
280// -------------------------------------------------------------------------
282{
283
284 CbmMuchLayer* layer = GetLayerByDetId(detId);
286 assert(iSide < 2);
287 return layer ? layer->GetSide(iSide) : nullptr;
288}
289// -------------------------------------------------------------------------
290
291// -------------------------------------------------------------------------
293{
294
296 Int_t iModule = CbmMuchAddress::GetModuleIndex(detId);
297 assert(iModule < side->GetNModules());
298 return side ? side->GetModule(iModule) : nullptr;
299}
300// -------------------------------------------------------------------------
301
302// -------------------------------------------------------------------------
304{
305
307 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
308 CbmMuchModule* module = (*it);
309 module->SetPoints(new TClonesArray("CbmVisPoint", 1));
310 }
311}
312// -------------------------------------------------------------------------
313
314// -------------------------------------------------------------------------
316{
317
319 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
320 CbmMuchModule* module = (*it);
321 if (module->GetDetectorType() == 1) {
322 CbmMuchModuleGem* mod = (CbmMuchModuleGem*) module;
323 mod->SetHits(new TClonesArray("CbmVisPixelHit", 1));
324 /*
325 } else if (module->GetDetectorType()==2) {
326 CbmMuchModuleStraws* mod = (CbmMuchModuleStraws*)module;
327 mod->SetHits(new TClonesArray("CbmVisStripHit",1));
328*/
329 }
330 }
331}
332// -------------------------------------------------------------------------
333
334// -------------------------------------------------------------------------
336{
337
339 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
340 CbmMuchModule* module = (*it);
341 if (module->GetDetectorType() != 1) continue;
342 CbmMuchModuleGem* mod = (CbmMuchModuleGem*) module;
343 mod->SetClusters(new TClonesArray("CbmVisMuchCluster", 1));
344 }
345}
346// -------------------------------------------------------------------------
347
348// -------------------------------------------------------------------------
350{
351
353 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
354 (*it)->GetPoints()->Clear();
355 }
356}
357// -------------------------------------------------------------------------
358
359
360// -------------------------------------------------------------------------
362{
363
365 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
366 (*it)->GetHits()->Clear();
367 }
368}
369// -------------------------------------------------------------------------
370
371// -------------------------------------------------------------------------
373{
374
376 for (vector<CbmMuchModule*>::iterator it = modules.begin(); it != modules.end(); it++) {
377 CbmMuchModule* module = (*it);
378 if (module->GetDetectorType() != 1) continue;
379 CbmMuchModuleGem* mod = (CbmMuchModuleGem*) module;
380 mod->GetClusters()->Clear();
381 }
382}
383// -------------------------------------------------------------------------
384
385// -------------------------------------------------------------------------
387{
388
389 try {
390 return fSides.at(iStation);
391 }
392 catch (const std::out_of_range& exc) {
393 Fatal("GetLayerSides", "No input array of stations.");
394 }
396}
397
398//Int_t CbmMuchGeoScheme::GetLayerSideNr(Int_t detId){
399// int i = 0;
400// Int_t sideId = GetLayerSideByDetId(detId)->GetDetectorId();
401// Int_t iStation = GetStationIndex(detId);
402// for(Int_t iSt=0; iSt<=iStation; iSt++){
403// vector<CbmMuchLayerSide*> sides = GetLayerSides(iSt);
404// for(Int_t iSide=0; iSide<sides.size(); iSide++){
405// i++;
406// }
407// }
408// printf("%i, %i\n",fMapSides[sideId] + 1, i);
409// assert(fMapSides[sideId] + 1 == i);
410// return i;
411//}
412
414{
415 Int_t sideId = GetLayerSideByDetId(detId)->GetDetectorId();
416 if (fMapSides.find(sideId) == fMapSides.end())
417 Fatal("GetLayerSideNr", "Wrong side id or no modules in the layer side");
418 return fMapSides.find(sideId)->second + 1;
419}
420
421// -------------------------------------------------------------------------
422void CbmMuchGeoScheme::NavigateTo(const TString& path)
423{
424
425 gGeoManager->cd(path.Data());
426 // fGeoPathHash;
427 fGeoPathHash = path.Hash();
428 fCurrentVolume = gGeoManager->GetCurrentVolume();
429 fVolumeBoxShape = (TGeoBBox*) fCurrentVolume->GetShape();
430 Double_t local[3] = {0., 0., 0.};
431 gGeoManager->LocalToMaster(local, fGlobal);
432}
433
434//------------------------------------------------------
435Double_t CbmMuchGeoScheme::GetSizeX(const TString& path)
436{
437
438 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
439 return fVolumeBoxShape->GetDX();
440}
441
442
443Double_t CbmMuchGeoScheme::GetSizeY(const TString& path)
444{
445
446 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
447 return fVolumeBoxShape->GetDY();
448}
449
450
451Double_t CbmMuchGeoScheme::GetSizeZ(const TString& path)
452{
453 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
454 return fVolumeBoxShape->GetDZ();
455}
456
457
458Double_t CbmMuchGeoScheme::GetZ(const TString& path)
459{
460
461 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
462 return fGlobal[2];
463}
464
465
466Double_t CbmMuchGeoScheme::GetY(const TString& path)
467{
468
469 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
470 return fGlobal[1];
471}
472
473
474Double_t CbmMuchGeoScheme::GetX(const TString& path)
475{
476
477 if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
478 return fGlobal[0];
479}
480//-----------------------------------------------------------------------------------------------------
481void CbmMuchGeoScheme::ExtractGeoParameter(TGeoNode* ncave, const char* volumeName)
482{
483
484 TObjArray* caveArr = ncave->GetNodes();
485
486 for (int iSystem = 0; iSystem < caveArr->GetEntriesFast(); iSystem++) {
487 TGeoNode* SystemNode = static_cast<TGeoNode*>(caveArr->At(iSystem));
488
489 if (!TString(SystemNode->GetName()).Contains(volumeName)) continue;
490 TObjArray* MuchObj = SystemNode->GetNodes();
491
492 for (Int_t iMuchObj = 0; iMuchObj < MuchObj->GetEntriesFast(); iMuchObj++) {
493
494 TGeoNode* MuchObjNode = static_cast<TGeoNode*>(MuchObj->At(iMuchObj));
495
496 // if (!TString(MuchObjNode->GetName()).Contains("Station")) continue;
497 if (!TString(MuchObjNode->GetName()).Contains("station")) continue;
498 TString MuchObjPath =
499 TString("/") + ncave->GetName() + "/" + SystemNode->GetName() + "/" + MuchObjNode->GetName();
500
501 StationNode(MuchObjNode, MuchObjPath); //StationNode
502 } //iMuchObj
503
504 } //iSystem
505} //SetParameters
506
507//---------------------------------------------------------------------------------------------
508void CbmMuchGeoScheme::StationNode(TGeoNode* fSNode, TString Path)
509{
510
511 TObjArray* stations = fSNode->GetNodes();
512 //fStations=stations; // by PPB 1/11/2017
513 fNst = stations->GetEntriesFast();
514 // LOG(info) <<"check stations "<<fNst;
515 fStationZ0.Set(fNst); // Station Zceneter [cm]
516 fNlayers.Set(fNst); // Number of layers
517 fDetType.Set(fNst); // Detector type
518 fLayersDz.Set(fNst); // Distance between layers [cm]
519 fSupportLz.Set(fNst); // Support thickness [cm]
520 fLayersDz.Set(fNst); //
521 fModuleDesign.Set(fNst); // Module design (0/1)
522 fNSectorsPerLayer.Set(fNst); // Number of sectors per layer in sector GEM geometry
523
524
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();
530
531
532 // fDetType[iStation]=3;
533 // fLayersDz[iStation]=10.0;
534
535 //-----------------------------Layer1-------------------------------------------------------
536 TGeoNode* layer1 = static_cast<TGeoNode*>(layers->At(0)); //first layer position of station
537 TString Layer1Path = StationPath + "/" + layer1->GetName();
538 TObjArray* Supportlayer1 = layer1->GetNodes();
539 TGeoNode* Supportlayer1Node = static_cast<TGeoNode*>(Supportlayer1->At(0));
540
541 TString Supportlayer1Path = Layer1Path + "/" + Supportlayer1Node->GetName();
542 Double_t fLayer1Z0;
543 //if(Supportlayer2Path.Contains("mcbm")) fLayer2Z0=GetModuleZ(Supportlayer2Path);
544 if (fGeoID == 1) fLayer1Z0 = GetModuleZ(Supportlayer1Path);
545 else
546 fLayer1Z0 = GetZ(Supportlayer1Path);
547
548
549 //-----------------------------Layer2-------------------------------------------------------
550 TGeoNode* layer2 = static_cast<TGeoNode*>(layers->At(1)); //second layer position of station
551 TString Layer2Path = StationPath + "/" + layer2->GetName();
552
553 TObjArray* Supportlayer2 = layer2->GetNodes();
554 TGeoNode* Supportlayer2Node = static_cast<TGeoNode*>(Supportlayer2->At(0));
555
556 TString Supportlayer2Path = Layer2Path + "/" + Supportlayer2Node->GetName();
557
558 Double_t fLayer2Z0;
559 //if(Supportlayer2Path.Contains("mcbm")) fLayer2Z0=GetModuleZ(Supportlayer2Path);
560 if (fGeoID == 1) fLayer2Z0 = GetModuleZ(Supportlayer2Path);
561 else
562 fLayer2Z0 = GetZ(Supportlayer2Path);
563 //
564
565
566 fLayersDz[iStation] = fLayer2Z0 - fLayer1Z0;
567
568 //if(Supportlayer3Path.Contains("mcbm")) fSupportLz[iStation]=2.0*GetModuleDZ(Supportlayer3Path);
569 if (fGeoID == 1) fSupportLz[iStation] = 2.0 * GetModuleDZ(Supportlayer1Path);
570 else
571 fSupportLz[iStation] = 2.0 * GetSizeZ(Supportlayer1Path);
572 //LOG(info) <<fSupportLz[iStation]<<" "<<fLayersDz[iStation];
573
574
575 Double_t PosY = 0., Phi = 0., Dy = 0.;
576
577 if (fNlayers[iStation] == 3) {
578 //------------------------------Layer3-----------------------------------------------------------
579 TGeoNode* layer3 = static_cast<TGeoNode*>(layers->At(2));
580 TString Layer3Path = StationPath + "/" + layer3->GetName();
581
582 TObjArray* Supportlayer3 = layer3->GetNodes();
583 TGeoNode* Supportlayer3Node = static_cast<TGeoNode*>(Supportlayer3->At(0));
584 TString Supportlayer3Path = Layer3Path + "/" + Supportlayer3Node->GetName();
585
586 // Double_t fLayer3Z0;
587 //if(Supportlayer3Path.Contains("mcbm")) fLayer3Z0=GetModuleZ(Supportlayer3Path);
588 // if(fGeoID==1) fLayer3Z0=GetModuleZ(Supportlayer3Path);
589 // else fLayer3Z0 = GetZ(Supportlayer3Path);
590 TGeoNode* Activelayer3Node = static_cast<TGeoNode*>(Supportlayer3->At(1));
591 TString Activelayer3Path = Layer3Path + "/" + Activelayer3Node->GetName();
592
593 PosY = GetModuleY(Activelayer3Path);
594 // Double_t PosX=GetModuleX(Activelayer3Path);
595 Phi = GetModulePhi(Activelayer3Path);
596 Dy = GetModuleH1(Activelayer3Path);
597 fActiveLzSector = 2.0 * GetModuleDZ(Activelayer3Path);
598 fStationZ0[iStation] = fLayer2Z0;
599 }
600 else {
601 TGeoNode* Activelayer2Node = static_cast<TGeoNode*>(Supportlayer2->At(1));
602 TString Activelayer2Path = Layer2Path + "/" + Activelayer2Node->GetName();
603
604 PosY = GetModuleY(Activelayer2Path);
605 // Double_t PosX=GetModuleX(Activelayer3Path);
606 Phi = GetModulePhi(Activelayer2Path);
607 Dy = GetModuleH1(Activelayer2Path);
608 fActiveLzSector = 2.0 * GetModuleDZ(Activelayer2Path);
609 fStationZ0[iStation] = (fLayer2Z0 - fLayer1Z0) / 2.;
610 }
611
612
613 //chaned by PPB on 16.11.2017
614 //Double_t yMin = -(PosX/TMath::Sin(Phi))-Dy;
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;
619 Rmax = yMax;
620 Rmin = yMin; //-2.0; // Spacer width[cm] = 2.0
621
622
623 muchSt = new CbmMuchStation(iStation, fStationZ0[iStation]);
624 muchSt->SetRmin(Rmin);
625 muchSt->SetRmax(Rmax);
626
627 if (Supportlayer1->GetEntriesFast() > 0) fModuleDesign[iStation] = 1;
628 muchSt->SetModuleDesign(fModuleDesign[iStation]);
629
630
631 LayerNode(station, iStation, StationPath);
632
633
634 muchLy = muchSt->GetLayer(0);
635 Double_t supDx = muchLy->GetSupportDx();
636 Double_t supDy = muchLy->GetSupportDy();
637 // Double_t supDz = muchLy->GetSupportDz();
638 muchSt->SetTubeRmin(muchSt->GetRmin());
639 muchSt->SetTubeRmax(TMath::Sqrt(supDx * supDx + supDy * supDy) + 10);
640 //LOG(info) <<" fill fStations array "<<iStation<<" z cent "<<fStationZ0[iStation];
641 fStations->Add(muchSt);
642
643 } //Station
644} //StationNode
645//---------------------------------------------------------------------------------------------------------
646
647void CbmMuchGeoScheme::LayerNode(TGeoNode* StNode, Int_t iStation, TString StPath)
648{
649
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();
654
655 ModuleNode(layerNode, iStation, iLayer, layerPath);
656
657 //Set support shape
658 muchLy->SetSupportDx(sqrt(Rmax * Rmax + Dx2 * Dx2));
659 muchLy->SetSupportDy(sqrt(Rmax * Rmax + Dx2 * Dx2));
660 muchLy->SetSupportDz(fSupportLz[iStation] / 2.);
661
662 muchSt->AddLayer(muchLy);
663
664 } //iLayer
665}
666//---------------------------------------------------------------------------------------------------------------------------------
667
668void CbmMuchGeoScheme::ModuleNode(TGeoNode* layerNode, Int_t iStation, Int_t iLayer, TString layerPath)
669{
670
671
672 TObjArray* moduleArray = layerNode->GetNodes();
673 for (Int_t iModule = 0; iModule < moduleArray->GetEntriesFast(); iModule++) {
674 TGeoNode* moduleNode = static_cast<TGeoNode*>(moduleArray->At(iModule));
675
676 TString modulePath = layerPath + "/" + moduleNode->GetName();
677
678 ActiveModuleNode(moduleNode, iStation, iLayer, iModule, modulePath);
679
680
681 } //iModule
682}
683
684//----------------------------------------------------------------------------------------------------------------------------------------------------------------
685
686void CbmMuchGeoScheme::ActiveModuleNode(TGeoNode* moduleNode, Int_t iStation, Int_t iLayer, Int_t /*iModule*/,
687 TString modulePath)
688{
689
690 TString modName = moduleNode->GetName();
691
692
693 if (modName.Contains("support")) {
694
695
696 Double_t layerGlobalZ0;
697 // if(modulePath.Contains("mcbm")) layerGlobalZ0=GetModuleZ(modulePath);
698 if (fGeoID == 1) layerGlobalZ0 = GetModuleZ(modulePath);
699 else
700 layerGlobalZ0 = GetZ(modulePath);
701
702 Double_t layerZ0 = (iLayer - (fNlayers[iStation] - 1) / 2.) * fLayersDz[iStation];
703 Double_t sideDz = fSupportLz[iStation] / 2. + fActiveLzSector / 2.;
704
705 muchLy = new CbmMuchLayer(iStation, iLayer, layerGlobalZ0, layerZ0); //CbmMuchLayer Class
706 muchLy->GetSideB()->SetZ(layerGlobalZ0 + sideDz);
707 muchLy->GetSideF()->SetZ(layerGlobalZ0 - sideDz);
708 }
709
710
711 if (modName.Contains("active")) {
712
713 gGeoManager->cd(modulePath.Data());
714 // TGeoNode* moduleNode = gGeoManager->GetMother(0);
715 moduleNode = gGeoManager->GetMother(0);
716 // Int_t nModule=moduleNode->GetNumber();
717
718 Bool_t iSide;
719 if (modName.Contains("factive")) iSide = 0;
720 if (modName.Contains("bactive")) iSide = 1;
721 TVector3 pos;
722 pos[0] = GetModuleX(modulePath);
723 pos[1] = GetModuleY(modulePath);
724 pos[2] = GetModuleZ(modulePath);
725 // LOG(info) <<" positions "<<pos[0]<<" "<<pos[1]<<" "<<pos[2];
726 Double_t Dz = GetModuleDZ(modulePath);
727 // Double_t Phi = GetModulePhi(modulePath);
728 Double_t Dy = GetModuleH1(modulePath);
729 Double_t Dx1 = GetModuleBl1(modulePath);
730 Dx2 = GetModuleTl1(modulePath);
731 //LOG(info) <<" positions "<<pos[0]<<" "<<pos[1]<<" "<<pos[2]<<" phi "<<Phi;
732
733 // Is this formula correct? Check Omveer (PPB 16.11.2017)
734 // Double_t yMin = (pos[1]/TMath::Cos(Phi))-Dy;
735 // Double_t yMax = 2*Dy + yMin;
736 // Double_t Rmin = yMin-2.0; // Spacer width[cm] = 2.0
737 // Why is R0 required?
738 // Double_t R0 = yMax-Dy;
739 // Double_t Rmax = yMax;
740
741
742 Int_t DetType = -1;
743 if (modName.Contains("gasArgon")) DetType = 3; // Detector type 3 for GEM
744 if (modName.Contains("rpcgas")) DetType = 4; // Detector type 4 for RPC
745 // LOG(info) <<" detector type "<<DetType;
746
747 muchLySd = muchLy->GetSide(iSide);
748 muchLySd->AddModule(
749 new CbmMuchModuleGemRadial(DetType, iStation, iLayer, iSide, muchLySd->GetNModules(), pos, Dx1, Dx2, Dy, Dz,
750 Rmin)); // Detector type variable added in the class constructor on 03-07-2019
751
752
753 } //activeLayer
754
755
756} //ActiveModuleNode
757//----------------------------------------------------------------------------------------------------------
758void CbmMuchGeoScheme::NavigateModule(const TString& path)
759{
760 gGeoManager->cd(path.Data());
761 // fGeoPathHash;
762 fGeoPathHash = path.Hash();
763 fCurrentVolume = gGeoManager->GetCurrentVolume();
764 fVolumeTrapShape = (TGeoTrap*) fCurrentVolume->GetShape();
765 Double_t local[3] = {0., 0., 0.};
766 gGeoManager->LocalToMaster(local, fGlobalTrap);
767
768} //NavigateModule
769
770//----------------------------------------------------------------------------------------------------------
771
772Double_t CbmMuchGeoScheme::GetModuleDZ(const TString& path)
773{
774
775 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
776 return fVolumeTrapShape->GetDZ();
777}
778
779
780Double_t CbmMuchGeoScheme::GetModuleZ(const TString& path)
781{
782
783 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
784 return fGlobalTrap[2];
785}
786
787
788Double_t CbmMuchGeoScheme::GetModuleY(const TString& path)
789{
790
791 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
792 return fGlobalTrap[1];
793}
794
795
796Double_t CbmMuchGeoScheme::GetModuleX(const TString& path)
797{
798
799 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
800 return fGlobalTrap[0];
801}
802
803Double_t CbmMuchGeoScheme::GetModulePhi(const TString& path)
804{
805
806 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
807 return fVolumeTrapShape->GetPhi();
808}
809
810Double_t CbmMuchGeoScheme::GetModuleH1(const TString& path)
811{
812
813 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
814 return fVolumeTrapShape->GetH1();
815}
816
817Double_t CbmMuchGeoScheme::GetModuleBl1(const TString& path)
818{
819
820 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
821 return fVolumeTrapShape->GetBl1();
822}
823
824Double_t CbmMuchGeoScheme::GetModuleTl1(const TString& path)
825{
826
827 if (fGeoPathHash != path.Hash()) { NavigateModule(path); }
828 return fVolumeTrapShape->GetTl1();
829}
830
831// -------------------------------------------------------------------------
833{
834
835 Float_t x1 = x - dx;
836 Float_t x2 = x + dx;
837 Float_t y1 = y - dy;
838 Float_t y2 = y + dy;
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;
847 return 0;
848}
849// -------------------------------------------------------------------------
850
851// -------------------------------------------------------------------------
853{
854
856 for (Int_t iStation = 0; iStation < GetNStations(); ++iStation) {
857 vector<CbmMuchModule*> stationModules = GetModules(iStation);
858 for (vector<CbmMuchModule*>::iterator it = stationModules.begin(); it != stationModules.end(); it++) {
859 CbmMuchModule* module = (*it);
860 modules.push_back(module);
861 assert(CbmMuchAddress::GetStationIndex(module->GetDetectorId()) == iStation);
862 }
863 }
864 return modules;
865}
866// -------------------------------------------------------------------------
867
868
869// -------------------------------------------------------------------------
871{
872
874 for (Int_t iStation = 0; iStation < GetNStations(); ++iStation) {
875 vector<CbmMuchModule*> stationModules = GetModules(iStation);
876 for (vector<CbmMuchModule*>::iterator it = stationModules.begin(); it != stationModules.end(); it++) {
877 CbmMuchModule* module = (*it);
878 if (module->GetDetectorType() != 3 && module->GetDetectorType() != 4) continue; //Detector type 3:GEM, 4:RPC
879 modules.push_back((CbmMuchModuleGem*) module);
880 assert(CbmMuchAddress::GetStationIndex(module->GetDetectorId()) == iStation);
881 }
882 }
883 return modules;
884}
885// -------------------------------------------------------------------------
886
887
888// -------------------------------------------------------------------------
890{
891
892 try {
893 return fModules.at(iStation);
894 }
895 catch (const std::out_of_range& exc) {
896 Fatal("GetModules", "No input array of stations.");
897 }
898 return vector<CbmMuchModule*>();
899}
900// -------------------------------------------------------------------------
901
ClassImp(CbmConverterManager)
friend fvec sqrt(const fvec &a)
float Float_t
int Int_t
bool Bool_t
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 fGlobalTrap[3]
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
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
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)
CbmMuchStation * muchSt
Int_t GetNStations() const
CbmMuchLayer * muchLy
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
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 GetNLayers() const
Int_t GetDetectorId() const