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<int64_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 ;
@@ -181,6 +195,9 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
181195 continue ;
182196 }
183197 }
198+
199+ bcFreq[currentIR.toLong ()].set (feeID, true );
200+
184201 // Correct the cell time for the bc mod 4 (LHC: 40 MHz clock - ALTRO: 10 MHz clock)
185202 // Convention: All times shifted with respect to BC % 4 = 0 for trigger BC
186203 // Attention: Correction only works for the permutation (0 1 2 3) of the BC % 4, if the permutation is
@@ -338,6 +355,20 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
338355 mOutputTriggerRecords .emplace_back (interaction, currentevent.getTriggerBits (), eventstart, ncellsEvent + nLEDMONsEvent);
339356 }
340357
358+ for (const auto & [globalBC, activelinks] : bcFreq) {
359+ if (activelinks != bitSetActiveLinks) {
360+ LOG (error) << " Not all EMC active links contributed in global BCid=" << globalBC << " : mask=" << (activelinks ^ bitSetActiveLinks);
361+ mOutputCells .clear ();
362+ mOutputTriggerRecords .clear ();
363+ mOutputDecoderErrors .clear ();
364+ sendData (ctx, mOutputCells , mOutputTriggerRecords , mOutputDecoderErrors );
365+ bcFreq.clear ();
366+ return ;
367+ }
368+ }
369+
370+ bcFreq.clear ();
371+
341372 LOG (info) << " [EMCALRawToCellConverter - run] Writing " << mOutputCells .size () << " cells from " << mOutputTriggerRecords .size () << " events ..." ;
342373 sendData (ctx, mOutputCells , mOutputTriggerRecords , mOutputDecoderErrors );
343374}
@@ -355,9 +386,9 @@ void RawToCellConverterSpec::updateCalibrationObjects()
355386 LOG (info) << " RecoParams updated" ;
356387 o2::emcal::RecoParam::Instance ().printKeyValues (true , true );
357388 }
358- // if (mCalibHandler->hasUpdateFEEDCS()) {
359- // LOG(info) << "DCS params updated";
360- // }
389+ if (mCalibHandler ->hasUpdateFEEDCS ()) {
390+ LOG (info) << " DCS params updated" ;
391+ }
361392}
362393
363394bool RawToCellConverterSpec::isLostTimeframe (framework::ProcessingContext& ctx) const
@@ -677,7 +708,7 @@ o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getRawToCellConverter
677708 // CCDB objects
678709 auto calibhandler = std::make_shared<o2::emcal::CalibLoader>();
679710 calibhandler->enableRecoParams (true );
680- // calibhandler->enableFEEDCS(true);
711+ calibhandler->enableFEEDCS (true );
681712 calibhandler->defineInputSpecs (inputs);
682713
683714 return o2::framework::DataProcessorSpec{" EMCALRawToCellConverterSpec" ,
0 commit comments