@@ -38,6 +38,7 @@ struct EventSelectionQaTask {
3838 Configurable<int > nOrbitsConf{" nOrbits" , 10000 , " number of orbits" };
3939 Configurable<int > refBC{" refBC" , 1238 , " reference bc" };
4040 Configurable<bool > isLowFlux{" isLowFlux" , 1 , " 1 - low flux (pp, pPb), 0 - high flux (PbPb)" };
41+ Configurable<bool > flagMonitorBcInTF{" flagMonitorBcInTF" , 1 , " 0 - no, 1 - yes" };
4142
4243 uint64_t minGlobalBC = 0 ;
4344 Service<o2::ccdb::BasicCCDBManager> ccdb;
@@ -47,6 +48,8 @@ struct EventSelectionQaTask {
4748 int lastRunNumber = -1 ;
4849 int nOrbits = nOrbitsConf;
4950 double minOrbit = minOrbitConf;
51+ int64_t bcSOR = -1 ; // global bc of the start of the first orbit
52+ int64_t nBCsPerTF = -1 ; // duration of TF in bcs, should be 128*3564 or 32*3564
5053 std::bitset<o2::constants::lhc::LHCMaxBunches> beamPatternA;
5154 std::bitset<o2::constants::lhc::LHCMaxBunches> beamPatternC;
5255 std::bitset<o2::constants::lhc::LHCMaxBunches> bcPatternA;
@@ -260,6 +263,12 @@ struct EventSelectionQaTask {
260263 histos.add (" hMultT0MVsNcontribAcc" , " " , kTH2F , {axisMultT0M, axisNcontrib}); // before ITS RO Frame border cut
261264 histos.add (" hMultT0MVsNcontribCut" , " " , kTH2F , {axisMultT0M, axisNcontrib}); // after ITS RO Frame border cut
262265
266+ if (flagMonitorBcInTF) {
267+ AxisSpec axisBCinTF{128 * nBCsPerOrbit + 1 + 10 , -0.5 , 128 * nBCsPerOrbit + 0.5 + 10 , " bc in TF" };
268+ histos.add (" hNcontribVsBcInTF" , " ;bc in TF; n vertex contributors" , kTH1F , {axisBCinTF});
269+ histos.add (" hNcontribAfterCutsVsBcInTF" , " ;bc in TF; n vertex contributors" , kTH1F , {axisBCinTF});
270+ }
271+
263272 // MC histograms
264273 histos.add (" hGlobalBcColMC" , " " , kTH1F , {axisGlobalBCs});
265274 histos.add (" hBcColMC" , " " , kTH1F , {axisBCs});
@@ -494,6 +503,7 @@ struct EventSelectionQaTask {
494503 aod::FDDs const & fdds)
495504 {
496505 int runNumber = bcs.iteratorAt (0 ).runNumber ();
506+ uint32_t nOrbitsPerTF = 128 ; // 128 in 2022, 32 in 2023
497507 if (runNumber != lastRunNumber) {
498508 lastRunNumber = runNumber; // do it only once
499509 int64_t tsSOR = 0 ;
@@ -528,39 +538,44 @@ struct EventSelectionQaTask {
528538 LOGP (info, " tsOrbitReset={} us" , tsOrbitReset);
529539
530540 // access TF duration, start-of-run and end-of-run timestamps from ECS GRP
531- // std::map<std::string, std::string> metadata;
532- // metadata["runNumber"] = Form("%d", runNumber);
533- // auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
534- // uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF
535- // tsSOR = grpecs->getTimeStart(); // ms
536- // tsEOR = grpecs->getTimeEnd(); // ms
541+ std::map<std::string, std::string> metadata;
542+ metadata[" runNumber" ] = Form (" %d" , runNumber);
543+ auto grpecs = ccdb->getSpecific <o2::parameters::GRPECSObject>(" GLO/Config/GRPECS" , ts, metadata);
544+ nOrbitsPerTF = grpecs->getNHBFPerTF (); // assuming 1 orbit = 1 HBF
545+ tsSOR = grpecs->getTimeStart (); // ms
546+ tsEOR = grpecs->getTimeEnd (); // ms
537547
538548 // Temporary workaround for 22q (due to ZDC bc shifts)
539- o2::ccdb::CcdbApi ccdb_api;
540- ccdb_api.init (" http://alice-ccdb.cern.ch" );
541- std::map<string, string> metadataRCT, headers;
542- headers = ccdb_api.retrieveHeaders (Form (" RCT/Info/RunInformation/%i" , runNumber), metadataRCT, -1 );
543- tsSOR = atol (headers[" SOR" ].c_str ());
544- tsEOR = atol (headers[" EOR" ].c_str ());
545- uint32_t nOrbitsPerTF = 128 ;
549+ // o2::ccdb::CcdbApi ccdb_api;
550+ // ccdb_api.init("http://alice-ccdb.cern.ch");
551+ // std::map<string, string> metadataRCT, headers;
552+ // headers = ccdb_api.retrieveHeaders(Form("RCT/Info/RunInformation/%i", runNumber), metadataRCT, -1);
553+ // tsSOR = atol(headers["SOR"].c_str());
554+ // tsEOR = atol(headers["EOR"].c_str());
555+ // uint32_t nOrbitsPerTF = 128;
546556 LOGP (info, " nOrbitsPerTF={} tsSOR={} ms tsEOR={} ms" , nOrbitsPerTF, tsSOR, tsEOR);
547557
548558 // calculate SOR and EOR orbits
549559 int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
550560 int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
551561
552562 // adjust to the nearest TF edge
553- orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF - 1 ;
554- orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF - 1 ;
563+ orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF; // was with - 1;
564+ orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF; // was with - 1;
555565
556566 // set nOrbits and minOrbit used for orbit-axis binning
557567 nOrbits = orbitEOR - orbitSOR;
558568 minOrbit = orbitSOR;
569+
570+ // first bc of the first orbit (should coincide with TF start)
571+ bcSOR = orbitSOR * nBCsPerOrbit;
572+ // duration of TF in bcs
573+ nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit;
559574 }
560575
561576 // create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available
562577 // otherwise default minOrbit and nOrbits will be used
563- const AxisSpec axisOrbits{nOrbits / 128 , 0 ., static_cast <double >(nOrbits), " " };
578+ const AxisSpec axisOrbits{nOrbits / static_cast < int >(nOrbitsPerTF) /* 128*/ , 0 ., static_cast <double >(nOrbits), " " };
564579 histos.add (" hOrbitAll" , " " , kTH1F , {axisOrbits});
565580 histos.add (" hOrbitCol" , " " , kTH1F , {axisOrbits});
566581 histos.add (" hOrbitAcc" , " " , kTH1F , {axisOrbits});
@@ -946,11 +961,17 @@ struct EventSelectionQaTask {
946961 }
947962 }
948963
964+ int nContributorsAfterEtaTPCCuts = 0 ;
965+
949966 // fill track time histograms
950967 for (auto & track : tracksGrouped) {
951968 if (!track.isPVContributor ()) {
952969 continue ;
953970 }
971+
972+ if (fabs (track.eta ()) < 0.8 && track.tpcNClsFound () > 80 && track.tpcNClsCrossedRows () > 100 )
973+ nContributorsAfterEtaTPCCuts++;
974+
954975 if (track.hasTOF ())
955976 continue ;
956977 if (track.hasTRD ())
@@ -971,6 +992,13 @@ struct EventSelectionQaTask {
971992
972993 histos.fill (HIST (" hNcontribCol" ), nContributors);
973994
995+ // monitor nContributors vs bc in timeframe:
996+ if (flagMonitorBcInTF) {
997+ int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF;
998+ histos.fill (HIST (" hNcontribVsBcInTF" ), bcInTF, nContributors);
999+ histos.fill (HIST (" hNcontribAfterCutsVsBcInTF" ), bcInTF, nContributorsAfterEtaTPCCuts);
1000+ }
1001+
9741002 const auto & foundBC = col.foundBC_as <BCsRun3>();
9751003
9761004 float timeZNA = foundBC.has_zdc () ? foundBC.zdc ().timeZNA () : -999 .f ;
0 commit comments