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
97 changes: 78 additions & 19 deletions PWGUD/Core/SGSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,57 @@
// 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 SGSelector.h
/// \author Alexander Bylinkin
/// \author Adam Matyja
/// \since 2023-11-21
/// \brief Support class holding tools to work with Single Gap selection in central barrel UPCs
///

#ifndef PWGUD_CORE_SGSELECTOR_H_
#define PWGUD_CORE_SGSELECTOR_H_

#include <cmath>
#include "TDatabasePDG.h"
#include "TLorentzVector.h"
#include "Framework/Logger.h"
#include "Framework/AnalysisTask.h"
#include "PWGUD/Core/UDHelpers.h"
#include "PWGUD/Core/SGCutParHolder.h"
#include "PWGUD/Core/UDHelpers.h"

#include "Common/CCDB/RCTSelectionFlags.h"

#include "Framework/AnalysisTask.h"
#include "Framework/Logger.h"

#include <cmath>

template <typename BC>
struct SelectionResult {
int value; // The original integer return value
BC* bc; // Pointer to the BC object
};

namespace o2::aod::sgselector
{
enum TrueGap : int {
NoGap = -1,
SingleGapA = 0,
SingleGapC = 1,
DoubleGap = 2
};
}

class SGSelector
{
public:
SGSelector() : fPDG(TDatabasePDG::Instance()) {}
SGSelector() : myRCTChecker{"CBT"}, myRCTCheckerHadron{"CBT_hadronPID"}, myRCTCheckerZDC{"CBT", true}, myRCTCheckerHadronZDC{"CBT_hadronPID", true} {}

template <typename CC, typename BCs, typename TCs, typename FWs>
int Print(SGCutParHolder /*diffCuts*/, CC& collision, BCs& /*bcRange*/, TCs& /*tracks*/, FWs& /*fwdtracks*/)

Check failure on line 54 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
{
LOGF(info, "Size of array %i", collision.size());
return 1;
}

template <typename CC, typename BCs, typename BC>
SelectionResult<BC> IsSelected(SGCutParHolder diffCuts, CC& collision, BCs& bcRange, BC& oldbc)

Check failure on line 61 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
{
// LOGF(info, "Collision %f", collision.collisionTime());
// LOGF(info, "Number of close BCs: %i", bcRange.size());
Expand Down Expand Up @@ -105,9 +124,10 @@
return result;
}
template <typename TFwdTrack>
int FwdTrkSelector(TFwdTrack const& fwdtrack)

Check failure on line 127 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
{
if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3)
// if (fwdtrack.trackType() == 0 || fwdtrack.trackType() == 3)
if (fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack || fwdtrack.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)
return 1;
else
return 0;
Expand All @@ -116,38 +136,77 @@
template <typename CC>
int trueGap(CC& collision, float fv0, float ft0a, float ft0c, float zdc_cut)
{
float fit_cut[3] = {fv0, ft0a, ft0c};

Check failure on line 139 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
int gap = collision.gapSide();
int true_gap = gap;

Check failure on line 141 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
float FV0A, FT0A, FT0C, ZNA, ZNC;

Check failure on line 142 in PWGUD/Core/SGSelector.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
FV0A = collision.totalFV0AmplitudeA();
FT0A = collision.totalFT0AmplitudeA();
FT0C = collision.totalFT0AmplitudeC();
ZNA = collision.energyCommonZNA();
ZNC = collision.energyCommonZNC();
if (gap == 0) {
if (gap == o2::aod::sgselector::SingleGapA) { // gap == 0
if (FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut)
true_gap = -1;
} else if (gap == 1) {
true_gap = o2::aod::sgselector::NoGap; // -1
} else if (gap == o2::aod::sgselector::SingleGapC) { // gap == 1
if (FT0C > fit_cut[2] || ZNC > zdc_cut)
true_gap = -1;
} else if (gap == 2) {
true_gap = o2::aod::sgselector::NoGap; // -1
} else if (gap == o2::aod::sgselector::DoubleGap) { // gap == 2
if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut))
true_gap = -1;
true_gap = o2::aod::sgselector::NoGap; // -1
else if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C <= fit_cut[2] && ZNC <= zdc_cut))
true_gap = 1;
true_gap = o2::aod::sgselector::SingleGapC; // 1
else if ((FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut))
true_gap = 0;
true_gap = o2::aod::sgselector::SingleGapA; // 0
else if (FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut && FT0C <= fit_cut[2] && ZNC <= zdc_cut)
true_gap = 2;
true_gap = o2::aod::sgselector::DoubleGap; // 2
else
std::cout << "Something wrong with DG" << std::endl;
LOGF(info, "Something wrong with DG");
}
return true_gap;
}

// check CBT flags
template <typename CC>
bool isCBTOk(CC& collision)
{
if (myRCTChecker(collision))
return true;
return false;
}

// check CBT+hadronPID flags
template <typename CC>
bool isCBTHadronOk(CC& collision)
{
if (myRCTCheckerHadron(collision))
return true;
return false;
}

// check CBT+ZDC flags
template <typename CC>
bool isCBTZdcOk(CC& collision)
{
if (myRCTCheckerZDC(collision))
return true;
return false;
}

// check CBT+hadronPID+ZDC flags
template <typename CC>
bool isCBTHadronZdcOk(CC& collision)
{
if (myRCTCheckerHadronZDC(collision))
return true;
return false;
}

private:
TDatabasePDG* fPDG;
o2::aod::rctsel::RCTFlagsChecker myRCTChecker;
o2::aod::rctsel::RCTFlagsChecker myRCTCheckerHadron;
o2::aod::rctsel::RCTFlagsChecker myRCTCheckerZDC;
o2::aod::rctsel::RCTFlagsChecker myRCTCheckerHadronZDC;
};

#endif // PWGUD_CORE_SGSELECTOR_H_
43 changes: 38 additions & 5 deletions PWGUD/DataModel/UDTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@
// 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 UDTables.h
/// \brief Defines tables and colums for derived data used by UD group
/// \author Paul Buhler <paul.buhler@cern.ch>, Wiena
/// \since January 2023
/// \author Sasha Bylinkin <sasha.bylinkin@cern.ch>, Bergen
/// \since January 2024
/// \author Adam Matyja <adam.tomasz.matyja@cern.ch>, INP PAN Krakow, Poland
/// \since May 2025

#ifndef PWGUD_DATAMODEL_UDTABLES_H_
#define PWGUD_DATAMODEL_UDTABLES_H_

#include <vector>
#include <cmath>
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/DataTypes.h"
#include "MathUtils/Utils.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include <cmath>
#include <vector>

namespace o2::aod
{
Expand All @@ -44,7 +55,7 @@

namespace udmcparticle
{
DECLARE_SOA_INDEX_COLUMN(UDMcCollision, udMcCollision); //!

Check failure on line 58 in PWGUD/DataModel/UDTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(Mothers, mothers); //! Mother tracks (possible empty) array. Iterate over mcParticle.mothers_as<aod::McParticles>())
DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(Daughters, daughters); //! Daughter tracks (possibly empty) slice. Check for non-zero with mcParticle.has_daughters(). Iterate over mcParticle.daughters_as<aod::McParticles>())
DECLARE_SOA_COLUMN(Px, px, float); //!
Expand Down Expand Up @@ -106,11 +117,15 @@
DECLARE_SOA_COLUMN(Trs, trs, int);
DECLARE_SOA_COLUMN(Trofs, trofs, int);
DECLARE_SOA_COLUMN(Hmpr, hmpr, int);
DECLARE_SOA_COLUMN(TFb, tfb, int);

Check failure on line 120 in PWGUD/DataModel/UDTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(ITSROFb, itsROFb, int);

Check failure on line 121 in PWGUD/DataModel/UDTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(Sbp, sbp, int);
DECLARE_SOA_COLUMN(ZvtxFT0vPV, zVtxFT0vPV, int);

Check failure on line 123 in PWGUD/DataModel/UDTables.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-column]

Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters.
DECLARE_SOA_COLUMN(VtxITSTPC, vtxITSTPC, int);
// information about mask names -> Common/CCDB/RCTSelectionFlags.h
// DECLARE_SOA_COLUMN(Rct, rct, uint32_t); //! run condition table mask
DECLARE_SOA_BITMAP_COLUMN(Rct, rct, 32); //! run condition table mask

// Gap Side Information
DECLARE_SOA_COLUMN(GapSide, gapSide, uint8_t); // 0 for side A, 1 for side C, 2 for both sides (or use an enum for better readability)
// FIT selection flags
Expand Down Expand Up @@ -249,6 +264,24 @@
udcollision::ZvtxFT0vPV, //! kIsGoodZvtxFT0vsPV
udcollision::VtxITSTPC); //! kIsVertexITSTPC

DECLARE_SOA_TABLE_VERSIONED(UDCollisionSelExtras_003, "AOD", "UDCOLSELEXTRA", 3,
udcollision::ChFT0A, //! number of active channels in FT0A
udcollision::ChFT0C, //! number of active channels in FT0C
udcollision::ChFDDA, //! number of active channels in FDDA
udcollision::ChFDDC, //! number of active channels in FDDC
udcollision::ChFV0A, //! number of active channels in FV0A
udcollision::OccupancyInTime, //! Occupancy
udcollision::HadronicRate, //! Interaction Rate
udcollision::Trs, //! kNoCollInTimeRangeStandard
udcollision::Trofs, //! kNoCollInRofStandard
udcollision::Hmpr, //! kNoHighMultCollInPrevRof
udcollision::TFb, //! kNoTimeFrameBorder
udcollision::ITSROFb, //! kNoITSROFrameBorder
udcollision::Sbp, //! kNoSameBunchPileup
udcollision::ZvtxFT0vPV, //! kIsGoodZvtxFT0vsPV
udcollision::VtxITSTPC, //! kIsVertexITSTPC
udcollision::Rct); //! RCT mask

// central barrel-specific selections
DECLARE_SOA_TABLE(UDCollisionsSelsCent, "AOD", "UDCOLSELCNT",
udcollision::DBcTOR,
Expand All @@ -272,7 +305,7 @@
udcollision::UDMcCollisionId);

using UDCollisions = UDCollisions_001;
using UDCollisionSelExtras = UDCollisionSelExtras_002;
using UDCollisionSelExtras = UDCollisionSelExtras_003;

using UDCollision = UDCollisions::iterator;
using SGCollision = SGCollisions::iterator;
Expand Down
5 changes: 5 additions & 0 deletions PWGUD/TableProducer/Converters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ o2physics_add_dpl_workflow(collisionselextras-converter-v002
SOURCES UDCollisionSelExtrasV002Converter.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(collisionselextras-converter-v003
SOURCES UDCollisionSelExtrasV003Converter.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
126 changes: 126 additions & 0 deletions PWGUD/TableProducer/Converters/UDCollisionSelExtrasV003Converter.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// 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.

/// \file UDCollisionSelExtrasV003Converter.cxx
/// \brief Converts UDCollisionSelExtras table from version 000 to 003 and 001 to 003 and 002 to 003
/// \author Adam Matyja <adam.tomasz.matyja@cern.ch>

#include "PWGUD/DataModel/UDTables.h"

#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/runDataProcessing.h"

using namespace o2;
using namespace o2::framework;

// Converts UDCollisions for version 000 to 003 and 001 to 003 and 002 to 003
struct UDCollisionSelExtrasV003Converter {
Produces<o2::aod::UDCollisionSelExtras_003> udCollisionSelExtras_003;

void init(InitContext const&)
{
if (!doprocessV000ToV003 && !doprocessV001ToV003 && !doprocessV002ToV003) {
LOGF(fatal, "Neither processV000ToV003 nor processV001ToV003 nor processV002ToV003 is enabled. Please choose one!");
}
if (static_cast<int>(doprocessV000ToV003) + static_cast<int>(doprocessV001ToV003) + static_cast<int>(doprocessV002ToV003) > 1) {
LOGF(fatal, "More than one among processV000ToV003, processV001ToV003, processV002ToV003 is enabled. Please choose only one!");
}
}

void processV000ToV003(o2::aod::UDCollisionSelExtras_000 const& collisions)
{

for (const auto& collision : collisions) {

udCollisionSelExtras_003(collision.chFT0A(),
collision.chFT0C(),
collision.chFDDA(),
collision.chFDDC(),
collision.chFV0A(),
0, // dummy occupancy
0.0f, // dummy rate
0, // dummy trs
0, // dummy trofs
0, // dummy hmpr
0, // dummy tfb
0, // dummy itsROFb
0, // dummy sbp
0, // dummy zVtxFT0vPV
0, // dummy vtxITSTPC
0); // dummy rct
}
}
PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV000ToV003, "process v000-to-v003 conversion", false);

void processV001ToV003(o2::aod::UDCollisionSelExtras_001 const& collisions)
{

for (const auto& collision : collisions) {

udCollisionSelExtras_003(collision.chFT0A(),
collision.chFT0C(),
collision.chFDDA(),
collision.chFDDC(),
collision.chFV0A(),
collision.occupancyInTime(),
collision.hadronicRate(),
collision.trs(),
collision.trofs(),
collision.hmpr(),
0, // dummy tfb
0, // dummy itsROFb
0, // dummy sbp
0, // dummy zVtxFT0vPV
0, // dummy vtxITSTPC
0); // dummy rct
}
}
PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV001ToV003, "process v001-to-v003 conversion", false);

void processV002ToV003(o2::aod::UDCollisionSelExtras_002 const& collisions)
{

for (const auto& collision : collisions) {

udCollisionSelExtras_003(collision.chFT0A(),
collision.chFT0C(),
collision.chFDDA(),
collision.chFDDC(),
collision.chFV0A(),
collision.occupancyInTime(),
collision.hadronicRate(),
collision.trs(),
collision.trofs(),
collision.hmpr(),
collision.tfb(),
collision.itsROFb(),
collision.sbp(),
collision.zVtxFT0vPV(),
collision.vtxITSTPC(),
0); // dummy rct
}
}
PROCESS_SWITCH(UDCollisionSelExtrasV003Converter, processV002ToV003, "process v002-to-v003 conversion", true);
};

/// Spawn the extended table for UDCollisionSelExtras003 to avoid the call to the internal spawner and a consequent circular dependency
// struct UDCollisionSelExtrasSpawner {
// Spawns<aod::UDCollisionSelExtras_003> udCollisionSelExtras_003;
// };

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<UDCollisionSelExtrasV003Converter>(cfgc),
// adaptAnalysisTask<UDCollisionSelExtrasSpawner>(cfgc),
};
}
Loading
Loading