Skip to content

Commit b37cbcf

Browse files
bazinskidavidrohr
authored andcommitted
TRD fix pid in mc to raw
1 parent b2bc53c commit b37cbcf

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct TrackletMCMData {
192192
struct {
193193
uint8_t checkbit : 1; //
194194
uint16_t slope : 8; // Deflection angle of tracklet
195-
uint16_t pid : 12; // Particle Identity 7 bits of Q0 and 5 bits of Q1
195+
uint16_t pid : 12; // Particle Identity 6 bits of Q0 and 6 bits of Q1
196196
uint16_t pos : 11; // Position of tracklet, signed 11 bits, granularity 1/80 pad widths, -12.80 to +12.80, relative to centre of pad 10
197197
} __attribute__((__packed__));
198198
};

DataFormats/Detectors/TRD/src/RawData.cxx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,16 @@ void constructTrackletMCMData(TrackletMCMData& trackletword, const int format, c
278278
trackletword.word = 0;
279279
// create a tracklet word as it would be sent from the FEE
280280
// slope and position have the 8-th bit flipped each
281-
trackletword.word = 0;
282281
trackletword.slope = slope ^ 0x80;
283282
trackletword.pos = pos ^ 0x80;
284283
trackletword.checkbit = 0;
285284
if (format & 0x1) {
286-
//length of q1 and q2 are 6 with a 2 bit offset.
287-
//What happens when q2 and q1 dont share the same offset (upper 2 bits ?) ?
288-
LOG(error) << "This tracklet format has not been tested yet";
289-
trackletword.pid = (q0 & 0x3f) & ((q1 & 0x1) << 6);
290-
//TODO check the 2 bit offset is still valid ... ??
285+
//length of q1 and q2 are 6 with a 2 bit offset sitting in the header.
286+
trackletword.pid = (q0 & 0x3f) | ((q1 & 0x3f) << 6);
291287
} else {
292-
trackletword.pid = (q0 & 0x3f) & ((q1 & 0x1) << 6);
288+
//q2 sits with upper 1 bit of q1 in the header pid word, hence the 0x3f so 6 bits of q1 are used here, shifted up above the 6 bits of q0.
289+
trackletword.pid = (int)(q0 & 0x3f) | ((q1 & 0x3f) << 6);
293290
}
294-
//q2 sits with upper 2 bits of q1 in the header pid word, hence the 0x1f so 5 bits are used here.
295291
}
296292

297293
void constructTrackletMCMData(TrackletMCMData& trackletword, const Tracklet64& tracklet)
@@ -319,7 +315,7 @@ void printTrackletHCHeader(o2::trd::TrackletHCHeader& halfchamber)
319315

320316
void printTrackletMCMData(o2::trd::TrackletMCMData& tracklet)
321317
{
322-
LOGF(info, "TrackletMCMData: Raw:0x%08x pos:%d slope:%d pid:0x%08x checkbit:0x%02x",
318+
LOGF(info, "TrackletMCMData: Raw:0x%08x pos:%d slope:%d pid:0x%03x checkbit:0x%02x",
323319
tracklet.word, tracklet.pos, tracklet.slope, tracklet.pid, tracklet.checkbit);
324320
}
325321
void printTrackletMCMHeader(o2::trd::TrackletMCMHeader& mcmhead)

Detectors/TRD/simulation/src/Trap2CRU.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ int Trap2CRU::buildTrackletRawData(const int trackletindex, const int linkid)
495495
while (linkid == HelperMethods::getLinkIDfromHCID(mTracklets[trackletindex + trackletcounter].getHCID()) && header.col == mTracklets[trackletindex + trackletcounter].getColumn() && header.padrow == mTracklets[trackletindex + trackletcounter].getPadRow()) {
496496
int trackletoffset = trackletindex + trackletcounter;
497497
constructTrackletMCMData(trackletdata[trackletcounter], mTracklets[trackletoffset]);
498-
unsigned int headerqpart = ((mTracklets[trackletoffset].getQ2() & 0x2f) << 2) + ((mTracklets[trackletoffset].getQ1() >> 6) & 0x3);
498+
unsigned int headerqpart = ((mTracklets[trackletoffset].getQ2() & 0x7f) << 1) + ((mTracklets[trackletoffset].getQ1() >> 6) & 0x3);
499499
//all 6 bits of Q1 and 2 upper bits of 7bit Q1
500500
if (mVerbosity) {
501501
if (mTracklets[trackletoffset].getQ2() > 0x3f) {
@@ -539,13 +539,15 @@ int Trap2CRU::buildTrackletRawData(const int trackletindex, const int linkid)
539539
setNumberOfTrackletsInHeader(header, trackletcounter);
540540
if (trackletcounter > 0) { // dont write header if there are no tracklets.
541541
if (mVerbosity) {
542-
LOG(info) << " TTT TrackletMCMHeader : 0x" << std::hex << header;
542+
LOG(info) << " TTT TrackletMCMHeader : 0x" << std::hex << header << " pid : " << header.pid0 << " pid1: " << header.pid1;
543+
printTrackletMCMHeader(header);
543544
}
544545
memcpy((char*)mRawDataPtr, (char*)&header, sizeof(TrackletMCMHeader));
545546
mRawDataPtr += sizeof(TrackletMCMHeader);
546547
for (int i = 0; i < trackletcounter; ++i) {
547548
if (mVerbosity) {
548549
LOG(info) << " TTTx TrackletMCMData : 0x" << std::hex << trackletdata[i];
550+
printTrackletMCMData(trackletdata[i]);
549551
}
550552
memcpy((char*)mRawDataPtr, (char*)&trackletdata[i], sizeof(TrackletMCMData));
551553
mRawDataPtr += sizeof(TrackletMCMData);

0 commit comments

Comments
 (0)