Skip to content

Commit 155a551

Browse files
authored
[PWGLF] Add vertex reconstruction rate monitoring (AliceO2Group#8539)
1 parent f068ec9 commit 155a551

File tree

2 files changed

+64
-5
lines changed

2 files changed

+64
-5
lines changed

PWGLF/Tasks/QC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ o2physics_add_dpl_workflow(tpc-dedx-qa
7272

7373
o2physics_add_dpl_workflow(vertexqa
7474
SOURCES vertexQA.cxx
75-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
75+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB
7676
COMPONENT_NAME Analysis)
7777

7878
o2physics_add_dpl_workflow(efficiencyqa

PWGLF/Tasks/QC/vertexQA.cxx

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include <algorithm>
1213
#include <cmath>
13-
#include <vector>
1414
#include <deque>
15-
#include <algorithm>
15+
#include <string>
16+
#include <vector>
17+
#include <utility>
1618

17-
#include "Framework/runDataProcessing.h"
19+
#include "CCDB/BasicCCDBManager.h"
20+
#include "Common/CCDB/ctpRateFetcher.h"
1821
#include "Framework/AnalysisDataModel.h"
1922
#include "Framework/AnalysisTask.h"
23+
#include "Framework/runDataProcessing.h"
2024

2125
using namespace o2;
2226
using namespace o2::framework;
@@ -34,7 +38,7 @@ double deltaTimeColl(BCcoll const bccoll1, BCcoll const bccoll2)
3438
auto coll2 = std::get<aod::Collision>(bccoll2);
3539
auto bc1 = std::get<aod::BC>(bccoll1);
3640
auto bc2 = std::get<aod::BC>(bccoll2);
37-
int64_t tmpDT = int64_t(bc1.globalBC()) - int64_t(bc2.globalBC());
41+
int64_t tmpDT = static_cast<int64_t>(bc1.globalBC()) - static_cast<int64_t>(bc2.globalBC());
3842
double deltaT = tmpDT * LHCBunchSpacingNS + coll1.collisionTime() - coll2.collisionTime();
3943
return deltaT;
4044
}
@@ -57,6 +61,9 @@ DECLARE_SOA_TABLE(VtxQAtable, "AOD", "VTXQATABLE",
5761
} // namespace o2::aod
5862

5963
struct vertexQA {
64+
Service<o2::ccdb::BasicCCDBManager> ccdb;
65+
ctpRateFetcher mRateFetcher;
66+
6067
Produces<o2::aod::VtxQAtable> vtxQAtable;
6168

6269
Configurable<int> storeTree{"storeTree", 1000, "Store in tree collisions from BC's with more than 'storeTree' vertices, for in-depth analysis"};
@@ -87,10 +94,15 @@ struct vertexQA {
8794
ConfigurableAxis nContribAxis{"nContribBins", {1000, 0, 5000}, "Binning for number of contributors to PV"};
8895
ConfigurableAxis nContribDiffAxis{"nContribDiffBins", {1000, -5000, 5000}, "Binning for the difference in number of contributors to PV"};
8996

97+
ConfigurableAxis irBinning{"IRbinning", {500, 0, 100}, "Binning for the interaction rate (kHz)"};
98+
Configurable<std::string> irSource{"irSource", "ZNC hadronic", "Source of the interaction rate"};
99+
90100
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
91101

92102
std::deque<BCcoll> colls;
93103

104+
int64_t mFirstBCid = -1;
105+
94106
void init(InitContext const&)
95107
{
96108
histos.add<TH1>("nVtxHistogram", ";#it{N}_{vtx}^{rec};Entries", HistType::kTH1F, {nVtxAxis});
@@ -121,6 +133,11 @@ struct vertexQA {
121133

122134
histos.add<TH2>("nContribITSRofTimeSeriesHistogram", ";#it{N}_{contrib}^{1};#it{N}_{contrib}^{2}", HistType::kTH2F, {nContribAxis, nContribAxis});
123135
histos.add<TH1>("tDiffDuplicateTimeSeriesHistogram", ";#Delta#it{t}_{vtx} (ns);Entries", HistType::kTH1F, {tDiffVtxAxisExtend});
136+
histos.add<TH2>("tIRvsCollisionRateHistogram", Form(";IR from %s (kHz);IR from reconstructed vertices (kHz)", irSource.value.data()), HistType::kTH2D, {irBinning, irBinning});
137+
138+
ccdb->setURL("http://alice-ccdb.cern.ch");
139+
ccdb->setCaching(true);
140+
ccdb->setFatalWhenNull(false);
124141
}
125142

126143
void process(aod::BC const& bc, aod::Collisions const& collisions)
@@ -231,6 +248,48 @@ struct vertexQA {
231248
}
232249
}
233250
}
251+
PROCESS_SWITCH(vertexQA, process, "Standard vertex QA", true);
252+
253+
void processIR(aod::BCsWithTimestamps const& bcs, aod::Collisions const& collisions)
254+
{
255+
if (collisions.size() <= 2) {
256+
return;
257+
}
258+
259+
std::vector<int64_t> jumps{0ll};
260+
int64_t lastBC = bcs.rawIteratorAt(0).globalBC();
261+
for (auto bc : bcs) {
262+
if (bc.globalBC() - lastBC > 3564 * 32) { // 32 orbits
263+
jumps.push_back(bc.globalIndex());
264+
lastBC = bc.globalBC();
265+
}
266+
}
267+
uint64_t jumpsSentinel{1};
268+
std::vector<int64_t> collisionsIndices{0ll};
269+
for (auto col : collisions) {
270+
if (jumpsSentinel == jumps.size()) {
271+
break;
272+
}
273+
if (col.bcId() > jumps[jumpsSentinel]) {
274+
collisionsIndices.push_back(col.globalIndex());
275+
jumpsSentinel++;
276+
}
277+
}
278+
jumps.push_back(bcs.size());
279+
collisionsIndices.push_back(collisions.size());
280+
281+
for (size_t i{0}; i < jumps.size() - 1; ++i) {
282+
auto startBC = bcs.rawIteratorAt(jumps[i]);
283+
auto endBC = bcs.rawIteratorAt(jumps[i + 1] - 1);
284+
double startIR = mRateFetcher.fetch(ccdb.service, startBC.timestamp(), startBC.runNumber(), irSource.value);
285+
double endIR = mRateFetcher.fetch(ccdb.service, endBC.timestamp(), endBC.runNumber(), irSource.value);
286+
double deltaT = (endBC.globalBC() - startBC.globalBC()) * LHCBunchSpacingNS * 1.e-9;
287+
double collisionRate = (collisionsIndices[i + 1] - collisionsIndices[i]) / deltaT; /// -1 to remove the bias of the collisions at extremities?
288+
double ir = (startIR + endIR) * 0.5;
289+
histos.fill(HIST("tIRvsCollisionRateHistogram"), ir * 1.e-3, collisionRate * 1.e-3);
290+
}
291+
}
292+
PROCESS_SWITCH(vertexQA, processIR, "Checks on interaction rate", true);
234293
};
235294

236295
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)