Skip to content

Commit 87606a3

Browse files
authored
Merge branch 'AliceO2Group:master' into dev1
2 parents d5a4f6e + b8f9ea3 commit 87606a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3840
-1025
lines changed

Common/Core/CollisionAssociation.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class CollisionAssociation
8080
switch (mTrackSelection) {
8181
case o2::aod::track_association::TrackSelection::CentralBarrelRun2: {
8282
unsigned char itsClusterMap = track.itsClusterMap();
83-
if (!(track.tpcNClsFound() >= 50 && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
83+
int minTpcNClsFound{50};
84+
if (!(track.tpcNClsFound() >= minTpcNClsFound && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
8485
hasGoodQuality = false;
8586
}
8687
break;
@@ -127,7 +128,7 @@ class CollisionAssociation
127128
TTracksUnfiltered const& tracksUnfiltered,
128129
TTracks const& tracks,
129130
TAmbiTracks const& ambiguousTracks,
130-
o2::aod::BCs const&,
131+
o2::aod::BCs const& bcs,
131132
Assoc& association,
132133
RevIndices& reverseIndices)
133134
{
@@ -151,6 +152,11 @@ class CollisionAssociation
151152
for (const auto& ambTrack : ambiguousTracks) {
152153
if constexpr (isCentralBarrel) { // FIXME: to be removed as soon as it is possible to use getId<Table>() for joined tables
153154
if (ambTrack.trackId() == track.globalIndex()) {
155+
// special check to avoid crashes (in particular on some MC datasets)
156+
// related to shifts in ambiguous tracks association to bc slices (off by 1) - see https://mattermost.web.cern.ch/alice/pl/g9yaaf3tn3g4pgn7c1yex9copy
157+
if (ambTrack.bcIds()[0] >= bcs.size() || ambTrack.bcIds()[1] >= bcs.size()) {
158+
break;
159+
}
154160
if (!ambTrack.has_bc() || ambTrack.bc().size() == 0) {
155161
break;
156162
}
@@ -194,7 +200,7 @@ class CollisionAssociation
194200
uint64_t collBC = collision.bc().globalBC();
195201

196202
// This is done per block to allow optimization below. Within each block the globalBC increase continously
197-
for (auto& iterationWindow : trackIterationWindows) {
203+
for (auto& iterationWindow : trackIterationWindows) { // o2-linter: disable=const-ref-in-for-loop (iterationWindow is modified)
198204
bool iteratorMoved = false;
199205
const bool isAssignedTrackWindow = (iterationWindow.first != iterationWindow.second) ? iterationWindow.first.has_collision() : false;
200206
for (auto trackInWindow = iterationWindow.first; trackInWindow != iterationWindow.second; ++trackInWindow) {

Common/TableProducer/zdcExtraTableProducer.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <TH1.h>
3333
#include <TH2.h>
34+
#include <TRandom3.h>
3435

3536
#include <cstdint>
3637

@@ -64,7 +65,9 @@ struct ZdcExtraTableProducer {
6465
Configurable<bool> cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", true, "Event selection: no collision in time range standard"};
6566
Configurable<bool> cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", true, "Event selection: is vertex ITSTPC"};
6667
Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", true, "Event selection: is good ITS layers all"};
67-
//
68+
// Calibration settings
69+
Configurable<float> cfgCalibrationDownscaling{"cfgCalibrationDownscaling", 1.f, "Percentage of events to be saved to derived table"};
70+
6871
HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
6972

7073
enum SelectionCriteria {
@@ -311,7 +314,7 @@ struct ZdcExtraTableProducer {
311314
auto vx = collision.posX();
312315
auto vy = collision.posY();
313316

314-
if (isZNAhit || isZNChit) {
317+
if ((isZNAhit || isZNChit) && (gRandom->Uniform() < cfgCalibrationDownscaling)) {
315318
zdcextras(pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], tdcZNA, centroidZNA[0], centroidZNA[1], pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3], tdcZNC, centroidZNC[0], centroidZNC[1], centrality, vx, vy, vz, foundBC.timestamp(), foundBC.runNumber(), evSelection);
316319
}
317320
}

Common/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@ o2physics_add_dpl_workflow(flow-test
9292
o2physics_add_dpl_workflow(muon-qa
9393
SOURCES qaMuon.cxx
9494
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::Field O2::DetectorsBase O2::DetectorsCommonDataFormats O2::MathUtils O2::MCHTracking O2::DataFormatsMCH O2::GlobalTracking O2::MCHBase O2::MCHGeometryTransformer O2::CommonUtils
95+
COMPONENT_NAME Analysis)
96+
97+
o2physics_add_dpl_workflow(zdc-table-reader
98+
SOURCES zdcTableReader.cxx
99+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
95100
COMPONENT_NAME Analysis)

Common/Tasks/zdcTableReader.cxx

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
/// \brief Read output table from ZDC light ion task
13+
/// \author chiara.oppedisano@cern.ch
14+
//
15+
16+
#include "Common/DataModel/ZDCLightIons.h"
17+
18+
#include <Framework/AnalysisDataModel.h>
19+
#include <Framework/AnalysisTask.h>
20+
#include <Framework/HistogramRegistry.h>
21+
#include <Framework/runDataProcessing.h>
22+
23+
#include <TH1F.h>
24+
#include <TH2F.h>
25+
26+
using namespace o2;
27+
using namespace o2::framework;
28+
using namespace o2::framework::expressions;
29+
using namespace o2::aod;
30+
31+
struct ZDCLIAnalysis {
32+
33+
// Configurable number of bins
34+
Configurable<bool> useZvtx{"useZvtx", false, "If true uses Z_vertex"};
35+
Configurable<float> zVval{"zVval", 10., "Z_vertex cut value"};
36+
Configurable<float> tStampMin{"tStampMin", 100000., "minimum value for timestamp"};
37+
Configurable<float> tStampMax{"tStampMax", 100000., ",maximum value for timestamp"};
38+
//
39+
Configurable<int> nBinsADC{"nBinsADC", 1000, "n bins 4 ZDC ADCs"};
40+
Configurable<int> nBinsAmp{"nBinsAmp", 1025, "n bins 4 ZDC amplitudes"};
41+
Configurable<int> nBinsTDC{"nBinsTDC", 480, "n bins 4 TDCs"};
42+
Configurable<int> nBinsFit{"nBinsFit", 1000, "n bins 4 FIT"};
43+
Configurable<float> MaxZN{"MaxZN", 4099.5, "Max 4 ZN histos"};
44+
Configurable<float> MaxZP{"MaxZP", 3099.5, "Max 4 ZP histos"};
45+
Configurable<float> MaxZEM{"MaxZEM", 3099.5, "Max 4 ZEM histos"};
46+
//
47+
Configurable<float> MaxMultFV0{"MaxMultFV0", 3000, "Max 4 FV0 histos"};
48+
Configurable<float> MaxMultFT0{"MaxMultFT0", 3000, "Max 4 FT0 histos"};
49+
//
50+
HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
51+
52+
void init(InitContext const&)
53+
{
54+
registry.add("hZNApmc", "ZNApmc; ZNA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZN}}});
55+
registry.add("hZPApmc", "ZPApmc; ZPA amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZP}}});
56+
registry.add("hZNCpmc", "ZNCpmc; ZNC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZN}}});
57+
registry.add("hZPCpmc", "ZPCpmc; ZPC amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZP}}});
58+
registry.add("hZEM", "ZEM; ZEM1+ZEM2 amplitude; Entries", {HistType::kTH1F, {{nBinsAmp, -0.5, MaxZEM}}});
59+
registry.add("hZNAamplvsADC", "ZNA amplitude vs. ADC; ZNA ADC; ZNA amplitude", {HistType::kTH2F, {{{nBinsAmp, -0.5, 3. * MaxZN}, {nBinsAmp, -0.5, MaxZN}}}});
60+
registry.add("hZNCamplvsADC", "ZNC amplitude vs. ADC; ZNC ADC; ZNC amplitude", {HistType::kTH2F, {{{nBinsAmp, -0.5, 3. * MaxZN}, {nBinsAmp, -0.5, MaxZN}}}});
61+
registry.add("hZPAamplvsADC", "ZPA amplitude vs. ADC; ZPA ADC; ZPA amplitude", {HistType::kTH2F, {{{nBinsAmp, -0.5, 3. * MaxZP}, {nBinsAmp, -0.5, MaxZP}}}});
62+
registry.add("hZPCamplvsADC", "ZPC amplitude vs. ADC; ZPC ADC; ZPC amplitude", {HistType::kTH2F, {{{nBinsAmp, -0.5, 3. * MaxZP}, {nBinsAmp, -0.5, MaxZP}}}});
63+
registry.add("hZNvsZEM", "ZN vs ZEM; ZEM; ZNA+ZNC", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZEM}, {nBinsAmp, -0.5, 2. * MaxZN}}}});
64+
registry.add("hZNAvsZNC", "ZNA vs ZNC; ZNC; ZNA", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZN}, {nBinsAmp, -0.5, MaxZN}}}});
65+
registry.add("hZPAvsZPC", "ZPA vs ZPC; ZPC; ZPA", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZP}, {nBinsAmp, -0.5, MaxZP}}}});
66+
registry.add("hZNAvsZPA", "ZNA vs ZPA; ZPA; ZNA", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZP}, {nBinsAmp, -0.5, MaxZN}}}});
67+
registry.add("hZNCvsZPC", "ZNC vs ZPC; ZPC; ZNC", {HistType::kTH2F, {{{nBinsAmp, -0.5, MaxZP}, {nBinsAmp, -0.5, MaxZN}}}});
68+
//
69+
registry.add("hZNCcvsZNCsum", "ZNC PMC vs PMsum; ZNCC ADC; ZNCsum", {HistType::kTH2F, {{{nBinsADC, -0.5, 3. * MaxZN}, {nBinsADC, -0.5, 3. * MaxZN}}}});
70+
registry.add("hZNAcvsZNAsum", "ZNA PMC vs PMsum; ZNAsum", {HistType::kTH2F, {{{nBinsADC, -0.5, 3. * MaxZN}, {nBinsADC, -0.5, 3. * MaxZN}}}});
71+
//
72+
registry.add("hZNCvstdc", "ZNC vs tdc; ZNC amplitude; ZNC TDC", {HistType::kTH2F, {{{480, -13.5, 11.45}, {nBinsAmp, -0.5, MaxZN}}}});
73+
registry.add("hZNAvstdc", "ZNA vs tdc; ZNA amplitude; ZNA TDC", {HistType::kTH2F, {{{480, -13.5, 11.45}, {nBinsAmp, -0.5, MaxZN}}}});
74+
registry.add("hZPCvstdc", "ZPC vs tdc; ZPC amplitude; ZPC TDC", {HistType::kTH2F, {{{480, -13.5, 11.45}, {nBinsAmp, -0.5, MaxZP}}}});
75+
registry.add("hZPAvstdc", "ZPA vs tdc; ZPA amplitude; ZPA TDC", {HistType::kTH2F, {{{480, -13.5, 11.45}, {nBinsAmp, -0.5, MaxZP}}}});
76+
//
77+
registry.add("hZNvsV0A", "ZN vs V0A", {HistType::kTH2F, {{{nBinsFit, 0., MaxMultFV0}, {nBinsAmp, -0.5, 2. * MaxZN}}}});
78+
registry.add("hZNAvsFT0A", "ZNA vs FT0A", {HistType::kTH2F, {{{nBinsFit, 0., MaxMultFT0}, {nBinsAmp, -0.5, MaxZN}}}});
79+
registry.add("hZNCvsFT0C", "ZNC vs FT0C", {HistType::kTH2F, {{{nBinsFit, 0., MaxMultFT0}, {nBinsAmp, -0.5, MaxZN}}}});
80+
//
81+
registry.add("hZNAvscentrFT0A", "ZNA vs centrality FT0A", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
82+
registry.add("hZNAvscentrFT0C", "ZNA vs centrality FT0C", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
83+
registry.add("hZNAvscentrFT0M", "ZNA vs centrality FT0M", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
84+
registry.add("hZPAvscentrFT0A", "ZPA vs centrality FT0A", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
85+
registry.add("hZPAvscentrFT0C", "ZPA vs centrality FT0C", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
86+
registry.add("hZPAvscentrFT0M", "ZPA vs centrality FT0M", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
87+
registry.add("hZNCvscentrFT0A", "ZNC vs centrality FT0A", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
88+
registry.add("hZNCvscentrFT0C", "ZNC vs centrality FT0C", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
89+
registry.add("hZNCvscentrFT0M", "ZNC vs centrality FT0M", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZN}}}});
90+
registry.add("hZPCvscentrFT0A", "ZPC vs centrality FT0A", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
91+
registry.add("hZPCvscentrFT0C", "ZPC vs centrality FT0C", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
92+
registry.add("hZPCvscentrFT0M", "ZPC vs centrality FT0M", {HistType::kTH2F, {{{100, 0., 100.}, {nBinsAmp, -0.5, MaxZP}}}});
93+
//
94+
registry.add("hZNAvstimestamp", "ZNA vs timestamp", {HistType::kTH2F, {{{100, tStampMin, tStampMax}, {nBinsAmp, -0.5, MaxZN}}}});
95+
registry.add("hZNCvstimestamp", "ZNC vs timestamp", {HistType::kTH2F, {{{100, tStampMin, tStampMax}, {nBinsAmp, -0.5, MaxZN}}}});
96+
registry.add("hZPAvstimestamp", "ZPA vs timestamp", {HistType::kTH2F, {{{100, tStampMin, tStampMax}, {nBinsAmp, -0.5, MaxZP}}}});
97+
registry.add("hZPCvstimestamp", "ZPC vs timestamp", {HistType::kTH2F, {{{100, tStampMin, tStampMax}, {nBinsAmp, -0.5, MaxZP}}}});
98+
}
99+
100+
void process(aod::ZDCLightIons const& zdclightions)
101+
{
102+
for (auto const& zdc : zdclightions) {
103+
auto tdczna = zdc.znaTdc();
104+
auto tdcznc = zdc.zncTdc();
105+
auto tdczpa = zdc.zpaTdc();
106+
auto tdczpc = zdc.zpcTdc();
107+
auto zna = zdc.znaAmpl();
108+
auto znaADC = zdc.znaPmc();
109+
auto znapm1 = zdc.znaPm1();
110+
auto znapm2 = zdc.znaPm2();
111+
auto znapm3 = zdc.znaPm3();
112+
auto znapm4 = zdc.znaPm4();
113+
auto znc = zdc.zncAmpl();
114+
auto zncADC = zdc.zncPmc();
115+
auto zncpm1 = zdc.zncPm1();
116+
auto zncpm2 = zdc.zncPm2();
117+
auto zncpm3 = zdc.zncPm3();
118+
auto zncpm4 = zdc.zncPm4();
119+
auto zpa = zdc.zpaAmpl();
120+
auto zpaADC = zdc.zpaPmc();
121+
auto zpc = zdc.zpcAmpl();
122+
auto zpcADC = zdc.zpcPmc();
123+
auto zem1 = zdc.zem1Ampl();
124+
auto zem2 = zdc.zem2Ampl();
125+
auto multFT0A = zdc.multFt0a();
126+
auto multFT0C = zdc.multFt0c();
127+
auto multV0A = zdc.multV0a();
128+
auto zvtx = zdc.vertexZ();
129+
auto centrFT0C = zdc.centralityFt0c();
130+
auto centrFT0A = zdc.centralityFt0a();
131+
auto centrFT0M = zdc.centralityFt0m();
132+
auto timestamp = zdc.timestamp();
133+
// auto selectionBits = zdc.selectionBits();
134+
135+
if ((useZvtx && (zvtx < zVval)) || !useZvtx) {
136+
registry.get<TH1>(HIST("hZNApmc"))->Fill(zna);
137+
registry.get<TH1>(HIST("hZNCpmc"))->Fill(znc);
138+
registry.get<TH1>(HIST("hZPApmc"))->Fill(zpa);
139+
registry.get<TH1>(HIST("hZPCpmc"))->Fill(zpc);
140+
registry.get<TH1>(HIST("hZEM"))->Fill(zem1 + zem2);
141+
//
142+
registry.get<TH2>(HIST("hZNAamplvsADC"))->Fill(znaADC, zna);
143+
registry.get<TH2>(HIST("hZNCamplvsADC"))->Fill(zncADC, znc);
144+
registry.get<TH2>(HIST("hZPAamplvsADC"))->Fill(zpaADC, zpa);
145+
registry.get<TH2>(HIST("hZPCamplvsADC"))->Fill(zpcADC, zpc);
146+
//
147+
registry.get<TH2>(HIST("hZNvsZEM"))->Fill(zem1 + zem2, zna + znc);
148+
registry.get<TH2>(HIST("hZNAvsZNC"))->Fill(znc, zna);
149+
registry.get<TH2>(HIST("hZPAvsZPC"))->Fill(zpc, zpa);
150+
registry.get<TH2>(HIST("hZNAvsZPA"))->Fill(zpa, zna);
151+
registry.get<TH2>(HIST("hZNCvsZPC"))->Fill(zpc, znc);
152+
//
153+
registry.get<TH2>(HIST("hZNAvstdc"))->Fill(tdczna, zna);
154+
registry.get<TH2>(HIST("hZNCvstdc"))->Fill(tdcznc, znc);
155+
registry.get<TH2>(HIST("hZPAvstdc"))->Fill(tdczpa, zpa);
156+
registry.get<TH2>(HIST("hZPCvstdc"))->Fill(tdczpc, zpc);
157+
//
158+
registry.get<TH2>(HIST("hZNAcvsZNAsum"))->Fill(znapm1 + znapm2 + znapm3 + znapm4, zna);
159+
registry.get<TH2>(HIST("hZNCcvsZNCsum"))->Fill(zncpm1 + zncpm2 + zncpm3 + zncpm4, znc);
160+
//
161+
registry.get<TH2>(HIST("hZNvsV0A"))->Fill(multV0A / 100., zna + znc);
162+
registry.get<TH2>(HIST("hZNAvsFT0A"))->Fill((multFT0A) / 100., zna);
163+
registry.get<TH2>(HIST("hZNCvsFT0C"))->Fill((multFT0C) / 100., znc);
164+
//
165+
registry.get<TH2>(HIST("hZNAvscentrFT0A"))->Fill(centrFT0A, zna);
166+
registry.get<TH2>(HIST("hZNAvscentrFT0C"))->Fill(centrFT0C, zna);
167+
registry.get<TH2>(HIST("hZNAvscentrFT0M"))->Fill(centrFT0M, zna);
168+
registry.get<TH2>(HIST("hZPAvscentrFT0A"))->Fill(centrFT0A, zpa);
169+
registry.get<TH2>(HIST("hZPAvscentrFT0C"))->Fill(centrFT0C, zpa);
170+
registry.get<TH2>(HIST("hZPAvscentrFT0M"))->Fill(centrFT0M, zpa);
171+
registry.get<TH2>(HIST("hZNCvscentrFT0A"))->Fill(centrFT0A, znc);
172+
registry.get<TH2>(HIST("hZNCvscentrFT0C"))->Fill(centrFT0C, znc);
173+
registry.get<TH2>(HIST("hZNCvscentrFT0M"))->Fill(centrFT0M, znc);
174+
registry.get<TH2>(HIST("hZPCvscentrFT0A"))->Fill(centrFT0A, zpc);
175+
registry.get<TH2>(HIST("hZPCvscentrFT0C"))->Fill(centrFT0C, zpc);
176+
registry.get<TH2>(HIST("hZPCvscentrFT0M"))->Fill(centrFT0M, zpc);
177+
//
178+
registry.get<TH2>(HIST("hZNAvstimestamp"))->Fill(timestamp, zna);
179+
registry.get<TH2>(HIST("hZNCvstimestamp"))->Fill(timestamp, znc);
180+
registry.get<TH2>(HIST("hZPAvstimestamp"))->Fill(timestamp, zpa);
181+
registry.get<TH2>(HIST("hZPCvstimestamp"))->Fill(timestamp, zpc);
182+
}
183+
}
184+
}
185+
};
186+
187+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
188+
{
189+
return WorkflowSpec{
190+
adaptAnalysisTask<ZDCLIAnalysis>(cfgc) //
191+
};
192+
}

EventFiltering/macros/getMenu.C

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@
1212
#include "CCDB/BasicCCDBManager.h"
1313

1414
#include <TAxis.h>
15+
#include <TFile.h>
16+
#include <TGrid.h>
1517
#include <TH1.h>
18+
#include <TSystem.h>
1619

20+
#include <iostream>
21+
#include <regex>
22+
#include <set>
23+
#include <sstream>
1724
#include <string>
25+
#include <vector>
1826

1927
void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/")
2028
{
@@ -29,3 +37,87 @@ void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFil
2937
std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n";
3038
}
3139
}
40+
41+
std::vector<std::string> getMenuForPeriod(std::string period)
42+
{
43+
std::regex pattern(R"(LHC(\d{2})[A-Za-z]{1,2})");
44+
std::smatch match;
45+
46+
int year{2000};
47+
if (!std::regex_match(period, match, pattern)) {
48+
std::cout << "Invalid format for period: " << period << std::endl;
49+
return {};
50+
}
51+
52+
year += std::stoi(match[1]);
53+
gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root > list_tmp_%s.txt", year, period.data(), period.data()));
54+
55+
std::ifstream file(Form("list_tmp_%s.txt", period.data()));
56+
if (!file) {
57+
std::cerr << "Error: could not open file for period " << period << "\n";
58+
return {};
59+
}
60+
61+
std::string firstLine;
62+
if (!std::getline(file, firstLine)) {
63+
std::cerr << "Error: file is empty or read failed for period " << period << "\n";
64+
return {};
65+
}
66+
67+
TGrid::Connect("alien://");
68+
TFile* scalersFile = TFile::Open((std::string("alien://") + firstLine).data(), "READ");
69+
TH1D* counters = (TH1D*)scalersFile->Get("central-event-filter-task/scalers/mFiltered");
70+
TAxis* axis = counters->GetXaxis();
71+
72+
std::vector<std::string> binLabels(axis->GetNbins() - 2);
73+
for (int i = 2; i < axis->GetNbins(); ++i) {
74+
binLabels[i - 2] = axis->GetBinLabel(i);
75+
}
76+
77+
scalersFile->Close();
78+
delete scalersFile;
79+
gSystem->Exec(Form("rm list_tmp_%s.txt", period.data()));
80+
81+
return binLabels;
82+
}
83+
84+
void getMenu(std::string periods)
85+
{
86+
std::stringstream ss(periods);
87+
std::string period;
88+
std::vector<std::string> periodList;
89+
90+
// Parse comma-separated periods
91+
while (std::getline(ss, period, ',')) {
92+
// Trim whitespace
93+
period.erase(0, period.find_first_not_of(" \t"));
94+
period.erase(period.find_last_not_of(" \t") + 1);
95+
periodList.push_back(period);
96+
}
97+
98+
std::map<std::vector<std::string>, std::vector<std::string>> menuGroups;
99+
100+
// Get menus for each period
101+
for (const auto& p : periodList) {
102+
auto menu = getMenuForPeriod(p);
103+
if (!menu.empty()) {
104+
menuGroups[menu].push_back(p);
105+
}
106+
}
107+
108+
// Report different menus
109+
int menuId = 1;
110+
for (const auto& [menu, periods] : menuGroups) {
111+
std::cout << "\n=== Menu " << menuId++ << " (periods: ";
112+
for (size_t i = 0; i < periods.size(); ++i) {
113+
std::cout << periods[i];
114+
if (i < periods.size() - 1)
115+
std::cout << ", ";
116+
}
117+
std::cout << ") ===\n";
118+
119+
for (size_t i = 0; i < menu.size(); ++i) {
120+
std::cout << "Id " << i << ": " << menu[i] << "\n";
121+
}
122+
}
123+
}

0 commit comments

Comments
 (0)