Skip to content

Commit 87130c2

Browse files
author
David Dobrigkeit Chinellato
committed
[Common] Add autodetection of TPC-only PIDTPC Nsigma need and switch evaluation on/off
1 parent 0462f59 commit 87130c2

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

Common/Tools/PID/pidTPCModule.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <Framework/AnalysisDataModel.h>
3434
#include <Framework/AnalysisHelpers.h>
3535
#include <Framework/Configurable.h>
36+
#include <Framework/RunningWorkflowInfo.h>
3637
#include <Framework/runDataProcessing.h>
3738
#include <ReconstructionDataFormats/PID.h>
3839

@@ -91,7 +92,7 @@ struct pidTPCConfigurables : o2::framework::ConfigurableGroup {
9192
// Parameters for loading network from a file / downloading the file
9293
o2::framework::Configurable<bool> useNetworkCorrection{"useNetworkCorrection", 0, "(bool) Wether or not to use the network correction for the TPC dE/dx signal"};
9394
o2::framework::Configurable<bool> autofetchNetworks{"autofetchNetworks", 1, "(bool) Automatically fetches networks from CCDB for the correct run number"};
94-
o2::framework::Configurable<bool> skipTPCOnly{"skipTPCOnly", false, "Flag to skip TPC only tracks (faster but affects the analyses that use TPC only tracks)"};
95+
o2::framework::Configurable<int> skipTPCOnly{"skipTPCOnly", -1, "Flag to skip TPC only tracks (faster but affects the analyses that use TPC only tracks). 0: do not skip, 1: skip, -1: check if needed by specific tasks"};
9596
o2::framework::Configurable<std::string> networkPathLocally{"networkPathLocally", "network.onnx", "(std::string) Path to the local .onnx file. If autofetching is enabled, then this is where the files will be downloaded"};
9697
o2::framework::Configurable<std::string> networkPathCCDB{"networkPathCCDB", "Analysis/PID/TPC/ML", "Path on CCDB"};
9798
o2::framework::Configurable<bool> enableNetworkOptimizations{"enableNetworkOptimizations", 1, "(bool) If the neural network correction is used, this enables GraphOptimizationLevel::ORT_ENABLE_EXTENDED in the ONNX session"};
@@ -244,6 +245,54 @@ class pidTPCModule
244245
LOGF(info, "***************************************************");
245246
}
246247

248+
if (pidTPCopts.skipTPCOnly.value == -1) {
249+
LOGF(info, "***************************************************");
250+
LOGF(info, " the skipTPConly flag has a value of -1! ");
251+
LOGF(info, " ---> autodetecting TPC-only track necessity now ");
252+
LOGF(info, "***************************************************");
253+
254+
// assume that TPC tracks are not needed, but check if tasks
255+
// requiring them are present in the chain
256+
pidTPCopts.skipTPCOnly.value = 1;
257+
258+
// loop over devices in this execution
259+
auto& workflows = context.services().template get<o2::framework::RunningWorkflowInfo const>();
260+
for (o2::framework::DeviceSpec const& device : workflows.devices) {
261+
262+
// Check 1: the photon builder (in any configuration) needs TPC only
263+
if (device.name.compare("photon-conversion-builder") == 0) {
264+
LOGF(info, " ---> photon conversion builder detected! ");
265+
LOGF(info, " ---> enabling TPC only track TPC PID calculations now.");
266+
pidTPCopts.skipTPCOnly.value = 0;
267+
}
268+
269+
// Check 2: propagation service with generation of photons
270+
if (device.name.compare("propagation-service") == 0) {
271+
LOGF(info, " ---> propagation service detected, checking if photons enabled...");
272+
for (auto const& option : device.options) {
273+
// check for photon generation enabled or not
274+
if (option.name.compare("v0BuilderOpts.generatePhotonCandidates") == 0) {
275+
if (option.defaultValue.get<bool>()) {
276+
LOGF(info, " ---> propagation service: photons enabled, will calculate TPC PID for TPC only tracks.");
277+
pidTPCopts.skipTPCOnly.value = 0;
278+
} else {
279+
LOGF(info, " ---> propagation service: photons disabled, TPC PID not required for TPC-only tracks");
280+
}
281+
}
282+
}
283+
}
284+
285+
// if extra tasks require TPC PID and enabling is to be automatic,
286+
// this is the place where one should add the conditionals.
287+
}
288+
289+
if (pidTPCopts.skipTPCOnly.value == 1) {
290+
LOGF(info, "No need for TPC only information detected. Will not generate Nsigma for TPC only tracks");
291+
LOGF(info, "If this is unexpected behaviour and a necessity was not identified, please add the");
292+
LOGF(info, "corresponding task to the list in pidTPCModule::Init().");
293+
}
294+
}
295+
247296
// initialize PID response
248297
response = new o2::pid::tpc::Response();
249298

0 commit comments

Comments
 (0)