CbmRoot
Loading...
Searching...
No Matches
CbmStsModule.cxx
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Florian Uhlig */
4
9#include "CbmStsModule.h"
10
11#include "CbmStsAddress.h" // for GetAddress, SetElementId, ToString
12#include "CbmStsParAsic.h" // for CbmStsParAsic
13#include "CbmStsParModule.h" // for CbmStsParModule
14#include "CbmStsSensor.h" // for CbmStsSensor
15
16#include <Logger.h> // for LOG, Logger
17
18#include <TGeoManager.h> // for gGeoManager
19#include <TGeoNode.h> // for TGeoNode
20#include <TGeoPhysicalNode.h> // for TGeoPhysicalNode
21
22#include <ostream> // for operator<<, basic_ostream, stringstream
23#include <string> // for string
24
25#include <assert.h> // for assert
26
27using namespace std;
28
29
30// ----- Default constructor -------------------------------------------
31CbmStsModule::CbmStsModule(UInt_t address, TGeoPhysicalNode* node, CbmStsElement* mother)
32 : CbmStsElement(address, kStsModule, node, mother)
33{
34}
35// -------------------------------------------------------------------------
36
37
38// --- Destructor --------------------------------------------------------
40// -------------------------------------------------------------------------
41
42
43// ----- Get the unique address from the sensor name (static) ----------
45{
46
47 Bool_t isValid = kTRUE;
48 if (name.Length() != 16) isValid = kFALSE;
49 if (isValid) {
50 if (!name.BeginsWith("STS")) isValid = kFALSE;
51 if (name[4] != 'U') isValid = kFALSE;
52 if (name[8] != 'L') isValid = kFALSE;
53 if (name[13] != 'M') isValid = kFALSE;
54 }
55 if (!isValid) {
56 LOG(fatal) << "GetAddressFromName: Not a valid module name " << name;
57 return 0;
58 }
59
60 Int_t unit = 10 * (name[5] - '0') + name[6] - '0' - 1;
61 Int_t ladder = 10 * (name[9] - '0') + name[10] - '0' - 1;
62 Int_t hLadder = (name[11] == 'U' ? 0 : 1);
63 Int_t module = 10 * (name[14] - '0') + name[15] - '0' - 1;
64
65 return CbmStsAddress::GetAddress(unit, ladder, hLadder, module);
66}
67// -------------------------------------------------------------------------
68
69
70// ----- Initialise daughters from geometry ----------------------------
72{
73
74 // --- Catch absence of TGeoManager
75 assert(gGeoManager);
76
77 // --- Catch physical node not being set
78 assert(fNode);
79
80 TGeoNode* moduleNode = fNode->GetNode(); // This node
81 TString modulePath = fNode->GetName(); // Full path to this node
82
83 for (Int_t iNode = 0; iNode < moduleNode->GetNdaughters(); iNode++) {
84
85 // Check name of daughter node for level name
86 TString daughterName = moduleNode->GetDaughter(iNode)->GetName();
87 if (daughterName.Contains("Sensor", TString::kIgnoreCase)) {
88
89 // Create physical node
90 TString daughterPath = modulePath + "/" + daughterName;
91 TGeoPhysicalNode* sensorNode = new TGeoPhysicalNode(daughterPath.Data());
92
93 // Get or create element from setup and add it as daughter
95 CbmStsSensor* sensor = new CbmStsSensor(address, sensorNode, this);
96 fDaughters.push_back(sensor);
97
98 } //? name of daughter node contains "sensor"
99
100 } //# daughter nodes
101}
102// -------------------------------------------------------------------------
103
104
105// ----- String output -------------------------------------------------
107{
108 stringstream ss;
109 ss << GetName() << ", address " << CbmStsAddress::ToString(fAddress);
110 return ss.str();
111}
112// -------------------------------------------------------------------------
113
114
ClassImp(CbmConverterManager)
@ kStsModule
@ kStsSensor
Class representing an element of the STS setup.
std::vector< CbmStsElement * > fDaughters
Array of daughters.
TGeoPhysicalNode * fNode
Pointer to geometry.
Int_t fAddress
Unique element address.
Int_t GetNofDaughters() const
Class representing an instance of a readout unit in the CBM-STS.
virtual void InitDaughters()
Initialise daughters from geometry.
static Int_t GetAddressFromName(TString name)
Get the address from the module name (static)
std::string ToString() const
CbmStsModule(UInt_t address=0, TGeoPhysicalNode *node=nullptr, CbmStsElement *mother=nullptr)
Standard constructor.
virtual ~CbmStsModule()
Destructor.
Class representing an instance of a sensor in the CBM-STS.
int32_t SetElementId(int32_t address, int32_t level, uint32_t newId)
Set the index of an element, leaving the other element levels untouched.
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.
std::string ToString(int32_t address)
String output.
Hash for CbmL1LinkKey.