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 @@ -21,8 +21,8 @@
#include <memory>
#include "DetectorsCommonDataFormats/DetMatrixCache.h"
#include "DetectorsCommonDataFormats/DetID.h"
//#include "MathUtils/Utils.h"
//#include "Rtypes.h" // for Int_t, Double_t, Bool_t, UInt_t, etc
// #include "MathUtils/Utils.h"
// #include "Rtypes.h" // for Int_t, Double_t, Bool_t, UInt_t, etc

namespace o2
{
Expand Down Expand Up @@ -58,21 +58,21 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
int extractNumberOfDiscs(int dir);
int extractNumberOfChips(int dir, int layer);
int extractChipId(std::string const volName);
void extractStaveChipId(std::string const volName, int &stave, int&chip);
void extractChipIds(std::string const volName, int &direction, int &layer, int &stave, int&chip);
void extractStaveChipId(std::string const volName, int& stave, int& chip);
void extractChipIds(std::string const volName, int& direction, int& layer, int& stave, int& chip);

int getChipIndex(int dir, int disc, int stave, int chip) const;
//int getDisk(int index) const {return -1;} // TODO: implement this
// int getDisk(int index) const {return -1;} // TODO: implement this
int getLayer(int chipIdx) const;
std::string getMatrixPath(int direction, int layer, int stave, int chip) const;
int getNumberOfChips() const { return mSize;}
int getNumberOfChips() const { return mSize; }
int getNumberOfLayers() const { return mNumberOfDiscs[0] + mNumberOfDiscs[1]; }
int getNumberOfStaves(int absDisc) const {return mNumberOfStavesPerDisc[absDisc]; }
int getSubDetID(int) const { return 2;}
int getNumberOfStaves(int absDisc) const { return mNumberOfStavesPerDisc[absDisc]; }
int getSubDetID(int) const { return 2; }
int getStave(int chipIdx) const;
int getChipOnStave(int chipIdx) const;
int getStaveIdxDisc(int absDisc) const { return mStaveIdxDisc[absDisc];}
int getChipIdxStave(int absStave) const { return mChipIdxStave[absStave];}
int getStaveIdxDisc(int absDisc) const { return mStaveIdxDisc[absDisc]; }
int getChipIdxStave(int absStave) const { return mChipIdxStave[absStave]; }
/// Exract FT3 parameters from TGeo

bool isOwner() const { return mOwner; }
Expand All @@ -85,13 +85,12 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
static const char* getFT3ChipPattern() { return sChipName.c_str(); }
static const char* getFT3SensorPattern() { return sSensorName.c_str(); }
static const char* getFT3PassivePattern() { return sPassiveName.c_str(); }

static const char* composeSymNameFT3(Int_t d) { return Form("%s_%d", o2::detectors::DetID(o2::detectors::DetID::FT3).getName(), d); }
static const char* composeSymNameLayer(Int_t d, Int_t lr);
static const char* composeSymNameChip(Int_t d, Int_t lr);
static const char* composeSymNameSensor(Int_t d, Int_t lr);


protected:
static std::string sInnerVolumeName; ///< Mother inner volume name
static std::string sVolumeName; ///< Mother volume name
Expand All @@ -100,19 +99,19 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache
static std::string sSensorName; ///< Sensor name
static std::string sPassiveName; ///< Passive material name

std::vector<float> mCacheRefXDiscs; /// cache for X of ML and OT
std::vector<float> mCacheRefAlphaDiscs; /// cache for sensor ref alpha ML and OT
std::vector<int> mNumberOfDiscs; ///< Number Discs per direction
std::vector<int> mNumberOfStavesPerDisc; /// TODO; in principle redundant?
std::vector<int> mStaveIdxDisc; /// Index of first global stave Id for each disc
std::vector<int> mChipIdxStave; /// Index of first chup for each global stave
std::vector<int> mNumberOfChipsPerDisc; ///
//std::vector<unsigned int> mChipIndexLayer; ///< ID of first chip in the layer
//std::vector<int> mChipStaveIds;
std::vector<float> mCacheRefXDiscs; /// cache for X of ML and OT
std::vector<float> mCacheRefAlphaDiscs; /// cache for sensor ref alpha ML and OT
std::vector<int> mNumberOfDiscs; ///< Number Discs per direction
std::vector<int> mNumberOfStavesPerDisc; /// TODO; in principle redundant?
std::vector<int> mStaveIdxDisc; /// Index of first global stave Id for each disc
std::vector<int> mChipIdxStave; /// Index of first chup for each global stave
std::vector<int> mNumberOfChipsPerDisc; ///
// std::vector<unsigned int> mChipIndexLayer; ///< ID of first chip in the layer
// std::vector<int> mChipStaveIds;

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

private:
private:
static std::unique_ptr<o2::ft3::GeometryTGeo> sInstance; ///< singleton instance
};

Expand Down
123 changes: 68 additions & 55 deletions Detectors/Upgrades/ALICE3/TRKFT3/FT3/base/src/GeometryTGeo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ std::string GeometryTGeo::sInnerVolumeName = "FT3Inner"; ///< Mother inner volum
std::string GeometryTGeo::sLayerName = "FT3Layer"; ///< Layer name
std::string GeometryTGeo::sChipName = "FT3Chip"; ///< Chip name
// TODO: this is now only used for the not-segmented version; synchronise?
std::string GeometryTGeo::sSensorName = "FT3Sensor"; ///< Sensor name
std::string GeometryTGeo::sPassiveName = "Passive"; ///< Passive material name
std::string GeometryTGeo::sSensorName = "FT3Sensor"; ///< Sensor name
std::string GeometryTGeo::sPassiveName = "Passive"; ///< Passive material name

GeometryTGeo::~GeometryTGeo()
{
Expand Down Expand Up @@ -86,33 +86,33 @@ void GeometryTGeo::Build(int loadTrans)
}

// Forward discs part
//int sensIdx = 0;
// int sensIdx = 0;
int totDiscs = 0;
int absStaveIdx = 0;
mSize = 0;
// TODO: clean up initialisation
if (mChipIdxStave.size() == 0)
{
if (mChipIdxStave.size() == 0) {
mChipIdxStave.push_back(0);
}
if (mStaveIdxDisc.size() == 0)
{
if (mStaveIdxDisc.size() == 0) {
mStaveIdxDisc.push_back(0);
}
for (int iDir = 0; iDir < 2; iDir++) {
mNumberOfDiscs.push_back(extractNumberOfDiscs(iDir));
LOG(info) << "direction " << iDir << " has " << mNumberOfDiscs[iDir] << " discs";
totDiscs += mNumberOfDiscs[iDir];

for (int iDisc = 0; iDisc < mNumberOfDiscs[iDir]; iDisc++) {
TGeoVolume* ft3V = gGeoManager->GetVolume(getFT3VolPattern());
if (ft3V == nullptr) {
LOG(fatal) << getName() << " volume " << getFT3VolPattern() << " is not in the geometry";
}
auto layerNode = ft3V->GetNode(Form("%s_1", composeSymNameLayer(iDir,iDisc)));
if (layerNode == nullptr) LOG(fatal) << "Could not find layer node " << Form("%s_1", composeSymNameLayer(iDir,iDisc));
auto layerNode = ft3V->GetNode(Form("%s_1", composeSymNameLayer(iDir, iDisc)));
if (layerNode == nullptr)
LOG(fatal) << "Could not find layer node " << Form("%s_1", composeSymNameLayer(iDir, iDisc));
auto layerVol = layerNode->GetVolume();
if (layerVol == nullptr) LOG(fatal) << "Could not find layer volume " << Form("%s_1",composeSymNameLayer(iDir,iDisc));
if (layerVol == nullptr)
LOG(fatal) << "Could not find layer volume " << Form("%s_1", composeSymNameLayer(iDir, iDisc));
TObjArray* nodes = layerVol->GetNodes();
int nNodes = nodes->GetEntriesFast();
int nStaves = 0;
Expand Down Expand Up @@ -142,21 +142,23 @@ void GeometryTGeo::Build(int loadTrans)
mChipIdxStave.resize(absStaveIdx + chipsPerStave.size() + 1);
mNumberOfStavesPerDisc.push_back(chipsPerStave.size()); // TODO: remove this? Or remove StaveIdxDisc
int totSensor = 0;
for (int nChips: chipsPerStave) {
for (int nChips : chipsPerStave) {
LOG(debug) << "Absolute Stave ID " << absStaveIdx << " : " << nChips << " sensors";
totSensor += nChips;
if (absStaveIdx) mChipIdxStave[absStaveIdx + 1] = mChipIdxStave[absStaveIdx] + nChips;
if (absStaveIdx)
mChipIdxStave[absStaveIdx + 1] = mChipIdxStave[absStaveIdx] + nChips;
absStaveIdx++;
}
if (totSensor != nSensor) LOG(info) << "Inconsistency in sensor count " << nSensor << " " << totSensor;
if (totSensor != nSensor)
LOG(info) << "Inconsistency in sensor count " << nSensor << " " << totSensor;
LOG(debug) << " adding stave Idx " << absStaveIdx << " to disc array; element " << mStaveIdxDisc.size();
mStaveIdxDisc.push_back(absStaveIdx);
mNumberOfChipsPerDisc.push_back(totSensor);
mSize += totSensor;
LOG(info) << "Total sensors so far " << mSize;
}
}
//mSize = mChipStaveIds.size();
// mSize = mChipStaveIds.size();
LOG(info) << "Total sensors " << mSize;
LOG(info) << "Length of stave-disc array " << mStaveIdxDisc.size();
fillMatrixCache(loadTrans); // Check whether this causes trouble
Expand All @@ -165,7 +167,7 @@ void GeometryTGeo::Build(int loadTrans)
//__________________________________________________________________________
const char* GeometryTGeo::composeSymNameLayer(int direction, int layerNumber)
{
return Form("%s%d_%d",GeometryTGeo::getFT3LayerPattern(), direction, layerNumber);
return Form("%s%d_%d", GeometryTGeo::getFT3LayerPattern(), direction, layerNumber);
}

//__________________________________________________________________________
Expand All @@ -181,19 +183,23 @@ const char* GeometryTGeo::composeSymNameSensor(Int_t d, Int_t lr)
}

//__________________________________________________________________________
int GeometryTGeo::extractNumberOfDiscs(int dir) {
int GeometryTGeo::extractNumberOfDiscs(int dir)
{
int numDiscs = 0;
while (gGeoManager->GetVolume(composeSymNameLayer(dir,numDiscs))) {numDiscs++;} // Check maybe subvolume?
while (gGeoManager->GetVolume(composeSymNameLayer(dir, numDiscs))) {
numDiscs++;
} // Check maybe subvolume?
return numDiscs; // Assume same # layers on both sides
}
//__________________________________________________________________________
int GeometryTGeo::extractNumberOfChips(int dir, int layer) {
int GeometryTGeo::extractNumberOfChips(int dir, int layer)
{
int numSensors = 0;
TGeoVolume* ft3V = gGeoManager->GetVolume(getFT3VolPattern());
if (ft3V == nullptr) {
LOG(fatal) << getName() << " volume " << getFT3VolPattern() << " is not in the geometry";
}
auto layerVol = ft3V->GetNode(Form("%s_1",composeSymNameLayer(dir,layer)))->GetVolume();
auto layerVol = ft3V->GetNode(Form("%s_1", composeSymNameLayer(dir, layer)))->GetVolume();
TObjArray* nodes = layerVol->GetNodes();
int nNodes = nodes->GetEntriesFast();
int nSensor = 0;
Expand All @@ -208,27 +214,30 @@ int GeometryTGeo::extractNumberOfChips(int dir, int layer) {
return nSensor;
}
//__________________________________________________________________________
int GeometryTGeo::extractChipId(std::string const volName) {
if (volName.find("FT3Sensor_Active")==0) {
return std::stoi(volName.substr(volName.rfind('_')+1));
int GeometryTGeo::extractChipId(std::string const volName)
{
if (volName.find("FT3Sensor_Active") == 0) {
return std::stoi(volName.substr(volName.rfind('_') + 1));
}
LOG(error) << "Not a sensor volume " << volName;
return -1;
}
void GeometryTGeo::extractStaveChipId(std::string const volName, int &stave, int &chip) {
if (volName.find("FT3Sensor_Active")==0) {
void GeometryTGeo::extractStaveChipId(std::string const volName, int& stave, int& chip)
{
if (volName.find("FT3Sensor_Active") == 0) {
int idx = volName.rfind('_');
chip = std::stoi(volName.substr(idx+1));
idx = volName.rfind('_',idx);
stave = std::stoi(volName.substr(idx+1));
}
else {
chip = std::stoi(volName.substr(idx + 1));
idx = volName.rfind('_', idx);
stave = std::stoi(volName.substr(idx + 1));
} else {
LOG(error) << "Not a sensor volume " << volName;
stave = -1; chip = -1;
stave = -1;
chip = -1;
}
}
void GeometryTGeo::extractChipIds(std::string const volName, int &direction, int &layer, int &stave, int &chip) {
if (volName.find("FT3Sensor_Active")==0) {
void GeometryTGeo::extractChipIds(std::string const volName, int& direction, int& layer, int& stave, int& chip)
{
if (volName.find("FT3Sensor_Active") == 0) {
int idx = volName.find('_') + 1;
idx = volName.find('_', idx) + 1;
direction = std::stoi(volName.substr(idx));
Expand All @@ -238,30 +247,32 @@ void GeometryTGeo::extractChipIds(std::string const volName, int &direction, int
stave = std::stoi(volName.substr(idx));
idx = volName.find('_', idx) + 1;
chip = std::stoi(volName.substr(idx));
}
else {
} else {
LOG(error) << "Not a sensor volume " << volName;
direction = -1;
}
}

int GeometryTGeo::getChipIndex(int dir, int layer, int stave, int chip) const {
int GeometryTGeo::getChipIndex(int dir, int layer, int stave, int chip) const
{
int absDisc = layer;
if (dir == 1) absDisc += mNumberOfDiscs[0];
if (dir == 1)
absDisc += mNumberOfDiscs[0];
return mChipIdxStave[mStaveIdxDisc[absDisc] + stave] + chip;
}

int GeometryTGeo::getLayer(int chipIdx) const {
int GeometryTGeo::getLayer(int chipIdx) const
{
int lay = mNumberOfDiscs[0] + mNumberOfDiscs[1] - 1;
while (chipIdx < mChipIdxStave[mStaveIdxDisc[lay]] && lay > 0) {
lay--;
lay--;
}
return lay;
}


// retrieve local stave number from chip ID
int GeometryTGeo::getStave(int chipIdx) const {
int GeometryTGeo::getStave(int chipIdx) const
{
int lay = getLayer(chipIdx);
int absStave = mStaveIdxDisc[lay];
while (chipIdx >= mChipIdxStave[absStave] && absStave < mStaveIdxDisc[lay + 1]) {
Expand All @@ -271,15 +282,16 @@ int GeometryTGeo::getStave(int chipIdx) const {
}

// retrieve local chip number on stave from chip ID
int GeometryTGeo::getChipOnStave(int chipIdx) const {
int GeometryTGeo::getChipOnStave(int chipIdx) const
{
int lay = getLayer(chipIdx);
int stave = getStave(chipIdx);
return chipIdx - mChipIdxStave[mStaveIdxDisc[lay] + stave];
}

std::string GeometryTGeo::getMatrixPath(int direction, int layer, int stave, int chip) const
{

// PrintChipID(index, subDetID, petalcase, disk, layer, stave, halfstave, mod, chip);

std::string path = Form("/cave_1/barrel_1/%s_2/", GeometryTGeo::getFT3VolPattern());
Expand All @@ -290,14 +302,14 @@ std::string GeometryTGeo::getMatrixPath(int direction, int layer, int stave, int
// Sensors directly placed in layer volume?

path += Form("%s%d_%d_1/", getFT3LayerPattern(), direction, layer); // TRKLayerx_1
//std::string sensorName = std::string("FT3Sensor_") + std::to_string(layer) + "_" + std::to_string(direction) + "_" + std::to_string(mChipStaveIds[index]) + "_" + index;
// std::string sensorName = std::string("FT3Sensor_") + std::to_string(layer) + "_" + std::to_string(direction) + "_" + std::to_string(mChipStaveIds[index]) + "_" + index;
path += Form("FT3Sensor_Active_%d_%d_%d_%d_%d", direction, layer, stave, chip, chip);
/*
if (mLayoutMLOT == FT3Layout::kCylindrical) {
// TODO: fix this caser?
path += Form("%s%d_1/", getTRKSensorPattern(), layer); // TRKSensorx_1
} else {
path += Form("%s%d_%d/", getFT3StavePattern(), layer, stave);
path += Form("%s%d_%d/", getFT3StavePattern(), layer, stave);
path += Form("%s%d_%d/", getFT3ModulePattern(), layer, mod);
path += Form("%s%d_%d_1", getFT3ChipPattern(), layer, chipID);
}
Expand Down Expand Up @@ -340,20 +352,21 @@ void GeometryTGeo::fillMatrixCache(int mask)
layer = absDisc - mNumberOfDiscs[0];
}
LOG(info) << "Direction " << direction << " layer " << layer;
if (absDisc >= mNumberOfStavesPerDisc.size()) LOG(fatal) << "Not enough entries in mNumberOfStavesPerDisc " << absDisc << " " << mNumberOfStavesPerDisc.size();
for (int stave = 0; stave < mNumberOfStavesPerDisc[absDisc]; stave++ ) {
if (absDisc >= mNumberOfStavesPerDisc.size())
LOG(fatal) << "Not enough entries in mNumberOfStavesPerDisc " << absDisc << " " << mNumberOfStavesPerDisc.size();
for (int stave = 0; stave < mNumberOfStavesPerDisc[absDisc]; stave++) {
int absStave = mStaveIdxDisc[absDisc] + stave;
if (absStave + 1 >= mChipIdxStave.size())
LOG(fatal) << "Attempting to get absStave + 1 from index array size " << mChipIdxStave.size();
LOG(fatal) << "Attempting to get absStave + 1 from index array size " << mChipIdxStave.size();
int nChip = mChipIdxStave[absStave + 1] - mChipIdxStave[absStave]; // TODO: this is too often == 0
LOG(debug) << "Getting matrices for direction " << direction << " layer " << layer << " stave " << stave << " : " << nChip << " chips";
for (int chip = 0; chip < nChip; chip++ ) {
int chipIdx = getChipIndex(direction, layer, stave, chip);
for (int chip = 0; chip < nChip; chip++) {
int chipIdx = getChipIndex(direction, layer, stave, chip);
if (!gGeoManager->cd(getMatrixPath(direction, layer, stave, chip).c_str()))
LOG(fatal) << "Geometry path not found " << getMatrixPath(direction, layer, stave, chip);
const TGeoHMatrix* matL2G = gGeoManager->GetCurrentMatrix();
if (chipIdx >= mSize)
LOG(fatal) << "ChipIdx " << chipIdx << " out of range " << mSize;
LOG(fatal) << "ChipIdx " << chipIdx << " out of range " << mSize;
cacheL2G.setMatrix(Mat3D(*matL2G), chipIdx);

matL2G->LocalToMaster(locA, gloA);
Expand All @@ -369,10 +382,10 @@ void GeometryTGeo::fillMatrixCache(int mask)

static TGeoHMatrix t2l;
t2l.Clear();
t2l.RotateZ(mCacheRefAlphaDiscs[chipIdx] * TMath::RadToDeg()); // TODO: do we need this cache?
t2l.RotateZ(mCacheRefAlphaDiscs[chipIdx] * TMath::RadToDeg()); // TODO: do we need this cache?
const TGeoHMatrix& matL2Gi = matL2G->Inverse();
t2l.MultiplyLeft(&matL2Gi);
cacheT2L.setMatrix(Mat3D(t2l),chipIdx); // TODO: may need deref with *
cacheT2L.setMatrix(Mat3D(t2l), chipIdx); // TODO: may need deref with *
}
}
}
Expand All @@ -394,5 +407,5 @@ void GeometryTGeo::Print(Option_t*) const
LOGF(info, "Total number of sensors: %d", mSize);
}

}
}
} // namespace ft3
} // namespace o2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct TRKBaseParam : public o2::conf::ConfigurableParamHelper<TRKBaseParam> {

eVDLayout layoutVD = kIRIS4; // VD detector layout design
eMLOTLayout layoutMLOT = kSegmented; // ML and OT detector layout design
eSrvLayout layoutSRV = kPeacockv1; // Layout of services
eSrvLayout layoutSRV = kPeacockv1; // Layout of services

eVDLayout getLayoutVD() const { return layoutVD; }
eMLOTLayout getLayoutMLOT() const { return layoutMLOT; }
Expand Down
Loading