Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,44 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
int extractNumberOfDisksVD() const;
int extractNumberOfChipsPerPetalVD() const;
int extractNumberOfStavesMLOT(int lay) const;
int extractNumberOfHalfStavesMLOT(int lay) const;

/// Extract number following the prefix in the name string
int extractVolumeCopy(const char* name, const char* prefix) const;

int getNumberOfLayersMLOT() const { return mNumberOfLayersMLOT; }
int getNumberOffActivePartsVD() const { return mNumberOfActivePartsVD; }
int getNumberOfActivePartsVD() const { return mNumberOfActivePartsVD; }
int getNumberOfHalfStaves(int lay) const { return mNumberOfHalfStaves[lay]; }

bool isOwner() const { return mOwner; }
void setOwner(bool v) { mOwner = v; }

void Print(Option_t* opt = "") const;
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int indexRetrieved) const;
void PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int indexRetrieved) const;

int getLayer(int index) const;
int getStave(int index) const;
int getHalfStave(int index) const;
int getSubDetID(int index) const;
int getPetalCase(int index) const;
int getDisk(int index) const;

/// This routine computes the chip index number from the subDetID, petal, disk, layer, stave /// TODO: retrieve also from chip when chips will be available
/// in substave
/// \param int subDetID The subdetector ID, 0 for VD, 1 for MLOT
/// \param int petalcase The petal case number for VD, from 0 to 3
/// \param int disk The disk number for VD, from 0 to 5
/// \param int lay The layer number. Starting from 0 both for VD and MLOT
/// \param int stave The stave number for MLOT. Starting from 0
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave) const;
/// \param int halfstave The half stave number for MLOT. Can be 0 or 1
int getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const;

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

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

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

bool mOwner = true; //! is it owned by the singleton?
Expand Down
117 changes: 90 additions & 27 deletions Detectors/Upgrades/ALICE3/TRK/base/src/GeometryTGeo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache(detectors
void GeometryTGeo::Build(int loadTrans)
{
///// current geometry organization:
///// total elements = 258 = x staves * 8 layers ML+OT + 4 petal cases * (3 layers + 6 disks)
///// total elements = x staves (*2 half staves if staggered geometry) * 8 layers ML+OT + 4 petal cases * (3 layers + 6 disks)
///// indexing from 0 to 35: VD petals -> layers -> disks
///// indexing from 36 to 257: MLOT staves
///// indexing from 36 to y: MLOT staves

if (isBuilt()) {
LOGP(warning, "Already built");
Expand All @@ -74,6 +74,7 @@ void GeometryTGeo::Build(int loadTrans)
mNumberOfDisksVD = extractNumberOfDisksVD();

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

int numberOfChipsTotal = 0;
Expand All @@ -99,13 +101,12 @@ void GeometryTGeo::Build(int loadTrans)

/// filling the information for the MLOT
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
mNumberOfChipsPerLayerMLOT[i] = extractNumberOfStavesMLOT(i); // for the moment, considering 1 stave = 1 chip. TODO: add the final segmentation in chips
mNumberOfChipsPerLayerMLOT[i] = extractNumberOfStavesMLOT(i) * extractNumberOfHalfStavesMLOT(i); // for the moment, considering 1 half stave = 1 chip. TODO: add the final segmentation in chips
numberOfChipsTotal += mNumberOfChipsPerLayerMLOT[i];
mLastChipIndex[i + mNumberOfPetalsVD] = numberOfChipsTotal - 1;
mLastChipIndexMLOT[i] = numberOfChipsTotal - 1;
}

// setSize(mNumberOfLayersMLOT + mNumberOfActivePartsVD); /// temporary, number of chips = number of layers and active parts
setSize(numberOfChipsTotal); /// temporary, number of chips = number of staves and active parts
fillMatrixCache(loadTrans);
}
Expand Down Expand Up @@ -155,7 +156,7 @@ int GeometryTGeo::getLayer(int index) const
while (index > mLastChipIndex[lay]) {
lay++;
}
return lay - mNumberOfPetalsVD; /// numeration of MLOT layesrs starting from 1
return lay - mNumberOfPetalsVD; /// numeration of MLOT layesrs starting from 0
}
return -1; /// -1 if not found
}
Expand All @@ -170,8 +171,26 @@ int GeometryTGeo::getStave(int index) const
return -1;
} else if (subDetID == 1) { /// MLOT
int lay = getLayer(index);
index -= getFirstChipIndex(lay, petalcase, subDetID);
return index; /// ||||
index -= getFirstChipIndex(lay, petalcase, subDetID); // get the index of the sensing element in the layer
return index / mNumberOfHalfStaves[lay];
}
return -1; /// not found
}

//__________________________________________________________________________
int GeometryTGeo::getHalfStave(int index) const
{
int subDetID = getSubDetID(index);
int lay = getLayer(index);
int petalcase = getPetalCase(index);
int stave = getStave(index);

if (subDetID == 0) { /// VD
return -1;
} else if (subDetID == 1) { /// MLOT
int lay = getLayer(index);
index -= getFirstChipIndex(lay, petalcase, subDetID); // get the index of the sensing element in the layer
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?
}
return -1; /// not found
}
Expand All @@ -193,28 +212,49 @@ int GeometryTGeo::getDisk(int index) const
}

//__________________________________________________________________________
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave) const
int GeometryTGeo::getChipIndex(int subDetID, int petalcase, int disk, int lay, int stave, int halfstave) const
{
if (subDetID == 0) { // VD
if (lay == -1) { // disk
return getFirstChipIndex(lay, petalcase, subDetID) + mNumberOfLayersVD + disk;
} else { // layer
return getFirstChipIndex(lay, petalcase, subDetID) + lay;
}
} else if (subDetID == 1) { // MLOT
return getFirstChipIndex(lay, petalcase, subDetID) + stave;
} else if (subDetID == 1) { // MLOT
if (mNumberOfHalfStaves[lay] == 2) { // staggered geometry
return getFirstChipIndex(lay, petalcase, subDetID) + stave * mNumberOfHalfStaves[lay] + halfstave;
} else if (mNumberOfHalfStaves[lay] == 1) { // turbo geometry
return getFirstChipIndex(lay, petalcase, subDetID) + stave;
}
}
return -1; // not found
}

//__________________________________________________________________________
int GeometryTGeo::getChipIndex(int subDetID, int volume, int lay, int stave, int halfstave) const
{
if (subDetID == 0) { // VD
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

} else if (subDetID == 1) { // MLOT
if (mNumberOfHalfStaves[lay] == 2) { // staggered geometry
return getFirstChipIndex(lay, -1, subDetID) + stave * mNumberOfHalfStaves[lay] + halfstave;
} else if (mNumberOfHalfStaves[lay] == 1) { // turbo geometry
return getFirstChipIndex(lay, -1, subDetID) + stave;
}
}
return -1; // not found
}

//__________________________________________________________________________
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave) const
bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk, int& lay, int& stave, int& halfstave) const
{
subDetID = getSubDetID(index);
petalcase = getPetalCase(index);
disk = getDisk(index);
lay = getLayer(index);
stave = getStave(index);
halfstave = getHalfStave(index);

return kTRUE;
}
Expand All @@ -223,13 +263,12 @@ bool GeometryTGeo::getChipID(int index, int& subDetID, int& petalcase, int& disk
TString GeometryTGeo::getMatrixPath(int index) const
{

// int lay, hba, stav, sstav, mod, chipInMod;
int subDetID, petalcase, disk, lay, stave; //// TODO: add chips in a second step
getChipID(index, subDetID, petalcase, disk, lay, stave);
int subDetID, petalcase, disk, lay, stave, halfstave; //// TODO: add chips in a second step
getChipID(index, subDetID, petalcase, disk, lay, stave, halfstave);

int indexRetrieved = getChipIndex(subDetID, petalcase, disk, lay, stave);
int indexRetrieved = getChipIndex(subDetID, petalcase, disk, lay, stave, halfstave);

PrintChipID(index, subDetID, petalcase, disk, lay, stave, indexRetrieved);
PrintChipID(index, subDetID, petalcase, disk, lay, stave, halfstave, indexRetrieved);

// TString path = Form("/cave_1/barrel_1/%s_2/", GeometryTGeo::getTRKVolPattern());
TString path = "/cave_1/barrel_1/TRKV_2/TRKLayer0_1/TRKStave0_1/TRKChip0_1/TRKSensor0_1/"; /// dummy path, to be replaced
Expand Down Expand Up @@ -291,7 +330,7 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
auto path = getMatrixPath(index);

static TGeoHMatrix matTmp;
gGeoManager->PushPath();
// gGeoManager->PushPath(); // Preserve the modeler state.

// if (!gGeoManager->cd(path.Data())) {
// gGeoManager->PopPath();
Expand Down Expand Up @@ -440,7 +479,6 @@ int GeometryTGeo::extractNumberOfActivePartsVD() const
if (vdV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKVolPattern() << " is not in the geometry";
}
LOG(info) << "Volume name: " << getTRKVolPattern();

// Loop on all TRKV nodes, count Layer volumes by checking names
TObjArray* nodes = vdV->GetNodes();
Expand Down Expand Up @@ -470,7 +508,6 @@ int GeometryTGeo::extractNumberOfDisksVD() const
if (vdV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKVolPattern() << " is not in the geometry";
}
LOG(info) << "Volume name: " << getTRKVolPattern();

// Loop on all TRKV nodes, count Layer volumes by checking names
TObjArray* nodes = vdV->GetNodes();
Expand Down Expand Up @@ -500,7 +537,6 @@ int GeometryTGeo::extractNumberOfPetalsVD() const
if (vdV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKVolPattern() << " is not in the geometry";
}
LOG(info) << "Volume name: " << getTRKVolPattern();

// Loop on all TRKV nodes, count Layer volumes by checking names
TObjArray* nodes = vdV->GetNodes();
Expand Down Expand Up @@ -530,7 +566,6 @@ int GeometryTGeo::extractNumberOfLayersVD() const
if (vdV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKVolPattern() << " is not in the geometry";
}
LOG(info) << "Volume name: " << getTRKVolPattern();

// Loop on all TRKV nodes, count Layer volumes by checking names
TObjArray* nodes = vdV->GetNodes();
Expand Down Expand Up @@ -560,7 +595,6 @@ int GeometryTGeo::extractNumberOfChipsPerPetalVD() const
if (vdV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKVolPattern() << " is not in the geometry";
}
LOG(info) << "Volume name: " << getTRKVolPattern();

// Loop on all TRKV nodes, count Layer volumes by checking names
TObjArray* nodes = vdV->GetNodes();
Expand Down Expand Up @@ -610,7 +644,35 @@ int GeometryTGeo::extractNumberOfStavesMLOT(int lay) const
}

//__________________________________________________________________________
void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int indexRetrieved) const
int GeometryTGeo::extractNumberOfHalfStavesMLOT(int lay) const
{
int numberOfHalfStaves = 0;

std::string staveName = Form("%s%d", getTRKStavePattern(), lay);
TGeoVolume* staveV = gGeoManager->GetVolume(staveName.c_str());

if (staveV == nullptr) {
LOG(fatal) << getName() << " volume " << getTRKStavePattern() << " is not in the geometry";
}

// Loop on all layV nodes, count Layer volumes by checking names
TObjArray* nodes = staveV->GetNodes();
// std::cout << "Printing nodes for layer " << lay << std::endl;
// nodes->Print();
int nNodes = nodes->GetEntriesFast();

for (int j = 0; j < nNodes; j++) {
auto nd = dynamic_cast<TGeoNode*>(nodes->At(j)); /// layer node
const char* name = nd->GetName();
if (strstr(name, getTRKChipPattern()) != nullptr) {
numberOfHalfStaves++;
}
}
return numberOfHalfStaves;
}

//__________________________________________________________________________
void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk, int lay, int stave, int halfstave, int indexRetrieved) const
{
std::cout << "\nindex = " << index << std::endl;
std::cout << "subDetID = " << subDetID << std::endl;
Expand All @@ -619,7 +681,8 @@ void GeometryTGeo::PrintChipID(int index, int subDetID, int petalcase, int disk,
std::cout << "disk = " << disk << std::endl;
std::cout << "first chip index = " << getFirstChipIndex(lay, petalcase, subDetID) << std::endl;
std::cout << "stave = " << stave << std::endl;
std::cout << "chck index Retrieved = " << indexRetrieved << std::endl;
std::cout << "halfstave = " << halfstave << std::endl;
std::cout << "check index Retrieved = " << indexRetrieved << std::endl;
}

//__________________________________________________________________________
Expand All @@ -641,11 +704,11 @@ void GeometryTGeo::Print(Option_t*) const
for (int i = 0; i < mNumberOfPetalsVD; i++) {
LOGF(info, "%d", mNumberOfChipsPerPetalVD[i]);
}
LOGF(info, "Number of staves per layer MLOT: ");
LOGF(info, "Number of staves and half staves per layer MLOT: ");
for (int i = 0; i < mNumberOfLayersMLOT; i++) {
std::string mlot = "";
mlot = (i < 5) ? "ML" : "OT";
LOGF(info, "Layer: %d, %s, %d staves", i, mlot.c_str(), mNumberOfStaves[i]);
mlot = (i < 4) ? "ML" : "OT";
LOGF(info, "Layer: %d, %s, %d staves, %d half staves per stave", i, mlot.c_str(), mNumberOfStaves[i], mNumberOfHalfStaves[i]);
}
LOGF(info, "Total number of chips: %d", getNumberOfChips());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ namespace trk
class Detector : public o2::base::DetImpl<Detector>
{
public:
static constexpr Int_t mNumberOfVolumes = 44; /// hardcoded for the current geometry = 8 MLOT layers + 36 volumes in the VD. TODO: automatize or change according to the current geometry
static constexpr Int_t mNumberOfVolumesVD = 36; /// hardcoded for the current geometry = 36 volumes in the VD. TODO: automatize or change according to the current geometry

Detector(bool active);
Detector();
~Detector();
Expand Down Expand Up @@ -96,6 +99,18 @@ class Detector : public o2::base::DetImpl<Detector>

void defineSensitiveVolumes();

protected:
std::vector<int> mSensorID; //! layer identifiers
std::vector<TString> mSensorName; //! layer names

public:
static constexpr Int_t sNumberVDPetalCases = 4; //! Number of VD petals
int getNumberOfLayers() const { return mLayers.size(); } //! Number of TRK layers
int getNumberOfLayersVD() const { return mPetalCases[0].mPetalLayers.size(); }
int getNumberOfDisksVD() const { return mPetalCases[0].mPetalDisks.size(); }

void Print(FairVolume* vol, int volume, int subDetID, int layer, int stave, int halfstave, int chipID) const;

template <typename Det>
friend class o2::base::DetImpl;
ClassDefOverride(Detector, 1);
Expand Down
Loading