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
49 changes: 46 additions & 3 deletions Common/Tools/TrackPropagationModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <Framework/AnalysisHelpers.h>
#include <Framework/Configurable.h>
#include <Framework/DataTypes.h>
#include <Framework/DeviceSpec.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/Logger.h>
Expand Down Expand Up @@ -70,7 +71,7 @@

struct TrackPropagationConfigurables : o2::framework::ConfigurableGroup {
std::string prefix = "trackPropagation";
o2::framework::Configurable<float> minPropagationRadius{"minPropagationDistance", o2::constants::geom::XTPCInnerRef + 0.1, "Only tracks which are at a smaller radius will be propagated, defaults to TPC inner wall"};

Check failure on line 74 in Common/Tools/TrackPropagationModule.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/configurable]

Use lowerCamelCase for names of configurables and use the same name for the struct member as for the JSON string. (Declare the type and names on the same line.)
// for TrackTuner only (MC smearing)
o2::framework::Configurable<bool> useTrackTuner{"useTrackTuner", false, "Apply track tuner corrections to MC"};
o2::framework::Configurable<bool> useTrkPid{"useTrkPid", false, "use pid in tracking"};
Expand Down Expand Up @@ -104,6 +105,7 @@
o2::dataformats::VertexBase mVtx;
o2::track::TrackParametrization<float> mTrackPar;
o2::track::TrackParametrizationWithError<float> mTrackParCov;
bool autoDetectDcaCalib = false; // track tuner setting

template <typename TConfigurableGroup, typename TInitContext, typename THistoRegistry>
void init(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, THistoRegistry& registry, TInitContext& initContext)
Expand Down Expand Up @@ -155,8 +157,8 @@
}

/// TrackTuner initialization
std::string outputStringParams = "";
if (cGroup.useTrackTuner.value) {
std::string outputStringParams = "";
switch (cGroup.trackTunerConfigSource.value) {
case o2::aod::track_tuner::InputString:
outputStringParams = trackTunerObj.configParams(cGroup.trackTunerParams.value);
Expand All @@ -170,10 +172,34 @@
break;
}

trackTunerObj.getDcaGraphs();
/// read the track tuner instance configurations,
/// to understand whether the TrackTuner::getDcaGraphs function can be called here (input path from string/configurables)
/// or inside the process function, to "auto-detect" the input file based on the run number
const auto& workflows = initContext.services().template get<o2::framework::RunningWorkflowInfo const>();
for (const o2::framework::DeviceSpec& device : workflows.devices) { /// loop over devices

Check failure on line 179 in Common/Tools/TrackPropagationModule.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.
if (device.name == "propagation-service") {
// loop over the options
// to find the value of TrackTuner::autoDetectDcaCalib
for (const auto& option : device.options) { /// loop over options
if (option.name == "trackTuner.autoDetectDcaCalib") {
// found it!
autoDetectDcaCalib = option.defaultValue.get<bool>();
break;
}
} /// end loop over options
break;
}
} /// end loop over devices
LOG(info) << "[TrackPropagationModule] trackTuner.autoDetectDcaCalib it's equal to " << autoDetectDcaCalib;
if (!autoDetectDcaCalib) {
LOG(info) << "[TrackPropagationModule] retrieve the graphs already (we are in propagationService::Init() function)";
trackTunerObj.getDcaGraphs();
} else {
LOG(info) << "[TrackPropagationModule] trackTunerObj.getDcaGraphs() function to be called later, in the process function!";
}
}

trackTunedTracks = registry.template add<TH1>("trackTunedTracks", "trackTunedTracks", o2::framework::kTH1D, {{1, 0.5f, 1.5f}});
trackTunedTracks = registry.template add<TH1>("trackTunedTracks", outputStringParams.c_str(), o2::framework::kTH1D, {{1, 0.5f, 1.5f}});

// Histograms for track tuner
o2::framework::AxisSpec axisBinsDCA = {600, -0.15f, 0.15f, "#it{dca}_{xy} (cm)"};
Expand All @@ -186,6 +212,23 @@
template <bool isMc, typename TConfigurableGroup, typename TCCDBLoader, typename TCollisions, typename TTracks, typename TOutputGroup, typename THistoRegistry>
void fillTrackTables(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, TCCDBLoader const& ccdbLoader, TCollisions const& collisions, TTracks const& tracks, TOutputGroup& cursors, THistoRegistry& registry)
{

/// retrieve the TrackTuner calibration graphs *if not done yet*
/// i.e. if autodetect is required
if (cGroup.useTrackTuner.value && autoDetectDcaCalib && !trackTunerObj.areGraphsConfigured) {

/// get the run number from the ccdb loader, already initialized
const int runNumber = ccdbLoader.runNumber;
trackTunerObj.setRunNumber(runNumber);

/// setup the "auto-detected" path based on the run number
trackTunerObj.getPathInputFileAutomaticFromCCDB();
trackTunedTracks->SetTitle(trackTunerObj.outputString.c_str());

/// now that the path is ok, retrieve the graphs
trackTunerObj.getDcaGraphs();
}

if (!fillTracks) {
return; // suppress everything
}
Expand Down
Loading
Loading