Skip to content

Commit

Permalink
[Common] QC flags added in event selection tables (#9418)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekryshen authored Jan 30, 2025
1 parent 51de5e6 commit 5eed443
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
11 changes: 11 additions & 0 deletions Common/CCDB/AnalysisCCDBLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file AnalysisCCDBLinkDef.h
/// \brief Dictionary definitions
///
/// \author Evgeny Kryshen <[email protected]>

#ifndef COMMON_CCDB_ANALYSISCCDBLINKDEF_H_
#define COMMON_CCDB_ANALYSISCCDBLINKDEF_H_

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class EventSelectionParams + ;
#pragma link C++ class TriggerAliases + ;
#pragma link C++ class std::map < uint64_t, uint32_t> + ;

#endif // COMMON_CCDB_ANALYSISCCDBLINKDEF_H_
14 changes: 11 additions & 3 deletions Common/DataModel/EventSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
// 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.

/// \file EventSelection.h
/// \brief Definitions of event selection tables
///
/// \author Evgeny Kryshen <[email protected]> and Igor Altsybeev <[email protected]>

#ifndef COMMON_DATAMODEL_EVENTSELECTION_H_
#define COMMON_DATAMODEL_EVENTSELECTION_H_

Expand Down Expand Up @@ -47,6 +53,7 @@ namespace evsel
{
DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); //! Bitmask of fired trigger aliases (see TriggerAliases.h for definitions)
DECLARE_SOA_BITMAP_COLUMN(Selection, selection, 64); //! Bitmask of selection flags (see EventSelectionParams.h for definitions)
DECLARE_SOA_BITMAP_COLUMN(Rct, rct, 32); //! Bitmask of RCT flags
DECLARE_SOA_COLUMN(Sel7, sel7, bool); //! Event selection decision based on V0A & V0C
DECLARE_SOA_COLUMN(Sel8, sel8, bool); //! Event selection decision based on TVX
DECLARE_SOA_INDEX_COLUMN_FULL(FoundBC, foundBC, int, BCs, "_foundBC"); //! BC entry index in BCs table (-1 if doesn't exist)
Expand All @@ -55,19 +62,20 @@ DECLARE_SOA_INDEX_COLUMN_FULL(FoundFV0, foundFV0, int, FV0As, "_foundFV0"); //!
DECLARE_SOA_INDEX_COLUMN_FULL(FoundFDD, foundFDD, int, FDDs, "_foundFDD"); //! FDD entry index in FDDs table (-1 if doesn't exist)
DECLARE_SOA_INDEX_COLUMN_FULL(FoundZDC, foundZDC, int, Zdcs, "_foundZDC"); //! ZDC entry index in ZDCs table (-1 if doesn't exist)
DECLARE_SOA_COLUMN(BcInTF, bcInTF, int); //! Position of a (found) bunch crossing inside a given timeframe
DECLARE_SOA_COLUMN(NumTracksInTimeRange, trackOccupancyInTimeRange, int); //! Occupancy in specified time interval by a number of tracks from nearby collisions
DECLARE_SOA_COLUMN(SumAmpFT0CInTimeRange, ft0cOccupancyInTimeRange, float); //! Occupancy in specified time interval by a sum of FT0C amplitudes from nearby collisions
DECLARE_SOA_COLUMN(NumTracksInTimeRange, trackOccupancyInTimeRange, int); //! Occupancy in specified time interval by a number of tracks from nearby collisions // o2-linter: disable=name/o2-column
DECLARE_SOA_COLUMN(SumAmpFT0CInTimeRange, ft0cOccupancyInTimeRange, float); //! Occupancy in specified time interval by a sum of FT0C amplitudes from nearby collisions // o2-linter: disable=name/o2-column
} // namespace evsel

// bc-joinable event selection decisions
DECLARE_SOA_TABLE(BcSels, "AOD", "BCSEL", //!
evsel::Alias, evsel::Selection, evsel::FoundFT0Id, evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId);
evsel::Alias, evsel::Selection, evsel::Rct, evsel::FoundFT0Id, evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId);
using BcSel = BcSels::iterator;

// collision-joinable event selection decisions
DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL", //!
evsel::Alias,
evsel::Selection,
evsel::Rct,
evsel::Sel7,
evsel::Sel8,
evsel::FoundBCId,
Expand Down
42 changes: 35 additions & 7 deletions Common/TableProducer/eventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <vector>
#include <map>
#include <string>

#include "Framework/ConfigParamSpec.h"
#include "Framework/runDataProcessing.h"
Expand Down Expand Up @@ -80,13 +81,13 @@ struct BcSelectionTask {
bool isPP = 1; // default value
TriggerAliases* aliases = nullptr;
EventSelectionParams* par = nullptr;
std::map<uint64_t, uint32_t>* mapRCT = nullptr;
std::map<int64_t, std::vector<int16_t>> mapInactiveChips; // number of inactive chips vs orbit per layer
int64_t prevOrbitForInactiveChips = 0; // cached next stored orbit in the inactive chip map
int64_t nextOrbitForInactiveChips = 0; // cached previous stored orbit in the inactive chip map
bool isGoodITSLayer3 = true; // default value
bool isGoodITSLayer0123 = true; // default value
bool isGoodITSLayersAll = true; // default value

void init(InitContext&)
{
if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration)
Expand Down Expand Up @@ -242,8 +243,9 @@ struct BcSelectionTask {
histos.get<TH1>(HIST("hCounterTVX"))->Fill(Form("%d", bc.runNumber()), 1);
}

uint32_t rct = 0;
// Fill bc selection columns
bcsel(alias, selection, foundFT0, foundFV0, foundFDD, foundZDC);
bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC);
}
}
PROCESS_SWITCH(BcSelectionTask, processRun2, "Process Run2 event selection", true);
Expand Down Expand Up @@ -311,6 +313,18 @@ struct BcSelectionTask {
}
} // loop over vector of inactive chip ids
} // loop over orbits

// QC info
std::map<std::string, std::string> metadata;
metadata["run"] = Form("%d", run);
ccdb->setFatalWhenNull(0);
mapRCT = ccdb->getSpecific<std::map<uint64_t, uint32_t>>("Users/j/jian/RCT", ts, metadata);
ccdb->setFatalWhenNull(1);
if (mapRCT == nullptr) {
LOGP(info, "rct object missing... inserting dummy rct flags");
mapRCT = new std::map<uint64_t, uint32_t>;
mapRCT->insert(std::pair<uint64_t, uint32_t>(sorTimestamp, 0));
}
}

// map from GlobalBC to BcId needed to find triggerBc
Expand All @@ -326,6 +340,13 @@ struct BcSelectionTask {

// bc loop
for (auto bc : bcs) { // o2-linter: disable=const-ref-in-for-loop
// store rct flags
auto itrct = mapRCT->upper_bound(bc.timestamp());
if (itrct != mapRCT->begin())
itrct--;
uint32_t rct = itrct->second;
LOGP(debug, "sor={} eor={} ts={} rct={}", sorTimestamp, eorTimestamp, bc.timestamp(), rct);

uint32_t alias{0};
// workaround for pp2022 (trigger info is shifted by -294 bcs)
int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift];
Expand Down Expand Up @@ -424,7 +445,7 @@ struct BcSelectionTask {
LOGP(debug, "prev inactive chips: {} {} {} {} {} {} {}", vPrevInactiveChips[0], vPrevInactiveChips[1], vPrevInactiveChips[2], vPrevInactiveChips[3], vPrevInactiveChips[4], vPrevInactiveChips[5], vPrevInactiveChips[6]);
isGoodITSLayer3 = vPrevInactiveChips[3] <= maxInactiveChipsPerLayer->at(3) && vNextInactiveChips[3] <= maxInactiveChipsPerLayer->at(3);
isGoodITSLayer0123 = true;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 4; i++) {
isGoodITSLayer0123 &= vPrevInactiveChips[i] <= maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= maxInactiveChipsPerLayer->at(i);
}
isGoodITSLayersAll = true;
Expand Down Expand Up @@ -506,7 +527,7 @@ struct BcSelectionTask {
}

// Fill bc selection columns
bcsel(alias, selection, foundFT0, foundFV0, foundFDD, foundZDC);
bcsel(alias, selection, rct, foundFT0, foundFV0, foundFDD, foundZDC);
}
}
PROCESS_SWITCH(BcSelectionTask, processRun3, "Process Run3 event selection", false);
Expand Down Expand Up @@ -677,6 +698,9 @@ struct EventSelectionTask {
selection |= (spdClusters < par->fSPDClsVsTklA + nTkl * par->fSPDClsVsTklB) ? BIT(kNoSPDClsVsTklBG) : 0;
selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(kNoV0C012vsTklBG) : 0;

// copy rct flags from bcsel table
uint32_t rct = bc.rct_raw();

// apply int7-like selections
bool sel7 = 1;
for (int i = 0; i < kNsel; i++) {
Expand All @@ -702,7 +726,7 @@ struct EventSelectionTask {
}
}

evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0, 0);
evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0, 0);
}
PROCESS_SWITCH(EventSelectionTask, processRun2, "Process Run2 event selection", true);

Expand Down Expand Up @@ -757,7 +781,8 @@ struct EventSelectionTask {
int32_t foundFDD = bc.foundFDDId();
int32_t foundZDC = bc.foundZDCId();
int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF;
evsel(bc.alias_raw(), bc.selection_raw(), kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, -1, -1);
uint32_t rct = 0;
evsel(bc.alias_raw(), bc.selection_raw(), rct, kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, -1, -1);
}
return;
}
Expand Down Expand Up @@ -1171,6 +1196,9 @@ struct EventSelectionTask {
selection |= (vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) ? BIT(kNoCollInRofStandard) : 0;
selection |= vNoHighMultCollInPrevRof[colIndex] ? BIT(kNoHighMultCollInPrevRof) : 0;

// copy rct flags from bcsel table
uint32_t rct = bc.rct_raw();

// apply int7-like selections
bool sel7 = 0;

Expand All @@ -1190,7 +1218,7 @@ struct EventSelectionTask {

int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF;

evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF,
evsel(alias, selection, rct, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF,
vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]);
}
}
Expand Down

0 comments on commit 5eed443

Please sign in to comment.