Skip to content

Commit f73ef1e

Browse files
martenoleshahor02
authored andcommitted
Add getters for global pos/slope of TRD tracklets
1 parent 3b21318 commit f73ef1e

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

DataFormats/Detectors/TRD/include/DataFormatsTRD/Constants.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ constexpr int NCOLMCM = 18; // the number of pads per MCM
4242

4343
constexpr int NBITSTRKLPOS = 11; // number of bits for position in tracklet64 word
4444
constexpr int NBITSTRKLSLOPE = 8; // number of bits for slope in tracklet64 word
45-
constexpr float GRANULARITYTRKLPOS = 1.f / 75; // granularity of position in tracklet64 word in pad-widths
46-
constexpr float GRANULARITYTRKLSLOPE = 1.f / 1000; // granularity of slope in tracklet64 word in pads/timebin
45+
constexpr float PADGRANULARITYTRKLPOS = 80.f;
46+
constexpr float PADGRANULARITYTRKLSLOPE = 1000.f;
47+
constexpr float GRANULARITYTRKLPOS = 1.f / PADGRANULARITYTRKLPOS; // granularity of position in tracklet64 word in pad-widths
48+
constexpr float GRANULARITYTRKLSLOPE = 1.f / PADGRANULARITYTRKLSLOPE; // granularity of slope in tracklet64 word in pads/timebin
4749

4850
// OS: Should this not be flexible for example in case of Kr calib?
4951
constexpr int TIMEBINS = 30; // the number of time bins

DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Tracklet64
8181
// ----- Getters for tracklet information -----
8282
int getMCM() const { return 4 * (getPadRow() % 4) + getColumn(); } // returns MCM position on ROB [0..15]
8383
int getROB() const { return (getHCID() % 2) ? (getPadRow() / 4) * 2 + 1 : (getPadRow() / 4) * 2; } // returns ROB number [0..5] for C0 chamber and [0..7] for C1 chamber
84+
float getY() const; // translate local position into global y (in cm)
85+
float getDy(float nTbDrift = 19.4f) const; // translate local slope into dy/dx with dx=3m (drift length) and default drift time in time bins (19.4 timebins / 3cm)
8486

8587
// ----- Getters for offline corresponding values -----
8688
int getDetector() const { return getHCID() / 2; }

DataFormats/Detectors/TRD/src/Tracklet64.cxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "DataFormatsTRD/Tracklet64.h"
12+
#include "DataFormatsTRD/Constants.h"
1213

1314
#include "fairlogger/Logger.h"
1415
#include <iostream>
@@ -19,6 +20,37 @@ namespace o2
1920
namespace trd
2021
{
2122

23+
using namespace constants;
24+
25+
float Tracklet64::getY() const
26+
{
27+
int padLocalBin = getPosition();
28+
int padLocal = 0;
29+
if (padLocalBin & (1 << (NBITSTRKLPOS - 1))) {
30+
padLocal = -((~(padLocalBin - 1)) & ((1 << NBITSTRKLPOS) - 1));
31+
} else {
32+
padLocal = padLocalBin & ((1 << NBITSTRKLPOS) - 1);
33+
}
34+
int mcmCol = (getMCM() % NMCMROBINCOL) + NMCMROBINCOL * (getROB() % 2);
35+
float offset = -63.f + ((float)NCOLMCM) * mcmCol;
36+
float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER);
37+
return (offset + padLocal * GRANULARITYTRKLPOS) * padWidth;
38+
}
39+
40+
float Tracklet64::getDy(float nTbDrift) const
41+
{
42+
float dy;
43+
int dyLocalBin = getSlope();
44+
if (dyLocalBin & (1 << (NBITSTRKLSLOPE - 1))) {
45+
dy = (~(dyLocalBin - 1)) & ((1 << NBITSTRKLSLOPE) - 1);
46+
dy *= -1.f;
47+
} else {
48+
dy = dyLocalBin & ((1 << NBITSTRKLSLOPE) - 1);
49+
}
50+
float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER);
51+
return dy * GRANULARITYTRKLSLOPE * padWidth * nTbDrift;
52+
}
53+
2254
void Tracklet64::printStream(std::ostream& stream) const
2355
{
2456
stream << "Tracklet64 : 0x" << std::hex << getTrackletWord();

Detectors/TRD/simulation/src/TrapSimulator.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,9 +1920,9 @@ void TrapSimulator::fitTracklet()
19201920
yoffs = yoffs << decPlaces; // holds position of ADC channel 1
19211921

19221922
// we need to scale the offset since we want to store it in units of 1/80 pad and the calculation is done in 1/256 pad width granularity
1923-
unsigned int scaleY = (unsigned int)(80. / 256. * shift);
1923+
unsigned int scaleY = (unsigned int)(PADGRANULARITYTRKLPOS / 256. * shift);
19241924
// the slope is given in units of 1/1000 pads/timebin
1925-
unsigned long scaleD = (unsigned long)(1000. / 256. * shift);
1925+
unsigned long scaleD = (unsigned long)(PADGRANULARITYTRKLSLOPE / 256. * shift);
19261926
LOG(debug) << "scaleY : " << scaleY << " scaleD=" << scaleD << " shift:" << std::hex << shift << std::dec;
19271927
int deflCorr = (int)mTrapConfig->getDmemUnsigned(mgkDmemAddrDeflCorr, mDetector, mRobPos, mMcmPos);
19281928
int ndrift = (int)mTrapConfig->getDmemUnsigned(mgkDmemAddrNdrift, mDetector, mRobPos, mMcmPos);

0 commit comments

Comments
 (0)