Skip to content

Commit a9233df

Browse files
committed
try to remove erroneous digit data at start of tracklet parsing
1 parent 8ae952b commit a9233df

10 files changed

Lines changed: 300 additions & 215 deletions

File tree

DataFormats/Detectors/TRD/src/RawData.cxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ uint32_t getQFromRaw(const o2::trd::TrackletMCMHeader* header, const o2::trd::Tr
124124
qa = header->pid2;
125125
break;
126126
default:
127-
LOG(warn) << " unknown trackletindex to getQFromRaw : " << pidindex;
127+
LOG(warn) << " unknown trackletindex of " << trackletindex << " to getQFromRaw : " << pidindex;
128128
break;
129129
}
130130
//qa is 6bits of Q2 and 2 bits of Q1
@@ -253,7 +253,7 @@ void printHalfCRUHeader(o2::trd::HalfCRUHeader& halfcru)
253253
for (int i = 0; i < 15; i++) {
254254
LOGF(INFO, "Link %d size: %ul eflag: 0x%02x", i, sizes[i], errorflags[i]);
255255
}
256-
LOG(INFO) << "Raw: " << std::hex << halfcru.word0<< " " << halfcru.word12[0]<< " " << halfcru.word12[1]<< " " << halfcru.word3<< " " << halfcru.word47[0]<< " " << halfcru.word47[1]<< " " <<halfcru.word47[2]<< " " <<halfcru.word47[3];
256+
LOG(INFO) << "Raw: " << std::hex << halfcru.word0 << " " << halfcru.word12[0] << " " << halfcru.word12[1] << " " << halfcru.word3 << " " << halfcru.word47[0] << " " << halfcru.word47[1] << " " << halfcru.word47[2] << " " << halfcru.word47[3];
257257
for (int i = 0; i < 15; i++) {
258258
LOGF(INFO, "Raw: %d word: %ul x", i, sizes[i], errorflags[i]);
259259
}
@@ -444,15 +444,16 @@ void setNumberOfTrackletsInHeader(o2::trd::TrackletMCMHeader& header, int number
444444
int nextmcmadc(unsigned int& bp, int channel)
445445
{
446446
//given a bitpattern (adcmask) find next channel with in the mask starting from the current channel;
447-
if(bp==0) return 22;
448-
int position=channel;
449-
int m=1<<channel;
447+
if (bp == 0)
448+
return 22;
449+
int position = channel;
450+
int m = 1 << channel;
450451
while (!(bp & m)) {
451-
m= m<<1;
452+
m = m << 1;
452453
position++;
453454
}
454455
bp &= ~(1UL << (position));
455-
return position;
456+
return position;
456457
}
457458

458459
} // namespace trd

Detectors/TRD/reconstruction/include/TRDReconstruction/DigitsParser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ class DigitsParser
3939
DigitsParser() = default;
4040
~DigitsParser() = default;
4141
void setData(std::array<uint32_t, o2::trd::constants::HBFBUFFERMAX>* data) { mData = data; }
42-
// void setLinkLengths(std::array<uint32_t, 15>& lengths) { mCurrentHalfCRULinkLengths = lengths; };
4342
int Parse(bool verbose = false); // presupposes you have set everything up already.
4443
int Parse(std::array<uint32_t, o2::trd::constants::HBFBUFFERMAX>* data, std::array<uint32_t, o2::trd::constants::HBFBUFFERMAX>::iterator start,
4544
std::array<uint32_t, o2::trd::constants::HBFBUFFERMAX>::iterator end, int detector, bool cleardigits = false, bool disablebyteswap = false, bool verbose = false, bool headerverbose = false, bool dataverbose = false)
4645
{
4746
setData(data);
48-
// setLinkLengths(lengths);
4947
mStartParse = start;
5048
mEndParse = end;
5149
mDetector = detector;

Detectors/TRD/reconstruction/include/TRDReconstruction/TrackletsParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TrackletsParser
104104
bool mReturnVector{false}; // whether weare returing a vector or the raw data buffer.
105105

106106
uint16_t mEventCounter;
107-
std::chrono::duration<double>mTrackletparsetime; // store the time it takes to parse
107+
std::chrono::duration<double> mTrackletparsetime; // store the time it takes to parse
108108
std::array<uint32_t, o2::trd::constants::HBFBUFFERMAX>::iterator mStartParse, mEndParse; // limits of parsing, effectively the link limits to parse on.
109109
//uint32_t mCurrentLinkDataPosition256; // count of data read for current link in units of 256 bits
110110

Detectors/TRD/reconstruction/src/CruRawReader.cxx

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool CruRawReader::processHBFs(int datasizealreadyread, bool verbose)
127127
int counthalfcru = 0;
128128
mHBFoffset32 = 0;
129129

130-
while ((mHBFoffset32 < ((mTotalHBFPayLoad) / 4))) {// the blank event of eeeeee at the end
130+
while ((mHBFoffset32 < ((mTotalHBFPayLoad) / 4))) { // the blank event of eeeeee at the end
131131
if (mVerbose) {
132132
LOG(info) << "Looping over cruheaders in HBF, loop count " << counthalfcru << " current offset is" << mHBFoffset32 << " total payload is " << mTotalHBFPayLoad / 4 << " raw :" << mTotalHBFPayLoad;
133133
}
@@ -143,17 +143,19 @@ bool CruRawReader::processHBFs(int datasizealreadyread, bool verbose)
143143
case 1:
144144
LOG(info) << "all good parsing half cru";
145145
break;
146-
default : return true;
146+
default:
147+
return true;
147148
}
148149
}
149-
//take care of the case where there is an "empty" rdh containing all 0xeeeeeeee as payload.
150-
if(mTotalHBFPayLoad/4 - mHBFoffset32 == 8 && mHBFPayload[mHBFoffset32+7]== o2::trd::constants::CRUPADDING32){
151-
mHBFoffset32+=8;
152-
}
150+
//take care of the case where there is an "empty" rdh containing all 0xeeeeeeee as payload.
151+
if (mTotalHBFPayLoad / 4 - mHBFoffset32 == 8 && mHBFPayload[mHBFoffset32 + 7] == o2::trd::constants::CRUPADDING32) {
152+
mHBFoffset32 += 8;
153+
}
153154
counthalfcru++;
154-
if(counthalfcru==1)break;
155+
if (counthalfcru == 1)
156+
break;
155157
} // loop of halfcru's while there is still data in the heart beat frame.
156-
if(totaldataread>0){
158+
if (totaldataread > 0) {
157159
mDatareadfromhbf = totaldataread;
158160
}
159161
return true; //totaldataread;
@@ -198,28 +200,39 @@ int CruRawReader::processHalfCRU(int cruhbfstartoffset)
198200
mCurrentHalfCRULinkLengths.end(),
199201
decltype(mCurrentHalfCRULinkLengths)::value_type(0));
200202
mTotalHalfCRUDataLength = mTotalHalfCRUDataLength256 * 32; //convert to bytes.
201-
202-
if(mDataVerbose){
203-
if(mTotalHalfCRUDataLength!=mTotalHBFPayLoad){
203+
//check for cru errors :
204+
if (mHeaderVerbose) {
205+
int linkerrorcounter = 0;
206+
LOG(info) << "link errors";
207+
for (auto& linkerror : mCurrentHalfCRULinkErrorFlags) {
208+
if (linkerror != 0)
209+
LOG(info) << "E link error FEEID:" << mFEEID << " CRUID:" << mCRUID << " Endpoint:" << mCRUEndpoint
210+
<< " on linkcount:" << linkerrorcounter++ << " errorval:0x" << std::hex << linkerror;
211+
}
212+
LOG(info) << "link errors end";
213+
}
214+
if (mDataVerbose) {
215+
if (mTotalHalfCRUDataLength != mTotalHBFPayLoad) {
204216
LOG(info) << "mTotalHalfCRUDataLength ?!= mTotalHBFPayLoad " << mTotalHalfCRUDataLength << "?!=" << mTotalHBFPayLoad;
205217
}
206218
}
219+
207220
std::array<uint32_t, 1024>::iterator currentlinkstart = mHBFPayload.begin() + cruhbfstartoffset;
208-
/*LOG(info) << "CRU dump begin ************************** ";
209-
for(int z=0;z<15;++z){
221+
/*LOG(info) << "CRU dump begin ************************** ";
222+
for(int z=0;z<15;++z){
210223
LOG(info) << "link " << z << " length : " << mCurrentHalfCRULinkLengths[z]*8;
211-
}
212-
int linkzcount=0;
213-
uint64_t linkzsum=0;
214-
for(int di=0;di<mTotalHalfCRUDataLength;++di){
224+
}
225+
int linkzcount=0;
226+
uint64_t linkzsum=0;
227+
for(int di=0;di<mTotalHalfCRUDataLength;++di){
215228
LOG(info) << "di:" << di << " " << std::hex << mHBFPayload[di+8];
216229
if(di == cruhbfstartoffset) LOG(info) << "start there ^^^^^";
217230
if(di == mCurrentHalfCRULinkLengths[linkzcount]*8+linkzsum) {LOG(info) << "end of link "<< linkzcount; linkzsum+=mCurrentHalfCRULinkLengths[linkzcount]*8;linkzcount++;}
218-
}
219-
for(int di=mTotalHalfCRUDataLength; di < mTotalHalfCRUDataLength+16;++di){
231+
}
232+
for(int di=mTotalHalfCRUDataLength; di < mTotalHalfCRUDataLength+16;++di){
220233
LOG(info) << "**di:" << di << " " << std::hex << mHBFPayload[di];
221-
}
222-
LOG(info) << "CRU dump end ***************";*/
234+
}
235+
LOG(info) << "CRU dump end ***************";*/
223236
std::array<uint32_t, 1024>::iterator linkstart, linkend;
224237
int dataoffsetstart32 = sizeof(mCurrentHalfCRUHeader) / 4 + cruhbfstartoffset; // in uint32
225238
//CHECK 1 does rdh endpoint match cru header end point.
@@ -267,8 +280,9 @@ int CruRawReader::processHalfCRU(int cruhbfstartoffset)
267280
FeeParam::unpackORI(oriindex, side, stack, layer, halfchamberside);
268281
int currentdetector = stack * constants::NLAYER + layer + supermodule * constants::NLAYER * constants::NSTACK;
269282
if (mVerbose) {
270-
LOG(info) << "******* LINK # " << currentlinkindex << " and starting at "<< mHBFoffset32 << " unpackORI(" << oriindex << "," << side << "," << stack << "," << layer << "," << halfchamberside << ") and an FEEID:" << std::hex << mFEEID << " det:" << std::dec << currentdetector;
283+
LOG(info) << "******* LINK # " << currentlinkindex << " and starting at " << mHBFoffset32 << " unpackORI(" << oriindex << "," << side << "," << stack << "," << layer << "," << halfchamberside << ") and an FEEID:" << std::hex << mFEEID << " det:" << std::dec << currentdetector;
271284
}
285+
LOG(info) << "******* LINK # " << currentlinkindex << " an FEEID:" << std::hex << mFEEID << " det:" << std::dec << currentdetector << " Error Flags : " << mCurrentHalfCRULinkErrorFlags[currentlinkindex];
272286
// tracklet first then digit ??
273287
// tracklets end with tracklet end marker(0x10001000 0x10001000), digits end with digit endmarker (0x0 0x0)
274288
if (linkstart != linkend) { // if link is not empty
@@ -280,7 +294,7 @@ int CruRawReader::processHalfCRU(int cruhbfstartoffset)
280294
LOG(info) << "trackletwordsread:" << trackletwordsread << " mem copy with offset of : " << cruhbfstartoffset << " parsing with linkstart: " << linkstart << " ending at : " << linkend;
281295
}
282296
linkstart += trackletwordsread;
283-
//now we have a tracklethcheader and a digithcheader.
297+
//now we have a tracklethcheader and a digithcheader.
284298
mHBFoffset32 += trackletwordsread;
285299
mTotalTrackletsFound += mTrackletsParser.getTrackletsFound();
286300
digitwordsread = 0;

Detectors/TRD/reconstruction/src/DataReader.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
9696
Options{}});
9797

9898
if (cfgc.options().get<bool>("enable-root-output")) {
99-
workflow.emplace_back(o2::trd::getTRDDigitWriterSpec(false, false));
99+
workflow.emplace_back(o2::trd::getTRDDigitWriterSpec(false, true));
100100
workflow.emplace_back(o2::trd::getTRDTrackletWriterSpec(false));
101101
}
102102

Detectors/TRD/reconstruction/src/DataReaderTask.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void DataReaderTask::run(ProcessingContext& pc)
115115
const auto* headerIn = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
116116
auto payloadIn = ref.payload;
117117
auto payloadInSize = headerIn->payloadSize;
118-
// const auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
118+
// const auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
119119
if (std::string(headerIn->dataDescription.str) != std::string("DISTSUBTIMEFRAMEFLP")) {
120120
if (!mCompressedData) { //we have raw data coming in from flp
121121
if (mVerbose) {
@@ -135,10 +135,9 @@ void DataReaderTask::run(ProcessingContext& pc)
135135
mCompressedReader.run();
136136
}
137137
} // ignore the input of DISTSUBTIMEFRAMEFLP
138-
// auto inputprocessingtime = std::chrono::high_resolution_clock::now() - inputprocessingstart;
139-
// LOGP(info, "Input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : processed in {} us",
140-
// dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, dh->payloadSize,std::chrono::duration_cast<std::chrono::microseconds>(inputprocessingtime).count());
141-
138+
// auto inputprocessingtime = std::chrono::high_resolution_clock::now() - inputprocessingstart;
139+
// LOGP(info, "Input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : processed in {} us",
140+
// dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, dh->payloadSize,std::chrono::duration_cast<std::chrono::microseconds>(inputprocessingtime).count());
142141
}
143142
/* output */
144143
sendData(pc, false);

0 commit comments

Comments
 (0)