1212#include < iomanip>
1313#include < iostream>
1414#include < bitset>
15+ #include < map>
1516
1617#include < InfoLogger/InfoLogger.hxx>
1718
4243#include " SimulationDataFormat/MCCompLabel.h"
4344#include " SimulationDataFormat/MCTruthContainer.h"
4445#include " CommonUtils/VerbosityConfig.h"
46+ #include " EMCALCalib/FeeDCS.h"
4547
4648using namespace o2 ::emcal::reco_workflow;
4749
@@ -103,10 +105,22 @@ void RawToCellConverterSpec::init(framework::InitContext& ctx)
103105
104106void RawToCellConverterSpec::run (framework::ProcessingContext& ctx)
105107{
108+
106109 LOG (debug) << " [EMCALRawToCellConverter - run] called" ;
107110 mCalibHandler ->checkUpdates (ctx);
108111 updateCalibrationObjects ();
109112
113+ FeeDCS* feedcs = mCalibHandler ->getFEEDCS ();
114+ std::bitset<32 > list0 = feedcs->getDDLlist0 ();
115+ std::bitset<14 > list1 = feedcs->getDDLlist1 ();
116+ // links 21 and 39 do not exist, but they are set active in DCS
117+ list0.set (21 , false );
118+ list1.set (7 , false );
119+ // must be 0x307FFFDFFFFF if all links are active
120+ std::bitset<46 > bitSetActiveLinks ((list1.to_ullong () << 32 ) + list0.to_ullong ());
121+ // container with BCid and feeID
122+ std::unordered_map<ULong64_t, std::bitset<46 >> bcFreq;
123+
110124 double timeshift = RecoParam::Instance ().getCellTimeShiftNanoSec (); // subtract offset in ns in order to center the time peak around the nominal delay
111125 constexpr auto originEMC = o2::header::gDataOriginEMC ;
112126 constexpr auto descRaw = o2::header::gDataDescriptionRawData ;
@@ -167,6 +181,12 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
167181 auto feeID = raw::RDHUtils::getFEEID (header);
168182 auto triggerbits = raw::RDHUtils::getTriggerType (header);
169183
184+ ULong64_t BCcoll = ULong64_t (triggerBC) + ULong64_t (triggerOrbit * 3564 );
185+ bcFreq[BCcoll].set (feeID, true );
186+
187+ // std::cout << "__ BCcoll=" << BCcoll << " FEEID=" << feeID << std::endl;
188+ // LOG(info) << "__ BCcoll=" << BCcoll << " FEEID=" << feeID << std::endl;
189+
170190 int correctionShiftBCmod4 = 0 ;
171191 o2::InteractionRecord currentIR (triggerBC, triggerOrbit);
172192 // Correct physics triggers for the shift of the BC due to the LM-L0 delay
@@ -338,6 +358,21 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
338358 mOutputTriggerRecords .emplace_back (interaction, currentevent.getTriggerBits (), eventstart, ncellsEvent + nLEDMONsEvent);
339359 }
340360
361+ std::unordered_map<ULong64_t, std::bitset<46 >>::iterator p;
362+ for (p = bcFreq.begin (); p != bcFreq.end (); p++) {
363+ if (p->second != bitSetActiveLinks) {
364+ LOG (error) << " Not all EMC active links contributed in global BCid=" << p->first << " : mask=" << (p->second ^ bitSetActiveLinks);
365+ mOutputCells .clear ();
366+ mOutputTriggerRecords .clear ();
367+ mOutputDecoderErrors .clear ();
368+ sendData (ctx, mOutputCells , mOutputTriggerRecords , mOutputDecoderErrors );
369+ bcFreq.clear ();
370+ return ;
371+ }
372+ }
373+
374+ bcFreq.clear ();
375+
341376 LOG (info) << " [EMCALRawToCellConverter - run] Writing " << mOutputCells .size () << " cells from " << mOutputTriggerRecords .size () << " events ..." ;
342377 sendData (ctx, mOutputCells , mOutputTriggerRecords , mOutputDecoderErrors );
343378}
@@ -355,9 +390,9 @@ void RawToCellConverterSpec::updateCalibrationObjects()
355390 LOG (info) << " RecoParams updated" ;
356391 o2::emcal::RecoParam::Instance ().printKeyValues (true , true );
357392 }
358- // if (mCalibHandler->hasUpdateFEEDCS()) {
359- // LOG(info) << "DCS params updated";
360- // }
393+ if (mCalibHandler ->hasUpdateFEEDCS ()) {
394+ LOG (info) << " DCS params updated" ;
395+ }
361396}
362397
363398bool RawToCellConverterSpec::isLostTimeframe (framework::ProcessingContext& ctx) const
@@ -677,7 +712,7 @@ o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getRawToCellConverter
677712 // CCDB objects
678713 auto calibhandler = std::make_shared<o2::emcal::CalibLoader>();
679714 calibhandler->enableRecoParams (true );
680- // calibhandler->enableFEEDCS(true);
715+ calibhandler->enableFEEDCS (true );
681716 calibhandler->defineInputSpecs (inputs);
682717
683718 return o2::framework::DataProcessorSpec{" EMCALRawToCellConverterSpec" ,
0 commit comments