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