Skip to content

Commit

Permalink
[Common] add parameters for event selection based on data quality
Browse files Browse the repository at this point in the history
- definition of bits in the CCDB objects
- utility class to check a collision/bc based on a given list of bits
  • Loading branch information
aferrero2707 committed Jan 6, 2025
1 parent 58f18a6 commit fb6edb6
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions Common/CCDB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

o2physics_add_library(AnalysisCCDB
SOURCES EventSelectionParams.cxx
SOURCES QualitySelectionParams.cxx
SOURCES TriggerAliases.cxx
SOURCES ctpRateFetcher.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore)
Expand Down
42 changes: 42 additions & 0 deletions Common/CCDB/QualitySelectionParams.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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 "QualitySelectionParams.h"

namespace o2::aod::qualitysel
{
} // namespace o2::aod::qualitysel

using namespace o2::aod::qualitysel;

QualityChecker QualitySelectionFactory::create(const std::string& label)
{
if (label == "CBT") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID};
}
else if (label == "CBT_hadronPID") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kTOFBad};
}
else if (label == "CBT_electronPID") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kTRDBad};
}
else if (label == "CBT_calo") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kTPCBadPID, kEMCBad};
}
else if (label == "CBT_muon") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kMCHBad, kMIDBad};
}
else if (label == "CBT_muon_glo") {
return {kFT0Bad, kITSBad, kTPCBadTracking, kMCHBad, kMFTBad, kMIDBad};
}

return {};
}
99 changes: 99 additions & 0 deletions Common/CCDB/QualitySelectionParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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 COMMON_CCDB_QUALITYSELECTIONPARAMS_H_
#define COMMON_CCDB_QUALITYSELECTIONPARAMS_H_

#include <Rtypes.h>
#include <TMath.h>

#include <stdexcept>

namespace o2::aod::qualitysel
{

// Quality selection criteria
enum QualitySelectionFlags {
kCPVBad = 0,
kEMCLimAccMCRepr,
kEMCBad,
kFDDBad,
kFT0Bad,
kFV0Bad,
kHMPBad,
kITSLimAccMCRepr,
kITSBad,
kMCHLimAccMCRepr,
kMCHBad,
kMFTLimAccMCRepr,
kMFTBad,
kMIDLimAccMCRepr,
kMIDBad,
kPHSBad,
kTOFLimAccMCRepr,
kTOFBad,
kTPCLimAccMCRepr,
kTPCBadTracking,
kTPCBadPID,
kTRDBad,
kZDCBad,
kNQualitySelectionFlags
};

template <typename T>
concept HasDetectorQuality = requires(T a, int bit)
{
{ a.detectorQuality_bit(bit) } -> std::convertible_to<bool>;
};

class QualityChecker
{
public:
QualityChecker() = default;
QualityChecker(std::initializer_list<QualitySelectionFlags> bitsTocheck) : vBitsToCheck(bitsTocheck.size())
{
std::copy(bitsTocheck.begin(), bitsTocheck.end(), vBitsToCheck.begin());
}

QualityChecker(const std::vector<QualitySelectionFlags> bitsTocheck) : vBitsToCheck(bitsTocheck) {}

bool checkTable(const HasDetectorQuality auto& table)
{
if (vBitsToCheck.empty()) {
throw std::out_of_range ("QualityChecker with empty QualitySelectionFlags bits vector");
}

for (auto bit : vBitsToCheck) {
if (table.detectorQuality_bit(bit)) {
return false;
}
}
return true;
}

bool operator ()(const HasDetectorQuality auto& table)
{
return checkTable(table);
}

private:
std::vector<QualitySelectionFlags> vBitsToCheck;
};

} // namespace o2::aod::qualitysel

class QualitySelectionFactory
{
public:
static o2::aod::qualitysel::QualityChecker create(const std::string& label);
};

#endif // COMMON_CCDB_QUALITYSELECTIONPARAMS_H_

0 comments on commit fb6edb6

Please sign in to comment.