Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EventFiltering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ o2physics_add_dpl_workflow(lf-f1proton-filter
COMPONENT_NAME Analysis)

o2physics_add_library(EventFilteringUtils
SOURCES Zorro.cxx
INSTALL_HEADERS ZorroHelper.h
SOURCES Zorro.cxx ZorroSummary.cxx
INSTALL_HEADERS ZorroHelper.h ZorroSummary.h
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore Arrow::arrow_shared)

o2physics_target_root_dictionary(EventFilteringUtils
HEADERS ZorroHelper.h
HEADERS ZorroHelper.h ZorroSummary.h
LINKDEF EventFilteringUtilsLinkDef.h)
1 change: 1 addition & 0 deletions EventFiltering/EventFilteringUtilsLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
#pragma link off all functions;

#pragma link C++ class ZorroHelper + ;
#pragma link C++ class ZorroSummary + ;
#pragma link C++ class std::vector < ZorroHelper> + ;
13 changes: 11 additions & 2 deletions EventFiltering/Zorro.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
for (size_t i{0}; i < mTOIs.size(); ++i) {
LOGF(info, ">>> %s : %i", mTOIs[i].data(), mTOIidx[i]);
}
mZorroSummary.setupTOIs(mTOIs.size(), tois);
std::vector<double> toiCounters(mTOIs.size(), 0.);
for (size_t i{0}; i < mTOIs.size(); ++i) {
toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2);
}
mZorroSummary.setupRun(runNumber, mInspectedTVX->GetBinContent(1), toiCounters);

return mTOIidx;
}

Expand Down Expand Up @@ -174,18 +181,20 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
{
uint64_t lastSelectedIdx = mLastSelectedIdx;
fetch(bcGlobalId, tolerance);
bool retVal{false};
for (size_t i{0}; i < mTOIidx.size(); ++i) {
if (mTOIidx[i] < 0) {
continue;
} else if (mLastResult.test(mTOIidx[i])) {
mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting
if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) {
mAnalysedTriggersOfInterest->Fill(i);
mZorroSummary.increaseTOIcounter(mRunNumber, i);
}
return true;
retVal = true;
}
}
return false;
return retVal;
}

std::vector<bool> Zorro::getTriggerOfInterestResults(uint64_t bcGlobalId, uint64_t tolerance)
Expand Down
5 changes: 5 additions & 0 deletions EventFiltering/Zorro.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "CommonDataFormat/IRFrame.h"
#include "Framework/HistogramRegistry.h"
#include "ZorroHelper.h"
#include "ZorroSummary.h"

namespace o2
{
Expand Down Expand Up @@ -55,7 +56,11 @@ class Zorro
void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; }
void setBCtolerance(int tolerance) { mBCtolerance = tolerance; }

ZorroSummary* getZorroSummary() { return &mZorroSummary; }

private:
ZorroSummary mZorroSummary{"ZorroSummary", "ZorroSummary"};

std::string mBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/";
int mRunNumber = 0;
TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run
Expand Down
69 changes: 69 additions & 0 deletions EventFiltering/ZorroSummary.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include "ZorroSummary.h"

#include "TCollection.h"

void ZorroSummary::Copy(TObject& c) const
{
static_cast<ZorroSummary&>(c) = *this;
}

Long64_t ZorroSummary::Merge(TCollection* list)
{
if (!list) {
return 0;
}
int n = 1;
if (list->IsEmpty()) {
return n;
}

for (auto* obj : *list) {
auto* entry = dynamic_cast<ZorroSummary*>(obj);
if (!entry || entry->getTOInames() != mTOInames) {
continue;
}
n++;
auto& analysedToiCounters = entry->getAnalysedTOIcounters();
for (const auto& [runNumber, currentAnalysedToiCounters] : analysedToiCounters) {
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
mAnalysedTOIcounters[runNumber] = currentAnalysedToiCounters;
mTVXcounters[runNumber] = entry->getTVXcounters().at(runNumber);
mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber);
} else {
auto& thisCounters = mAnalysedTOIcounters[runNumber];
for (size_t i = 0; i < thisCounters.size(); ++i) {
thisCounters[i] += currentAnalysedToiCounters[i];
}
}
}
}
return n;
}

double ZorroSummary::getNormalisationFactor(int toiId) const
{
double totalTOI{0.}, totalTVX{0.};
ULong64_t totalAnalysedTOI{0};
for (const auto& [runNumber, toiCounters] : mTOIcounters) {
totalTOI += toiCounters.at(toiId);
}
for (const auto& [runNumber, tvxCounters] : mTVXcounters) {
totalTVX += tvxCounters;
}
for (const auto& [runNumber, analysedTOIcounters] : mAnalysedTOIcounters) {
totalAnalysedTOI += analysedTOIcounters.at(toiId);
}

return totalTVX * totalAnalysedTOI / totalTOI;
}
76 changes: 76 additions & 0 deletions EventFiltering/ZorroSummary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//

#ifndef EVENTFILTERING_ZORROSUMMARY_H_
#define EVENTFILTERING_ZORROSUMMARY_H_

#include <TNamed.h>

#include <string>
#include <unordered_map>
#include <vector>

class ZorroSummary : public TNamed
{
public:
ZorroSummary() = default;
ZorroSummary(const char* name, const char* objTitle) : TNamed(name, objTitle) {}
virtual ~ZorroSummary() = default; // NOLINT: Making this override breaks compilation for unknown reason
virtual void Copy(TObject& c) const; // NOLINT: Making this override breaks compilation for unknown reason
virtual Long64_t Merge(TCollection* list);

void setupTOIs(int ntois, const std::string& toinames)
{
mNtois = ntois;
mTOInames = toinames;
}
void setupRun(int runNumber, double tvxCountes, const std::vector<double>& toiCounters)
{
if (mRunNumber == runNumber) {
return;
}
mRunNumber = runNumber;
mTVXcounters[runNumber] = tvxCountes;
mTOIcounters[runNumber] = toiCounters;
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
mAnalysedTOIcounters[runNumber] = std::vector<ULong64_t>(mNtois, 0ull);
}
mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber];
}
double getNormalisationFactor(int toiId) const;
void increaseTOIcounter(int runNumber, int toiId)
{
if (runNumber != mRunNumber) {
return;
}
mCurrentAnalysedTOIcounters->at(toiId)++;
}

std::string getTOInames() const { return mTOInames; }
const auto& getTOIcounters() const { return mTOIcounters; }
const auto& getTVXcounters() const { return mTVXcounters; }
const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; }

private:
int mRunNumber = 0; //! Run currently being analysed
std::vector<ULong64_t>* mCurrentAnalysedTOIcounters = nullptr; //! Analysed TOI counters for the current run

int mNtois = 0;
std::string mTOInames;
std::unordered_map<int, std::vector<ULong64_t>> mAnalysedTOIcounters;
std::unordered_map<int, std::vector<double>> mTOIcounters;
std::unordered_map<int, double> mTVXcounters;

ClassDef(ZorroSummary, 1);
};

#endif // EVENTFILTERING_ZORROSUMMARY_H_
3 changes: 3 additions & 0 deletions PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "DetectorsBase/Propagator.h"

#include "EventFiltering/Zorro.h"
#include "EventFiltering/ZorroSummary.h"

#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
Expand Down Expand Up @@ -232,6 +233,7 @@ struct nucleiSpectra {
Produces<o2::aod::NucleiTableFlow> nucleiTableFlow;
Service<o2::ccdb::BasicCCDBManager> ccdb;
Zorro zorro;
OutputObj<ZorroSummary> zorroSummary{"zorroSummary"};
TrackTuner trackTunerObj;

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

void init(o2::framework::InitContext&)
{
zorroSummary.setObject(zorro.getZorroSummary());
ccdb->setURL(cfgCCDBurl);
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
Expand Down