Skip to content

Commit 631ebb0

Browse files
robincaron13rpezzi
andauthored
Add MFT alignable volume functions (#5974)
* Add alignable volume functions * Fix clang * Fix conversion ID when extracting NumberOfSensorsPerLadder * Fix chipID for alignable entry * Restoring files that should not be touched by this PR * Restoring files that should not be touched by this PR (bis) * Small fix Co-authored-by: Rafael Pezzi <rafael.pezzi@cern.ch>
1 parent c5650dc commit 631ebb0

4 files changed

Lines changed: 211 additions & 3 deletions

File tree

Detectors/ITSMFT/MFT/base/include/MFTBase/GeometryTGeo.h

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,34 @@ class GeometryTGeo : public o2::itsmft::GeometryTGeo
103103
/// ladder is the matrix ID and is converted to geometry ID
104104
Int_t getNumberOfSensorsPerLadder(Int_t half, Int_t disk, Int_t ladder) const
105105
{
106-
Int_t ladderID = mLadderIndex2Id[disk][ladder];
107-
return extractNumberOfSensorsPerLadder(half, disk, ladderID);
106+
return extractNumberOfSensorsPerLadder(half, disk, ladder);
107+
}
108+
/// Returns the number of ladders in each disk of each half
109+
Int_t getNumberOfLaddersPerDisk(Int_t half, Int_t disk, Int_t sensors) const
110+
{
111+
return extractNumberOfLadders(half, disk, sensors);
112+
}
113+
/// Returns the number of disks in each half
114+
Int_t getNumberOfDisksPerHalf(Int_t half) const
115+
{
116+
return extractNumberOfDisks(half);
117+
}
118+
/// Returns the number of halfs MFT
119+
Int_t getNumberOfHalfs()
120+
{
121+
return extractNumberOfHalves();
122+
}
123+
124+
/// Returns the min number of sensors per ladder
125+
Int_t getMinSensorsPerLadder()
126+
{
127+
return MinSensorsPerLadder;
128+
}
129+
130+
/// Returns the max number of sensors per ladder
131+
Int_t getMaxSensorsPerLadder()
132+
{
133+
return MaxSensorsPerLadder;
108134
}
109135

110136
/// Returns the ladder geometry ID from the matrix ID
@@ -113,6 +139,21 @@ class GeometryTGeo : public o2::itsmft::GeometryTGeo
113139
return mLadderIndex2Id[disk][ladder];
114140
}
115141

142+
/// sym name of the MFT
143+
static const char* composeSymNameMFT() { return o2::detectors::DetID(o2::detectors::DetID::MFT).getName(); }
144+
145+
/// sym name of the half
146+
static const char* composeSymNameHalf(int hf);
147+
148+
/// Sym name of the disk at given half
149+
static const char* composeSymNameDisk(int hf, int dk);
150+
151+
/// Sym name of the ladder at given half/disk
152+
static const char* composeSymNameLadder(int hf, int dk, int lr);
153+
154+
/// Sym name of the chip in the given half/disk/ladder
155+
static const char* composeSymNameChip(int hf, int dk, int lr, int chip);
156+
116157
protected:
117158
/// Determines the number of detector halves in the Geometry
118159
Int_t extractNumberOfHalves();

Detectors/ITSMFT/MFT/base/src/GeometryTGeo.cxx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,3 +568,27 @@ Int_t GeometryTGeo::getSensorIndex(Int_t halfID, Int_t diskID, Int_t ladderID, I
568568

569569
//__________________________________________________________________________
570570
Int_t GeometryTGeo::getLayer(Int_t index) const { return mSensorIndexToLayer[index]; }
571+
572+
//__________________________________________________________________________
573+
const char* GeometryTGeo::composeSymNameHalf(int hf)
574+
{
575+
return Form("%s_0/%s_%d_%d", composeSymNameMFT(), getMFTHalfPattern(), hf, hf);
576+
}
577+
578+
//__________________________________________________________________________
579+
const char* GeometryTGeo::composeSymNameDisk(int hf, int dk)
580+
{
581+
return Form("%s/%s_%d_%d_%d", composeSymNameHalf(hf), getMFTDiskPattern(), hf, dk, dk);
582+
}
583+
584+
//__________________________________________________________________________
585+
const char* GeometryTGeo::composeSymNameLadder(int hf, int dk, int lr)
586+
{
587+
return Form("%s/%s_%d_%d_%d_%d", composeSymNameDisk(hf, dk), getMFTLadderPattern(), hf, dk, lr, lr);
588+
}
589+
590+
//__________________________________________________________________________
591+
const char* GeometryTGeo::composeSymNameChip(int hf, int dk, int lr, int chip)
592+
{
593+
return Form("%s/%s_%d_%d_%d_%d", composeSymNameLadder(hf, dk, lr), getMFTChipPattern(), hf, dk, lr, chip);
594+
}

Detectors/ITSMFT/MFT/simulation/include/MFTSimulation/Detector.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,38 @@ class Detector : public o2::base::DetImpl<Detector>
8484
void PreTrack() override { ; }
8585
void ConstructGeometry() override; // inherited from FairModule
8686

87-
//
87+
/// Add alignable top volumes
88+
void addAlignableVolumes() const override;
89+
90+
/// Add alignable Half volumes
91+
/// \param hf Half number
92+
/// \param parent path of the parent volume
93+
/// \param lastUID on output, UID of the last volume
94+
void addAlignableVolumesHalf(Int_t hf, TString& parent, Int_t& lastUID) const;
95+
96+
/// Add alignable Disk volumes
97+
/// \param hf half number
98+
/// \param dk disk number
99+
/// \param parent path of the parent volume
100+
/// \param lastUID on output, UID of the last volume
101+
void addAlignableVolumesDisk(Int_t hf, Int_t dk, TString& parent, Int_t& lastUID) const;
102+
103+
/// Add alignable Ladder volumes
104+
/// \param hf half number
105+
/// \param dk disk number
106+
/// \param lr ladder stave number
107+
/// \param parent path of the parent volume
108+
/// \param lastUID on output, UID of the last volume
109+
void addAlignableVolumesLadder(Int_t hf, Int_t dk, Int_t lr, TString& parent, Int_t& lastUID) const;
110+
111+
/// Add alignable Sensor volumes
112+
/// \param hf half number
113+
/// \param dk disk number
114+
/// \param lr ladder number
115+
/// \param ms sensor number
116+
/// \param parent path of the parent volume
117+
/// \param lastUID on output, UID of the last volume
118+
void addAlignableVolumesChip(Int_t hf, Int_t dk, Int_t lr, Int_t ms, TString& parent, Int_t& lastUID) const;
88119

89120
Int_t isVersion() const { return mVersion; }
90121
/// Creating materials for the detector

Detectors/ITSMFT/MFT/simulation/src/Detector.cxx

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,118 @@ void Detector::defineSensitiveVolumes()
598598
}
599599
}
600600

601+
//_____________________________________________________________________________
602+
void Detector::addAlignableVolumes() const
603+
{
604+
// Creates entries for MFT alignable volumes associating the symbolic volume
605+
// name with the corresponding volume path.
606+
// Created: 06 Mar 2018 Mario Sitta First version (mainly ported from AliRoot)
607+
// Modified: 21 Apr 2021 Robin Caron
608+
609+
if (!gGeoManager) {
610+
LOG(FATAL) << "TGeoManager doesn't exist !";
611+
return;
612+
}
613+
614+
TString path = Form("/cave_1/barrel_1/%s_0", GeometryTGeo::getMFTVolPattern());
615+
TString sname = GeometryTGeo::composeSymNameMFT();
616+
617+
if (!gGeoManager->SetAlignableEntry(sname.Data(), path.Data())) {
618+
LOG(FATAL) << "Unable to set alignable entry ! " << sname << " : " << path;
619+
}
620+
621+
Int_t lastUID = 0;
622+
Int_t nHalf = mGeometryTGeo->getNumberOfHalfs();
623+
624+
for (Int_t hf = 0; hf < nHalf; hf++) {
625+
addAlignableVolumesHalf(hf, path, lastUID);
626+
}
627+
}
628+
629+
//_____________________________________________________________________________
630+
void Detector::addAlignableVolumesHalf(int hf, TString& parent, Int_t& lastUID) const
631+
{
632+
// Add alignable volumes for half-MFT and its daughters
633+
634+
TString path = Form("%s/%s_%d_%d", parent.Data(), GeometryTGeo::getMFTHalfPattern(), hf, hf);
635+
TString sname = mGeometryTGeo->composeSymNameHalf(hf);
636+
637+
if (!gGeoManager->SetAlignableEntry(sname.Data(), path.Data())) {
638+
LOG(FATAL) << "Unable to set alignable entry ! " << sname << " : " << path;
639+
}
640+
641+
Int_t nDisks = mGeometryTGeo->getNumberOfDisksPerHalf(hf);
642+
643+
for (int dk = 0; dk < nDisks; dk++) {
644+
addAlignableVolumesDisk(hf, dk, path, lastUID);
645+
}
646+
}
647+
648+
//_____________________________________________________________________________
649+
void Detector::addAlignableVolumesDisk(Int_t hf, Int_t dk,
650+
TString& parent, Int_t& lastUID) const
651+
{
652+
// Add alignable volumes for disk and its daughters
653+
654+
TString path = Form("%s/%s_%d_%d_%d", parent.Data(), GeometryTGeo::getMFTDiskPattern(), hf, dk, dk);
655+
TString sname = mGeometryTGeo->composeSymNameDisk(hf, dk);
656+
657+
if (!gGeoManager->SetAlignableEntry(sname.Data(), path.Data())) {
658+
LOG(FATAL) << "Unable to set alignable entry ! " << sname << " : " << path;
659+
}
660+
661+
Int_t nLadders = 0;
662+
663+
for (Int_t sensor = mGeometryTGeo->getMinSensorsPerLadder(); sensor < mGeometryTGeo->getMaxSensorsPerLadder() + 1; sensor++) {
664+
nLadders += mGeometryTGeo->getNumberOfLaddersPerDisk(hf, dk, sensor);
665+
}
666+
667+
for (Int_t lr = 0; lr < nLadders; lr++) {
668+
addAlignableVolumesLadder(hf, dk, lr, path, lastUID);
669+
}
670+
}
671+
672+
//_____________________________________________________________________________
673+
void Detector::addAlignableVolumesLadder(Int_t hf, Int_t dk, Int_t lr,
674+
TString& parent, Int_t& lastUID) const
675+
{
676+
// Add alignable volumes for ladder and its daughters
677+
678+
TString path = parent;
679+
path = Form("%s/%s_%d_%d_%d_%d", parent.Data(), GeometryTGeo::getMFTLadderPattern(), hf, dk, lr, lr);
680+
TString sname = mGeometryTGeo->composeSymNameLadder(hf, dk, lr);
681+
682+
LOG(DEBUG) << "Add " << sname << " <-> " << path;
683+
684+
if (!gGeoManager->SetAlignableEntry(sname.Data(), path.Data())) {
685+
LOG(FATAL) << "Unable to set alignable entry ! " << sname << " : " << path;
686+
}
687+
688+
Int_t nSensors = mGeometryTGeo->getNumberOfSensorsPerLadder(hf, dk, lr);
689+
690+
for (Int_t ms = 0; ms < nSensors; ms++) {
691+
addAlignableVolumesChip(hf, dk, lr, ms, path, lastUID);
692+
}
693+
}
694+
695+
//_____________________________________________________________________________
696+
void Detector::addAlignableVolumesChip(Int_t hf, Int_t dk, Int_t lr, Int_t ms,
697+
TString& parent, Int_t& lastUID) const
698+
{
699+
// Add alignable volumes for a Chip
700+
701+
TString path = Form("%s/%s_%d_%d_%d_%d", parent.Data(), GeometryTGeo::getMFTChipPattern(), hf, dk, lr, ms);
702+
TString sname = mGeometryTGeo->composeSymNameChip(hf, dk, lr, ms);
703+
704+
Int_t uid = o2::base::GeometryManager::getSensID(o2::detectors::DetID::MFT, lastUID++);
705+
706+
LOG(DEBUG) << "Add " << sname << " <-> " << path << " uid: " << uid;
707+
708+
if (!gGeoManager->SetAlignableEntry(sname, path.Data(), uid)) {
709+
LOG(FATAL) << "Unable to set alignable entry ! " << sname << " : " << path;
710+
}
711+
}
712+
601713
//_____________________________________________________________________________
602714
void Detector::EndOfEvent() { Reset(); }
603715

0 commit comments

Comments
 (0)