Skip to content

Commit f6dc2ff

Browse files
committed
adding histo for rate correction by filled jobs in alihyperloop
1 parent a039d9b commit f6dc2ff

File tree

1 file changed

+57
-32
lines changed

1 file changed

+57
-32
lines changed

PWGMM/Lumi/Tasks/lumiStability.cxx

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/// \author Josue Martinez Garcia, josuem@cern.ch
1616

1717
#include "Common/CCDB/EventSelectionParams.h"
18+
#include "Common/CCDB/ctpRateFetcher.h"
1819
#include "Common/DataModel/EventSelection.h"
1920
#include "Common/DataModel/TrackSelectionTables.h"
2021

@@ -57,8 +58,10 @@ struct LumiStabilityTask {
5758
Configurable<int> minEmpty{"minEmpty", 5, "number of BCs empty for leading BC"};
5859

5960
Service<o2::ccdb::BasicCCDBManager> ccdb;
61+
parameters::GRPLHCIFData* grplhcif = nullptr;
6062
int nBCsPerOrbit = 3564;
6163
int lastRunNumber = -1;
64+
int64_t currentTFid = -1;
6265
int nOrbits = nOrbitsConf;
6366
double minOrbit = minOrbitConf;
6467
int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC
@@ -90,6 +93,7 @@ struct LumiStabilityTask {
9093
const AxisSpec axisCountsTime{2, -0.5, 1.5};
9194
const AxisSpec axisOrbits{static_cast<int>(nOrbits / nOrbitsPerTF), 0., static_cast<double>(nOrbits), ""};
9295
const AxisSpec axisTimeRate{int(double(43200) / (nOrbitsPerTF * 89e-6)), 0., 43200, ""}; // t in seconds. Histo for 12 hrs. Each bin contain one time frame (128/32 orbits for Run2/3).
96+
const AxisSpec timeAxis{1200, 0., 1200., "#bf{t-t_{SOF} (min)}"};
9397

9498
histos.add("hBcA", "BC pattern A; BC ; It is present", kTH1F, {axisTrigger});
9599
histos.add("hBcC", "BC pattern C; BC ; It is present", kTH1F, {axisTrigger});
@@ -107,10 +111,13 @@ struct LumiStabilityTask {
107111
histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits});
108112
histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits});
109113
histos.add("tsValues", "", kTH1D, {{2, -0.5, 1.5}});
114+
histos.add("TFsPerMinute", "TFs seen in this minute (to account for failed jobs);#bf{t-t_{SOF} (min)};#bf{#it{N}_{TFs}}", kTH1F, {timeAxis});
115+
110116
// time 32.766 is dummy time
111117

112118
// histo about triggers
113119
histos.add("FDD/hCounts", "0 FDDCount - 1 FDDVertexCount - 2 FDDPPVertexCount - 3 FDDCoincidencesVertexCount - 4 FDDPPCoincidencesVertexCount - 5 FDDPPBotSidesCount; Number; counts", kTH1F, {axisCounts});
120+
histos.add("FDD/nBCsVsTime", "Time of TVX triggered BCs since the start of fill. FDD;;#bf{#it{N}_{BC}}", kTH1F, {timeAxis});
114121
histos.add("FDD/bcVertexTriggerCTP", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger});
115122
histos.add("FDD/bcVertexTrigger", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger});
116123
histos.add("FDD/bcVertexTriggerPP", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTrigger});
@@ -171,6 +178,7 @@ struct LumiStabilityTask {
171178
histos.add("FDD/hTimeForRateLeadingBCCTP", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate});
172179

173180
histos.add("FT0/hCounts", "0 FT0Count - 1 FT0VertexCount - 2 FT0PPVertexCount - 3 FT0PPBothSidesCount; Number; counts", kTH1F, {axisCounts});
181+
histos.add("FT0/nBCsVsTime", "Time of TVX triggered BCs since the start of fill. FT0;;#bf{#it{N}_{BC}}", kTH1F, {timeAxis});
174182
histos.add("FT0/bcVertexTriggerCTP", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger});
175183
histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTrigger});
176184
histos.add("FT0/bcVertexTriggerPP", "vertex trigger per BC (FT0) with Past Protection;BC in FT0; counts", kTH1F, {axisTrigger});
@@ -243,6 +251,11 @@ struct LumiStabilityTask {
243251
return false;
244252
}
245253

254+
float getTimeSinceSOF(const auto& bc)
255+
{
256+
return (bc.timestamp() - grplhcif->getFillNumberTime()) / 1e3 / 60; // Convert to minutes
257+
}
258+
246259
void processMain(aod::FDDs const& fdds, aod::FT0s const& ft0s, aod::FV0As const& fv0s, aod::BCsWithTimestamps const& bcs)
247260
{
248261
int executionCounter = 0;
@@ -264,7 +277,7 @@ struct LumiStabilityTask {
264277
int64_t ts = bcs.iteratorAt(0).timestamp();
265278

266279
// access colliding and beam-gas bc patterns
267-
auto grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
280+
grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
268281
beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0);
269282
beamPatternC = grplhcif->getBunchFilling().getBeamPattern(1);
270283
bcPatternA = beamPatternA & ~beamPatternC;
@@ -345,6 +358,7 @@ struct LumiStabilityTask {
345358
if (bc.timestamp() == 0) {
346359
continue;
347360
}
361+
348362
std::bitset<64> ctpInputMask(bc.inputMask());
349363
bool trgFDD = ctpInputMask[15];
350364
bool trgFT0 = ctpInputMask[2];
@@ -353,40 +367,51 @@ struct LumiStabilityTask {
353367
int64_t globalBC = bc.globalBC();
354368
int localBC = globalBC % nBCsPerOrbit;
355369

356-
if (bcPatternB[localBC]) {
357-
if (trgFDD) {
358-
histos.fill(HIST("FDD/bcVertexTriggerCTP"), localBC);
359-
histos.fill(HIST("FDD/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
360-
}
361-
if (trgFT0) {
362-
histos.fill(HIST("FT0/bcVertexTriggerCTP"), localBC);
363-
histos.fill(HIST("FT0/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
364-
}
365-
if (trgFV0) {
366-
histos.fill(HIST("FV0/bcChargeTriggerCTP"), localBC);
367-
histos.fill(HIST("FV0/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
368-
}
369-
bool isLeadBC = true;
370-
for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) {
371-
int kbit = jbit;
372-
if (kbit < 0)
373-
kbit += nbin;
374-
if (bcPatternB[kbit]) {
375-
isLeadBC = false;
376-
break;
377-
}
378-
}
379-
if (isLeadBC)
380-
if (trgFDD) {
381-
histos.fill(HIST("FDD/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
382-
}
383-
if (trgFT0) {
384-
histos.fill(HIST("FT0/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
370+
float timeSinceSOF = getTimeSinceSOF(bc);
371+
372+
int64_t thisTFid = (globalBC - bcSOR) / nBCsPerTF;
373+
374+
if (thisTFid != currentTFid) {
375+
currentTFid = thisTFid;
376+
histos.fill(HIST("TFsPerMinute"), timeSinceSOF);
377+
}
378+
379+
// if (bcPatternB[localBC]) {
380+
if (trgFDD) {
381+
histos.fill(HIST("FDD/nBCsVsTime"), timeSinceSOF);
382+
histos.fill(HIST("FDD/bcVertexTriggerCTP"), localBC + 7);
383+
histos.fill(HIST("FDD/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
384+
}
385+
if (trgFT0) {
386+
histos.fill(HIST("FT0/nBCsVsTime"), timeSinceSOF);
387+
histos.fill(HIST("FT0/bcVertexTriggerCTP"), localBC);
388+
histos.fill(HIST("FT0/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
389+
}
390+
if (trgFV0) {
391+
histos.fill(HIST("FV0/bcChargeTriggerCTP"), localBC);
392+
histos.fill(HIST("FV0/hTimeForRateCTP"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
393+
}
394+
bool isLeadBC = true;
395+
for (int jbit = localBC - minEmpty; jbit < localBC; jbit++) {
396+
int kbit = jbit;
397+
if (kbit < 0)
398+
kbit += nbin;
399+
if (bcPatternB[kbit]) {
400+
isLeadBC = false;
401+
break;
385402
}
386-
if (trgFV0) {
387-
histos.fill(HIST("FV0/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
403+
}
404+
if (isLeadBC)
405+
if (trgFDD) {
406+
histos.fill(HIST("FDD/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
388407
}
408+
if (trgFT0) {
409+
histos.fill(HIST("FT0/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
410+
}
411+
if (trgFV0) {
412+
histos.fill(HIST("FV0/hTimeForRateLeadingBCCTP"), (bc.timestamp() - tsSOR) * 1.e-3);
389413
}
414+
// }
390415
} // loop over bcs
391416

392417
for (auto const& fdd : fdds) {

0 commit comments

Comments
 (0)