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
31 changes: 24 additions & 7 deletions EventFiltering/Zorro.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)

Check failure on line 1 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Provide mandatory file documentation.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -8,17 +8,34 @@
// 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.
//

Check failure on line 11 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \author is missing, incorrect or misplaced.

Check failure on line 11 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \brief is missing, incorrect or misplaced.

Check failure on line 11 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

#include "Zorro.h"

#include <algorithm>
#include <map>
#include "EventFiltering/ZorroHelper.h"

#include <CCDB/BasicCCDBManager.h>
#include <CommonConstants/LHCConstants.h>
#include <CommonDataFormat/IRFrame.h>
#include <CommonDataFormat/InteractionRecord.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/Logger.h>

#include <TList.h>
#include <TH1.h>
#include <TH2.h>
#include <TString.h>

#include "CCDB/BasicCCDBManager.h"
#include "CommonDataFormat/InteractionRecord.h"
#include <RtypesCore.h>

#include <algorithm>
#include <bitset>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <vector>

using o2::InteractionRecord;

Expand Down Expand Up @@ -171,7 +188,7 @@
metadata["runNumber"] = std::to_string(runNumber);
mRunDuration = mCCDB->getRunDuration(runNumber, true);
int64_t runTs = (mRunDuration.first / 2 + mRunDuration.second / 2);
auto ctp = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", runTs);

Check failure on line 191 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
mOrbitResetTimestamp = (*ctp)[0];
mScalers = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "FilterCounters", runTs, metadata);
mSelections = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "SelectionCounters", runTs, metadata);
Expand Down Expand Up @@ -212,7 +229,7 @@
{
mLastResult.reset();
if (bcGlobalId < mBCranges.front().getMin().toLong() - tolerance || bcGlobalId > mBCranges.back().getMax().toLong() + tolerance) {
setupHelpers((mOrbitResetTimestamp + int64_t(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000);
setupHelpers((mOrbitResetTimestamp + static_cast<int64_t>(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000);
}

o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance};
Expand All @@ -223,8 +240,8 @@
mLastBCglobalId = bcGlobalId;
for (size_t i = mLastSelectedIdx; i < mBCranges.size(); i++) {
if (!mBCranges[i].isOutside(bcFrame)) {
for (int iMask{0}; iMask < 2; ++iMask) {

Check failure on line 243 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (int iTOI{0}; iTOI < 64; ++iTOI) {

Check failure on line 244 in EventFiltering/Zorro.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI)) {
mLastResult.set(iMask * 64 + iTOI, 1);
if (mAnalysedTriggers && !mAccountedBCranges[i]) {
Expand Down Expand Up @@ -306,7 +323,7 @@
std::sort(mZorroHelpers->begin(), mZorroHelpers->end(), [](const auto& a, const auto& b) { return std::min(a.bcAOD, a.bcEvSel) < std::min(b.bcAOD, b.bcEvSel); });
mBCranges.clear();
mAccountedBCranges.clear();
for (auto helper : *mZorroHelpers) {
for (const auto& helper : *mZorroHelpers) {
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel)));
}
mAccountedBCranges.resize(mBCranges.size(), false);
Expand Down
26 changes: 14 additions & 12 deletions EventFiltering/Zorro.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
#ifndef EVENTFILTERING_ZORRO_H_
#define EVENTFILTERING_ZORRO_H_

#include "ZorroHelper.h"
#include "ZorroSummary.h"

#include <CommonDataFormat/IRFrame.h>
#include <Framework/HistogramRegistry.h>

#include <TH1.h>
#include <TH2.h>

#include <bitset>
#include <memory>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>

#include "TH1D.h"
#include "TH2D.h"
#include "CommonDataFormat/IRFrame.h"
#include "Framework/HistogramRegistry.h"
#include "ZorroHelper.h"
#include "ZorroSummary.h"

namespace o2
{
namespace ccdb
Expand Down Expand Up @@ -61,8 +63,8 @@ class Zorro
std::vector<bool> getTriggerOfInterestResults() const;
int getNTOIs() const { return mTOIs.size(); }

void setCCDBpath(std::string path) { mBaseCCDBPath = path; }
void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; }
void setCCDBpath(const std::string& path) { mBaseCCDBPath = path; }
void setBaseCCDBPath(const std::string& path) { mBaseCCDBPath = path; }
void setBCtolerance(int tolerance) { mBCtolerance = tolerance; }

ZorroSummary* getZorroSummary() { return &mZorroSummary; }
Expand All @@ -76,8 +78,8 @@ class Zorro
int mRunNumber = 0;
std::pair<int64_t, int64_t> mRunDuration;
int64_t mOrbitResetTimestamp = 0;
TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run
TH1* mAnalysedTriggersOfInterest; /// Accounting for triggers of interest in the current run
TH1* mAnalysedTriggers = nullptr; /// Accounting for all triggers in the current run
TH1* mAnalysedTriggersOfInterest = nullptr; /// Accounting for triggers of interest in the current run

std::vector<int> mRunNumberHistos;
std::vector<TH1*> mAnalysedTriggersList; /// Per run histograms
Expand Down
3 changes: 2 additions & 1 deletion EventFiltering/ZorroHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
// 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.
//

Check failure on line 11 in EventFiltering/ZorroHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[doc/file]

Documentation for \file is missing, incorrect or misplaced.

#ifndef EVENTFILTERING_ZORROHELPER_H_
#define EVENTFILTERING_ZORROHELPER_H_

#include "Rtypes.h"
#include <Rtypes.h>
#include <RtypesCore.h>

struct ZorroHelper {
ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2];

Check failure on line 20 in EventFiltering/ZorroHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
ClassDefNV(ZorroHelper, 1);
};

Expand Down
11 changes: 8 additions & 3 deletions EventFiltering/ZorroSummary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

#include "ZorroSummary.h"

#include "TCollection.h"
#include <TCollection.h>
#include <TObject.h>

#include <RtypesCore.h>

#include <cstddef>

void ZorroSummary::Copy(TObject& c) const
{
Expand Down Expand Up @@ -42,7 +47,7 @@ Long64_t ZorroSummary::Merge(TCollection* list)
mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber);
} else {
auto& thisCounters = mAnalysedTOIcounters[runNumber];
for (size_t i = 0; i < thisCounters.size(); ++i) {
for (std::size_t i = 0; i < thisCounters.size(); ++i) {
thisCounters[i] += currentAnalysedToiCounters[i];
}
}
Expand All @@ -66,4 +71,4 @@ double ZorroSummary::getNormalisationFactor(int toiId) const
}

return totalTVX * totalAnalysedTOI / totalTOI;
}
}
9 changes: 5 additions & 4 deletions EventFiltering/ZorroSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#include <TNamed.h>

#include <Rtypes.h>
#include <RtypesCore.h>

#include <string>
#include <unordered_map>
#include <vector>
Expand All @@ -41,9 +44,7 @@ class ZorroSummary : public TNamed
mRunNumber = runNumber;
mTVXcounters[runNumber] = tvxCountes;
mTOIcounters[runNumber] = toiCounters;
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
mAnalysedTOIcounters[runNumber] = std::vector<ULong64_t>(mNtois, 0ull);
}
mAnalysedTOIcounters.try_emplace(runNumber, std::vector<ULong64_t>(mNtois, 0ull));
mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber];
}
double getNormalisationFactor(int toiId) const;
Expand Down Expand Up @@ -73,4 +74,4 @@ class ZorroSummary : public TNamed
ClassDef(ZorroSummary, 1);
};

#endif // EVENTFILTERING_ZORROSUMMARY_H_
#endif // EVENTFILTERING_ZORROSUMMARY_H_
Loading