Skip to content

Commit d6172fd

Browse files
author
David Dobrigkeit Chinellato
committed
Configurable list of TPC only requirers, fix run 2 bug
1 parent 55f3eea commit d6172fd

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

Common/Tools/PID/pidTPCModule.h

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct pidTPCConfigurables : o2::framework::ConfigurableGroup {
9393
o2::framework::Configurable<bool> useNetworkCorrection{"useNetworkCorrection", 0, "(bool) Wether or not to use the network correction for the TPC dE/dx signal"};
9494
o2::framework::Configurable<bool> autofetchNetworks{"autofetchNetworks", 1, "(bool) Automatically fetches networks from CCDB for the correct run number"};
9595
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"};
96+
o2::framework::Configurable<std::vector<std::string>> devicesRequiringTPCOnlyPID{"devicesRequiringTPCOnlyPID", std::vector<std::string>{"photon-conversion-builder"}, "List of device names of tasks requiring TPC-only tracks to have TPC PID calculated"};
9697
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"};
9798
o2::framework::Configurable<std::string> networkPathCCDB{"networkPathCCDB", "Analysis/PID/TPC/ML", "Path on CCDB"};
9899
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"};
@@ -250,6 +251,11 @@ class pidTPCModule
250251
LOGF(info, " the skipTPConly flag has a value of -1! ");
251252
LOGF(info, " ---> autodetecting TPC-only track necessity now ");
252253
LOGF(info, "***************************************************");
254+
// print list of devices that are being checked for
255+
for (std::size_t devIdx{0}; devIdx < pidTPCopts.devicesRequiringTPCOnlyPID->size(); devIdx++) {
256+
LOGF(info, "Will search for #%i device requiring TPC PID for TPC only: %s", devIdx, pidTPCopts.devicesRequiringTPCOnlyPID->at(devIdx));
257+
}
258+
LOGF(info, "***************************************************");
253259

254260
// assume that TPC tracks are not needed, but check if tasks
255261
// requiring them are present in the chain
@@ -274,18 +280,10 @@ class pidTPCModule
274280
}
275281
}
276282

277-
// if extra tasks require TPC PID for TPC-only tracks and enabling is to be automatic,
278-
// this is the place where one should add the conditionals.
279-
//
280-
// note: this should be the device name (the name that gets printed in the
281-
// logs when executing the task) and it is sufficient to just extend this array
282-
// with the corresponding string.
283-
std::vector<std::string> devicesRequiringTPCOnlyPID = {"photon-conversion-builder"};
284-
285-
// Check 2: specific tasks that require TPC PID
286-
for (const std::string& requiringDevice : devicesRequiringTPCOnlyPID) {
287-
if (device.name.compare(requiringDevice) == 0) {
288-
LOGF(info, " ---> %s detected! ", requiringDevice);
283+
// Check 2: specific tasks that require TPC PID based on configurable
284+
for (std::size_t devIdx{0}; devIdx < pidTPCopts.devicesRequiringTPCOnlyPID->size(); devIdx++) {
285+
if (device.name.compare(pidTPCopts.devicesRequiringTPCOnlyPID->at(devIdx)) == 0) {
286+
LOGF(info, " ---> %s detected! ", pidTPCopts.devicesRequiringTPCOnlyPID->at(devIdx));
289287
LOGF(info, " ---> enabling TPC only track TPC PID calculations now.");
290288
pidTPCopts.skipTPCOnly.value = 0;
291289
}
@@ -387,12 +385,16 @@ class pidTPCModule
387385
LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << time << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"];
388386
metadata["RecoPassName"] = headers["RecoPassName"]; // Force pass number for NN request to match retrieved BB
389387
o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp<o2::parameters::GRPLHCIFData>(pidTPCopts.cfgPathGrpLhcIf.value, time);
390-
LOG(info) << " collision type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
391-
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
392-
if (collsys == CollisionSystemType::kCollSyspp) {
393-
irSource = std::string("T0VTX");
388+
if (grpo) {
389+
LOG(info) << " collision type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
390+
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
391+
if (collsys == CollisionSystemType::kCollSyspp) {
392+
irSource = std::string("T0VTX");
393+
} else {
394+
irSource = std::string("ZNC hadronic");
395+
}
394396
} else {
395-
irSource = std::string("ZNC hadronic");
397+
LOGF(info, "No grpo object found. irSource will remain undefined.");
396398
}
397399
response->PrintAll();
398400
}
@@ -469,12 +471,16 @@ class pidTPCModule
469471
LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"];
470472
metadata["RecoPassName"] = headers["RecoPassName"]; // Force pass number for NN request to match retrieved BB
471473
o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp<o2::parameters::GRPLHCIFData>(pidTPCopts.cfgPathGrpLhcIf.value, bc.timestamp());
472-
LOG(info) << "Collision type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
473-
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
474-
if (collsys == CollisionSystemType::kCollSyspp) {
475-
irSource = std::string("T0VTX");
474+
if (grpo) {
475+
LOG(info) << "Collision type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
476+
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
477+
if (collsys == CollisionSystemType::kCollSyspp) {
478+
irSource = std::string("T0VTX");
479+
} else {
480+
irSource = std::string("ZNC hadronic");
481+
}
476482
} else {
477-
irSource = std::string("ZNC hadronic");
483+
LOGF(info, "No grpo object found. irSource will remain undefined.");
478484
}
479485
response->PrintAll();
480486
}
@@ -515,11 +521,19 @@ class pidTPCModule
515521
size_t i = 0;
516522
for (const auto& collision : collisions) {
517523
const auto& bc = collision.template bc_as<B>();
518-
hadronicRateForCollision[i] = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3;
524+
if (irSource.compare("") != 0) {
525+
hadronicRateForCollision[i] = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3;
526+
} else {
527+
hadronicRateForCollision[i] = 0.0f;
528+
}
519529
i++;
520530
}
521531
auto bc = bcs.begin();
522-
hadronicRateBegin = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3; // kHz
532+
if (irSource.compare("") != 0) {
533+
hadronicRateBegin = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3; // kHz
534+
} else {
535+
hadronicRateBegin = 0.0f;
536+
}
523537

524538
// Filling a std::vector<float> to be evaluated by the network
525539
// Evaluation on single tracks brings huge overhead: Thus evaluation is done on one large vector
@@ -742,11 +756,19 @@ class pidTPCModule
742756
size_t i = 0;
743757
for (const auto& collision : cols) {
744758
const auto& bc = collision.template bc_as<aod::BCsWithTimestamps>();
745-
hadronicRateForCollision[i] = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3;
759+
if (irSource.compare("") != 0) {
760+
hadronicRateForCollision[i] = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3;
761+
} else {
762+
hadronicRateForCollision[i] = 0.0f;
763+
}
746764
i++;
747765
}
748766
auto bc = bcs.begin();
749-
hadronicRateBegin = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3; // kHz
767+
if (irSource.compare("") != 0) {
768+
hadronicRateBegin = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource) * 1.e-3; // kHz
769+
} else {
770+
hadronicRateBegin = 0.0f;
771+
}
750772
}
751773

752774
for (auto const& trk : tracks) {
@@ -854,12 +876,16 @@ class pidTPCModule
854876
}
855877
LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"];
856878
o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp<o2::parameters::GRPLHCIFData>(pidTPCopts.cfgPathGrpLhcIf.value, bc.timestamp());
857-
LOG(info) << "Collisions type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
858-
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
859-
if (collsys == CollisionSystemType::kCollSyspp) {
860-
irSource = std::string("T0VTX");
879+
if (grpo) {
880+
LOG(info) << "Collisions type::" << CollisionSystemType::getCollisionTypeFromGrp(grpo);
881+
collsys = CollisionSystemType::getCollisionTypeFromGrp(grpo);
882+
if (collsys == CollisionSystemType::kCollSyspp) {
883+
irSource = std::string("T0VTX");
884+
} else {
885+
irSource = std::string("ZNC hadronic");
886+
}
861887
} else {
862-
irSource = std::string("ZNC hadronic");
888+
LOGF(info, "No grpo object found. irSource will remain undefined.");
863889
}
864890
response->PrintAll();
865891
}

0 commit comments

Comments
 (0)