Skip to content

Commit 2a94944

Browse files
authored
[PWGLF] PWGMM: Lumi (AliceO2Group#9073)
1 parent 1059ebb commit 2a94944

File tree

1 file changed

+69
-60
lines changed

1 file changed

+69
-60
lines changed

PWGMM/Lumi/Tasks/lumiStability.cxx

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
//
12+
/// \file lumiStability.cxx
13+
/// \brief Analysis over BCs to study the luminosity stability along time.
1114
///
12-
/// \brief This task is an empty skeleton that fills a simple eta histogram.
13-
/// it is meant to be a blank page for further developments.
14-
/// \author everyone
15+
/// \author Josue Martinez Garcia, [email protected]
1516

1617
#include <utility>
1718
#include <map>
@@ -39,17 +40,17 @@ using namespace o2::framework;
3940

4041
using BCsWithTimestamps = soa::Join<aod::BCs, aod::Timestamps>;
4142

42-
struct lumiStabilityTask {
43+
struct LumiStabilityTask {
4344
// Histogram registry: an object to hold your histograms
4445
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
4546

4647
// Declare configurables
4748
Configurable<int> myMaxDeltaBCFDD{"myMaxDeltaBCFDD", 5, {"My BC cut"}};
4849
Configurable<int> myMaxDeltaBCFT0{"myMaxDeltaBCFT0", 5, {"My BC cut"}};
4950
Configurable<int> myMaxDeltaBCFV0{"myMaxDeltaBCFV0", 5, {"My BC cut"}};
50-
Configurable<int> nOrbitsConf{"nOrbits", 972'288'000, "number of orbits"};
51+
Configurable<int> nOrbitsConf{"nOrbitsConf", 972'288'000, "number of orbits"};
5152
Configurable<int> nOrbitsPerTF{"nOrbitsPerTF", 128, "number of orbits per time frame"};
52-
Configurable<double> minOrbitConf{"minOrbit", 0, "minimum orbit"};
53+
Configurable<double> minOrbitConf{"minOrbitConf", 0, "minimum orbit"};
5354
Configurable<bool> is2022Data{"is2022Data", true, "To 2022 data"};
5455

5556
Service<o2::ccdb::BasicCCDBManager> ccdb;
@@ -83,6 +84,7 @@ struct lumiStabilityTask {
8384
const AxisSpec axisTimeFDD{1000, -20, 100};
8485
const AxisSpec axisCountsTime{2, -0.5, 1.5};
8586
const AxisSpec axisOrbits{static_cast<int>(nOrbits / nOrbitsPerTF), 0., static_cast<double>(nOrbits), ""};
87+
const AxisSpec axisTimeRate{1440, 0., 86400, ""}; // t in seconds. Histo for 24 hrs. Each bin contain 1 min.
8688

8789
histos.add("hBcA", "BC pattern A; BC ; It is present", kTH1F, {axisTriggger});
8890
histos.add("hBcC", "BC pattern C; BC ; It is present", kTH1F, {axisTriggger});
@@ -152,6 +154,7 @@ struct lumiStabilityTask {
152154
histos.add("FDD/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger});
153155
histos.add("FDD/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger});
154156
histos.add("FDD/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger});
157+
histos.add("FDD/hTimeForRate", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate});
155158

156159
histos.add("FT0/hCounts", "0 FT0Count - 1 FT0VertexCount - 2 FT0PPVertexCount - 3 FT0PPBothSidesCount; Number; counts", kTH1F, {axisCounts});
157160
histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger});
@@ -180,6 +183,7 @@ struct lumiStabilityTask {
180183
histos.add("FT0/hInvTimeCvsBC", "Invalid Time C vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger});
181184
histos.add("FT0/hValidTimevsBC", "Valid Time vs BC id;BC in FT0;valid time counts", kTH1F, {axisTriggger});
182185
histos.add("FT0/hInvTimevsBC", "Invalid Time vs BC id;BC in FT0;invalid time counts", kTH1F, {axisTriggger});
186+
histos.add("FT0/hTimeForRate", "Counts by time in FDD;t (in seconds) in FDD; counts", kTH1F, {axisTimeRate});
183187

184188
histos.add("FV0/hCounts", "0 CountCentralFV0 - 1 CountPFPCentralFV0 - 2 CountPFPOutInFV0 - 3 CountPPCentralFV0 - 4 CountPPOutInFV0; Number; counts", kTH1F, {axisV0Counts});
185189
histos.add("FV0/bcOutTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger});
@@ -202,13 +206,13 @@ struct lumiStabilityTask {
202206

203207
bool checkAnyCoincidence(const std::vector<int>& channels)
204208
{
205-
constexpr std::pair<int, int> pair0 = {0, 4};
206-
constexpr std::pair<int, int> pair1 = {1, 5};
207-
constexpr std::pair<int, int> pair2 = {2, 6};
208-
constexpr std::pair<int, int> pair3 = {3, 7};
209-
constexpr std::array<std::pair<int, int>, 4> channelPairs = {pair0, pair1, pair2, pair3};
210-
// std::map<int, int> channelPairs = {{0, 4}, {1, 5}, {2, 6}, {3, 7}};
211-
for (const auto& pair : channelPairs) {
209+
constexpr std::pair<int, int> kPair0 = {0, 4};
210+
constexpr std::pair<int, int> kPair1 = {1, 5};
211+
constexpr std::pair<int, int> kPair2 = {2, 6};
212+
constexpr std::pair<int, int> kPair3 = {3, 7};
213+
constexpr std::array<std::pair<int, int>, 4> kChannelPairs = {kPair0, kPair1, kPair2, kPair3};
214+
// std::map<int, int> kChannelPairs = {{0, 4}, {1, 5}, {2, 6}, {3, 7}};
215+
for (const auto& pair : kChannelPairs) {
212216
if (std::find(channels.begin(), channels.end(), pair.first) != channels.end() &&
213217
std::find(channels.begin(), channels.end(), pair.second) != channels.end()) {
214218
return true;
@@ -220,14 +224,20 @@ struct lumiStabilityTask {
220224
void processMain(aod::FDDs const& fdds, aod::FT0s const& ft0s, aod::FV0As const& fv0s, aod::BCsWithTimestamps const& bcs)
221225
{
222226
int executionCounter = 0;
223-
// uint32_t nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023
227+
uint32_t nOrbitsPerTF = 0; // 128 in 2022, 32 in 2023
228+
if (is2022Data) {
229+
nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023
230+
} else {
231+
nOrbitsPerTF = 32; // 128 in 2022, 32 in 2023
232+
}
224233
int runNumber = bcs.iteratorAt(0).runNumber();
225-
// std::string histName = "hOrbitFDDVertexCoinc_" + std::to_string(runNumber);
234+
int64_t tsSOR = 0;
235+
int64_t tsEOR = 1;
226236
if (runNumber != lastRunNumber && executionCounter < 1) {
237+
tsSOR = 0;
238+
tsEOR = 1;
227239
lastRunNumber = runNumber; // do it only once
228240
executionCounter++;
229-
// int64_t tsSOR = 0;
230-
// int64_t tsEOR = 1;
231241

232242
if (runNumber >= 500000) { // access CCDB for data or anchored MC only
233243
int64_t ts = bcs.iteratorAt(0).timestamp();
@@ -256,9 +266,9 @@ struct lumiStabilityTask {
256266
}
257267
}
258268

259-
/*EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
269+
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
260270
// access orbit-reset timestamp
261-
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
271+
auto ctpx = ccdb->getForTimeStamp<std::vector<int64_t>>("CTP/Calib/OrbitReset", ts);
262272
int64_t tsOrbitReset = (*ctpx)[0]; // us
263273
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
264274
std::map<std::string, std::string> metadata;
@@ -281,17 +291,15 @@ struct lumiStabilityTask {
281291
// duration of TF in bcs
282292
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
283293
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, EOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, tsEOR, orbitSOR, nBCsPerTF);
284-
std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<< Orbits per second: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << nOrbits << std::endl;*/
285294
}
286295

287296
// create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available
288297
// otherwise default minOrbit and nOrbits will be used
289-
/*const AxisSpec axisOrbits{static_cast<int>(nOrbits / nOrbitsPerTF), 0., static_cast<double>(nOrbits), ""};
290-
std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<< Creating histograms >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
291-
histos.add("hOrbitFDDVertexCoinc", "", kTH1F, {axisOrbits});
292-
histos.add("hOrbitFDDVertex", "", kTH1F, {axisOrbits});
293-
histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits});
294-
histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits});*/
298+
// const AxisSpec axisOrbits{static_cast<int>(nOrbits / nOrbitsPerTF), 0., static_cast<double>(nOrbits), ""};
299+
// histos.add("hOrbitFDDVertexCoinc", "", kTH1F, {axisOrbits});
300+
// histos.add("hOrbitFDDVertex", "", kTH1F, {axisOrbits});
301+
// histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits});
302+
// histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits});
295303
}
296304

297305
for (auto const& fdd : fdds) {
@@ -300,7 +308,7 @@ struct lumiStabilityTask {
300308
continue;
301309
}
302310

303-
Long64_t globalBC = bc.globalBC();
311+
int64_t globalBC = bc.globalBC();
304312
int localBC = globalBC % nBCsPerOrbit;
305313
uint64_t orbit = globalBC / nBCsPerOrbit;
306314

@@ -309,15 +317,15 @@ struct lumiStabilityTask {
309317
bool scentral = fddTriggers[o2::fdd::Triggers::bitSCen];
310318
bool central = fddTriggers[o2::fdd::Triggers::bitCen];
311319

312-
auto SideA = fdd.chargeA();
313-
auto SideC = fdd.chargeC();
320+
auto sideA = fdd.chargeA();
321+
auto sideC = fdd.chargeC();
314322
std::vector<int> channelA;
315323
std::vector<int> channelC;
316324
for (auto i = 0; i < 8; i++) {
317-
if (SideA[i] > 0) {
325+
if (sideA[i] > 0) {
318326
channelA.push_back(i);
319327
}
320-
if (SideC[i] > 0) {
328+
if (sideC[i] > 0) {
321329
channelC.push_back(i);
322330
}
323331
}
@@ -330,6 +338,7 @@ struct lumiStabilityTask {
330338
histos.fill(HIST("FDD/bcVertexTrigger"), localBC);
331339
histos.fill(HIST("FDD/hCounts"), 1);
332340
histos.fill(HIST("hOrbitFDDVertex"), orbit - minOrbit);
341+
histos.fill(HIST("FDD/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
333342

334343
int deltaIndex = 0; // backward move counts
335344
int deltaBC = 0; // current difference wrt globalBC
@@ -339,12 +348,12 @@ struct lumiStabilityTask {
339348
if (fdd.globalIndex() - deltaIndex < 0) {
340349
break;
341350
}
342-
const auto& fdd_past = fdds.iteratorAt(fdd.globalIndex() - deltaIndex);
343-
auto bc_past = fdd_past.bc_as<BCsWithTimestamps>();
344-
deltaBC = globalBC - bc_past.globalBC();
351+
const auto& fddPast = fdds.iteratorAt(fdd.globalIndex() - deltaIndex);
352+
auto bcPast = fddPast.bc_as<BCsWithTimestamps>();
353+
deltaBC = globalBC - bcPast.globalBC();
345354

346355
if (deltaBC < myMaxDeltaBCFDD) {
347-
std::bitset<8> fddTriggersPast = fdd_past.triggerMask();
356+
std::bitset<8> fddTriggersPast = fddPast.triggerMask();
348357
bool vertexPast = fddTriggersPast[o2::fdd::Triggers::bitVertex];
349358
pastActivityFDDVertex |= (vertexPast);
350359
}
@@ -461,24 +470,24 @@ struct lumiStabilityTask {
461470
if (fdd.globalIndex() - deltaIndex < 0) {
462471
break;
463472
}
464-
const auto& fdd_past = fdds.iteratorAt(fdd.globalIndex() - deltaIndex);
465-
auto bc_past = fdd_past.bc_as<BCsWithTimestamps>();
466-
deltaBC = globalBC - bc_past.globalBC();
473+
const auto& fddPast = fdds.iteratorAt(fdd.globalIndex() - deltaIndex);
474+
auto bcPast = fddPast.bc_as<BCsWithTimestamps>();
475+
deltaBC = globalBC - bcPast.globalBC();
467476

468477
if (deltaBC < myMaxDeltaBCFDD) {
469-
std::bitset<8> fddTriggersPast = fdd_past.triggerMask();
478+
std::bitset<8> fddTriggersPast = fddPast.triggerMask();
470479
bool vertexPast = fddTriggersPast[o2::fdd::Triggers::bitVertex];
471480
bool triggerAPast = fddTriggersPast[o2::fdd::Triggers::bitA];
472481
bool triggerCPast = fddTriggersPast[o2::fdd::Triggers::bitC];
473-
auto SideAPast = fdd_past.chargeA();
474-
auto SideCPast = fdd_past.chargeC();
482+
auto sideAPast = fddPast.chargeA();
483+
auto sideCPast = fddPast.chargeC();
475484
std::vector<int> channelAPast;
476485
std::vector<int> channelCPast;
477486
for (auto i = 0; i < 8; i++) {
478-
if (SideAPast[i] > 0) {
487+
if (sideAPast[i] > 0) {
479488
channelAPast.push_back(i);
480489
}
481-
if (SideCPast[i] > 0) {
490+
if (sideCPast[i] > 0) {
482491
channelCPast.push_back(i);
483492
}
484493
}
@@ -502,7 +511,6 @@ struct lumiStabilityTask {
502511
histos.fill(HIST("FDD/bcVertexTriggerBothSidesCoincidencePP"), localBC);
503512
}
504513
} // coincidences
505-
506514
} // vertex true
507515

508516
if (scentral) {
@@ -540,7 +548,7 @@ struct lumiStabilityTask {
540548
continue;
541549
}
542550

543-
Long64_t globalBC = bc.globalBC();
551+
int64_t globalBC = bc.globalBC();
544552
int localBC = globalBC % nBCsPerOrbit;
545553
uint64_t orbit = globalBC / nBCsPerOrbit;
546554

@@ -553,6 +561,7 @@ struct lumiStabilityTask {
553561
if (vertex) {
554562
histos.fill(HIST("FT0/bcVertexTrigger"), localBC);
555563
histos.fill(HIST("hOrbitFT0vertex"), orbit - minOrbit);
564+
histos.fill(HIST("FT0/hTimeForRate"), (bc.timestamp() - tsSOR) * 1.e-3); // Converting ms into seconds
556565

557566
if (bcPatternA[localBC]) {
558567
histos.fill(HIST("FT0/timeACbcA"), ft0.timeA(), ft0.timeC());
@@ -608,12 +617,12 @@ struct lumiStabilityTask {
608617
if (ft0.globalIndex() - deltaIndex < 0) {
609618
break;
610619
}
611-
const auto& ft0_past = ft0s.iteratorAt(ft0.globalIndex() - deltaIndex);
612-
auto bc_past = ft0_past.bc_as<BCsWithTimestamps>();
613-
deltaBC = globalBC - bc_past.globalBC();
620+
const auto& ft0Past = ft0s.iteratorAt(ft0.globalIndex() - deltaIndex);
621+
auto bcPast = ft0Past.bc_as<BCsWithTimestamps>();
622+
deltaBC = globalBC - bcPast.globalBC();
614623

615624
if (deltaBC < myMaxDeltaBCFT0) {
616-
std::bitset<8> fT0TriggersPast = ft0_past.triggerMask();
625+
std::bitset<8> fT0TriggersPast = ft0Past.triggerMask();
617626
bool vertexPast = fT0TriggersPast[o2::ft0::Triggers::bitVertex];
618627
bool triggerAPast = fT0TriggersPast[o2::ft0::Triggers::bitA];
619628
bool triggerCPast = fT0TriggersPast[o2::ft0::Triggers::bitC];
@@ -661,7 +670,7 @@ struct lumiStabilityTask {
661670
continue;
662671
}
663672

664-
Long64_t globalBC = bc.globalBC();
673+
int64_t globalBC = bc.globalBC();
665674
int localBC = globalBC % nBCsPerOrbit;
666675
uint64_t orbit = globalBC / nBCsPerOrbit;
667676

@@ -714,12 +723,12 @@ struct lumiStabilityTask {
714723
if (fv0.globalIndex() - deltaIndex < 0) {
715724
break;
716725
}
717-
const auto& fv0_past = fv0s.iteratorAt(fv0.globalIndex() - deltaIndex);
718-
auto bc_past = fv0_past.bc_as<BCsWithTimestamps>();
719-
deltaBC = globalBC - bc_past.globalBC();
726+
const auto& fv0Past = fv0s.iteratorAt(fv0.globalIndex() - deltaIndex);
727+
auto bcPast = fv0Past.bc_as<BCsWithTimestamps>();
728+
deltaBC = globalBC - bcPast.globalBC();
720729

721730
if (deltaBC < myMaxDeltaBCFV0) {
722-
std::bitset<8> fv0Triggers = fv0_past.triggerMask();
731+
std::bitset<8> fv0Triggers = fv0Past.triggerMask();
723732
bool centralPast = fv0Triggers[o2::fv0::Triggers::bitTrgCharge];
724733
bool triggerOutPast = fv0Triggers[o2::fv0::Triggers::bitAOut];
725734
bool triggerInPast = fv0Triggers[o2::fv0::Triggers::bitAIn];
@@ -740,11 +749,11 @@ struct lumiStabilityTask {
740749
if (fv0.globalIndex() + deltaIndex >= fv0s.size()) {
741750
break;
742751
}
743-
const auto& fv0_future = fv0s.iteratorAt(fv0.globalIndex() + deltaIndex);
744-
deltaBC = fv0_future.bcId() - fv0.bcId();
752+
const auto& fv0Future = fv0s.iteratorAt(fv0.globalIndex() + deltaIndex);
753+
deltaBC = fv0Future.bcId() - fv0.bcId();
745754

746755
if (deltaBC < myMaxDeltaBCFV0) {
747-
std::bitset<8> fv0Triggers = fv0_future.triggerMask();
756+
std::bitset<8> fv0Triggers = fv0Future.triggerMask();
748757
bool centralFuture = fv0Triggers[o2::fv0::Triggers::bitTrgCharge];
749758
bool triggerOutFuture = fv0Triggers[o2::fv0::Triggers::bitAOut];
750759
bool triggerInFuture = fv0Triggers[o2::fv0::Triggers::bitAIn];
@@ -780,7 +789,7 @@ struct lumiStabilityTask {
780789
} // loop over V0 events
781790
} // end processMain
782791

783-
PROCESS_SWITCH(lumiStabilityTask, processMain, "Process FDD and FT0 to lumi stability analysis", true);
792+
PROCESS_SWITCH(LumiStabilityTask, processMain, "Process FDD and FT0 to lumi stability analysis", true);
784793

785794
void processCollisions(aod::Collision const& collision)
786795
{
@@ -792,11 +801,11 @@ struct lumiStabilityTask {
792801
histos.fill(HIST("hvertexXvsTime"), collision.posX(), collision.collisionTime());
793802
}
794803

795-
PROCESS_SWITCH(lumiStabilityTask, processCollisions, "Process collision to get vertex position", true);
804+
PROCESS_SWITCH(LumiStabilityTask, processCollisions, "Process collision to get vertex position", true);
796805
};
797806

798807
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
799808
{
800809
return WorkflowSpec{
801-
adaptAnalysisTask<lumiStabilityTask>(cfgc)};
810+
adaptAnalysisTask<LumiStabilityTask>(cfgc)};
802811
}

0 commit comments

Comments
 (0)