2020#include " EMCALReconstruction/Channel.h"
2121#include " EMCALCalib/BadChannelMap.h"
2222#include " EMCALCalib/TimeCalibrationParams.h"
23+ #include " EMCALCalib/FeeDCS.h"
2324// QC includes
2425#include " QualityControl/QcInfoLogger.h"
2526#include " EMCAL/CalibMonitoringTask.h"
@@ -37,6 +38,60 @@ using namespace o2::quality_control::core;
3738namespace o2 ::quality_control_modules::emcal
3839{
3940
41+ int CalibMonitoringTask::GetTRUIndexFromSTUIndex (Int_t id, Int_t detector)
42+ {
43+ Int_t kEMCAL = 0 ;
44+ Int_t kDCAL = 1 ;
45+
46+ if ((id > 31 && detector == kEMCAL ) || (id > 13 && detector == kDCAL ) || id < 0 ) {
47+ return -1 ; // Error Condition
48+ }
49+
50+ if (detector == kEMCAL ) {
51+ return id;
52+ } else if (detector == kDCAL ) {
53+ return 32 + ((int )(id / 4 ) * 6 ) + ((id % 4 < 2 ) ? (id % 4 ) : (id % 4 + 2 ));
54+ }
55+ return -1 ;
56+ }
57+
58+ int CalibMonitoringTask::GetChannelForMaskRun2 (int mask, int bitnumber, bool onethirdsm)
59+ {
60+ if (onethirdsm)
61+ return mask * 16 + bitnumber;
62+ const int kChannelMap [6 ][16 ] = { { 8 , 9 , 10 , 11 , 20 , 21 , 22 , 23 , 32 , 33 , 34 , 35 , 44 , 45 , 46 , 47 }, // Channels in mask0
63+ { 56 , 57 , 58 , 59 , 68 , 69 , 70 , 71 , 80 , 81 , 82 , 83 , 92 , 93 , 94 , 95 }, // Channels in mask1
64+ { 4 , 5 , 6 , 7 , 16 , 17 , 18 , 19 , 28 , 29 , 30 , 31 , 40 , 41 , 42 , 43 }, // Channels in mask2
65+ { 52 , 53 , 54 , 55 , 64 , 65 , 66 , 67 , 76 , 77 , 78 , 79 , 88 , 89 , 90 , 91 }, // Channels in mask3
66+ { 0 , 1 , 2 , 3 , 12 , 13 , 14 , 15 , 24 , 25 , 26 , 27 , 36 , 37 , 38 , 39 }, // Channels in mask4
67+ { 48 , 49 , 50 , 51 , 60 , 61 , 62 , 63 , 72 , 73 , 74 , 75 , 84 , 85 , 86 , 87 } }; // Channels in mask5
68+ return kChannelMap [mask][bitnumber];
69+ }
70+
71+ std::vector<int > CalibMonitoringTask::GetAbsFastORIndexFromMask ()
72+ {
73+ std::vector<int > maskedfastors;
74+ int itru = 0 ;
75+ for (Int_t i = 0 ; i < 46 ; i++) {
76+ int localtru = itru % 32 , detector = itru >= 32 ? 1 : 0 ,
77+ globaltru = GetTRUIndexFromSTUIndex (localtru, detector);
78+ bool onethirdsm = ((globaltru >= 30 && globaltru < 32 ) || (globaltru >= 50 && globaltru < 52 ));
79+ for (int ipos = 0 ; ipos < 6 ; ipos++) {
80+ auto regmask = mFeeDCS ->getTRUDCS (i).getMaskReg (ipos);
81+ std::bitset<16 > bitsregmask (regmask);
82+ for (int ibit = 0 ; ibit < 16 ; ibit++) {
83+ if (bitsregmask.test (ibit)) {
84+ auto channel = GetChannelForMaskRun2 (ipos, ibit, onethirdsm);
85+ int absfastor = mTriggerMapping ->getAbsFastORIndexFromIndexInTRU (globaltru, channel);
86+ maskedfastors.push_back (absfastor);
87+ }
88+ }
89+ }
90+ itru++;
91+ }
92+ return maskedfastors;
93+ }
94+
4095void CalibMonitoringTask::configure (const boost::property_tree::ptree& config)
4196{
4297 mCalibDB = std::make_unique<o2::emcal::CalibDB>(config.get <std::string>(" qc.config.conditionDB.url" ).data ());
@@ -150,6 +205,55 @@ void CalibMonitoringTask::initialize(Trigger, framework::ServiceRegistryRef)
150205 }
151206 getObjectsManager ()->startPublishing (mNumberOfNonGoodChannelsFEC );
152207 }
208+ if (obj == " FeeDCS" ) {
209+ if (!mSRUFirmwareVersion ) {
210+ mSRUFirmwareVersion = new TH1D (" SRUFirmwareVersion" , " SRUFirmwareVersion of Supermodule" , 20 ., -0.5 , 19.5 );
211+ mSRUFirmwareVersion ->GetXaxis ()->SetTitle (" Supermodule ID" );
212+ mSRUFirmwareVersion ->GetYaxis ()->SetTitle (" SRUFirmwareVersion" );
213+ mSRUFirmwareVersion ->SetStats (false );
214+ }
215+ getObjectsManager ()->startPublishing (mSRUFirmwareVersion );
216+
217+ if (!mActiveDDLs ) {
218+ mActiveDDLs = new TH1D (" ActiveDDLs" , " Active Status of DDLs" , 46 ., -0.5 , 45.5 );
219+ mActiveDDLs ->GetXaxis ()->SetTitle (" DDL ID" );
220+ mActiveDDLs ->GetYaxis ()->SetTitle (" Active Status" );
221+ mActiveDDLs ->SetStats (false );
222+ }
223+ getObjectsManager ()->startPublishing (mActiveDDLs );
224+
225+ if (!mTRUThresholds ) {
226+ mTRUThresholds = new TH1D (" TRUThresholds" , " L0 threshold of TRUs" , 46 ., -0.5 , 45.5 );
227+ mTRUThresholds ->GetXaxis ()->SetTitle (" TRU ID" );
228+ mTRUThresholds ->GetYaxis ()->SetTitle (" L0 threshold" );
229+ mTRUThresholds ->SetStats (false );
230+ }
231+ getObjectsManager ()->startPublishing (mTRUThresholds );
232+
233+ if (!mL0Algorithm ) {
234+ mL0Algorithm = new TH1D (" L0Algorithm" , " L0 algorithm of TRUs" , 46 ., -0.5 , 45.5 );
235+ mL0Algorithm ->GetXaxis ()->SetTitle (" TRU ID" );
236+ mL0Algorithm ->GetYaxis ()->SetTitle (" L0 algorithm" );
237+ mL0Algorithm ->SetStats (false );
238+ }
239+ getObjectsManager ()->startPublishing (mL0Algorithm );
240+
241+ if (!mRollbackSTU ) {
242+ mRollbackSTU = new TH1D (" RollbackSTU" , " Rollback Buffer of TRUs" , 46 ., -0.5 , 45.5 );
243+ mRollbackSTU ->GetXaxis ()->SetTitle (" TRU ID" );
244+ mRollbackSTU ->GetYaxis ()->SetTitle (" Rollback Buffer" );
245+ mRollbackSTU ->SetStats (false );
246+ }
247+ getObjectsManager ()->startPublishing (mRollbackSTU );
248+
249+ if (!mTRUMaskPosition ) {
250+ mTRUMaskPosition = new TH2D (" TRUMaskPosition" , " TRU Mask Position" , 48 ., -0.5 , 47.5 , 104 , -0.5 , 103.5 );
251+ mTRUMaskPosition ->GetXaxis ()->SetTitle (" FastOR Abs Eta" );
252+ mTRUMaskPosition ->GetYaxis ()->SetTitle (" FastOR Abs Phi" );
253+ mTRUMaskPosition ->SetStats (false );
254+ }
255+ getObjectsManager ()->startPublishing (mTRUMaskPosition );
256+ }
153257 }
154258 o2::emcal::Geometry::GetInstanceFromRunNumber (300000 );
155259 mMapper = std::make_unique<o2::emcal::MappingHandler>();
@@ -217,6 +321,36 @@ void CalibMonitoringTask::update(Trigger t, framework::ServiceRegistryRef)
217321 mTimeCalibParamPosition ->SetBinContent (column + 1 , row + 1 , hist_temp->GetBinContent (i + 1 ));
218322 }
219323 }
324+ if (obj == " FeeDCS" ) {
325+ mFeeDCS = mCalibDB ->readFeeDCSData (o2::ccdb::getCurrentTimestamp (), metadata);
326+ if (!mFeeDCS ) {
327+ ILOG (Info, Support) << " No FEE DCS object " << ENDM ;
328+ continue ;
329+ }
330+ for (Int_t i = 0 ; i < mSRUFirmwareVersion ->GetNbinsX (); i++) {
331+ mSRUFirmwareVersion ->SetBinContent (i + 1 , mFeeDCS ->getSRUFWversion (i));
332+ }
333+ for (Int_t i = 0 ; i < mActiveDDLs ->GetNbinsX (); i++) {
334+ mActiveDDLs ->SetBinContent (i + 1 , mFeeDCS ->isDDLactive (i));
335+ }
336+ for (Int_t i = 0 ; i < mTRUThresholds ->GetNbinsX (); i++) {
337+ mTRUThresholds ->SetBinContent (i + 1 , static_cast <double >(mFeeDCS ->getTRUDCS (i).getGTHRL0 ()));
338+ }
339+ for (Int_t i = 0 ; i < mL0Algorithm ->GetNbinsX (); i++) {
340+ mL0Algorithm ->SetBinContent (i + 1 , mFeeDCS ->getTRUDCS (i).getL0SEL ());
341+ }
342+
343+ for (Int_t i = 0 ; i < mRollbackSTU ->GetNbinsX (); i++) {
344+ mRollbackSTU ->SetBinContent (i + 1 , mFeeDCS ->getTRUDCS (i).getRLBKSTU ());
345+ }
346+
347+ auto fastORs = GetAbsFastORIndexFromMask ();
348+
349+ for (auto fastORID : fastORs) {
350+ auto [eta, phi] = mTriggerMapping ->getPositionInEMCALFromAbsFastORIndex (fastORID);
351+ mTRUMaskPosition ->SetBinContent (eta + 1 , phi + 1 , 1 .);
352+ }
353+ }
220354 }
221355}
222356
@@ -237,6 +371,14 @@ void CalibMonitoringTask::finalize(Trigger t, framework::ServiceRegistryRef)
237371 getObjectsManager ()->stopPublishing (mTimeCalibParamHisto );
238372 getObjectsManager ()->stopPublishing (mTimeCalibParamPosition );
239373 }
374+ if (obj == " FeeDCS" ) {
375+ getObjectsManager ()->stopPublishing (mSRUFirmwareVersion );
376+ getObjectsManager ()->stopPublishing (mActiveDDLs );
377+ getObjectsManager ()->stopPublishing (mTRUThresholds );
378+ getObjectsManager ()->stopPublishing (mL0Algorithm );
379+ getObjectsManager ()->stopPublishing (mRollbackSTU );
380+ getObjectsManager ()->stopPublishing (mTRUMaskPosition );
381+ }
240382 }
241383}
242384void CalibMonitoringTask::reset ()
@@ -271,5 +413,23 @@ void CalibMonitoringTask::reset()
271413 if (mTimeCalibParamHisto ) {
272414 mTimeCalibParamHisto ->Reset ();
273415 }
416+ if (mSRUFirmwareVersion ) {
417+ mSRUFirmwareVersion ->Reset ();
418+ }
419+ if (mActiveDDLs ) {
420+ mActiveDDLs ->Reset ();
421+ }
422+ if (mTRUThresholds ) {
423+ mTRUThresholds ->Reset ();
424+ }
425+ if (mL0Algorithm ) {
426+ mL0Algorithm ->Reset ();
427+ }
428+ if (mRollbackSTU ) {
429+ mRollbackSTU ->Reset ();
430+ }
431+ if (mTRUMaskPosition ) {
432+ mTRUMaskPosition ->Reset ();
433+ }
274434}
275435} // namespace o2::quality_control_modules::emcal
0 commit comments