1212// /
1313// / \file DigitQcTask.cxx
1414// / \author Artur Furs afurs@cern.ch
15- // / LATEST modification for FDD on 24.08.2022 (sbysiak @cern.ch)
15+ // / LATEST modification for FDD on 25.04.2023 (akhuntia @cern.ch)
1616
1717#include " FDD/DigitQcTask.h"
1818#include " TCanvas.h"
@@ -129,7 +129,8 @@ bool DigitQcTask::chIsVertexEvent(const o2::fdd::ChannelData chd)
129129 return (chd.getFlag (o2::fdd::ChannelData::kIsCFDinADCgate ) &&
130130 !(chd.getFlag (o2::fdd::ChannelData::kIsTimeInfoNOTvalid ) || chd.getFlag (o2::fdd::ChannelData::kIsTimeInfoLate ) || chd.getFlag (o2::fdd::ChannelData::kIsTimeInfoLost )) &&
131131 std::abs (static_cast <Int_t>(chd.mTime )) < mTrgOrGate &&
132- !chd.getFlag (o2::fdd::ChannelData::kIsAmpHigh ));
132+ static_cast <Int_t>(chd.mChargeADC ) > mTrgChargeLevelLow &&
133+ static_cast <Int_t>(chd.mChargeADC ) < mTrgChargeLevelHigh );
133134}
134135
135136void DigitQcTask::initialize (o2::framework::InitContext& /* ctx*/ )
@@ -175,6 +176,10 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
175176 mTrgChargeLevelHigh = getNumericalParameter (" trgChargeLevelHigh" , 4095 );
176177 mTrgThresholdTimeLow = getNumericalParameter (" trgThresholdTimeLow" , -192 );
177178 mTrgThresholdTimeHigh = getNumericalParameter (" trgThresholdTimeHigh" , 192 );
179+ mBinMinADCSaturationCheck = getNumericalParameter (" BinMinADCSaturationCheck" , 1 );
180+ mBinMaxADCSaturationCheck = getNumericalParameter (" BinMaxADCSaturationCheck" , 3600 );
181+ mMinTimeGate = getNumericalParameter (" minGateTimeForRatioHistogram" , -192 );
182+ mMaxTimeGate = getNumericalParameter (" maxGateTimeForRatioHistogram" , 192 );
178183 if (mTrgModeSide == TrgModeSide::kAplusC ) {
179184 mTrgThresholdCenA = getNumericalParameter (" trgThresholdCenA" , 20 );
180185 mTrgThresholdSCenA = getNumericalParameter (" trgThresholdSCenA" , 10 );
@@ -286,7 +291,10 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
286291 mHistTimeSum2Diff ->GetYaxis ()->SetRangeUser (-5 , 5 );
287292 mHistNumADC = std::make_unique<TH1F >(" HistNumADC" , " HistNumADC" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
288293 mHistNumCFD = std::make_unique<TH1F >(" HistNumCFD" , " HistNumCFD" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
289- mHistCFDEff = std::make_unique<TH1F >(" CFD_efficiency" , " CFD efficiency;ChannelID;efficiency" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
294+ mHistCFDEff = std::make_unique<TH1F >(" CFD_efficiency" , " Fraction of events with CFD in ADC gate vs ChannelID;ChannelID;Event fraction with CFD in ADC gate" , sNCHANNELS_PM , 0 , sNCHANNELS_PM );
295+ mHistSaturationFraction = std::make_unique<TH1F >(" ADCChargeFractionInRange" , Form (" Fraction of charge in [%d, %d] ADC;Channel ID;Event fraction in [%d, %d] ADC" , mBinMinADCSaturationCheck , mBinMaxADCSaturationCheck , mBinMinADCSaturationCheck , mBinMaxADCSaturationCheck ), sNCHANNELS_PM , 0 , sNCHANNELS_PM );
296+ std::string gateTimeRatioTitle = " Ratio of events between time " + std::to_string (mMinTimeGate ) + " and " + std::to_string (mMaxTimeGate );
297+ mHistGateTimeRatio2Ch = std::make_unique<TH1F >(" EventsInGateTime" , gateTimeRatioTitle.c_str (), sNCHANNELS_PM , 0 , sNCHANNELS_PM );
290298 mHistNchA = std::make_unique<TH1F >(" NumChannelsA" , " Number of channels(TCM), side A;Nch" , sNCHANNELS_A , 0 , sNCHANNELS_A );
291299 mHistNchC = std::make_unique<TH1F >(" NumChannelsC" , " Number of channels(TCM), side C;Nch" , sNCHANNELS_C , 0 , sNCHANNELS_C );
292300 mHistSumAmpA = std::make_unique<TH1F >(" SumAmpA" , " Sum of amplitudes(TCM), side A;" , 5e3 , 0 , 5e3 );
@@ -353,6 +361,8 @@ void DigitQcTask::initialize(o2::framework::InitContext& /*ctx*/)
353361 rebinFromConfig (); // after all histos are created
354362 // 1-dim hists
355363 getObjectsManager ()->startPublishing (mHistCFDEff .get ());
364+ getObjectsManager ()->startPublishing (mHistSaturationFraction .get ());
365+ getObjectsManager ()->startPublishing (mHistGateTimeRatio2Ch .get ());
356366 getObjectsManager ()->startPublishing (mHistBC .get ());
357367 getObjectsManager ()->startPublishing (mHistNchA .get ());
358368 getObjectsManager ()->startPublishing (mHistNchC .get ());
@@ -420,6 +430,8 @@ void DigitQcTask::startOfActivity(Activity& activity)
420430 mHistBC ->Reset ();
421431 mHistChDataBits ->Reset ();
422432 mHistCFDEff ->Reset ();
433+ mHistSaturationFraction ->Reset ();
434+ mHistGateTimeRatio2Ch ->Reset ();
423435 mHistNumADC ->Reset ();
424436 mHistNumCFD ->Reset ();
425437 mHistTimeSum2Diff ->Reset ();
@@ -823,6 +835,29 @@ void DigitQcTask::endOfCycle()
823835 // one has to set num. of entries manually because
824836 // default TH1Reductor gets only mean,stddev and entries (no integral)
825837 mHistCFDEff ->Divide (mHistNumADC .get (), mHistNumCFD .get ());
838+ for (int iPM = 0 ; iPM < sNCHANNELS_PM ; iPM++) {
839+ double intNumerator = mHistAmp2Ch ->ProjectionY (" yNum" , iPM + 1 , iPM + 1 )->Integral (mBinMinADCSaturationCheck , mBinMaxADCSaturationCheck );
840+ double intDenominator = mHistAmp2Ch ->ProjectionY (" yDen" , iPM + 1 , iPM + 1 )->Integral (mBinMinADCSaturationCheck , mHistAmp2Ch ->GetNbinsY ());
841+ if (intDenominator)
842+ mHistSaturationFraction ->SetBinContent (iPM, intNumerator / intDenominator);
843+ }
844+
845+ for (int channel = 0 ; channel <= sNCHANNELS_PM ; channel++) {
846+ float events_in_range = 0 ;
847+ float events_per_channel = 0 ;
848+ for (int bin_on_y_axis = 1 ; bin_on_y_axis <= mHistTime2Ch ->GetNbinsY (); bin_on_y_axis++) {
849+ if (mHistTime2Ch ->GetYaxis ()->GetBinLowEdge (bin_on_y_axis) > mMinTimeGate && mHistTime2Ch ->GetYaxis ()->GetBinLowEdge (bin_on_y_axis) < mMaxTimeGate ) {
850+ events_in_range += mHistTime2Ch ->GetBinContent (channel + 1 , bin_on_y_axis);
851+ }
852+ events_per_channel += mHistTime2Ch ->GetBinContent (channel + 1 , bin_on_y_axis);
853+ }
854+ if (events_per_channel) {
855+ mHistGateTimeRatio2Ch ->SetBinContent (channel + 1 , events_in_range / events_per_channel);
856+ } else {
857+ mHistGateTimeRatio2Ch ->SetBinContent (channel + 1 , 0 );
858+ }
859+ }
860+ mHistSaturationFraction ->GetYaxis ()->SetRangeUser (0 , 1.1 );
826861 mHistCycleDurationRange ->SetBinContent (1 ., mTimeMaxNS - mTimeMinNS );
827862 mHistCycleDurationRange ->SetEntries (mTimeMaxNS - mTimeMinNS );
828863 mHistCycleDurationNTF ->SetBinContent (1 ., mTfCounter );
@@ -847,6 +882,8 @@ void DigitQcTask::reset()
847882 mHistBC ->Reset ();
848883 mHistChDataBits ->Reset ();
849884 mHistCFDEff ->Reset ();
885+ mHistSaturationFraction ->Reset ();
886+ mHistGateTimeRatio2Ch ->Reset ();
850887 mHistNumADC ->Reset ();
851888 mHistNumCFD ->Reset ();
852889 mHistTimeSum2Diff ->Reset ();
0 commit comments