25#include <TCollection.h>
26#include <TDirectory.h>
28#include <TGeoManager.h>
29#include <TGeoMatrix.h>
31#include <TGeoPhysicalNode.h>
32#include <TGeoShapeAssembly.h>
33#include <TGeoVolume.h>
34#include <TGeoVoxelFinder.h>
75 TString name = Form(
"STS_S%02i", stationId + 1);
76 TString title = Form(
"STS Station %i", stationId + 1);
97 Int_t nodeNumber = ladder->
GetPnode()->GetNode()->GetNumber();
98 Int_t stationId = nodeNumber / 100 - 1;
102 TString name = Form(
"STS_S%02i", stationId + 1);
103 TString title = Form(
"STS Station %i", stationId + 1);
126 Double_t zPrevious = -999999;
127 for (UInt_t iStation = 0; iStation <
fStations.size(); iStation++) {
129 LOG(error) << GetName() <<
": Number of stations is " <<
fStations.size() <<
", but station " << iStation
130 <<
"is not present!";
133 if (
fStations[iStation]->GetZ() <= zPrevious) {
134 LOG(error) << GetName() <<
": Disordered stations. Station " << iStation
135 <<
" is at z = " <<
fStations[iStation]->GetZ() <<
"cm , previous is at z = " << zPrevious <<
" cm.";
139 if (!isOk) LOG(fatal) << GetName() <<
": Error in creation of stations.";
151 if (!
fAddress) LOG(fatal) << fName <<
": not initialised!";
155 LOG(warn) << fName <<
": No STS address " << address;
161 LOG(warn) << fName <<
": Illegal level " << level;
166 for (Int_t iLevel = 1; iLevel <= level; iLevel++) {
185 case kStsUnit:
return "unit";
break;
190 case kStsSide:
return "side";
break;
191 default:
return "";
break;
207 return ladder->
GetPnode()->GetNode()->GetNumber() / 100 - 1;
220 LOG(info) <<
"==========================================================";
221 LOG(info) <<
"Initialising STS Setup \n";
236 LOG(info) << fName <<
": Elements in setup: ";
237 for (Int_t iLevel = 1; iLevel <=
kStsSensor; iLevel++) {
240 LOG(info) <<
" " << setw(12) << name << setw(5) << right <<
GetNofElements(iLevel);
254 Int_t moduleAddress =
module->GetAddress();
255 assert(!
fModules.count(moduleAddress));
275 LOG(info) << GetName() <<
": Setup contains " << nStations <<
" stations objects.";
276 if (fair::Logger::Logging(fair::Severity::debug)) {
279 LOG(debug) <<
" " << it->second->ToString();
292 LOG(info) <<
"=========================================================="
315 LOG(info) << it->second->ToString();
326 LOG(info) << fName <<
": Reading geometry from TGeoManager " << geo->GetName();
330 TGeoNode* cave = geo->GetCurrentNode();
333 TGeoNode* sts =
nullptr;
334 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
335 TString name = cave->GetDaughter(iNode)->GetName();
336 if (name.Contains(
"STS", TString::kIgnoreCase)) {
337 sts = cave->GetDaughter(iNode);
338 LOG(info) << fName <<
": STS top node is " << sts->GetName();
343 LOG(error) << fName <<
": No top STS node found in geometry!";
348 TString path = cave->GetName();
349 path = path +
"/" + sts->GetName();
350 fNode =
new TGeoPhysicalNode(path);
355 geo->RefreshPhysicalNodes();
358 Bool_t hasStation = kFALSE;
359 Bool_t hasUnit = kFALSE;
360 for (Int_t iDaughter = 0; iDaughter <
fNode->GetNode()->GetNdaughters(); iDaughter++) {
361 TString dName =
fNode->GetNode()->GetDaughter(iDaughter)->GetName();
362 if (dName.Contains(
"station", TString::kIgnoreCase)) hasStation = kTRUE;
363 if (dName.Contains(
"unit", TString::kIgnoreCase)) hasUnit = kTRUE;
366 else if ((!hasUnit) && hasStation)
368 else if (hasUnit && hasStation)
369 LOG(fatal) << GetName() <<
": geometry contains both units and stations!";
371 LOG(fatal) << GetName() <<
": geometry contains neither units nor stations!";
373 if (
fHasStations) LOG(warn) << GetName() <<
": using old geometry (with stations)";
384 TIter nextv(geo->GetListOfVolumes());
386 while ((vol =
dynamic_cast<TGeoVolume*
>(nextv()))) {
387 if (vol->IsAssembly()) vol->GetShape()->ComputeBBox();
388 auto finder = vol->GetVoxels();
389 if (finder && finder->NeedRebuild()) {
400 LOG(info) << fName <<
": Reading geometry from file " << fileName;
403 assert(!gGeoManager);
405 TFile* oldFile = gFile;
406 TDirectory* oldDir = gDirectory;
409 TFile geoFile(fileName);
410 if (!geoFile.IsOpen()) {
411 LOG(fatal) << GetName() <<
": Could not open geometry file " << fileName;
418 TGeoManager* stsGeometry =
new TGeoManager(
"StsGeo",
"STS stand-alone geometry");
421 TGeoVolume* topVolume =
nullptr;
422 TList* keyList = geoFile.GetListOfKeys();
424 TIter keyIter(keyList);
425 while ((key = (TKey*) keyIter())) {
426 if (strcmp(key->GetClassName(),
"TGeoVolumeAssembly") == 0) {
427 TGeoVolume* volume = (TGeoVolume*) key->ReadObj();
428 if (strcmp(volume->GetName(),
"TOP") == 0) {
435 LOG(fatal) << GetName() <<
": No TOP volume in file!";
440 stsGeometry->SetTopVolume(topVolume);
443 stsGeometry->CdTop();
444 TGeoNode* cave = stsGeometry->GetCurrentNode();
447 TGeoNode* sts =
nullptr;
448 for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
449 TString name = cave->GetDaughter(iNode)->GetName();
450 if (name.Contains(
"STS", TString::kIgnoreCase)) {
451 sts = cave->GetDaughter(iNode);
452 stsGeometry->CdDown(iNode);
453 LOG(info) << fName <<
": STS top node is " << sts->GetName();
458 LOG(error) << fName <<
": No top STS node found in geometry!";
465 TString path = cave->GetName();
466 path = path +
"/" + sts->GetName();
467 fNode =
new TGeoPhysicalNode(path);
470 TString dName =
fNode->GetNode()->GetDaughter(0)->GetName();
471 if (dName.Contains(
"station", TString::kIgnoreCase))
fHasStations = kTRUE;
472 else if (dName.Contains(
"unit", TString::kIgnoreCase))
475 LOG(fatal) << GetName() <<
": unknown geometry type; first level name is " << dName;
476 if (
fHasStations) LOG(warn) << GetName() <<
": using old geometry (with stations)";
493 UInt_t address = moduleIt.first;
494 moduleIt.second->SetParameters(params->
GetParModule(address));
497 LOG(info) << GetName() <<
": Set parameters for " << nModules <<
" modules";
510 UInt_t address = sensorIt.first;
511 sensorIt.second->SetConditions(&(conds->
GetParSensor(address)));
514 LOG(info) << GetName() <<
": Set conditions for " << nSensors <<
" sensors";
526 UInt_t address = sensorIt.first;
527 sensorIt.second->SetParameters(&(parSet->
GetParSensor(address)));
530 LOG(info) << GetName() <<
": Set parameters for " << nSensors <<
" sensors";
ClassImp(CbmConverterManager)
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
@ kSts
Silicon Tracking System.
Class representing an element of the STS setup.
TGeoPhysicalNode * fNode
Pointer to geometry.
TGeoPhysicalNode * GetPnode() const
Int_t fAddress
Unique element address.
Int_t GetNofDaughters() const
Int_t GetNofElements(Int_t level) const
virtual void InitDaughters()
CbmStsElement * GetDaughter(Int_t index) const
Class representing an instance of a readout unit in the CBM-STS.
Parameters container for CbmStsParModule.
const CbmStsParModule & GetParModule(UInt_t address)
Get condition parameters of a sensor.
Parameters container for CbmStsParSensorCond.
const CbmStsParSensorCond & GetParSensor(UInt_t address)
Get condition parameters of a sensor.
Parameters container for CbmStsParSensor.
const CbmStsParSensor & GetParSensor(UInt_t address)
Get condition parameters of a sensor.
Class representing an instance of a sensor in the CBM-STS.
Class representing the top level of the STS setup.
const char * GetLevelName(Int_t level) const
static CbmStsSetup * fgInstance
Static instance of this class.
CbmStsSetup()
Default constructor
Int_t GetNofSensors() const
Bool_t fIsSensorCondInit
Sensor conditions set.
Bool_t ReadGeometry(TGeoManager *geoManager)
Read the geometry from TGeoManager.
Bool_t fHasStations
Legacy with stations instead of units.
Bool_t Init(const char *geometryFile=nullptr)
Initialise the setup.
Bool_t fIsSensorParsInit
Sensor parameters set.
CbmStsElement * GetElement(Int_t address, Int_t level)
UInt_t SetSensorConditions(CbmStsParSetSensorCond *conds)
Set sensor conditions from parameter container.
Int_t CreateStations()
Create station objects.
std::map< Int_t, CbmStsSensor * > fSensors
void RecomputePhysicalAssmbBbox(TGeoManager *geo)
static CbmStsSetup * Instance()
std::vector< CbmStsModule * > fModuleVector
Bool_t fIsModuleParsInit
Module parameters set.
UInt_t SetModuleParameters(CbmStsParSetModule *modulePars)
Set module parameters from parameter container.
UInt_t SetSensorParameters(CbmStsParSetSensor *parSet)
Set sensor parameters from parameter container.
std::vector< CbmStsSensor * > fSensorVector
Int_t GetStationNumber(Int_t address)
std::map< Int_t, CbmStsModule * > fModules
Bool_t fIsInitialised
All parameter containers set.
std::map< Int_t, CbmStsStation * > fStations
Class representing a station of the StsSystem.
void Init()
Initialise the station parameters.
void AddLadder(CbmStsElement *ladder)
int32_t GetAddress(uint32_t unit=0, uint32_t ladder=0, uint32_t halfladder=0, uint32_t module=0, uint32_t sensor=0, uint32_t side=0, uint32_t version=kCurrentVersion)
Construct address.
ECbmModuleId GetSystemId(int32_t address)
Get system Id (should be ECbmModuleId::kSts)
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.