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 <cassert> // for assert
23#include <ostream> // for operator<<, basic_ostream, stringstream
24#include <string> // for string
25
26using namespace std;
27
28
29// ----- Default constructor -------------------------------------------
30CbmStsModule::CbmStsModule(UInt_t address, TGeoPhysicalNode* node, CbmStsElement* mother)
31 : CbmStsElement(address, kStsModule, node, mother)
32{
33}
34// -------------------------------------------------------------------------
35
36
37// --- Destructor --------------------------------------------------------
39// -------------------------------------------------------------------------
40
41
42// ----- Get the unique address from the sensor name (static) ----------
44{
45
46 Bool_t isValid = kTRUE;
47 if (name.Length() != 16) isValid = kFALSE;
48 if (isValid) {
49 if (!name.BeginsWith("STS")) isValid = kFALSE;
50 if (name[4] != 'U') isValid = kFALSE;
51 if (name[8] != 'L') isValid = kFALSE;
52 if (name[13] != 'M') isValid = kFALSE;
53 }
54 if (!isValid) {
55 LOG(fatal) << "GetAddressFromName: Not a valid module name " << name;
56 return 0;
57 }
58
59 Int_t unit = 10 * (name[5] - '0') + name[6] - '0' - 1;
60 Int_t ladder = 10 * (name[9] - '0') + name[10] - '0' - 1;
61 Int_t hLadder = (name[11] == 'U' ? 0 : 1);
62 Int_t module = 10 * (name[14] - '0') + name[15] - '0' - 1;
63
64 return CbmStsAddress::GetAddress(unit, ladder, hLadder, module);
65}
66// -------------------------------------------------------------------------
67
68
69// ----- Initialise daughters from geometry ----------------------------
71{
72
73 // --- Catch absence of TGeoManager
74 assert(gGeoManager);
75
76 // --- Catch physical node not being set
77 assert(fNode);
78
79 TGeoNode* moduleNode = fNode->GetNode(); // This node
80 TString modulePath = fNode->GetName(); // Full path to this node
81
82 for (Int_t iNode = 0; iNode < moduleNode->GetNdaughters(); iNode++) {
83
84 // Check name of daughter node for level name
85 TString daughterName = moduleNode->GetDaughter(iNode)->GetName();
86 if (daughterName.Contains("Sensor", TString::kIgnoreCase)) {
87
88 // Create physical node
89 TString daughterPath = modulePath + "/" + daughterName;
90 TGeoPhysicalNode* sensorNode = new TGeoPhysicalNode(daughterPath.Data());
91
92 // Get or create element from setup and add it as daughter
94 CbmStsSensor* sensor = new CbmStsSensor(address, sensorNode, this);
95 fDaughters.push_back(sensor);
96
97 } //? name of daughter node contains "sensor"
98
99 } //# daughter nodes
100}
101// -------------------------------------------------------------------------
102
103
104// ----- String output -------------------------------------------------
106{
107 stringstream ss;
108 ss << GetName() << ", address " << CbmStsAddress::ToString(fAddress);
109 return ss.str();
110}
111// -------------------------------------------------------------------------
112
113
ClassImp(CbmConverterManager)
@ kStsModule
@ kStsSensor
int Int_t
bool Bool_t
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.