@@ -33,7 +33,7 @@ TrackletTransformer::TrackletTransformer()
3333 mXtb0 = -100 ;
3434
3535 // dummy values for testing. This will change in the future when values are pulled from CCDB
36- mt0Correction = -0.1 ;
36+ mt0Correction = -0.279 ;
3737 mOldLorentzAngle = 0.16 ;
3838 mLorentzAngle = -0.14 ;
3939 mDriftVRatio = 1.1 ;
@@ -52,8 +52,17 @@ float TrackletTransformer::calculateY(int hcid, int column, int position)
5252 double padWidth = mPadPlane ->getWidthIPad ();
5353 int side = hcid % 2 ;
5454
55+ // the position calculated in TRAPsim is a signed integer
56+ int positionUnsigned = 0 ;
57+ if (position & (1 << (NBITSTRKLPOS - 1 ))) {
58+ positionUnsigned = -((~(position - 1 )) & ((1 << NBITSTRKLPOS) - 1 ));
59+ } else {
60+ positionUnsigned = position & ((1 << NBITSTRKLPOS) - 1 );
61+ }
62+ positionUnsigned += 1 << (NBITSTRKLPOS - 1 ); // shift such that positionUnsigned = 1 << (NBITSTRKLPOS - 1) corresponds to the MCM center
63+
5564 // slightly modified TDP eq 16.1 (appended -1 to the end to account for MCM shared pads)
56- double pad = float (position - (1 << (NBITSTRKLPOS - 1 ))) * GRANULARITYTRKLPOS + NCOLMCM * (4 * side + column) + 10.5 - 1 ;
65+ double pad = float (positionUnsigned - (1 << (NBITSTRKLPOS - 1 ))) * GRANULARITYTRKLPOS + NCOLMCM * (4 * side + column) + 10 . - 1 . ;
5766 float y = padWidth * (pad - 72 );
5867
5968 return y;
@@ -62,25 +71,29 @@ float TrackletTransformer::calculateY(int hcid, int column, int position)
6271float TrackletTransformer::calculateZ (int padrow)
6372{
6473 double rowPos = mPadPlane ->getRowPos (padrow);
65- double rowWidth = mPadPlane ->getRowSize (padrow);
74+ double rowSize = mPadPlane ->getRowSize (padrow);
6675 double middleRowPos = mPadPlane ->getRowPos (mPadPlane ->getNrows () / 2 );
6776
68- float z = rowPos - rowWidth / 2 . - middleRowPos;
69-
70- return z;
77+ return rowPos - rowSize / 2 . - middleRowPos;
7178}
7279
7380float TrackletTransformer::calculateDy (int slope, double oldLorentzAngle, double lorentzAngle, double driftVRatio)
7481{
7582 double padWidth = mPadPlane ->getWidthIPad ();
7683
7784 // temporary dummy value in cm/microsecond
78- float vDrift = 1.56 ;
85+ float vDrift = 1 .5464f ;
7986 float driftHeight = mGeo ->cdrHght ();
8087
88+ int dYsigned = 0 ;
89+ if (slope & (1 << (NBITSTRKLSLOPE - 1 ))) {
90+ dYsigned = -((~(slope - 1 )) & ((1 << NBITSTRKLSLOPE) - 1 ));
91+ } else {
92+ dYsigned = slope & ((1 << NBITSTRKLSLOPE) - 1 );
93+ }
8194 // dy = slope * nTimeBins * padWidth * GRANULARITYTRKLSLOPE;
8295 // nTimeBins should be number of timebins in drift region. 1 timebin is 100 nanosecond
83- double rawDy = slope * ((driftHeight / vDrift) / 0.1 ) * padWidth * GRANULARITYTRKLSLOPE;
96+ double rawDy = dYsigned * ((driftHeight / vDrift) * 10 . ) * padWidth * GRANULARITYTRKLSLOPE;
8497
8598 // driftDistance = 3.35
8699 float driftDistance = mGeo ->cdrHght () + mGeo ->camHght ();
@@ -107,7 +120,7 @@ float TrackletTransformer::calculateDy(int slope, double oldLorentzAngle, double
107120 // LOG(info) << "ORIGINAL: " << calibratedDy;
108121 // LOG(info) << "ALTERNATIVE: " << rawDy + calibrationShift;
109122
110- return calibratedDy;
123+ return rawDy; // OS: temporary until calibratedDy is checked. Currently it is too far off from rawDy
111124}
112125
113126float TrackletTransformer::calibrateX (double x, double t0Correction)
@@ -132,9 +145,8 @@ CalibratedTracklet TrackletTransformer::transformTracklet(Tracklet64 tracklet)
132145 uint64_t hcid = tracklet.getHCID ();
133146 uint64_t padrow = tracklet.getPadRow ();
134147 uint64_t column = tracklet.getColumn ();
135- // 0-2048 | units:pad-widths | granularity=1/75 (measured from center pad 10) 1024 is 0/center of pad 10
136148 uint64_t position = tracklet.getPosition ();
137- // 0-127 | units:pads/timebin | granularity=1/1000
149+ // 0-255 | units:pads/timebin | granularity=1/1000 (signed integer)
138150 uint64_t slope = tracklet.getSlope ();
139151
140152 // calculate raw local chamber space point
@@ -146,7 +158,7 @@ CalibratedTracklet TrackletTransformer::transformTracklet(Tracklet64 tracklet)
146158 float dy = calculateDy (slope, mOldLorentzAngle , mLorentzAngle , mDriftVRatio );
147159 float calibratedX = calibrateX (x, mt0Correction);
148160
149- std::array<float , 3 > sectorSpacePoint = transformL2T (hcid, std::array<double , 3 >{x , y, z});
161+ std::array<float , 3 > sectorSpacePoint = transformL2T (hcid, std::array<double , 3 >{calibratedX , y, z});
150162
151163 LOG (debug) << " x: " << sectorSpacePoint[0 ] << " | "
152164 << " y: " << sectorSpacePoint[1 ] << " | "
0 commit comments