@@ -1175,6 +1175,7 @@ struct LumiTask {
11751175 std::vector<double > mPileupCorrectionTCE ;
11761176 std::vector<double > mPileupCorrectionZEM ;
11771177 std::vector<double > mPileupCorrectionZNC ;
1178+
11781179 int64_t minOrbitInRange = std::numeric_limits<int64_t >::max();
11791180 int64_t maxOrbitInRange = 0 ;
11801181 uint32_t currentOrbitIndex = 0 ;
@@ -1183,6 +1184,13 @@ struct LumiTask {
11831184
11841185 void init (InitContext&)
11851186 {
1187+ if (metadataInfo.isFullyDefined () && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration)
1188+ LOG (info) << " Autosetting the processing mode (Run2 or Run3) based on metadata" ;
1189+ if (metadataInfo.isRun3 ()) {
1190+ doprocessRun3.value = true ;
1191+ }
1192+ }
1193+
11861194 histos.add (" hCounterTVX" , " " , kTH1D , {{1 , 0 ., 1 .}});
11871195 histos.add (" hCounterTCE" , " " , kTH1D , {{1 , 0 ., 1 .}});
11881196 histos.add (" hCounterZEM" , " " , kTH1D , {{1 , 0 ., 1 .}});
@@ -1232,14 +1240,14 @@ struct LumiTask {
12321240 }
12331241 }
12341242
1235- void process (BCsWithBcSelsRun3 const & bcs, aod::FT0s const &)
1243+ void processRun3 (BCsWithBcSelsRun3 const & bcs, aod::FT0s const &)
12361244 {
12371245 if (bcs.size () == 0 )
12381246 return ;
12391247 int run = bcs.iteratorAt (0 ).runNumber ();
12401248 if (run < 500000 ) // o2-linter: disable=magic-number (skip for unanchored MCs)
12411249 return ;
1242- if (run != lastRun) {
1250+ if (run != lastRun && run >= 520259 ) { // o2-linter: disable=magic-number (scalers available for runs above 520120)
12431251 lastRun = run;
12441252 int64_t ts = bcs.iteratorAt (0 ).timestamp ();
12451253
@@ -1293,25 +1301,26 @@ struct LumiTask {
12931301 auto classes = config->getCTPClasses ();
12941302 TString lumiClassNameZNC = " C1ZNC-B-NOPF-CRU" ;
12951303 TString lumiClassNameTCE = " CMTVXTCE-B-NOPF-CRU" ;
1296- TString lumiClassNameTVX = run < 534202 ? " MINBIAS_TVX_L0" : " CMTVX-NONE-NOPF-CRU" ; // o2-linter: disable=magic-number (change in class name)
1304+ TString lumiClassNameTVX1 = " MINBIAS_TVX" ; // run >= 534467
1305+ TString lumiClassNameTVX2 = " MINBIAS_TVX_NOMASK" ; // run >= 534468
1306+ TString lumiClassNameTVX3 = " CMTVX-NONE-NOPF-CRU" ; // run >= 534996
1307+ TString lumiClassNameTVX4 = " CMTVX-B-NOPF-CRU" ; // run >= 543437
12971308
12981309 // find class indices
12991310 int classIdZNC = -1 ;
13001311 int classIdTCE = -1 ;
13011312 int classIdTVX = -1 ;
1302- // shift in scaler record needed for some runs in 2022-2023 (bug in CTP config?)
1303- int shift = 0 ;
1304- if (run >= 544116 && run <= 544122 ) // o2-linter: disable=magic-number (bug in CTP config for this run range)
1305- shift = -9 ;
1306- for (const auto & cl : classes) {
1307- TString clname = cl.name ;
1313+ for (unsigned int i = 0 ; i < classes.size (); i++) {
1314+ TString clname = classes[i].name ;
13081315 clname.ToUpper ();
1316+ // using position (i) in the vector of classes instead of classes[i].getIndex()
1317+ // due to bug or inconsistencies in scaler record and class indices
13091318 if (clname == lumiClassNameZNC)
1310- classIdZNC = cl. getIndex () + shift ;
1319+ classIdZNC = i ;
13111320 if (clname == lumiClassNameTCE)
1312- classIdTCE = cl. getIndex () + shift ;
1313- if (clname == lumiClassNameTVX )
1314- classIdTVX = cl. getIndex () + shift ;
1321+ classIdTCE = i ;
1322+ if (clname == lumiClassNameTVX4 || clname == lumiClassNameTVX3 || clname == lumiClassNameTVX2 || clname == lumiClassNameTVX1 )
1323+ classIdTVX = i ;
13151324 }
13161325
13171326 // extract trigger counts from CTP scalers
@@ -1379,8 +1388,9 @@ struct LumiTask {
13791388 bool isTriggerZNC = TESTBIT (selection, kIsBBZNC );
13801389 bool isTriggerZEM = isTriggerZNA || isTriggerZNC;
13811390
1391+ // determine pileup correction
13821392 int64_t orbit = bc.globalBC () / nBCsPerOrbit;
1383- if (orbit < minOrbitInRange || orbit > maxOrbitInRange) {
1393+ if (( orbit < minOrbitInRange || orbit > maxOrbitInRange) && mOrbits . size () > 1 ) {
13841394 auto it = std::lower_bound (mOrbits .begin (), mOrbits .end (), orbit);
13851395 uint32_t nextOrbitIndex = std::distance (mOrbits .begin (), it);
13861396 if (nextOrbitIndex == 0 ) // if orbit is below stored scaler orbits
@@ -1391,10 +1401,15 @@ struct LumiTask {
13911401 minOrbitInRange = mOrbits [currentOrbitIndex];
13921402 maxOrbitInRange = mOrbits [nextOrbitIndex];
13931403 }
1394- float lumiTVX = 1 . / csTVX * mPileupCorrectionTVX [currentOrbitIndex];
1395- float lumiTCE = 1 . / csTCE * mPileupCorrectionTCE [currentOrbitIndex];
1396- float lumiZNC = 1 . / csZNC * mPileupCorrectionZNC [currentOrbitIndex];
1397- float lumiZEM = 1 . / csZEM * mPileupCorrectionZEM [currentOrbitIndex];
1404+ double pileupCorrectionTVX = currentOrbitIndex < mPileupCorrectionTVX .size () ? mPileupCorrectionTVX [currentOrbitIndex] : 1 .;
1405+ double pileupCorrectionTCE = currentOrbitIndex < mPileupCorrectionTCE .size () ? mPileupCorrectionTCE [currentOrbitIndex] : 1 .;
1406+ double pileupCorrectionZNC = currentOrbitIndex < mPileupCorrectionZNC .size () ? mPileupCorrectionZNC [currentOrbitIndex] : 1 .;
1407+ double pileupCorrectionZEM = currentOrbitIndex < mPileupCorrectionZEM .size () ? mPileupCorrectionZEM [currentOrbitIndex] : 1 .;
1408+
1409+ double lumiTVX = 1 . / csTVX * pileupCorrectionTVX;
1410+ double lumiTCE = 1 . / csTCE * pileupCorrectionTCE;
1411+ double lumiZNC = 1 . / csZNC * pileupCorrectionZNC;
1412+ double lumiZEM = 1 . / csZEM * pileupCorrectionZEM;
13981413
13991414 if (isTriggerTVX) {
14001415 histos.get <TH1>(HIST (" hCounterTVX" ))->Fill (srun, 1 );
@@ -1450,6 +1465,7 @@ struct LumiTask {
14501465
14511466 } // bcs
14521467 } // process
1468+ PROCESS_SWITCH (LumiTask, processRun3, " Process Run3 lumi task" , false );
14531469};
14541470
14551471WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments