|
33 | 33 | #include <Framework/AnalysisDataModel.h> |
34 | 34 | #include <Framework/AnalysisHelpers.h> |
35 | 35 | #include <Framework/Configurable.h> |
| 36 | +#include <Framework/RunningWorkflowInfo.h> |
36 | 37 | #include <Framework/runDataProcessing.h> |
37 | 38 | #include <ReconstructionDataFormats/PID.h> |
38 | 39 |
|
@@ -91,7 +92,7 @@ struct pidTPCConfigurables : o2::framework::ConfigurableGroup { |
91 | 92 | // Parameters for loading network from a file / downloading the file |
92 | 93 | o2::framework::Configurable<bool> useNetworkCorrection{"useNetworkCorrection", 0, "(bool) Wether or not to use the network correction for the TPC dE/dx signal"}; |
93 | 94 | 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"}; |
95 | 96 | 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"}; |
96 | 97 | o2::framework::Configurable<std::string> networkPathCCDB{"networkPathCCDB", "Analysis/PID/TPC/ML", "Path on CCDB"}; |
97 | 98 | 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 |
244 | 245 | LOGF(info, "***************************************************"); |
245 | 246 | } |
246 | 247 |
|
| 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 | + |
247 | 296 | // initialize PID response |
248 | 297 | response = new o2::pid::tpc::Response(); |
249 | 298 |
|
|
0 commit comments