@@ -33,8 +33,6 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
3333{
3434 mOutputDigits .clear ();
3535 std::map<o2::InteractionRecord, CTPDigit> digits;
36- const gbtword80_t bcidmask = 0xfff ;
37- gbtword80_t pldmask;
3836 using InputSpec = o2::framework::InputSpec;
3937 using ConcreteDataTypeMatcher = o2::framework::ConcreteDataTypeMatcher;
4038 using Lifetime = o2::framework::Lifetime;
@@ -80,6 +78,8 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
8078 for (auto it = parser.begin (); it != parser.end (); ++it) {
8179 auto rdh = it.get_if <o2::header::RAWDataHeader>();
8280 auto triggerOrbit = o2::raw::RDHUtils::getTriggerOrbit (rdh);
81+ uint32_t stopBit = o2::raw::RDHUtils::getStop (rdh);
82+ uint32_t packetCounter = o2::raw::RDHUtils::getPageCounter (rdh);
8383 // std::cout << "==================>" << std::hex << triggerOrbit << std::endl;
8484 if (first) {
8585 orbit0 = triggerOrbit;
@@ -97,12 +97,12 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
9797 } else {
9898 LOG (error) << " Unxpected CTP CRU link:" << linkCRU;
9999 }
100- LOG (debug) << " RDH FEEid: " << feeID << " CTP CRU link:" << linkCRU << " Orbit:" << triggerOrbit;
101- pldmask = 0 ;
100+ LOG (debug) << " RDH FEEid: " << feeID << " CTP CRU link:" << linkCRU << " Orbit:" << triggerOrbit << " stopbit:" << stopBit << " packet:" << packetCounter;
101+ // LOG(info) << "remnant :" << remnant.count();
102+ gbtword80_t pldmask = 0 ;
102103 for (uint32_t i = 0 ; i < payloadCTP; i++) {
103104 pldmask[12 + i] = 1 ;
104105 }
105- // LOG(info) << "pldmask:" << pldmask;
106106 // TF in 128 bits words
107107 gsl::span<const uint8_t > payload (it.data (), it.size ());
108108 gbtword80_t gbtWord = 0 ;
@@ -117,6 +117,7 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
117117 size_gbt = 0 ;
118118 orbit0 = triggerOrbit;
119119 }
120+ // LOG(info) << "payload size:" << payload.size();
120121 for (auto payloadWord : payload) {
121122 // LOG(info) << wordCount << " payload:" << int(payloadWord);
122123 if (wordCount == 15 ) {
@@ -132,61 +133,18 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
132133 // LOG(info) << " gbtword:" << gbtWord;
133134 makeGBTWordInverse (diglets, gbtWord, remnant, size_gbt, payloadCTP);
134135 // save digit in buffer recs
136+ // LOG(info) << "diglets size:" << diglets.size();
135137 for (auto diglet : diglets) {
136138 if (mDoLumi && payloadCTP == o2::ctp::NIntRecPayload) {
137- gbtword80_t pld = (diglet & mTVXMask ) ;
139+ gbtword80_t pld = (diglet >> 12 ) & mTVXMask ;
138140 if (pld.count () != 0 ) {
139141 countsMB++;
140142 }
141143 }
142144 if (!mDoDigits ) {
143145 continue ;
144146 }
145- gbtword80_t pld = (diglet & pldmask);
146- if (pld.count () == 0 ) {
147- continue ;
148- }
149- // LOG(info) << " pld:" << pld;
150- pld >>= 12 ;
151- CTPDigit digit;
152- uint32_t bcid = (diglet & bcidmask).to_ulong ();
153- o2::InteractionRecord ir;
154- ir.orbit = triggerOrbit;
155- ir.bc = bcid;
156- digit.intRecord = ir;
157- if (linkCRU == o2::ctp::GBTLinkIDIntRec) {
158- LOG (debug) << " InputMaskCount:" << digits[ir].CTPInputMask .count ();
159- if (digits.count (ir) == 0 ) {
160- digit.setInputMask (pld);
161- digits[ir] = digit;
162- LOG (debug) << bcid << " inputs case 0 bcid orbit " << triggerOrbit << " pld:" << pld;
163- } else if (digits.count (ir) == 1 ) {
164- if (digits[ir].CTPInputMask .count () == 0 ) {
165- digits[ir].setInputMask (pld);
166- LOG (debug) << bcid << " inputs bcid vase 1 orbit " << triggerOrbit << " pld:" << pld;
167- } else {
168- LOG (error) << " Two CTP IRs with the same timestamp." ;
169- }
170- } else {
171- LOG (error) << " Two digits with the same rimestamp." ;
172- }
173- } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
174- if (digits.count (ir) == 0 ) {
175- digit.setClassMask (pld);
176- digits[ir] = digit;
177- LOG (debug) << bcid << " class bcid case 0 orbit " << triggerOrbit << " pld:" << pld;
178- } else if (digits.count (ir) == 1 ) {
179- if (digits[ir].CTPClassMask .count () == 0 ) {
180- digits[ir].setClassMask (pld);
181- LOG (debug) << bcid << " class bcid case 1 orbit " << triggerOrbit << " pld:" << pld;
182- } else {
183- LOG (error) << " Two CTP Class masks for same timestamp" ;
184- }
185- } else {
186- }
187- } else {
188- LOG (error) << " Unxpected CTP CRU link:" << linkCRU;
189- }
147+ addCTPDigit (linkCRU, triggerOrbit, diglet, pldmask, digits);
190148 }
191149 gbtWord = 0 ;
192150 } else {
@@ -196,6 +154,20 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
196154 wordCount++;
197155 }
198156 }
157+ // LOG(info) << "remnant:" << remnant;
158+ if ((remnant.count () > 0 ) && stopBit) {
159+ if (mDoLumi && payloadCTP == o2::ctp::NIntRecPayload) {
160+ gbtword80_t pld = (remnant >> 12 ) & mTVXMask ;
161+ if (pld.count () != 0 ) {
162+ countsMB++;
163+ }
164+ }
165+ if (!mDoDigits ) {
166+ continue ;
167+ }
168+ addCTPDigit (linkCRU, triggerOrbit, remnant, pldmask, digits);
169+ remnant = 0 ;
170+ }
199171 }
200172 if (mDoDigits ) {
201173 for (auto const digmap : digits) {
@@ -210,6 +182,7 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
210182 for (auto const & lp : lumiPointsHBF1) {
211183 tfCounts += lp.counts ;
212184 }
185+ // LOG(info) << "Lumi rate:" << tfCounts/(128.*88e-6);
213186 mHistory .push_back (tfCounts);
214187 mCounts += tfCounts;
215188 if (mHistory .size () <= mNTFToIntegrate ) {
@@ -250,6 +223,57 @@ void RawDecoderSpec::makeGBTWordInverse(std::vector<gbtword80_t>& diglets, gbtwo
250223 size_gbt = NGBT - i;
251224 remnant = GBTWord;
252225}
226+ int RawDecoderSpec::addCTPDigit (uint32_t linkCRU, uint32_t triggerOrbit, gbtword80_t & diglet, gbtword80_t & pldmask, std::map<o2::InteractionRecord, CTPDigit>& digits)
227+ {
228+ gbtword80_t pld = (diglet & pldmask);
229+ if (pld.count () == 0 ) {
230+ return 0 ;
231+ }
232+ pld >>= 12 ;
233+ CTPDigit digit;
234+ const gbtword80_t bcidmask = 0xfff ;
235+ uint32_t bcid = (diglet & bcidmask).to_ulong ();
236+ // LOG(info) << bcid << " pld:" << pld;
237+ o2::InteractionRecord ir;
238+ ir.orbit = triggerOrbit;
239+ ir.bc = bcid;
240+ digit.intRecord = ir;
241+ if (linkCRU == o2::ctp::GBTLinkIDIntRec) {
242+ LOG (debug) << " InputMaskCount:" << digits[ir].CTPInputMask .count ();
243+ if (digits.count (ir) == 0 ) {
244+ digit.setInputMask (pld);
245+ digits[ir] = digit;
246+ LOG (debug) << bcid << " inputs case 0 bcid orbit " << triggerOrbit << " pld:" << pld;
247+ } else if (digits.count (ir) == 1 ) {
248+ if (digits[ir].CTPInputMask .count () == 0 ) {
249+ digits[ir].setInputMask (pld);
250+ LOG (debug) << bcid << " inputs bcid vase 1 orbit " << triggerOrbit << " pld:" << pld;
251+ } else {
252+ LOG (error) << " Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit ;
253+ }
254+ } else {
255+ LOG (error) << " Two digits with the same rimestamp:" << ir.bc << " " << ir.orbit ;
256+ }
257+ } else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
258+ if (digits.count (ir) == 0 ) {
259+ digit.setClassMask (pld);
260+ digits[ir] = digit;
261+ LOG (debug) << bcid << " class bcid case 0 orbit " << triggerOrbit << " pld:" << pld;
262+ } else if (digits.count (ir) == 1 ) {
263+ if (digits[ir].CTPClassMask .count () == 0 ) {
264+ digits[ir].setClassMask (pld);
265+ LOG (debug) << bcid << " class bcid case 1 orbit " << triggerOrbit << " pld:" << pld;
266+ } else {
267+ LOG (error) << " Two CTP Class masks for same timestamp" ;
268+ }
269+ } else {
270+ }
271+ } else {
272+ LOG (error) << " Unxpected CTP CRU link:" << linkCRU;
273+ }
274+ return 0 ;
275+ }
276+
253277o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec (bool askDISTSTF, bool digits, bool lumi)
254278{
255279 if (!digits && !lumi) {
0 commit comments