Skip to content

Commit 0e259a6

Browse files
authored
Add the ZorroSummary utility (#7409)
1 parent b52579b commit 0e259a6

7 files changed

Lines changed: 168 additions & 5 deletions

File tree

EventFiltering/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ o2physics_add_dpl_workflow(lf-f1proton-filter
108108
COMPONENT_NAME Analysis)
109109

110110
o2physics_add_library(EventFilteringUtils
111-
SOURCES Zorro.cxx
112-
INSTALL_HEADERS ZorroHelper.h
111+
SOURCES Zorro.cxx ZorroSummary.cxx
112+
INSTALL_HEADERS ZorroHelper.h ZorroSummary.h
113113
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore Arrow::arrow_shared)
114114

115115
o2physics_target_root_dictionary(EventFilteringUtils
116-
HEADERS ZorroHelper.h
116+
HEADERS ZorroHelper.h ZorroSummary.h
117117
LINKDEF EventFilteringUtilsLinkDef.h)

EventFiltering/EventFilteringUtilsLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
#pragma link off all functions;
1515

1616
#pragma link C++ class ZorroHelper + ;
17+
#pragma link C++ class ZorroSummary + ;
1718
#pragma link C++ class std::vector < ZorroHelper> + ;

EventFiltering/Zorro.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
135135
for (size_t i{0}; i < mTOIs.size(); ++i) {
136136
LOGF(info, ">>> %s : %i", mTOIs[i].data(), mTOIidx[i]);
137137
}
138+
mZorroSummary.setupTOIs(mTOIs.size(), tois);
139+
std::vector<double> toiCounters(mTOIs.size(), 0.);
140+
for (size_t i{0}; i < mTOIs.size(); ++i) {
141+
toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2);
142+
}
143+
mZorroSummary.setupRun(runNumber, mInspectedTVX->GetBinContent(1), toiCounters);
144+
138145
return mTOIidx;
139146
}
140147

@@ -174,18 +181,20 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
174181
{
175182
uint64_t lastSelectedIdx = mLastSelectedIdx;
176183
fetch(bcGlobalId, tolerance);
184+
bool retVal{false};
177185
for (size_t i{0}; i < mTOIidx.size(); ++i) {
178186
if (mTOIidx[i] < 0) {
179187
continue;
180188
} else if (mLastResult.test(mTOIidx[i])) {
181189
mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting
182190
if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) {
183191
mAnalysedTriggersOfInterest->Fill(i);
192+
mZorroSummary.increaseTOIcounter(mRunNumber, i);
184193
}
185-
return true;
194+
retVal = true;
186195
}
187196
}
188-
return false;
197+
return retVal;
189198
}
190199

191200
std::vector<bool> Zorro::getTriggerOfInterestResults(uint64_t bcGlobalId, uint64_t tolerance)

EventFiltering/Zorro.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "CommonDataFormat/IRFrame.h"
2424
#include "Framework/HistogramRegistry.h"
2525
#include "ZorroHelper.h"
26+
#include "ZorroSummary.h"
2627

2728
namespace o2
2829
{
@@ -55,7 +56,11 @@ class Zorro
5556
void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; }
5657
void setBCtolerance(int tolerance) { mBCtolerance = tolerance; }
5758

59+
ZorroSummary* getZorroSummary() { return &mZorroSummary; }
60+
5861
private:
62+
ZorroSummary mZorroSummary{"ZorroSummary", "ZorroSummary"};
63+
5964
std::string mBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/";
6065
int mRunNumber = 0;
6166
TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run

EventFiltering/ZorroSummary.cxx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
#include "ZorroSummary.h"
13+
14+
#include "TCollection.h"
15+
16+
void ZorroSummary::Copy(TObject& c) const
17+
{
18+
static_cast<ZorroSummary&>(c) = *this;
19+
}
20+
21+
Long64_t ZorroSummary::Merge(TCollection* list)
22+
{
23+
if (!list) {
24+
return 0;
25+
}
26+
int n = 1;
27+
if (list->IsEmpty()) {
28+
return n;
29+
}
30+
31+
for (auto* obj : *list) {
32+
auto* entry = dynamic_cast<ZorroSummary*>(obj);
33+
if (!entry || entry->getTOInames() != mTOInames) {
34+
continue;
35+
}
36+
n++;
37+
auto& analysedToiCounters = entry->getAnalysedTOIcounters();
38+
for (const auto& [runNumber, currentAnalysedToiCounters] : analysedToiCounters) {
39+
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
40+
mAnalysedTOIcounters[runNumber] = currentAnalysedToiCounters;
41+
mTVXcounters[runNumber] = entry->getTVXcounters().at(runNumber);
42+
mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber);
43+
} else {
44+
auto& thisCounters = mAnalysedTOIcounters[runNumber];
45+
for (size_t i = 0; i < thisCounters.size(); ++i) {
46+
thisCounters[i] += currentAnalysedToiCounters[i];
47+
}
48+
}
49+
}
50+
}
51+
return n;
52+
}
53+
54+
double ZorroSummary::getNormalisationFactor(int toiId) const
55+
{
56+
double totalTOI{0.}, totalTVX{0.};
57+
ULong64_t totalAnalysedTOI{0};
58+
for (const auto& [runNumber, toiCounters] : mTOIcounters) {
59+
totalTOI += toiCounters.at(toiId);
60+
}
61+
for (const auto& [runNumber, tvxCounters] : mTVXcounters) {
62+
totalTVX += tvxCounters;
63+
}
64+
for (const auto& [runNumber, analysedTOIcounters] : mAnalysedTOIcounters) {
65+
totalAnalysedTOI += analysedTOIcounters.at(toiId);
66+
}
67+
68+
return totalTVX * totalAnalysedTOI / totalTOI;
69+
}

EventFiltering/ZorroSummary.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
13+
#ifndef EVENTFILTERING_ZORROSUMMARY_H_
14+
#define EVENTFILTERING_ZORROSUMMARY_H_
15+
16+
#include <TNamed.h>
17+
18+
#include <string>
19+
#include <unordered_map>
20+
#include <vector>
21+
22+
class ZorroSummary : public TNamed
23+
{
24+
public:
25+
ZorroSummary() = default;
26+
ZorroSummary(const char* name, const char* objTitle) : TNamed(name, objTitle) {}
27+
virtual ~ZorroSummary() = default; // NOLINT: Making this override breaks compilation for unknown reason
28+
virtual void Copy(TObject& c) const; // NOLINT: Making this override breaks compilation for unknown reason
29+
virtual Long64_t Merge(TCollection* list);
30+
31+
void setupTOIs(int ntois, const std::string& toinames)
32+
{
33+
mNtois = ntois;
34+
mTOInames = toinames;
35+
}
36+
void setupRun(int runNumber, double tvxCountes, const std::vector<double>& toiCounters)
37+
{
38+
if (mRunNumber == runNumber) {
39+
return;
40+
}
41+
mRunNumber = runNumber;
42+
mTVXcounters[runNumber] = tvxCountes;
43+
mTOIcounters[runNumber] = toiCounters;
44+
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
45+
mAnalysedTOIcounters[runNumber] = std::vector<ULong64_t>(mNtois, 0ull);
46+
}
47+
mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber];
48+
}
49+
double getNormalisationFactor(int toiId) const;
50+
void increaseTOIcounter(int runNumber, int toiId)
51+
{
52+
if (runNumber != mRunNumber) {
53+
return;
54+
}
55+
mCurrentAnalysedTOIcounters->at(toiId)++;
56+
}
57+
58+
std::string getTOInames() const { return mTOInames; }
59+
const auto& getTOIcounters() const { return mTOIcounters; }
60+
const auto& getTVXcounters() const { return mTVXcounters; }
61+
const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; }
62+
63+
private:
64+
int mRunNumber = 0; //! Run currently being analysed
65+
std::vector<ULong64_t>* mCurrentAnalysedTOIcounters = nullptr; //! Analysed TOI counters for the current run
66+
67+
int mNtois = 0;
68+
std::string mTOInames;
69+
std::unordered_map<int, std::vector<ULong64_t>> mAnalysedTOIcounters;
70+
std::unordered_map<int, std::vector<double>> mTOIcounters;
71+
std::unordered_map<int, double> mTVXcounters;
72+
73+
ClassDef(ZorroSummary, 1);
74+
};
75+
76+
#endif // EVENTFILTERING_ZORROSUMMARY_H_

PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "DetectorsBase/Propagator.h"
4646

4747
#include "EventFiltering/Zorro.h"
48+
#include "EventFiltering/ZorroSummary.h"
4849

4950
#include "Framework/AnalysisDataModel.h"
5051
#include "Framework/AnalysisTask.h"
@@ -232,6 +233,7 @@ struct nucleiSpectra {
232233
Produces<o2::aod::NucleiTableFlow> nucleiTableFlow;
233234
Service<o2::ccdb::BasicCCDBManager> ccdb;
234235
Zorro zorro;
236+
OutputObj<ZorroSummary> zorroSummary{"zorroSummary"};
235237
TrackTuner trackTunerObj;
236238

237239
Configurable<bool> cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"};
@@ -370,6 +372,7 @@ struct nucleiSpectra {
370372

371373
void init(o2::framework::InitContext&)
372374
{
375+
zorroSummary.setObject(zorro.getZorroSummary());
373376
ccdb->setURL(cfgCCDBurl);
374377
ccdb->setCaching(true);
375378
ccdb->setLocalObjectValidityChecking();

0 commit comments

Comments
 (0)