Skip to content

Commit 336dcef

Browse files
committed
Update indexing scheme
1 parent 614f9a9 commit 336dcef

File tree

2 files changed

+111
-21
lines changed

2 files changed

+111
-21
lines changed

Detectors/Upgrades/ALICE3/TRK/base/include/TRKBase/GeometryTGeo.h

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
4646
static const char* getTRKPetalDiskPattern() { return sPetalDiskName.c_str(); }
4747
static const char* getTRKPetalLayerPattern() { return sPetalLayerName.c_str(); }
4848
static const char* getTRKStavePattern() { return sStaveName.c_str(); }
49+
static const char* getTRKHalfStavePattern() { return sHalfStaveName.c_str(); }
4950
static const char* getTRKModulePattern() { return sModuleName.c_str(); }
5051
static const char* getTRKChipPattern() { return sChipName.c_str(); }
5152
static const char* getTRKSensorPattern() { return sSensorName.c_str(); }
@@ -64,6 +65,8 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
6465
int extractNumberOfChipsPerPetalVD() const;
6566
int extractNumberOfStavesMLOT(int lay) const;
6667
int extractNumberOfHalfStavesMLOT(int lay) const;
68+
int extractNumberOfModulesMLOT(int lay) const;
69+
int extractNumberOfChipsMLOT(int lay) const;
6770

6871
/// Extract number following the prefix in the name string
6972
int extractVolumeCopy(const char* name, const char* prefix) const;
@@ -85,6 +88,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
8588
int getHalfStave(int index) const;
8689
int getDisk(int index) const;
8790
int getModule(int index) const;
91+
int getChip(int index) const;
8892

8993
/// This routine computes the chip index number from the subDetID, petal, disk, layer, stave /// TODO: retrieve also from chip when chips will be available
9094
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
@@ -93,15 +97,19 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
9397
/// \param int lay The layer number. Starting from 0 both for VD and MLOT
9498
/// \param int stave The stave number for MLOT. Starting from 0
9599
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
96-
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const;
100+
/// \param int module The module number for MLOT, from 0 to 10 (or 20)
101+
/// \param int chip The chip number for MLOT, from 0 to 8
102+
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int module, int chip) const;
97103

98104
/// This routine computes the chip index number from the subDetID, volume, layer, stave /// TODO: retrieve also from chip when chips will be available
99105
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
100106
/// \param int volume is needed only with the current configuration for VD where each single element is a volume. // TODO: when the geometry naming scheme will be changed, change this method
101107
/// \param int lay The layer number for the MLOT. In the current configuration for VD this is not needed. // TODO: when the geometry naming scheme will be changed, change this method
102108
/// \param int stave The stave number in each layer for MLOT. Starting from 0.
103109
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
104-
int getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave) const;
110+
/// \param int module The module number for MLOT, from 0 to 10 (or 20)
111+
/// \param int chip The chip number for MLOT, from 0 to 8
112+
int getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int module, int chip) const;
105113

106114
/// This routine computes subDetID, petal, disk, layer, stave given the chip index number /// TODO: copute also from chip when chips will be available
107115
/// \param int index The chip index number, starting from 0
@@ -111,7 +119,9 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
111119
/// \param int lay The layer number. Starting from 0 both for VD and MLOT
112120
/// \param int stave The stave number for MLOT. Starting from 0
113121
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
114-
bool getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave) const;
122+
/// \param int module The module number for MLOT, from 0 to 10 (or 20)
123+
/// \param int chip The chip number for MLOT, from 0 to 8
124+
bool getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave, int& module, int& chip) const;
115125

116126
int getLastChipIndex(int lay) const { return mLastChipIndex[lay]; }
117127
int getFirstChipIndex(int lay, int petalcase, int subDetID) const
@@ -147,6 +157,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
147157
static std::string sPetalDiskName;
148158
static std::string sPetalLayerName;
149159
static std::string sStaveName;
160+
static std::string sHalfStaveName;
150161
static std::string sModuleName;
151162
static std::string sChipName;
152163
static std::string sSensorName;
@@ -159,16 +170,22 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
159170
Int_t mNumberOfLayersVD; ///< number of layers
160171
Int_t mNumberOfPetalsVD; ///< number of Petals = chip in each VD layer
161172
Int_t mNumberOfDisksVD; ///< number of Disks = 6
162-
std::vector<int> mLastChipIndex; ///< max ID of the detctor in the petal(VD) or layer(MLOT)
163-
std::vector<int> mLastChipIndexVD; ///< max ID of the detctor in the layer for the VD
164-
std::vector<int> mLastChipIndexMLOT; ///< max ID of the detctor in the layer for the MLOT
173+
std::vector<int> mNumberOfStaves; ///< Number Of Staves per layer in ML/OT
174+
std::vector<int> mNumberOfHalfStaves; ///< Number Of Half staves in each stave of the layer in ML/OT
175+
std::vector<int> mNumberOfModules; ///< Number Of Modules per stave (half stave) in ML/OT
176+
std::vector<int> mNumberOfChips; ///< number of chips per module in ML/OT
165177
std::vector<int> mNumberOfChipsPerLayerVD; ///< number of chips per layer VD ( = number of petals)
166-
std::vector<int> mNumberOfChipsPerLayerMLOT; ///< number of chips per layer MLOT ( = 1 for the moment)
178+
std::vector<int> mNumberOfChipsPerLayerMLOT; ///< number of chips per layer MLOT
167179
std::vector<int> mNumbersOfChipPerDiskVD; ///< numbersOfChipPerDiskVD
168180
std::vector<int> mNumberOfChipsPerPetalVD; ///< numbersOfChipPerPetalVD
169-
std::vector<int> mNumberOfStaves; ///< Number Of Staves per layer in ML/OT
170-
std::vector<int> mNumberOfHalfStaves; ///< Number Of Staves in each stave of the layer in ML/OT
171-
std::array<char, MAXLAYERS> mLayerToWrapper; ///< Layer to wrapper correspondence
181+
// std::vector<int> mNumberOfChipsPerStave; ///< number of chips per stave in ML/OT
182+
// std::vector<int> mNumberOfChipsPerHalfStave; ///< number of chips per half stave in ML/OT
183+
// std::vector<int> mNumberOfChipsPerModule; ///< number of chips per module in ML/OT
184+
std::vector<int> mLastChipIndex; ///< max ID of the detctor in the petal(VD) or layer(MLOT)
185+
std::vector<int> mLastChipIndexVD; ///< max ID of the detctor in the layer for the VD
186+
std::vector<int> mLastChipIndexMLOT; ///< max ID of the detctor in the layer for the MLOT
187+
188+
std::array<char, MAXLAYERS> mLayerToWrapper; ///< Layer to wrapper correspondence, not implemented yet
172189

173190
bool mOwner = true; //! is it owned by the singleton?
174191

Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx

Lines changed: 84 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ std::string GeometryTGeo::sPetalName = "PETALCASE";
2828
std::string GeometryTGeo::sPetalDiskName = "DISK";
2929
std::string GeometryTGeo::sPetalLayerName = "LAYER";
3030
std::string GeometryTGeo::sStaveName = "TRKStave";
31+
std::string GeometryTGeo::sHalfStaveName = "TRKHalfStave";
3132
std::string GeometryTGeo::sModuleName = "TRKModule";
3233
std::string GeometryTGeo::sChipName = "TRKChip";
3334
std::string GeometryTGeo::sSensorName = "TRKSensor";
@@ -78,18 +79,24 @@ void GeometryTGeo::Build(int loadTrans)
7879

7980
mNumberOfStaves.resize(mNumberOfLayersMLOT);
8081
mNumberOfHalfStaves.resize(mNumberOfLayersMLOT);
81-
mLastChipIndex.resize(mNumberOfPetalsVD + mNumberOfLayersMLOT);
82-
mLastChipIndexVD.resize(mNumberOfPetalsVD);
83-
mLastChipIndexMLOT.resize(mNumberOfLayersMLOT); /// ML and OT are part of TRK as the same detector, without disks
82+
mNumberOfModules.resize(mNumberOfLayersMLOT);
83+
mNumberOfChips.resize(mNumberOfLayersMLOT);
84+
8485
mNumberOfChipsPerLayerVD.resize(mNumberOfLayersVD);
8586
mNumberOfChipsPerLayerMLOT.resize(mNumberOfLayersMLOT);
8687
mNumbersOfChipPerDiskVD.resize(mNumberOfDisksVD);
8788
mNumberOfChipsPerPetalVD.resize(mNumberOfPetalsVD);
8889

90+
mLastChipIndex.resize(mNumberOfPetalsVD + mNumberOfLayersMLOT);
91+
mLastChipIndexVD.resize(mNumberOfPetalsVD);
92+
mLastChipIndexMLOT.resize(mNumberOfLayersMLOT); /// ML and OT are part of TRK as the same detector, without disks
93+
8994
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
9095
std::cout << "Layer MLOT: " << i << std::endl;
9196
mNumberOfStaves[i] = extractNumberOfStavesMLOT(i);
9297
mNumberOfHalfStaves[i] = extractNumberOfHalfStavesMLOT(i);
98+
mNumberOfModules[i] = extractNumberOfModulesMLOT(i);
99+
mNumberOfChips[i] = extractNumberOfChipsMLOT(i);
93100
}
94101

95102
int numberOfChipsTotal = 0;
@@ -104,13 +111,13 @@ void GeometryTGeo::Build(int loadTrans)
104111

105112
/// filling the information for the MLOT
106113
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
107-
mNumberOfChipsPerLayerMLOT[i] = extractNumberOfStavesMLOT(i) * extractNumberOfHalfStavesMLOT(i); // for the moment, considering 1 half stave = 1 chip. TODO: add the final segmentation in chips
114+
mNumberOfChipsPerLayerMLOT[i] = mNumberOfStaves[i] * mNumberOfHalfStaves[i] * mNumberOfModules[i] * mNumberOfChips[i];
108115
numberOfChipsTotal += mNumberOfChipsPerLayerMLOT[i];
109116
mLastChipIndex[i + mNumberOfPetalsVD] = numberOfChipsTotal - 1;
110117
mLastChipIndexMLOT[i] = numberOfChipsTotal - 1;
111118
}
112119

113-
setSize(numberOfChipsTotal); /// temporary, number of chips = number of staves and active parts
120+
setSize(numberOfChipsTotal);
114121
fillMatrixCache(loadTrans);
115122
}
116123

@@ -221,7 +228,15 @@ int GeometryTGeo::getModule(int index) const
221228
}
222229

223230
//__________________________________________________________________________
224-
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
231+
int GeometryTGeo::getChip(int index) const
232+
{
233+
int subDetID = getSubDetID(index);
234+
235+
return -1; /// not implemented yet
236+
}
237+
238+
//__________________________________________________________________________
239+
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int module, int chip) const
225240
{
226241
if (subDetID == 0) { // VD
227242
if (lay == -1) { // disk
@@ -240,7 +255,7 @@ int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, i
240255
}
241256

242257
//__________________________________________________________________________
243-
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave) const
258+
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave, int module, int chip) const
244259
{
245260
if (subDetID == 0) { // VD
246261
return volume; /// In the current configuration for VD, each volume is the sensor element = chip. // TODO: when the geometry naming scheme will be changed, change this method
@@ -256,14 +271,16 @@ int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int
256271
}
257272

258273
//__________________________________________________________________________
259-
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave) const
274+
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave, int& module, int& chip) const
260275
{
261276
subDetID = getSubDetID(index);
262277
petalcase = getPetalCase(index);
263278
disk = getDisk(index);
264279
lay = getLayer(index);
265280
stave = getStave(index);
266281
halfstave = getHalfStave(index);
282+
module = getModule(index);
283+
chip = getChip(index);
267284

268285
return kTRUE;
269286
}
@@ -272,8 +289,8 @@ bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk
272289
TString GeometryTGeo::getMatrixPath(int index) const
273290
{
274291

275-
int subDetID, petalcase, disk, layer, stave, halfstave; //// TODO: add chips in a second step
276-
getChipID(index, subDetID, petalcase, disk, layer, stave, halfstave);
292+
int subDetID, petalcase, disk, layer, stave, halfstave, module, chip; //// TODO: add chips in a second step
293+
getChipID(index, subDetID, petalcase, disk, layer, stave, halfstave, module, chip);
277294

278295
// PrintChipID(index, subDetID, petalcase, disk, layer, stave, halfstave);
279296

@@ -662,13 +679,69 @@ int GeometryTGeo::extractNumberOfHalfStavesMLOT(int lay) const
662679
for (int j = 0; j < nNodes; j++) {
663680
auto nd = dynamic_cast<TGeoNode*>(nodes->At(j)); /// layer node
664681
const char* name = nd->GetName();
665-
if (strstr(name, getTRKChipPattern()) != nullptr) {
682+
if (strstr(name, getTRKHalfStavePattern()) != nullptr) {
666683
numberOfHalfStaves++;
667684
}
668685
}
686+
687+
if (numberOfHalfStaves == 0) {
688+
numberOfHalfStaves = 1; /// in case of turbo geometry, there is no half stave volume, but only stave volume
689+
}
669690
return numberOfHalfStaves;
670691
}
671692

693+
//__________________________________________________________________________
694+
int GeometryTGeo::extractNumberOfModulesMLOT(int lay) const
695+
{
696+
int numberOfModules = 0;
697+
698+
std::string staveName = Form("%s%d", getTRKStavePattern(), lay);
699+
TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
700+
701+
if (staveV == nullptr) {
702+
LOG(fatal) << getName() << " volume " << getTRKStavePattern() << " is not in the geometry";
703+
}
704+
705+
// Loop on all staveV nodes, count Module volumes by checking names
706+
TObjArray* nodes = staveV->GetNodes();
707+
int nNodes = nodes->GetEntriesFast();
708+
709+
for (int j = 0; j < nNodes; j++) {
710+
auto nd = dynamic_cast<TGeoNode*>(nodes->At(j)); /// stave node
711+
const char* name = nd->GetName();
712+
if (strstr(name, getTRKModulePattern()) != nullptr) {
713+
numberOfModules++;
714+
}
715+
}
716+
return numberOfModules;
717+
}
718+
719+
//__________________________________________________________________________
720+
int GeometryTGeo::extractNumberOfChipsMLOT(int lay) const
721+
{
722+
int numberOfChips = 0;
723+
724+
std::string moduleName = Form("%s%d", getTRKModulePattern(), lay);
725+
TGeoVolume* moduleV = gGeoManager->GetVolume(moduleName.c_str());
726+
727+
if (moduleV == nullptr) {
728+
LOG(fatal) << getName() << " volume " << getTRKModulePattern() << " is not in the geometry";
729+
}
730+
731+
// Loop on all moduleV nodes, count Chip volumes by checking names
732+
TObjArray* nodes = moduleV->GetNodes();
733+
int nNodes = nodes->GetEntriesFast();
734+
735+
for (int j = 0; j < nNodes; j++) {
736+
auto nd = dynamic_cast<TGeoNode*>(nodes->At(j)); /// module node
737+
const char* name = nd->GetName();
738+
if (strstr(name, getTRKChipPattern()) != nullptr) {
739+
numberOfChips++;
740+
}
741+
}
742+
return numberOfChips;
743+
}
744+
672745
//__________________________________________________________________________
673746
void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
674747
{

0 commit comments

Comments
 (0)