Skip to content

Commit 1160d89

Browse files
committed
ALICE3-TRK: considering half staves for the staggered geometry for ML/OT
1 parent 9c392f6 commit 1160d89

File tree

3 files changed

+77
-21
lines changed

3 files changed

+77
-21
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
6060
int extractNumberOfDisksVD() const;
6161
int extractNumberOfChipsPerPetalVD() const;
6262
int extractNumberOfStavesMLOT(int lay) const;
63+
int extractNumberOfHalfStavesMLOT(int lay) const;
6364

6465
/// Extract number following the prefix in the name string
6566
int extractVolumeCopy(const char* name, const char* prefix) const;
@@ -71,10 +72,11 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
7172
void setOwner(bool v) { mOwner = v; }
7273

7374
void Print(Option_t* opt = "") const;
74-
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int indexRetrieved) const;
75+
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int indexRetrieved) const;
7576

7677
int getLayer(int index) const;
7778
int getStave(int index) const;
79+
int getHalfStave(int index) const;
7880
int getSubDetID(int index) const;
7981
int getPetalCase(int index) const;
8082
int getDisk(int index) const;
@@ -85,14 +87,16 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
8587
/// \param int disk The disk number for VD, from 0 to 5
8688
/// \param int lay The layer number. Starting from 0 both for VD and MLOT
8789
/// \param int stave The stave number for MLOT. Starting from 0
88-
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave) const;
90+
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
91+
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const;
8992

9093
/// This routine computes the chip index number from the subDetID, volume, layer, stave /// TODO: retrieve also from chip when chips will be available
9194
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
9295
/// \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
9396
/// \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
9497
/// \param int stave The stave number in each layer for MLOT. Starting from 0.
95-
int getChipIndex(int subDetID, int volume, int lay, int stave) const;
98+
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
99+
int getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave) const;
96100

97101
/// This routine computes subDetID, petal, disk, layer, stave given the chip index number /// TODO: copute also from chip when chips will be available
98102
/// \param int index The chip index number, starting from 0
@@ -101,7 +105,8 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
101105
/// \param int disk The disk number for VD, from 0 to 5
102106
/// \param int lay The layer number. Starting from 0 both for VD and MLOT
103107
/// \param int stave The stave number for MLOT. Starting from 0
104-
bool getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave) const;
108+
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
109+
bool getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave) const;
105110

106111
int getLastChipIndex(int lay) const { return mLastChipIndex[lay]; }
107112
int getFirstChipIndex(int lay, int petalcase, int subDetID) const
@@ -156,6 +161,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
156161
std::vector<int> mNumbersOfChipPerDiskVD; ///< numbersOfChipPerDiskVD
157162
std::vector<int> mNumberOfChipsPerPetalVD; ///< numbersOfChipPerPetalVD
158163
std::vector<int> mNumberOfStaves; ///< Number Of Staves per layer in ML/OT
164+
std::vector<int> mNumberOfHalfStaves; ///< Number Of Staves in each stave of the layer in ML/OT
159165
std::array<char, MAXLAYERS> mLayerToWrapper; ///< Layer to wrapper correspondence
160166

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

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

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void GeometryTGeo::Build(int loadTrans)
7474
mNumberOfDisksVD = extractNumberOfDisksVD();
7575

7676
mNumberOfStaves.resize(mNumberOfLayersMLOT);
77+
mNumberOfHalfStaves.resize(mNumberOfLayersMLOT);
7778
mLastChipIndex.resize(mNumberOfPetalsVD + mNumberOfLayersMLOT);
7879
mLastChipIndexVD.resize(mNumberOfPetalsVD);
7980
mLastChipIndexMLOT.resize(mNumberOfLayersMLOT); /// ML and OT are part of TRK as the same detector, without disks
@@ -85,6 +86,7 @@ void GeometryTGeo::Build(int loadTrans)
8586
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
8687
std::cout << "Layer MLOT: " << i << std::endl;
8788
mNumberOfStaves[i] = extractNumberOfStavesMLOT(i);
89+
mNumberOfHalfStaves[i] = extractNumberOfHalfStavesMLOT(i);
8890
}
8991

9092
int numberOfChipsTotal = 0;
@@ -99,7 +101,7 @@ void GeometryTGeo::Build(int loadTrans)
99101

100102
/// filling the information for the MLOT
101103
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
102-
mNumberOfChipsPerLayerMLOT[i] = extractNumberOfStavesMLOT(i); // for the moment, considering 1 stave = 1 chip. TODO: add the final segmentation in chips
104+
mNumberOfChipsPerLayerMLOT[i] = extractNumberOfStavesMLOT(i) * extractNumberOfHalfStavesMLOT(i); // for the moment, considering 1 half stave = 1 chip. TODO: add the final segmentation in chips
103105
numberOfChipsTotal += mNumberOfChipsPerLayerMLOT[i];
104106
mLastChipIndex[i + mNumberOfPetalsVD] = numberOfChipsTotal - 1;
105107
mLastChipIndexMLOT[i] = numberOfChipsTotal - 1;
@@ -170,8 +172,26 @@ int GeometryTGeo::getStave(int index) const
170172
return -1;
171173
} else if (subDetID == 1) { /// MLOT
172174
int lay = getLayer(index);
173-
index -= getFirstChipIndex(lay, petalcase, subDetID);
174-
return index; /// ||||
175+
index -= getFirstChipIndex(lay, petalcase, subDetID); // get the index of the sensing element in the layer
176+
return index / mNumberOfHalfStaves[lay];
177+
}
178+
return -1; /// not found
179+
}
180+
181+
//__________________________________________________________________________
182+
int GeometryTGeo::getHalfStave(int index) const
183+
{
184+
int subDetID = getSubDetID(index);
185+
int lay = getLayer(index);
186+
int petalcase = getPetalCase(index);
187+
int stave = getStave(index);
188+
189+
if (subDetID == 0) { /// VD
190+
return -1;
191+
} else if (subDetID == 1) { /// MLOT
192+
int lay = getLayer(index);
193+
index -= getFirstChipIndex(lay, petalcase, subDetID); // get the index of the sensing element in the layer
194+
return index % 2; /// 0 = half stave left, 1 = half stave right, as geometry is filled /// TODO: generalize once chips will be in place. Can it be working also with chips?
175195
}
176196
return -1; /// not found
177197
}
@@ -193,7 +213,7 @@ int GeometryTGeo::getDisk(int index) const
193213
}
194214

195215
//__________________________________________________________________________
196-
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave) const
216+
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
197217
{
198218
if (subDetID == 0) { // VD
199219
if (lay == -1) { // disk
@@ -202,31 +222,32 @@ int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, i
202222
return getFirstChipIndex(lay, petalcase, subDetID) + lay;
203223
}
204224
} else if (subDetID == 1) { // MLOT
205-
return getFirstChipIndex(lay, petalcase, subDetID) + stave;
225+
return getFirstChipIndex(lay, petalcase, subDetID) + stave * mNumberOfHalfStaves[lay] + halfstave;
206226
}
207227
return -1; // not found
208228
}
209229

210230
//__________________________________________________________________________
211-
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave) const
231+
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave) const
212232
{
213233
if (subDetID == 0) { // VD
214234
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
215235

216236
} else if (subDetID == 1) { // MLOT
217-
return getFirstChipIndex(lay, -1, subDetID) + stave;
237+
return getFirstChipIndex(lay, -1, subDetID) + stave * mNumberOfHalfStaves[lay] + halfstave;
218238
}
219239
return -1; // not found
220240
}
221241

222242
//__________________________________________________________________________
223-
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave) const
243+
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave) const
224244
{
225245
subDetID = getSubDetID(index);
226246
petalcase = getPetalCase(index);
227247
disk = getDisk(index);
228248
lay = getLayer(index);
229249
stave = getStave(index);
250+
halfstave = getHalfStave(index);
230251

231252
return kTRUE;
232253
}
@@ -236,12 +257,12 @@ TString GeometryTGeo::getMatrixPath(int index) const
236257
{
237258

238259
// int lay, hba, stav, sstav, mod, chipInMod;
239-
int subDetID, petalcase, disk, lay, stave; //// TODO: add chips in a second step
240-
getChipID(index, subDetID, petalcase, disk, lay, stave);
260+
int subDetID, petalcase, disk, lay, stave, halfstave; //// TODO: add chips in a second step
261+
getChipID(index, subDetID, petalcase, disk, lay, stave, halfstave);
241262

242-
int indexRetrieved = getChipIndex(subDetID, petalcase, disk, lay, stave);
263+
int indexRetrieved = getChipIndex(subDetID, petalcase, disk, lay, stave, halfstave);
243264

244-
PrintChipID(index, subDetID, petalcase, disk, lay, stave, indexRetrieved);
265+
PrintChipID(index, subDetID, petalcase, disk, lay, stave, halfstave, indexRetrieved);
245266

246267
// TString path = Form("/cave_1/barrel_1/%s_2/", GeometryTGeo::getTRKVolPattern());
247268
TString path = "/cave_1/barrel_1/TRKV_2/TRKLayer0_1/TRKStave0_1/TRKChip0_1/TRKSensor0_1/"; /// dummy path, to be replaced
@@ -617,7 +638,35 @@ int GeometryTGeo::extractNumberOfStavesMLOT(int lay) const
617638
}
618639

619640
//__________________________________________________________________________
620-
void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int indexRetrieved) const
641+
int GeometryTGeo::extractNumberOfHalfStavesMLOT(int lay) const
642+
{
643+
int numberOfHalfStaves = 0;
644+
645+
std::string staveName = Form("%s%d", getTRKStavePattern(), lay);
646+
TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());
647+
648+
if (staveV == nullptr) {
649+
LOG(fatal) << getName() << " volume " << getTRKStavePattern() << " is not in the geometry";
650+
}
651+
652+
// Loop on all layV nodes, count Layer volumes by checking names
653+
TObjArray* nodes = staveV->GetNodes();
654+
// std::cout << "Printing nodes for layer " << lay << std::endl;
655+
// nodes->Print();
656+
int nNodes = nodes->GetEntriesFast();
657+
658+
for (int j = 0; j < nNodes; j++) {
659+
auto nd = dynamic_cast<TGeoNode*>(nodes->At(j)); /// layer node
660+
const char* name = nd->GetName();
661+
if (strstr(name, getTRKChipPattern()) != nullptr) {
662+
numberOfHalfStaves++;
663+
}
664+
}
665+
return numberOfHalfStaves;
666+
}
667+
668+
//__________________________________________________________________________
669+
void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int indexRetrieved) const
621670
{
622671
std::cout << "\nindex = " << index << std::endl;
623672
std::cout << "subDetID = " << subDetID << std::endl;
@@ -626,7 +675,8 @@ void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk,
626675
std::cout << "disk = " << disk << std::endl;
627676
std::cout << "first chip index = " << getFirstChipIndex(lay, petalcase, subDetID) << std::endl;
628677
std::cout << "stave = " << stave << std::endl;
629-
std::cout << "chck index Retrieved = " << indexRetrieved << std::endl;
678+
std::cout << "halfstave = " << halfstave << std::endl;
679+
std::cout << "check index Retrieved = " << indexRetrieved << std::endl;
630680
}
631681

632682
//__________________________________________________________________________
@@ -648,11 +698,11 @@ void GeometryTGeo::Print(Option_t*) const
648698
for (int i = 0; i < mNumberOfPetalsVD; i++) {
649699
LOGF(info, "%d", mNumberOfChipsPerPetalVD[i]);
650700
}
651-
LOGF(info, "Number of staves per layer MLOT: ");
701+
LOGF(info, "Number of staves and half staves per layer MLOT: ");
652702
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
653703
std::string mlot = "";
654704
mlot = (i < 5) ? "ML" : "OT";
655-
LOGF(info, "Layer: %d, %s, %d staves", i, mlot.c_str(), mNumberOfStaves[i]);
705+
LOGF(info, "Layer: %d, %s, %d staves, %d half staves", i, mlot.c_str(), mNumberOfStaves[i], mNumberOfStaves[i] * mNumberOfHalfStaves[i]);
656706
}
657707
LOGF(info, "Total number of chips: %d", getNumberOfChips());
658708

Detectors/Upgrades/ALICE3/TRK/simulation/src/Detector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ bool Detector::ProcessHits(FairVolume* vol)
452452
fMC->CurrentVolOffID(2, stave);
453453
} /// if VD, for the moment the volume is the "chipID" so no need to retrieve other elments
454454

455-
int chipID = mGeometryTGeo->getChipIndex(subDetID, volume, layer, stave);
455+
int chipID = mGeometryTGeo->getChipIndex(subDetID, volume, layer, stave, halfstave);
456456

457457
Print(vol, volume, subDetID, layer, stave, halfstave, chipID);
458458

0 commit comments

Comments
 (0)