2525#include " DataFormatsFT0/LookUpTable.h"
2626#include " Common/Utils.h"
2727
28+ #include " DataFormatsParameters/GRPLHCIFData.h"
29+ #include " CCDB/BasicCCDBManager.h"
30+
2831#include " FITCommon/HelperHist.h"
2932#include " FITCommon/HelperCommon.h"
3033
@@ -106,6 +109,7 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
106109 mHistTime2Ch = helper::registerHist<TH2F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " TimePerChannel" , " Time vs Channel;Channel;Time" , sNCHANNELS_PM , 0 , sNCHANNELS_PM , 4100 , -2050 , 2050 );
107110 mHistAmp2Ch = helper::registerHist<TH2F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " AmpPerChannel" , " Amplitude vs Channel;Channel;Amp" , sNCHANNELS_PM , 0 , sNCHANNELS_PM , 4200 , -100 , 4100 );
108111 mHistBC = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " BC" , " BC;BC;counts;" , sBCperOrbit , 0 , sBCperOrbit );
112+ mHistBCBeamBeam = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " BC_BeamBeam" , " Colliding BCs;BC;counts;" , sBCperOrbit , 0 , sBCperOrbit );
109113 mHistChDataBits = helper::registerHist<TH2F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " ChannelDataBits" , " ChannelData bits per ChannelID;Channel;Bit" , sNCHANNELS_PM , 0 , sNCHANNELS_PM , mMapPMbits );
110114
111115 // Trg plots
@@ -170,6 +174,9 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
170174 mHistNchC = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " NumChannelsC" , " Number of channels(TCM), side C;Nch" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
171175 mHistSumAmpA = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " SumAmpA" , " Sum of amplitudes(TCM), side A;" , 1e4 , 0 , 1e4 );
172176 mHistSumAmpC = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " SumAmpC" , " Sum of amplitudes(TCM), side C;" , 1e4 , 0 , 1e4 );
177+ mHistSumAmpAVTXBeamBeam = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " SumAmpAVTXBeamBeam" , " Sum of amplitudes(VTX+BeamBeam), FT0 A;ADC units;" , 4e5 , 0 , 4e5 );
178+ mHistSumAmpCVTXBeamBeam = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " SumAmpCVTXBeamBeam" , " Sum of amplitudes(VTX+BeamBeam), FT0 C;ADC units;" , 4e5 , 0 , 4e5 );
179+ mHistSumAmpACVTXBeamBeam = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " SumAmpACVTXBeamBeam" , " Sum of amplitudes(VTX+BeamBeam), FT0 A+C;ADC units;" , 9e5 , 0 , 9e5 );
173180 mHistAverageTimeA = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " AverageTimeA" , " Average time(TCM), side A" , 4100 , -2050 , 2050 );
174181 mHistAverageTimeC = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " AverageTimeC" , " Average time(TCM), side C" , 4100 , -2050 , 2050 );
175182 mHistChannelID = helper::registerHist<TH1F>(getObjectsManager (), PublicationPolicy::Forever, " COLZ" , " StatChannelID" , " ChannelID statistics;ChannelID" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
@@ -249,6 +256,7 @@ void DigitQcTask::startOfActivity(const Activity& activity)
249256 mHistTime2Ch ->Reset ();
250257 mHistAmp2Ch ->Reset ();
251258 mHistBC ->Reset ();
259+ mHistBCBeamBeam ->Reset ();
252260 mHistChDataBits ->Reset ();
253261 mHistTimeSum2Diff ->Reset ();
254262 mHistBCvsFEEmodules ->Reset ();
@@ -264,6 +272,9 @@ void DigitQcTask::startOfActivity(const Activity& activity)
264272 mHistNchC ->Reset ();
265273 mHistSumAmpA ->Reset ();
266274 mHistSumAmpC ->Reset ();
275+ mHistSumAmpAVTXBeamBeam ->Reset ();
276+ mHistSumAmpCVTXBeamBeam ->Reset ();
277+ mHistSumAmpACVTXBeamBeam ->Reset ();
267278 mHistAverageTimeA ->Reset ();
268279 mHistAverageTimeC ->Reset ();
269280 mHistChannelID ->Reset ();
@@ -299,10 +310,54 @@ void DigitQcTask::startOfCycle()
299310 mTimeSum = 0 .;
300311}
301312
313+ void DigitQcTask::loadBcPatternIfNeeded ()
314+ {
315+ if (mBcPatternLoaded ) {
316+ return ;
317+ }
318+ auto & ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
319+ ccdbManager.setTimestamp (mTFcreationTime );
320+ ccdbManager.setCaching (true );
321+ auto lhcIf = ccdbManager.get <o2::parameters::GRPLHCIFData>(" GLO/Config/GRPLHCIF" );
322+ if (!lhcIf) {
323+ ILOG (Error) << " GRPLHCIF missing → no colliding BC mask will be applied" << ENDM;
324+ mCollBC .reset ();
325+ mBcPatternLoaded = true ;
326+ return ;
327+ }
328+ const auto & pattern = lhcIf->getBunchFilling ().getBCPattern ();
329+ mCollBC .reset ();
330+ for (size_t bc = 0 ; bc < pattern.size (); ++bc) {
331+ if (pattern.test (bc)) {
332+ mCollBC .set (bc);
333+ }
334+ }
335+ mBcPatternLoaded = true ;
336+ }
337+
338+ void DigitQcTask::loadDeadChannelMapIfNeeded ()
339+ {
340+ if (mDeadChannelMapLoaded ) {
341+ return ;
342+ }
343+ auto & ccdbManager = o2::ccdb::BasicCCDBManager::instance ();
344+ ccdbManager.setTimestamp (mTFcreationTime );
345+ mDeadChannelMap = ccdbManager.get <o2::fit::DeadChannelMap>(" FT0/Calib/DeadChannelMap" );
346+ if (!mDeadChannelMap ) {
347+ ILOG (Error) << " Failed to load FT0 dead channel map" << ENDM;
348+ mDeadChannelMapLoaded = true ;
349+ return ;
350+ }
351+ ILOG (Info) << " Loaded FT0 dead channel map with " << mDeadChannelMap ->map .size ()<< " entries" << ENDM;
352+ mDeadChannelMapLoaded = true ;
353+ }
354+
302355void DigitQcTask::monitorData (o2::framework::ProcessingContext& ctx)
303356{
304357 mTFcreationTime = ctx.services ().get <o2::framework::TimingInfo>().creation ;
305358 mTfCounter ++;
359+ loadBcPatternIfNeeded ();
360+ loadDeadChannelMapIfNeeded ();
306361 auto channels = ctx.inputs ().get <gsl::span<o2::ft0::ChannelData>>(" channels" );
307362 auto digits = ctx.inputs ().get <gsl::span<o2::ft0::Digit>>(" digits" );
308363 if (digits.size () > 0 ) {
@@ -325,6 +380,12 @@ void DigitQcTask::monitorData(o2::framework::ProcessingContext& ctx)
325380 mHistOrbit2BC ->Fill (digit.getIntRecord ().orbit % sOrbitsPerTF , digit.getIntRecord ().bc );
326381 mHistBC ->Fill (digit.getBC ());
327382
383+ const bool isCollidingBC = mCollBC .test (digit.getBC ());
384+
385+ if (isCollidingBC) {
386+ mHistBCBeamBeam ->Fill (digit.getBC ());
387+ }
388+
328389 std::set<uint8_t > setFEEmodules{};
329390
330391 int32_t pmSumAmplA = 0 ;
@@ -335,11 +396,15 @@ void DigitQcTask::monitorData(o2::framework::ProcessingContext& ctx)
335396 int pmSumTimeC{ 0 };
336397 int pmAverTimeA{ 0 };
337398 int pmAverTimeC{ 0 };
338-
399+
339400 std::map<uint8_t , int > mapPMhash2sumAmpl;
340401 for (const auto & entry : mMapPMhash2isAside ) {
341402 mapPMhash2sumAmpl.insert ({ entry.first , 0 });
342403 }
404+
405+ int32_t sumampAVTXBeamBeam = 0 ;
406+ int32_t sumampCVTXBeamBeam = 0 ;
407+
343408 for (const auto & chData : vecChData) {
344409 mHistTime2Ch ->Fill (static_cast <Double_t>(chData.ChId ), static_cast <Double_t>(chData.CFDTime ));
345410 mHistAmp2Ch ->Fill (static_cast <Double_t>(chData.ChId ), static_cast <Double_t>(chData.QTCAmpl ));
@@ -376,7 +441,24 @@ void DigitQcTask::monitorData(o2::framework::ProcessingContext& ctx)
376441 if (chData.getFlag (o2::ft0::ChannelData::kIsCFDinADCgate )) {
377442 mapPMhash2sumAmpl[mChID2PMhash [static_cast <uint8_t >(chData.ChId )]] += static_cast <Int_t>(chData.QTCAmpl );
378443 }
444+
445+ const auto chId = static_cast <uint8_t >(chData.ChId );
446+ if (mDeadChannelMap && !mDeadChannelMap ->isChannelAlive (chId)) {
447+ continue ;
448+ }
449+
450+ if (digit.mTriggers .getVertex () && chData.getFlag (o2::ft0::ChannelData::kIsCFDinADCgate ) && isCollidingBC) {
451+ if (!mMapPMhash2isAside [mChID2PMhash [static_cast <uint8_t >(chData.ChId )]]) {
452+ sumampCVTXBeamBeam += chData.QTCAmpl ;
453+ }
454+ else if (mMapPMhash2isAside [mChID2PMhash [static_cast <uint8_t >(chData.ChId )]]) {
455+ sumampAVTXBeamBeam += chData.QTCAmpl ;
456+ }
457+ }
379458 }
459+ mHistSumAmpAVTXBeamBeam ->Fill (sumampAVTXBeamBeam);
460+ mHistSumAmpCVTXBeamBeam ->Fill (sumampCVTXBeamBeam);
461+ mHistSumAmpACVTXBeamBeam ->Fill (sumampAVTXBeamBeam+sumampCVTXBeamBeam);
380462
381463 for (const auto & entry : mapPMhash2sumAmpl) {
382464 if (mMapPMhash2isAside [entry.first ])
@@ -430,9 +512,10 @@ void DigitQcTask::monitorData(o2::framework::ProcessingContext& ctx)
430512 mHistPmTcmNchC ->Fill (digit.mTriggers .getNChanC (), pmNChanC - digit.mTriggers .getNChanC ());
431513 mHistPmTcmSumAmpC ->Fill (digit.mTriggers .getAmplC (), pmSumAmplC - digit.mTriggers .getAmplC ());
432514 mHistPmTcmAverageTimeC ->Fill (digit.mTriggers .getTimeC (), pmAverTimeC - digit.mTriggers .getTimeC ());
433-
515+
434516 mHistTimeSum2Diff ->Fill ((digit.mTriggers .getTimeC () - digit.mTriggers .getTimeA ()) * sCFDChannel2NS / 2 , (digit.mTriggers .getTimeC () + digit.mTriggers .getTimeA ()) * sCFDChannel2NS / 2 );
435517 }
518+
436519 if (isTCM) {
437520 std::vector<unsigned int > vecTrgWords{};
438521 const uint64_t trgWordExt = digit.mTriggers .getExtendedTrgWordFT0 ();
@@ -490,13 +573,17 @@ void DigitQcTask::reset()
490573 mHistTime2Ch ->Reset ();
491574 mHistAmp2Ch ->Reset ();
492575 mHistBC ->Reset ();
576+ mHistBCBeamBeam ->Reset ();
493577 mHistChDataBits ->Reset ();
494578 mHistTimeSum2Diff ->Reset ();
495579 mHistOrbit2BC ->Reset ();
496580 mHistNchA ->Reset ();
497581 mHistNchC ->Reset ();
498582 mHistSumAmpA ->Reset ();
499583 mHistSumAmpC ->Reset ();
584+ mHistSumAmpAVTXBeamBeam ->Reset ();
585+ mHistSumAmpCVTXBeamBeam ->Reset ();
586+ mHistSumAmpACVTXBeamBeam ->Reset ();
500587 mHistAverageTimeA ->Reset ();
501588 mHistAverageTimeC ->Reset ();
502589 mHistChannelID ->Reset ();
0 commit comments