Skip to content
Open
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
15 changes: 12 additions & 3 deletions Common/Core/fwdtrackUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef COMMON_CORE_FWDTRACKUTILITIES_H_
#define COMMON_CORE_FWDTRACKUTILITIES_H_

#include <Framework/AnalysisDataModel.h>
#include <Framework/DataTypes.h>
#include <GlobalTracking/MatchGlobalFwd.h>
#include <MCHTracking/TrackExtrap.h>
Expand Down Expand Up @@ -48,22 +47,32 @@
using SMatrix55Std = ROOT::Math::SMatrix<double, 5>;
using SMatrix5 = ROOT::Math::SVector<double, 5>;

template <typename T>
concept is_fwd_track = requires(T t) {
{ t.rAtAbsorberEnd() } -> std::same_as<float>;
};

template <typename T>
concept is_fwd_cov = requires(T t) {
{ t.sigmaX() } -> std::same_as<float>;
};

/// Produce TrackParCovFwds for MFT and FwdTracks, w/ or w/o cov, with z shift
template <typename TFwdTrack, typename... TCovariance>
o2::track::TrackParCovFwd getTrackParCovFwdShift(TFwdTrack const& track, float zshift, TCovariance const&... covOpt)
{
double chi2 = track.chi2();
if constexpr (sizeof...(covOpt) == 0) {
// No covariance passed
if constexpr (std::is_same_v<std::decay_t<TFwdTrack>, aod::FwdTracks::iterator>) {
if constexpr (is_fwd_track<TFwdTrack>) {
if (track.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) {
chi2 = track.chi2() * (2.f * track.nClusters() - 5.f);
}
}
} else {
// Covariance passed
using TCov = std::decay_t<decltype((covOpt, ...))>;
if constexpr (std::is_same_v<TCov, aod::FwdTracksCov::iterator>) {
if constexpr (is_fwd_cov<TCov>) {
if (track.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) {
chi2 = track.chi2() * (2.f * track.nClusters() - 5.f);
}
Expand Down Expand Up @@ -144,7 +153,7 @@
o2::dataformats::GlobalFwdTrack propmuon;
o2::globaltracking::MatchGlobalFwd mMatching;

if (trackType > 2) { // MCH-MID or MCH standalone

Check failure on line 156 in Common/Core/fwdtrackUtilities.h

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.
o2::dataformats::GlobalFwdTrack track;
track.setParameters(fwdtrack.getParameters());
track.setZ(fwdtrack.getZ());
Expand All @@ -165,7 +174,7 @@
propmuon.setParameters(proptrack.getParameters());
propmuon.setZ(proptrack.getZ());
propmuon.setCovariances(proptrack.getCovariances());
} else if (trackType < 2) { // MFT-MCH-MID

Check failure on line 177 in Common/Core/fwdtrackUtilities.h

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.
// const double centerMFT[3] = {0, 0, -61.4};
// o2::field::MagneticField* field = static_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
// auto Bz = field->getBz(centerMFT); // Get field at centre of MFT in kG.
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ o2physics_add_library(PWGDQCore
o2physics_target_root_dictionary(PWGDQCore
HEADERS AnalysisCut.h
AnalysisCompositeCut.h
VarManager.h
VarManagerCore.h
HistogramManager.h
CutsLibrary.h
MixingHandler.h
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/CutsLibrary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "AnalysisCompositeCut.h"
#include "AnalysisCut.h"
#include "VarManager.h"
#include "VarManagerCore.h"

#include <Framework/Array2D.h>
#include <Framework/Logger.h>
Expand Down Expand Up @@ -5909,7 +5909,7 @@
if (icase == 0) {
cut->AddCut(VarManager::kTPCnSigmaEl, -4., 4., false, VarManager::kPin, 0.0, 1e+10, false);
cut->AddCut(VarManager::kTPCnSigmaPi, -99., 2.5, true, VarManager::kPin, 0.0, 1e+10, false);
} else if (icase == 1 || icase == 2) {

Check failure on line 5912 in PWGDQ/Core/CutsLibrary.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.
cut->AddCut(VarManager::kTPCnSigmaEl_Corr, -4., 4., false, VarManager::kPin, 0.0, 1e+10, false);
cut->AddCut(VarManager::kTPCnSigmaPi_Corr, -99., 2.5, true, VarManager::kPin, 0.0, 1e+10, false);
}
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/DQMlResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef PWGDQ_CORE_DQMLRESPONSE_H_
#define PWGDQ_CORE_DQMLRESPONSE_H_

#include "PWGDQ/Core/VarManager.h"
#include "PWGDQ/Core/VarManagerCore.h"

#include "Tools/ML/MlResponse.h"

Expand Down Expand Up @@ -122,7 +122,7 @@
std::vector<float> dqInputFeatures;
dqInputFeatures.reserve(MlResponse<TypeOutputScore>::mCachedIndices.size());

for (auto idx : MlResponse<TypeOutputScore>::mCachedIndices) {

Check failure on line 125 in PWGDQ/Core/DQMlResponse.h

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
auto enumIdx = static_cast<InputFeatures>(idx);
auto mapIdx = gFeatureNameMap.find(enumIdx);
if (mapIdx == gFeatureNameMap.end()) {
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/HistogramsLibrary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "PWGDQ/Core/HistogramsLibrary.h"

#include "HistogramManager.h"
#include "VarManager.h"
#include "VarManagerCore.h"

#include <CommonConstants/MathConstants.h>
#include <Framework/Logger.h>
Expand Down Expand Up @@ -2451,7 +2451,7 @@
LOG(fatal) << "histClass field should be an array of strings, e.g. [class1, class2]";
return false;
}
for (auto& v : hist->FindMember("histClass")->value.GetArray()) {

Check failure on line 2454 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (!v.IsString()) {
LOG(fatal) << "histClass field should be an array of strings, e.g. [class1, class2]";
return false;
Expand Down Expand Up @@ -2607,7 +2607,7 @@
}
}
if (isTHn) {
for (auto& v : hist->FindMember("vars")->value.GetArray()) {

Check failure on line 2610 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
if (VarManager::fgVarNamesMap.find(v.GetString()) == VarManager::fgVarNamesMap.end()) {
LOG(fatal) << "Bad variable in vars (" << v.GetString() << ") specified for histogram";
return false;
Expand Down Expand Up @@ -2670,7 +2670,7 @@

// create an array of strings to store the different histogram classes
std::vector<const char*> histClasses;
for (auto& v : hist.FindMember("histClass")->value.GetArray()) {

Check failure on line 2673 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
histClasses.push_back(v.GetString());
}
const char* title = hist.FindMember("title")->value.GetString();
Expand All @@ -2681,7 +2681,7 @@

int* vars = new int[nDimensions];
int iDim = 0;
for (auto& v : hist.FindMember("vars")->value.GetArray()) {

Check failure on line 2684 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
LOG(debug) << "iDim " << iDim << ": " << v.GetString();
vars[iDim++] = VarManager::fgVarNamesMap[v.GetString()];
}
Expand All @@ -2695,12 +2695,12 @@
xmin = new double[nDimensions];
xmax = new double[nDimensions];
int iDim = 0;
for (auto& v : hist.FindMember("nBins")->value.GetArray()) {

Check failure on line 2698 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
nBins[iDim++] = v.GetInt();
LOG(debug) << "nBins " << iDim << ": " << nBins[iDim - 1];
}
iDim = 0;
for (auto& v : hist.FindMember("xmin")->value.GetArray()) {

Check failure on line 2703 in PWGDQ/Core/HistogramsLibrary.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
xmin[iDim++] = v.GetDouble();
LOG(debug) << "xmin " << iDim << ": " << xmin[iDim - 1];
}
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/MixingHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "PWGDQ/Core/MixingHandler.h"

#include "PWGDQ/Core/VarManager.h"
#include "PWGDQ/Core/VarManagerCore.h"

#include <TArrayF.h>
#include <TMathBase.h>
Expand Down
3 changes: 1 addition & 2 deletions PWGDQ/Core/MixingHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
#ifndef PWGDQ_CORE_MIXINGHANDLER_H_
#define PWGDQ_CORE_MIXINGHANDLER_H_

#include "PWGDQ/Core/VarManager.h"
#include "PWGDQ/Core/VarManagerCore.h"

#include <TArrayF.h>
#include <TNamed.h>

#include <Rtypes.h>

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion PWGDQ/Core/MixingLibrary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "PWGDQ/Core/MixingLibrary.h"

#include "PWGDQ/Core/MixingHandler.h"
#include "PWGDQ/Core/VarManager.h"
#include "PWGDQ/Core/VarManagerCore.h"

#include <Framework/Logger.h>

Expand Down
227 changes: 227 additions & 0 deletions PWGDQ/Core/VarManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,233 @@ std::tuple<float, float, float, float, float, int> VarManager::BimodalityCoeffic
return std::make_tuple((skewness * skewness + 1.0) / kurtosis, mean, stddev, skewness, kurtosis, nPeaks);
}

void VarManager::SetUseVariable(int var)
{
if (var >= 0 && var < kNVars) {
fgUsedVars[var] = kTRUE;
}
SetVariableDependencies();
}

void VarManager::SetUseVars(const bool* usedVars)
{
for (int i = 0; i < kNVars; ++i) {
if (usedVars[i]) {
fgUsedVars[i] = true; // overwrite only the variables that are being used since there are more channels to modify the used variables array, independently
}
}
SetVariableDependencies();
}

void VarManager::SetUseVars(const std::vector<int> usedVars)
{
for (auto& var : usedVars) {
fgUsedVars[var] = true;
}
}
bool VarManager::GetUsedVar(int var)
{
if (var >= 0 && var < kNVars) {
return fgUsedVars[var];
}
return false;
}

// Flag to set PV recalculation via KF
void VarManager::SetPVrecalculationKF(const bool pvRecalKF)
{
fgPVrecalKF = pvRecalKF;
}

void VarManager::SetMagneticField(float magField)
{
fgMagField = magField;
}

// Setup plane position for MFT-MCH matching
void VarManager::SetMatchingPlane(float z)
{
fgzMatching = z;
}

float VarManager::GetMatchingPlane()
{
return fgzMatching;
}

// Set z shift for forward tracks
void VarManager::SetZShift(float z)
{
fgzShiftFwd = z;
}

// Setup the 2 prong KFParticle
void VarManager::SetupTwoProngKFParticle(float magField)
{
KFParticle::SetField(magField);
fgUsedKF = true;
}
// Setup magnetic field for muon propagation
void VarManager::SetupMuonMagField()
{
o2::mch::TrackExtrap::setField();
}

// Setup the 2 prong DCAFitterN
void VarManager::SetupTwoProngDCAFitter(float magField, bool propagateToPCA, float maxR, float maxDZIni, float minParamChange, float minRelChi2Change, bool useAbsDCA)
{
fgFitterTwoProngBarrel.setBz(magField);
fgFitterTwoProngBarrel.setPropagateToPCA(propagateToPCA);
fgFitterTwoProngBarrel.setMaxR(maxR);
fgFitterTwoProngBarrel.setMaxDZIni(maxDZIni);
fgFitterTwoProngBarrel.setMinParamChange(minParamChange);
fgFitterTwoProngBarrel.setMinRelChi2Change(minRelChi2Change);
fgFitterTwoProngBarrel.setUseAbsDCA(useAbsDCA);
fgUsedKF = false;
}

// Setup the 2 prong FwdDCAFitterN
void VarManager::SetupTwoProngFwdDCAFitter(float magField, bool propagateToPCA, float maxR, float minParamChange, float minRelChi2Change, bool useAbsDCA)
{
fgFitterTwoProngFwd.setBz(magField);
fgFitterTwoProngFwd.setPropagateToPCA(propagateToPCA);
fgFitterTwoProngFwd.setMaxR(maxR);
fgFitterTwoProngFwd.setMinParamChange(minParamChange);
fgFitterTwoProngFwd.setMinRelChi2Change(minRelChi2Change);
fgFitterTwoProngFwd.setUseAbsDCA(useAbsDCA);
fgUsedKF = false;
}
// Use MatLayerCylSet to correct MCS in fwdtrack propagation
void VarManager::SetupMatLUTFwdDCAFitter(o2::base::MatLayerCylSet* m)
{
fgFitterTwoProngFwd.setTGeoMat(false);
fgFitterTwoProngFwd.setMatLUT(m);
}
// Use GeometryManager to correct MCS in fwdtrack propagation
void VarManager::SetupTGeoFwdDCAFitter()
{
fgFitterTwoProngFwd.setTGeoMat(true);
}
// No material budget in fwdtrack propagation
void VarManager::SetupFwdDCAFitterNoCorr()
{
fgFitterTwoProngFwd.setTGeoMat(false);
}
// Setup the 3 prong KFParticle
void VarManager::SetupThreeProngKFParticle(float magField)
{
KFParticle::SetField(magField);
fgUsedKF = true;
}

// Setup the 3 prong DCAFitterN
void VarManager::SetupThreeProngDCAFitter(float magField, bool propagateToPCA, float maxR, float /*maxDZIni*/, float minParamChange, float minRelChi2Change, bool useAbsDCA)
{
fgFitterThreeProngBarrel.setBz(magField);
fgFitterThreeProngBarrel.setPropagateToPCA(propagateToPCA);
fgFitterThreeProngBarrel.setMaxR(maxR);
fgFitterThreeProngBarrel.setMinParamChange(minParamChange);
fgFitterThreeProngBarrel.setMinRelChi2Change(minRelChi2Change);
fgFitterThreeProngBarrel.setUseAbsDCA(useAbsDCA);
fgUsedKF = false;
}

// Setup the 4 prong KFParticle
void VarManager::SetupFourProngKFParticle(float magField)
{
KFParticle::SetField(magField);
fgUsedKF = true;
}

// Setup the 4 prong DCAFitterN
void VarManager::SetupFourProngDCAFitter(float magField, bool propagateToPCA, float maxR, float /*maxDZIni*/, float minParamChange, float minRelChi2Change, bool useAbsDCA)
{
fgFitterFourProngBarrel.setBz(magField);
fgFitterFourProngBarrel.setPropagateToPCA(propagateToPCA);
fgFitterFourProngBarrel.setMaxR(maxR);
fgFitterFourProngBarrel.setMinParamChange(minParamChange);
fgFitterFourProngBarrel.setMinRelChi2Change(minRelChi2Change);
fgFitterFourProngBarrel.setUseAbsDCA(useAbsDCA);
fgUsedKF = false;
}

double VarManager::getEventPlane(int harm, float qnxa, float qnya)
{
// Compute event plane angle from qn vector components for the sub-event A
return (1.0 / harm) * TMath::ATan2(qnya, qnxa);
};

float VarManager::getDeltaPsiInRange(float psi1, float psi2, float harmonic)
{
float deltaPsi = psi1 - psi2;
if (std::abs(deltaPsi) > o2::constants::math::PI / harmonic) {
if (deltaPsi > 0.) {
deltaPsi -= o2::constants::math::TwoPI / harmonic;
} else {
deltaPsi += o2::constants::math::TwoPI / harmonic;
}
}
return deltaPsi;
}

void VarManager::SetCalibrationObject(CalibObjects calib, TObject* obj)
{
fgCalibs[calib] = obj;
// Check whether all the needed objects for TPC postcalibration are available
if (fgCalibs.find(kTPCElectronMean) != fgCalibs.end() && fgCalibs.find(kTPCElectronSigma) != fgCalibs.end()) {
fgRunTPCPostCalibration[0] = true;
fgUsedVars[kTPCnSigmaEl_Corr] = true;
}
if (fgCalibs.find(kTPCPionMean) != fgCalibs.end() && fgCalibs.find(kTPCPionSigma) != fgCalibs.end()) {
fgRunTPCPostCalibration[1] = true;
fgUsedVars[kTPCnSigmaPi_Corr] = true;
}
if (fgCalibs.find(kTPCKaonMean) != fgCalibs.end() && fgCalibs.find(kTPCKaonSigma) != fgCalibs.end()) {
fgRunTPCPostCalibration[2] = true;
fgUsedVars[kTPCnSigmaKa_Corr] = true;
}
if (fgCalibs.find(kTPCProtonMean) != fgCalibs.end() && fgCalibs.find(kTPCProtonSigma) != fgCalibs.end()) {
fgRunTPCPostCalibration[3] = true;
fgUsedVars[kTPCnSigmaPr_Corr] = true;
}
}

void VarManager::SetCalibrationType(int type, bool useInterpolation)
{
if (type < 0 || type > 2) {
LOG(fatal) << "Invalid calibration type. Must be 0, 1, or 2.";
}
fgCalibrationType = type;
fgUseInterpolatedCalibration = useInterpolation;
}

TObject* VarManager::GetCalibrationObject(CalibObjects calib)
{
auto obj = fgCalibs.find(calib);
if (obj == fgCalibs.end()) {
return 0x0;
} else {
return obj->second;
}
}
void VarManager::SetTPCInterSectorBoundary(float boundarySize)
{
fgTPCInterSectorBoundary = boundarySize;
}
void VarManager::SetITSROFBorderselection(int bias, int length, int marginLow, int marginHigh)
{
fgITSROFbias = bias;
fgITSROFlength = length;
fgITSROFBorderMarginLow = marginLow;
fgITSROFBorderMarginHigh = marginHigh;
}

void VarManager::SetSORandEOR(uint64_t sor, uint64_t eor)
{
fgSOR = sor;
fgEOR = eor;
}

//__________________________________________________________________
void VarManager::SetDefaultVarNames()
{
Expand Down
Loading
Loading