Skip to content

Commit 0462f59

Browse files
mfagginmattia
andauthored
[Common] TrackTuner: dca calib. "autodetection" based on run number. (#13493)
Co-authored-by: mattia <mfaggin@cern.ch>
1 parent 534786d commit 0462f59

File tree

2 files changed

+182
-19
lines changed

2 files changed

+182
-19
lines changed

Common/Tools/TrackPropagationModule.h

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <Framework/AnalysisHelpers.h>
2828
#include <Framework/Configurable.h>
2929
#include <Framework/DataTypes.h>
30+
#include <Framework/DeviceSpec.h>
3031
#include <Framework/HistogramRegistry.h>
3132
#include <Framework/HistogramSpec.h>
3233
#include <Framework/Logger.h>
@@ -104,6 +105,7 @@ class TrackPropagationModule
104105
o2::dataformats::VertexBase mVtx;
105106
o2::track::TrackParametrization<float> mTrackPar;
106107
o2::track::TrackParametrizationWithError<float> mTrackParCov;
108+
bool autoDetectDcaCalib = false; // track tuner setting
107109

108110
template <typename TConfigurableGroup, typename TInitContext, typename THistoRegistry>
109111
void init(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, THistoRegistry& registry, TInitContext& initContext)
@@ -155,8 +157,8 @@ class TrackPropagationModule
155157
}
156158

157159
/// TrackTuner initialization
160+
std::string outputStringParams = "";
158161
if (cGroup.useTrackTuner.value) {
159-
std::string outputStringParams = "";
160162
switch (cGroup.trackTunerConfigSource.value) {
161163
case o2::aod::track_tuner::InputString:
162164
outputStringParams = trackTunerObj.configParams(cGroup.trackTunerParams.value);
@@ -170,10 +172,34 @@ class TrackPropagationModule
170172
break;
171173
}
172174

173-
trackTunerObj.getDcaGraphs();
175+
/// read the track tuner instance configurations,
176+
/// to understand whether the TrackTuner::getDcaGraphs function can be called here (input path from string/configurables)
177+
/// or inside the process function, to "auto-detect" the input file based on the run number
178+
const auto& workflows = initContext.services().template get<o2::framework::RunningWorkflowInfo const>();
179+
for (const o2::framework::DeviceSpec& device : workflows.devices) { /// loop over devices
180+
if (device.name == "propagation-service") {
181+
// loop over the options
182+
// to find the value of TrackTuner::autoDetectDcaCalib
183+
for (const auto& option : device.options) { /// loop over options
184+
if (option.name == "trackTuner.autoDetectDcaCalib") {
185+
// found it!
186+
autoDetectDcaCalib = option.defaultValue.get<bool>();
187+
break;
188+
}
189+
} /// end loop over options
190+
break;
191+
}
192+
} /// end loop over devices
193+
LOG(info) << "[TrackPropagationModule] trackTuner.autoDetectDcaCalib it's equal to " << autoDetectDcaCalib;
194+
if (!autoDetectDcaCalib) {
195+
LOG(info) << "[TrackPropagationModule] retrieve the graphs already (we are in propagationService::Init() function)";
196+
trackTunerObj.getDcaGraphs();
197+
} else {
198+
LOG(info) << "[TrackPropagationModule] trackTunerObj.getDcaGraphs() function to be called later, in the process function!";
199+
}
174200
}
175201

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

178204
// Histograms for track tuner
179205
o2::framework::AxisSpec axisBinsDCA = {600, -0.15f, 0.15f, "#it{dca}_{xy} (cm)"};
@@ -186,6 +212,23 @@ class TrackPropagationModule
186212
template <bool isMc, typename TConfigurableGroup, typename TCCDBLoader, typename TCollisions, typename TTracks, typename TOutputGroup, typename THistoRegistry>
187213
void fillTrackTables(TConfigurableGroup const& cGroup, TrackTuner& trackTunerObj, TCCDBLoader const& ccdbLoader, TCollisions const& collisions, TTracks const& tracks, TOutputGroup& cursors, THistoRegistry& registry)
188214
{
215+
216+
/// retrieve the TrackTuner calibration graphs *if not done yet*
217+
/// i.e. if autodetect is required
218+
if (cGroup.useTrackTuner.value && autoDetectDcaCalib && !trackTunerObj.areGraphsConfigured) {
219+
220+
/// get the run number from the ccdb loader, already initialized
221+
const int runNumber = ccdbLoader.runNumber;
222+
trackTunerObj.setRunNumber(runNumber);
223+
224+
/// setup the "auto-detected" path based on the run number
225+
trackTunerObj.getPathInputFileAutomaticFromCCDB();
226+
trackTunedTracks->SetTitle(trackTunerObj.outputString.c_str());
227+
228+
/// now that the path is ok, retrieve the graphs
229+
trackTunerObj.getDcaGraphs();
230+
}
231+
189232
if (!fillTracks) {
190233
return; // suppress everything
191234
}

0 commit comments

Comments
 (0)