Skip to content

Commit fcdf98d

Browse files
authored
ITS3: Fix matrix generation in helper class (#13895)
* ITS: change layer name to debug severity Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch> * ITS: ITS3 matrix generation fix + demoting&removal of logging Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch> * ITS3: Propagate rename to ITS helper class Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch> * ITS3: make ITSRESPONSE cached var Allows reusing this variable later on. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch> * ITS: digiparams make print func virtual Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch> --------- Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 2640284 commit fcdf98d

File tree

4 files changed

+58
-72
lines changed

4 files changed

+58
-72
lines changed

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

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
#ifdef ENABLE_UPGRADES
2626
#include "ITS3Base/SpecsV2.h"
27-
#include "ITS3Base/SegmentationSuperAlpide.h"
28-
using SuperSegmentation = o2::its3::SegmentationSuperAlpide;
2927
#endif
3028

3129
#include <TGeoBBox.h> // for TGeoBBox
@@ -420,33 +418,20 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
420418
static int chipInGlo{0};
421419

422420
// account for the difference between physical sensitive layer (where charge collection is simulated) and effective sensor thicknesses
421+
// in the ITS3 case this accounted by specialized functions
423422
double delta = Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff;
424-
#ifdef ENABLE_UPGRADES
425-
if (mIsLayerITS3[getLayer(index)]) {
426-
delta = its3::SegmentationSuperAlpide::mSensorLayerThickness - its3::SegmentationSuperAlpide::mSensorLayerThicknessEff;
427-
}
428-
#endif
429-
430423
static TGeoTranslation tra(0., 0.5 * delta, 0.);
431-
424+
#ifdef ENABLE_UPGRADES // only apply for non ITS3 OB layers
425+
if (!mIsLayerITS3[getLayer(index)]) {
426+
matTmp *= tra;
427+
}
428+
#else
432429
matTmp *= tra;
430+
#endif
433431

434432
return &matTmp;
435433
}
436434

437-
//__________________________________________________________________________
438-
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
439-
{
440-
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations
441-
static TGeoHMatrix t2l;
442-
t2l.Clear();
443-
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
444-
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
445-
const auto& matL2Gi = matL2G.Inverse();
446-
t2l.MultiplyLeft(&matL2Gi);
447-
return Mat3D(t2l);
448-
}
449-
450435
//__________________________________________________________________________
451436
void GeometryTGeo::Build(int loadTrans)
452437
{
@@ -492,23 +477,6 @@ void GeometryTGeo::Build(int loadTrans)
492477
mLastChipIndex[i] = numberOfChips - 1;
493478
}
494479

495-
LOGP(debug, "Summary of extracted Geometry:");
496-
LOGP(debug, " There are {} Layers and {} HalfBarrels", mNumberOfLayers, mNumberOfHalfBarrels);
497-
for (int i = 0; i < mNumberOfLayers; i++) {
498-
LOGP(debug, " Layer {}: {:*^30}", i, "START");
499-
LOGP(debug, " - mNumberOfStaves={}", mNumberOfStaves[i]);
500-
LOGP(debug, " - mNumberOfChipsPerStave={}", mNumberOfChipsPerStave[i]);
501-
LOGP(debug, " - mNumberOfHalfStaves={}", mNumberOfHalfStaves[i]);
502-
LOGP(debug, " - mNumberOfChipsPerHalfStave={}", mNumberOfChipsPerHalfStave[i]);
503-
LOGP(debug, " - mNumberOfModules={}", mNumberOfModules[i]);
504-
LOGP(debug, " - mNumberOfChipsPerModules={}", mNumberOfChipsPerModule[i]);
505-
LOGP(debug, " - mNumberOfChipsPerLayer={}", mNumberOfChipsPerLayer[i]);
506-
LOGP(debug, " - mNumberOfChipsPerHalfBarrel={}", mNumberOfChipsPerHalfBarrel[i]);
507-
LOGP(debug, " - mLastChipIndex={}", mLastChipIndex[i]);
508-
LOGP(debug, " Layer {}: {:*^30}", i, "END");
509-
}
510-
LOGP(debug, "In total there {} chips registered", numberOfChips);
511-
512480
#ifdef ENABLE_UPGRADES
513481
if (std::any_of(mIsLayerITS3.cbegin(), mIsLayerITS3.cend(), [](auto b) { return b; })) {
514482
LOGP(info, "Found active IT3 layers -> Renaming Detector ITS to IT3");
@@ -880,34 +848,39 @@ void GeometryTGeo::extractSensorXAlpha(int isn, float& x, float& alp)
880848

881849
const TGeoHMatrix* matL2G = extractMatrixSensor(isn);
882850
double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
883-
int iLayer = getLayer(isn);
851+
double xp{0}, yp{0};
884852

885853
#ifdef ENABLE_UPGRADES
886-
if (mIsLayerITS3[iLayer]) {
887-
// We need to calcualte the line tangent at the mid-point in the geometry
854+
if (int iLayer = getLayer(isn); mIsLayerITS3[iLayer]) {
855+
// For a TGeoTubeSeg the local coordinate system is defined at the origin
856+
// of the circle of the side, since in our implementation we rotated the geometry a bit
888857
const auto radius = o2::its3::constants::radii[iLayer];
889858
const auto phi1 = o2::its3::constants::tile::width / radius;
890859
const auto phi2 = o2::its3::constants::pixelarray::width / radius + phi1;
891860
const auto phi3 = (phi2 - phi1) / 2.; // mid-point in phi
892-
const auto x = radius * std::cos(phi3);
893-
const auto y = radius * std::sin(phi3);
894-
// For the tangent we make the parametric line equation y = m * x - c
895-
const auto m = x / y;
896-
const auto c = y - m * x;
897-
// Now we can given any x calulate points along this line, we pick points far away,
898-
// the calculation of the normal should work then below.
899-
locA[1] = m * locA[0] + c;
900-
locB[1] = m * locB[0] + c;
901-
}
902-
#endif
903-
861+
locA[0] = radius * std::cos(phi3);
862+
locA[1] = radius * std::sin(phi3);
863+
matL2G->LocalToMaster(locA, gloA);
864+
xp = gloA[0];
865+
yp = gloA[1];
866+
} else {
867+
matL2G->LocalToMaster(locA, gloA);
868+
matL2G->LocalToMaster(locB, gloB);
869+
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
870+
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
871+
xp = gloB[0] - dx * t;
872+
yp = gloB[1] - dy * t;
873+
}
874+
#else // just ITS2 part
904875
matL2G->LocalToMaster(locA, gloA);
905876
matL2G->LocalToMaster(locB, gloB);
906877
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
907878
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
908-
double xp = gloB[0] - dx * t, yp = gloB[1] - dy * t;
909-
x = Sqrt(xp * xp + yp * yp);
910-
alp = ATan2(yp, xp);
879+
xp = gloB[0] - dx * t;
880+
yp = gloB[1] - dy * t;
881+
#endif
882+
x = std::hypot(xp, yp);
883+
alp = std::atan2(yp, xp);
911884
o2::math_utils::bringTo02Pi(alp);
912885
}
913886

@@ -926,6 +899,19 @@ TGeoHMatrix& GeometryTGeo::createT2LMatrix(int isn)
926899
return t2l;
927900
}
928901

902+
//__________________________________________________________________________
903+
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
904+
{
905+
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations with correction for effective thickness
906+
static TGeoHMatrix t2l;
907+
t2l.Clear();
908+
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
909+
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
910+
const auto& matL2Gi = matL2G.Inverse();
911+
t2l.MultiplyLeft(&matL2Gi);
912+
return Mat3D(t2l);
913+
}
914+
929915
//__________________________________________________________________________
930916
int GeometryTGeo::extractVolumeCopy(const char* name, const char* prefix) const
931917
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Detector::Detector(Bool_t active, TString name)
190190
} else {
191191
mLayerName[j].Form("%s%d", GeometryTGeo::getITSSensorPattern(), j); // See V3Layer
192192
}
193-
LOGP(info, "{}: mLayerName={}", j, mLayerName[j].Data());
193+
LOGP(debug, "{}: mLayerName={}", j, mLayerName[j].Data());
194194
}
195195

196196
if (mNumberLayers > 0) { // if not, we'll Fatal-ize in CreateGeometry
@@ -723,8 +723,8 @@ void Detector::defineLayer(Int_t nlay, Double_t phi0, Double_t r, Int_t nstav, I
723723
// Return:
724724
// none.
725725

726-
LOG(info) << "L# " << nlay << " Phi:" << phi0 << " R:" << r << " Nst:" << nstav << " Nunit:" << nunit
727-
<< " Lthick:" << lthick << " Dthick:" << dthick << " DetID:" << dettypeID << " B:" << buildLevel;
726+
LOG(debug) << "L# " << nlay << " Phi:" << phi0 << " R:" << r << " Nst:" << nstav << " Nunit:" << nunit
727+
<< " Lthick:" << lthick << " Dthick:" << dthick << " DetID:" << dettypeID << " B:" << buildLevel;
728728

729729
if (nlay >= mNumberLayers || nlay < 0) {
730730
LOG(error) << "Wrong layer number " << nlay;

Detectors/ITSMFT/common/data/AlpideResponseData/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DI
2020

2121
if(ITSRESPONSE)
2222
message(STATUS "ITSRESPONSE option provided, setting ITSRESPONSE_DIR from it: " ${ITSRESPONSE})
23-
set(ITSRESPONSE_DIR ${ITSRESPONSE})
23+
set(ITSRESPONSE_DIR ${ITSRESPONSE} CACHE PATH "ITSResponse directory")
2424
else()
2525
message(STATUS "ITSRESPONSE option not provided, setting ITSRESPONSE_DIR from environment ITSRESPONSE_ROOT: " $ENV{ITSRESPONSE_ROOT})
26-
set(ITSRESPONSE_DIR $ENV{ITSRESPONSE_ROOT})
26+
set(ITSRESPONSE_DIR $ENV{ITSRESPONSE_ROOT} CACHE PATH "ITSResponse directory")
2727
endif()
2828

2929
add_custom_command(TARGET O2exe-alpide-response-generator POST_BUILD

Detectors/ITSMFT/common/simulation/include/ITSMFTSimulation/DigiParams.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ class DigiParams
9696
const SignalShape& getSignalShape() const { return mSignalShape; }
9797
SignalShape& getSignalShape() { return (SignalShape&)mSignalShape; }
9898

99-
void print() const;
99+
virtual void print() const;
100100

101101
private:
102102
static constexpr double infTime = 1e99;
103-
bool mIsContinuous = false; ///< flag for continuous simulation
104-
float mNoisePerPixel = 1.e-8; ///< ALPIDE Noise per chip
105-
int mROFrameLengthInBC = 0; ///< ROF length in BC for continuos mode
106-
float mROFrameLength = 0; ///< length of RO frame in ns
107-
float mStrobeDelay = 0.; ///< strobe start (in ns) wrt ROF start
108-
float mStrobeLength = 0; ///< length of the strobe in ns (sig. over threshold checked in this window only)
109-
double mTimeOffset = -2 * infTime; ///< time offset (in seconds!) to calculate ROFrame from hit time
110-
int mROFrameBiasInBC = 0; ///< misalignment of the ROF start in BC
103+
bool mIsContinuous = false; ///< flag for continuous simulation
104+
float mNoisePerPixel = 1.e-8; ///< ALPIDE Noise per chip
105+
int mROFrameLengthInBC = 0; ///< ROF length in BC for continuos mode
106+
float mROFrameLength = 0; ///< length of RO frame in ns
107+
float mStrobeDelay = 0.; ///< strobe start (in ns) wrt ROF start
108+
float mStrobeLength = 0; ///< length of the strobe in ns (sig. over threshold checked in this window only)
109+
double mTimeOffset = -2 * infTime; ///< time offset (in seconds!) to calculate ROFrame from hit time
110+
int mROFrameBiasInBC = 0; ///< misalignment of the ROF start in BC
111111
int mChargeThreshold = 150; ///< charge threshold in Nelectrons
112112
int mMinChargeToAccount = 15; ///< minimum charge contribution to account
113113
int mNSimSteps = 7; ///< number of steps in response simulation
@@ -125,7 +125,7 @@ class DigiParams
125125
float mROFrameLengthInv = 0; ///< inverse length of RO frame in ns
126126
float mNSimStepsInv = 0; ///< its inverse
127127

128-
ClassDefNV(DigiParams, 2);
128+
ClassDef(DigiParams, 2);
129129
};
130130
} // namespace itsmft
131131
} // namespace o2

0 commit comments

Comments
 (0)