@@ -210,19 +210,97 @@ struct : ConfigurableGroup {
210210
211211 int mRunNumber ;
212212 bool lCalibLoaded;
213- TList* lCalibObjects ;
213+ TList* lCalibObjectsMultiplicity ;
214214 TProfile* hVtxZFV0A;
215215 TProfile* hVtxZFT0A;
216216 TProfile* hVtxZFT0C;
217217 TProfile* hVtxZFDDA;
218218
219219 TProfile* hVtxZFDDC;
220220 TProfile* hVtxZNTracks;
221- std::vector<int > mEnabledTables ; // Vector of enabled tables
221+ std::vector<int > mEnabledMultiplicityTables ; // Vector of enabled multiplicity tables
222+ std::vector<int > mEnabledCentralityTables ; // Vector of enabled centrality tables
223+
224+ struct TagRun2V0MCalibration {
225+ bool mCalibrationStored = false ;
226+ TFormula* mMCScale = nullptr ;
227+ float mMCScalePars [6 ] = {0.0 };
228+ TH1* mhVtxAmpCorrV0A = nullptr ;
229+ TH1* mhVtxAmpCorrV0C = nullptr ;
230+ TH1* mhMultSelCalib = nullptr ;
231+ } Run2V0MInfo;
232+ struct TagRun2V0ACalibration {
233+ bool mCalibrationStored = false ;
234+ TH1* mhVtxAmpCorrV0A = nullptr ;
235+ TH1* mhMultSelCalib = nullptr ;
236+ } Run2V0AInfo;
237+ struct TagRun2SPDTrackletsCalibration {
238+ bool mCalibrationStored = false ;
239+ TH1* mhVtxAmpCorr = nullptr ;
240+ TH1* mhMultSelCalib = nullptr ;
241+ } Run2SPDTksInfo;
242+ struct TagRun2SPDClustersCalibration {
243+ bool mCalibrationStored = false ;
244+ TH1* mhVtxAmpCorrCL0 = nullptr ;
245+ TH1* mhVtxAmpCorrCL1 = nullptr ;
246+ TH1* mhMultSelCalib = nullptr ;
247+ } Run2SPDClsInfo;
248+ struct TagRun2CL0Calibration {
249+ bool mCalibrationStored = false ;
250+ TH1* mhVtxAmpCorr = nullptr ;
251+ TH1* mhMultSelCalib = nullptr ;
252+ } Run2CL0Info;
253+ struct TagRun2CL1Calibration {
254+ bool mCalibrationStored = false ;
255+ TH1* mhVtxAmpCorr = nullptr ;
256+ TH1* mhMultSelCalib = nullptr ;
257+ } Run2CL1Info;
258+ struct CalibrationInfo {
259+ std::string name = " " ;
260+ bool mCalibrationStored = false ;
261+ TH1* mhMultSelCalib = nullptr ;
262+ float mMCScalePars [6 ] = {0.0 };
263+ TFormula* mMCScale = nullptr ;
264+ explicit CalibrationInfo (std::string name)
265+ : name(name),
266+ mCalibrationStored(false ),
267+ mhMultSelCalib(nullptr ),
268+ mMCScalePars{0.0 },
269+ mMCScale (nullptr )
270+ {
271+ }
272+ bool isSane (bool fatalize = false )
273+ {
274+ if (!mhMultSelCalib) {
275+ return true ;
276+ }
277+ for (int i = 1 ; i < mhMultSelCalib->GetNbinsX () + 1 ; i++) {
278+ if (mhMultSelCalib->GetXaxis ()->GetBinLowEdge (i) > mhMultSelCalib->GetXaxis ()->GetBinUpEdge (i)) {
279+ if (fatalize) {
280+ LOG (fatal) << " Centrality calibration table " << name << " has bins with low edge > up edge" ;
281+ }
282+ LOG (warning) << " Centrality calibration table " << name << " has bins with low edge > up edge" ;
283+ return false ;
284+ }
285+ }
286+ return true ;
287+ }
288+ };
289+ CalibrationInfo fv0aInfo = CalibrationInfo(" FV0" );
290+ CalibrationInfo ft0mInfo = CalibrationInfo(" FT0" );
291+ CalibrationInfo ft0aInfo = CalibrationInfo(" FT0A" );
292+ CalibrationInfo ft0cInfo = CalibrationInfo(" FT0C" );
293+ CalibrationInfo ft0cVariant1Info = CalibrationInfo(" FT0Cvar1" );
294+ CalibrationInfo fddmInfo = CalibrationInfo(" FDD" );
295+ CalibrationInfo ntpvInfo = CalibrationInfo(" NTracksPV" );
296+ CalibrationInfo nGlobalInfo = CalibrationInfo(" NGlobal" );
297+ CalibrationInfo mftInfo = CalibrationInfo(" MFT" );
298+
299+
222300
223301 // Debug output
224302 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::QAObject};
225- OutputObj<TList> listCalib {" calib-list" , OutputObjHandlingPolicy::QAObject};
303+ OutputObj<TList> listCalibMultiplicity {" calib-list" , OutputObjHandlingPolicy::QAObject};
226304
227305 unsigned int randomSeed = 0 ;
228306 void init (InitContext& context)
@@ -258,7 +336,7 @@ struct : ConfigurableGroup {
258336 enableFlagIfTableRequired (context, tableNames[i], f);
259337 if (f == 1 ) {
260338 enabledMultiplicities[i] = true ;
261- mEnabledTables .push_back (i);
339+ mEnabledMultiplicityTables .push_back (i);
262340 if (fractionOfEvents <= 1 .f && (tableNames[i] != " MultsExtra" )) {
263341 LOG (fatal) << " Cannot have a fraction of events <= 1 and multiplicity table consumed." ;
264342 }
@@ -274,33 +352,62 @@ struct : ConfigurableGroup {
274352
275353 // Check that the tables are enabled consistenly
276354 if (enabledMultiplicities[kFV0MultZeqs ] && !enabledMultiplicities[kFV0Mults ]) { // FV0
277- mEnabledTables .push_back (kFV0Mults );
355+ mEnabledMultiplicityTables .push_back (kFV0Mults );
278356 LOG (info) << " Cannot have the " << tableNames[kFV0MultZeqs ] << " table enabled and not the one on " << tableNames[kFV0Mults ] << " . Enabling it." ;
279357 }
280358 if (enabledMultiplicities[kFT0MultZeqs ] && !enabledMultiplicities[kFT0Mults ]) { // FT0
281- mEnabledTables .push_back (kFT0Mults );
359+ mEnabledMultiplicityTables .push_back (kFT0Mults );
282360 LOG (info) << " Cannot have the " << tableNames[kFT0MultZeqs ] << " table enabled and not the one on " << tableNames[kFT0Mults ] << " . Enabling it." ;
283361 }
284362 if (enabledMultiplicities[kFDDMultZeqs ] && !enabledMultiplicities[kFDDMults ]) { // FDD
285- mEnabledTables .push_back (kFDDMults );
363+ mEnabledMultiplicityTables .push_back (kFDDMults );
286364 LOG (info) << " Cannot have the " << tableNames[kFDDMultZeqs ] << " table enabled and not the one on " << tableNames[kFDDMults ] << " . Enabling it." ;
287365 }
288366 if (enabledMultiplicities[kPVMultZeqs ] && !enabledMultiplicities[kPVMults ]) { // PV
289- mEnabledTables .push_back (kPVMults );
367+ mEnabledMultiplicityTables .push_back (kPVMults );
290368 LOG (info) << " Cannot have the " << tableNames[kPVMultZeqs ] << " table enabled and not the one on " << tableNames[kPVMults ] << " . Enabling it." ;
291369 }
370+ std::sort (mEnabledMultiplicityTables .begin (), mEnabledMultiplicityTables .end ());
371+
372+
373+ /* Checking the tables which are requested in the workflow and enabling them */
374+ for (int i = 0 ; i < centrality::kNTables ; i++) {
375+ int f = enabledCentralityTables->get (centrality::tableNames[i].c_str (), " Enable" );
376+ enableFlagIfTableRequired (context, centrality::tableNames[i], f);
377+ if (f == 1 ) {
378+ if (centrality::tableNames[i].find (" Run2" ) != std::string::npos) {
379+ if (doprocessRun3) {
380+ LOG (fatal) << " Cannot enable Run2 table `" << centrality::tableNames[i] << " ` while running in Run3 mode. Please check and disable them." ;
381+ }
382+ } else {
383+ if (doprocessRun2) {
384+ LOG (fatal) << " Cannot enable Run3 table `" << centrality::tableNames[i] << " ` while running in Run2 mode. Please check and disable them." ;
385+ }
386+ }
387+ isTableEnabled[i] = true ;
388+ mEnabledTables .push_back (i);
389+ }
390+ }
391+
392+ if (mEnabledTables .size () == 0 ) {
393+ LOGF (fatal, " No table enabled. Please enable at least one table." );
394+ }
292395 std::sort (mEnabledTables .begin (), mEnabledTables .end ());
293396
397+
398+
399+
400+
294401 mRunNumber = 0 ;
295402 lCalibLoaded = false ;
296- lCalibObjects = nullptr ;
403+ lCalibObjectsMultiplicity = nullptr ;
297404 hVtxZFV0A = nullptr ;
298405 hVtxZFT0A = nullptr ;
299406 hVtxZFT0C = nullptr ;
300407 hVtxZFDDA = nullptr ;
301408 hVtxZFDDC = nullptr ;
302409 hVtxZNTracks = nullptr ;
303- listCalib .setObject (new TList);
410+ listCalibMultiplicity .setObject (new TList);
304411
305412 if (!produceHistograms.value ) {
306413 return ;
@@ -343,7 +450,7 @@ struct : ConfigurableGroup {
343450 aod::FDDs const &)
344451 {
345452 // reserve memory for multiplicity tables
346- for (const auto & i : mEnabledTables ) {
453+ for (const auto & i : mEnabledMultiplicityTables ) {
347454 switch (i) {
348455 case kFV0Mults : // FV0
349456 tableFV0.reserve (collisions.size ());
@@ -431,30 +538,30 @@ struct : ConfigurableGroup {
431538 if (bc.runNumber () != mRunNumber ) {
432539 mRunNumber = bc.runNumber (); // mark this run as at least tried
433540 if (ccdbConfig.reconstructionPass .value == " " ) {
434- lCalibObjects = ccdb->getForRun <TList>(ccdbConfig.ccdbPath , mRunNumber );
541+ lCalibObjectsMultiplicity = ccdb->getForRun <TList>(ccdbConfig.ccdbPath , mRunNumber );
435542 } else if (ccdbConfig.reconstructionPass .value == " metadata" ) {
436543 std::map<std::string, std::string> metadata;
437544 metadata[" RecoPassName" ] = metadataInfo.get (" RecoPassName" );
438545 LOGF (info, " Loading CCDB for reconstruction pass (from metadata): %s" , metadataInfo.get (" RecoPassName" ));
439- lCalibObjects = ccdb->getSpecificForRun <TList>(ccdbConfig.ccdbPath , mRunNumber , metadata);
546+ lCalibObjectsMultiplicity = ccdb->getSpecificForRun <TList>(ccdbConfig.ccdbPath , mRunNumber , metadata);
440547 } else {
441548 std::map<std::string, std::string> metadata;
442549 metadata[" RecoPassName" ] = ccdbConfig.reconstructionPass .value ;
443550 LOGF (info, " Loading CCDB for reconstruction pass (from provided argument): %s" , ccdbConfig.reconstructionPass .value );
444- lCalibObjects = ccdb->getSpecificForRun <TList>(ccdbConfig.ccdbPath , mRunNumber , metadata);
551+ lCalibObjectsMultiplicity = ccdb->getSpecificForRun <TList>(ccdbConfig.ccdbPath , mRunNumber , metadata);
445552 }
446553
447- if (lCalibObjects ) {
554+ if (lCalibObjectsMultiplicity ) {
448555 if (produceHistograms) {
449- listCalib ->Add (lCalibObjects ->Clone (Form (" %i" , bc.runNumber ())));
556+ listCalibMultiplicity ->Add (lCalibObjectsMultiplicity ->Clone (Form (" %i" , bc.runNumber ())));
450557 }
451558
452- hVtxZFV0A = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZFV0A" ));
453- hVtxZFT0A = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZFT0A" ));
454- hVtxZFT0C = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZFT0C" ));
455- hVtxZFDDA = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZFDDA" ));
456- hVtxZFDDC = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZFDDC" ));
457- hVtxZNTracks = static_cast <TProfile*>(lCalibObjects ->FindObject (" hVtxZNTracksPV" ));
559+ hVtxZFV0A = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZFV0A" ));
560+ hVtxZFT0A = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZFT0A" ));
561+ hVtxZFT0C = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZFT0C" ));
562+ hVtxZFDDA = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZFDDA" ));
563+ hVtxZFDDC = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZFDDC" ));
564+ hVtxZNTracks = static_cast <TProfile*>(lCalibObjectsMultiplicity ->FindObject (" hVtxZNTracksPV" ));
458565 lCalibLoaded = true ;
459566 // Capture error
460567 if (!hVtxZFV0A || !hVtxZFT0A || !hVtxZFT0C || !hVtxZFDDA || !hVtxZFDDC || !hVtxZNTracks) {
@@ -468,7 +575,7 @@ struct : ConfigurableGroup {
468575 }
469576 }
470577
471- for (const auto & i : mEnabledTables ) {
578+ for (const auto & i : mEnabledMultiplicityTables ) {
472579 switch (i) {
473580 case kFV0Mults : // FV0
474581 {
0 commit comments