Skip to content

Commit c6cbf57

Browse files
authored
Merge branch 'AliceO2Group:master' into Add-Omegac0Xic0ToOmegaKa-framework-reconstructed-by-KF
2 parents 67861d5 + 8fb6e00 commit c6cbf57

262 files changed

Lines changed: 14039 additions & 4030 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/Core/TableHelper.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#ifndef COMMON_CORE_TABLEHELPER_H_
1919
#define COMMON_CORE_TABLEHELPER_H_
2020

21-
#include <string>
22-
2321
#include "Framework/Configurable.h"
2422
#include "Framework/InitContext.h"
2523
#include "Framework/RunningWorkflowInfo.h"
2624

25+
#include <string>
26+
2727
/// Function to print the table required in the full workflow
2828
/// @param initContext initContext of the init function
2929
void printTablesInWorkflow(o2::framework::InitContext& initContext);
@@ -76,14 +76,16 @@ bool getTaskOptionValue(o2::framework::InitContext& initContext, const std::stri
7676
}
7777
if (device.name == taskName) { // Found the mother task
7878
int optionCounter = 0;
79-
for (auto const& option : device.options) {
79+
for (const o2::framework::ConfigParamSpec& option : device.options) {
8080
if (verbose) {
81-
LOG(info) << " Option " << optionCounter++ << " " << option.name << " = '" << option.defaultValue.asString() << "'";
81+
LOG(info) << " Option " << optionCounter++ << " " << option.name << " of type " << static_cast<int>(option.type) << " = '" << option.defaultValue.asString() << "'";
8282
}
8383
if (option.name == optName) {
8484
value = option.defaultValue.get<ValueType>();
8585
if (verbose) {
86-
LOG(info) << " Found option '" << optName << "' with value '" << value << "'";
86+
if constexpr (!std::is_same_v<ValueType, o2::framework::LabeledArray<float>>) {
87+
LOG(info) << " Found option '" << optName << "' with value '" << value << "'";
88+
}
8789
found = true;
8890
} else {
8991
return true;

Common/DataModel/PIDResponseITS.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
#define COMMON_DATAMODEL_PIDRESPONSEITS_H_
2424

2525
// O2 includes
26+
#include "TableHelper.h"
27+
2628
#include "Framework/ASoA.h"
2729
#include "Framework/AnalysisDataModel.h"
28-
#include "ReconstructionDataFormats/PID.h"
2930
#include "Framework/Logger.h"
31+
#include "ReconstructionDataFormats/PID.h"
3032

3133
namespace o2::aod
3234
{
@@ -125,6 +127,40 @@ struct ITSResponse {
125127
0.09, -999., -999.);
126128
}
127129

130+
/// Initialize the TOF response parameters in the init function of each task
131+
/// \param initContext Initialization context. Gets the configuration parameters from the pidITS task
132+
static void setParameters(o2::framework::InitContext& initContext, bool isMC = false)
133+
{
134+
float p0 = 0, p1 = 0, p2 = 0;
135+
float p0_Z2 = 0, p1_Z2 = 0, p2_Z2 = 0;
136+
float p0_res = 0, p1_res = 0, p2_res = 0;
137+
float p0_res_Z2 = 0, p1_res_Z2 = 0, p2_res_Z2 = 0;
138+
o2::framework::LabeledArray<float> itsParams;
139+
getTaskOptionValue(initContext, "its-pid", "itsParams", itsParams, true);
140+
auto data = itsParams.getData();
141+
const int col = isMC ? 1 : 0; // 0 for Data, 1 for MC
142+
if (data.rows != 2 || data.cols != 12) {
143+
LOG(fatal) << "ITSResponse parameters not initialized, check the itsParams configuration";
144+
}
145+
p0 = data(col, 0);
146+
p1 = data(col, 1);
147+
p2 = data(col, 2);
148+
p0_Z2 = data(col, 3);
149+
p1_Z2 = data(col, 4);
150+
p2_Z2 = data(col, 5);
151+
p0_res = data(col, 6);
152+
p1_res = data(col, 7);
153+
p2_res = data(col, 8);
154+
p0_res_Z2 = data(col, 9);
155+
p1_res_Z2 = data(col, 10);
156+
p2_res_Z2 = data(col, 11);
157+
158+
setParameters(p0, p1, p2,
159+
p0_Z2, p1_Z2, p2_Z2,
160+
p0_res, p1_res, p2_res,
161+
p0_res_Z2, p1_res_Z2, p2_res_Z2);
162+
}
163+
128164
private:
129165
static std::array<float, 3> mITSRespParams;
130166
static std::array<float, 3> mITSRespParamsZ2;

Common/TableProducer/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ o2physics_add_dpl_workflow(timestamp
5959
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
6060
COMPONENT_NAME Analysis)
6161

62+
o2physics_add_dpl_workflow(timestamptester
63+
SOURCES timestampTester.cxx
64+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
65+
COMPONENT_NAME Analysis)
66+
6267
o2physics_add_dpl_workflow(weak-decay-indices
6368
SOURCES weakDecayIndices.cxx
6469
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore

Common/TableProducer/PID/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ o2physics_add_dpl_workflow(pid-tof-full
4545

4646
o2physics_add_dpl_workflow(pid-tpc-base
4747
SOURCES pidTPCBase.cxx
48-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
48+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB
4949
COMPONENT_NAME Analysis)
5050

5151
o2physics_add_dpl_workflow(pid-tpc

Common/TableProducer/PID/pidTPC.cxx

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,34 @@
1818
/// \brief Task to produce PID tables for TPC split for each particle.
1919
/// Only the tables for the mass hypotheses requested are filled, and only for the requested table size ("Full" or "Tiny"). The others are sent empty.
2020
///
21-
#include <utility>
2221
#include <map>
2322
#include <memory>
2423
#include <string>
24+
#include <utility>
2525
#include <vector>
2626
// ROOT includes
2727
#include "TFile.h"
2828
#include "TRandom.h"
2929
#include "TSystem.h"
3030

3131
// O2 includes
32+
#include "MetadataHelper.h"
33+
#include "TableHelper.h"
34+
#include "pidTPCBase.h"
35+
36+
#include "Common/Core/PID/TPCPIDResponse.h"
37+
#include "Common/DataModel/EventSelection.h"
38+
#include "Common/DataModel/Multiplicity.h"
39+
#include "Common/DataModel/PIDResponseTPC.h"
40+
#include "Tools/ML/model.h"
41+
3242
#include "CCDB/BasicCCDBManager.h"
43+
#include "CCDB/CcdbApi.h"
44+
#include "Framework/ASoAHelpers.h"
45+
#include "Framework/AnalysisDataModel.h"
3346
#include "Framework/AnalysisTask.h"
3447
#include "Framework/runDataProcessing.h"
35-
#include "Framework/ASoAHelpers.h"
3648
#include "ReconstructionDataFormats/Track.h"
37-
#include "CCDB/CcdbApi.h"
38-
#include "Common/DataModel/PIDResponseTPC.h"
39-
#include "Common/Core/PID/TPCPIDResponse.h"
40-
#include "Framework/AnalysisDataModel.h"
41-
#include "Common/DataModel/Multiplicity.h"
42-
#include "Common/DataModel/EventSelection.h"
43-
#include "TableHelper.h"
44-
#include "Tools/ML/model.h"
45-
#include "pidTPCBase.h"
46-
#include "MetadataHelper.h"
4749

4850
using namespace o2;
4951
using namespace o2::framework;
@@ -155,8 +157,10 @@ struct tpcPid {
155157
void init(o2::framework::InitContext& initContext)
156158
{
157159
// Protection for process flags
158-
if ((doprocessStandard && doprocessMcTuneOnData) || (!doprocessStandard && !doprocessMcTuneOnData)) {
159-
LOG(fatal) << "pid-tpc must have only one of the options 'processStandard' OR 'processMcTuneOnData' enabled. Please check your configuration.";
160+
if (!((doprocessStandard && !doprocessStandard2 && !doprocessMcTuneOnData) ||
161+
(!doprocessStandard && doprocessStandard2 && !doprocessMcTuneOnData) ||
162+
(!doprocessStandard && !doprocessStandard2 && doprocessMcTuneOnData))) {
163+
LOG(fatal) << "pid-tpc must have only one of the options 'processStandard', 'processStandard2', 'processMcTuneOnData' enabled. Please check your configuration.";
160164
}
161165
response = new o2::pid::tpc::Response();
162166
// Checking the tables are requested in the workflow and enabling them
@@ -552,6 +556,98 @@ struct tpcPid {
552556
Partition<TrksMC> mcnotTPCStandaloneTracks = (aod::track::tpcNClsFindable > static_cast<uint8_t>(0)) && ((aod::track::itsClusterSizes > static_cast<uint32_t>(0)) || (aod::track::trdPattern > static_cast<uint8_t>(0)) || (aod::track::tofExpMom > 0.f && aod::track::tofChi2 > 0.f)); // To count number of tracks for use in NN array
553557
Partition<TrksMC> mctracksWithTPC = (aod::track::tpcNClsFindable > (uint8_t)0);
554558

559+
void processStandard2(Coll const& collisions, Trks const& tracks, aod::DEdxsCorrected const& dedxscorrected, aod::BCsWithTimestamps const& bcs)
560+
{
561+
const uint64_t outTable_size = tracks.size();
562+
const uint64_t dedxscorrected_size = dedxscorrected.size();
563+
564+
if (dedxscorrected_size != outTable_size) {
565+
LOG(fatal) << "Size of dEdx corrected table does not match size of tracks! dEdx size: " << dedxscorrected_size << ", tracks size: " << outTable_size;
566+
}
567+
568+
auto reserveTable = [&outTable_size](const Configurable<int>& flag, auto& table) {
569+
if (flag.value != 1) {
570+
return;
571+
}
572+
table.reserve(outTable_size);
573+
};
574+
575+
// Prepare memory for enabled tables
576+
reserveTable(pidFullEl, tablePIDFullEl);
577+
reserveTable(pidFullMu, tablePIDFullMu);
578+
reserveTable(pidFullPi, tablePIDFullPi);
579+
reserveTable(pidFullKa, tablePIDFullKa);
580+
reserveTable(pidFullPr, tablePIDFullPr);
581+
reserveTable(pidFullDe, tablePIDFullDe);
582+
reserveTable(pidFullTr, tablePIDFullTr);
583+
reserveTable(pidFullHe, tablePIDFullHe);
584+
reserveTable(pidFullAl, tablePIDFullAl);
585+
586+
reserveTable(pidTinyEl, tablePIDTinyEl);
587+
reserveTable(pidTinyMu, tablePIDTinyMu);
588+
reserveTable(pidTinyPi, tablePIDTinyPi);
589+
reserveTable(pidTinyKa, tablePIDTinyKa);
590+
reserveTable(pidTinyPr, tablePIDTinyPr);
591+
reserveTable(pidTinyDe, tablePIDTinyDe);
592+
reserveTable(pidTinyTr, tablePIDTinyTr);
593+
reserveTable(pidTinyHe, tablePIDTinyHe);
594+
reserveTable(pidTinyAl, tablePIDTinyAl);
595+
596+
const uint64_t tracksForNet_size = (skipTPCOnly) ? notTPCStandaloneTracks.size() : tracksWithTPC.size();
597+
std::vector<float> network_prediction;
598+
599+
if (useNetworkCorrection) {
600+
network_prediction = createNetworkPrediction(collisions, tracks, bcs, tracksForNet_size);
601+
}
602+
603+
uint64_t count_tracks = 0;
604+
uint64_t count_tracks2 = 0;
605+
606+
for (auto const& trk : tracks) {
607+
// Loop on Tracks
608+
609+
const auto& bc = trk.has_collision() ? collisions.iteratorAt(trk.collisionId()).bc_as<aod::BCsWithTimestamps>() : bcs.begin();
610+
auto dedx_corr = dedxscorrected.iteratorAt(count_tracks2);
611+
count_tracks2++;
612+
if (useCCDBParam && ccdbTimestamp.value == 0 && !ccdb->isCachedObjectValid(ccdbPath.value, bc.timestamp())) { // Updating parametrisation only if the initial timestamp is 0
613+
if (recoPass.value == "") {
614+
LOGP(info, "Retrieving latest TPC response object for timestamp {}:", bc.timestamp());
615+
} else {
616+
LOGP(info, "Retrieving TPC Response for timestamp {} and recoPass {}:", bc.timestamp(), recoPass.value);
617+
}
618+
response = ccdb->getSpecific<o2::pid::tpc::Response>(ccdbPath.value, bc.timestamp(), metadata);
619+
headers = ccdbApi.retrieveHeaders(ccdbPath.value, metadata, bc.timestamp());
620+
if (!response) {
621+
LOGP(warning, "!! Could not find a valid TPC response object for specific pass name {}! Falling back to latest uploaded object.", metadata["RecoPassName"]);
622+
response = ccdb->getForTimeStamp<o2::pid::tpc::Response>(ccdbPath.value, bc.timestamp());
623+
headers = ccdbApi.retrieveHeaders(ccdbPath.value, nullmetadata, bc.timestamp());
624+
if (!response) {
625+
LOGP(fatal, "Could not find ANY TPC response object for the timestamp {}!", bc.timestamp());
626+
}
627+
}
628+
LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << bc.timestamp() << ", period " << headers["LPMProductionTag"] << ", recoPass " << headers["RecoPassName"];
629+
response->PrintAll();
630+
}
631+
auto makePidTablesDefault = [&trk, &dedx_corr, &collisions, &network_prediction, &count_tracks, &tracksForNet_size, this](const int flagFull, auto& tableFull, const int flagTiny, auto& tableTiny, const o2::track::PID::ID pid) {
632+
makePidTables(flagFull, tableFull, flagTiny, tableTiny, pid, dedx_corr.tpcSignalCorrected(), trk, collisions, network_prediction, count_tracks, tracksForNet_size);
633+
};
634+
635+
makePidTablesDefault(pidFullEl, tablePIDFullEl, pidTinyEl, tablePIDTinyEl, o2::track::PID::Electron);
636+
makePidTablesDefault(pidFullMu, tablePIDFullMu, pidTinyMu, tablePIDTinyMu, o2::track::PID::Muon);
637+
makePidTablesDefault(pidFullPi, tablePIDFullPi, pidTinyPi, tablePIDTinyPi, o2::track::PID::Pion);
638+
makePidTablesDefault(pidFullKa, tablePIDFullKa, pidTinyKa, tablePIDTinyKa, o2::track::PID::Kaon);
639+
makePidTablesDefault(pidFullPr, tablePIDFullPr, pidTinyPr, tablePIDTinyPr, o2::track::PID::Proton);
640+
makePidTablesDefault(pidFullDe, tablePIDFullDe, pidTinyDe, tablePIDTinyDe, o2::track::PID::Deuteron);
641+
makePidTablesDefault(pidFullTr, tablePIDFullTr, pidTinyTr, tablePIDTinyTr, o2::track::PID::Triton);
642+
makePidTablesDefault(pidFullHe, tablePIDFullHe, pidTinyHe, tablePIDTinyHe, o2::track::PID::Helium3);
643+
makePidTablesDefault(pidFullAl, tablePIDFullAl, pidTinyAl, tablePIDTinyAl, o2::track::PID::Alpha);
644+
645+
if (trk.hasTPC() && (!skipTPCOnly || trk.hasITS() || trk.hasTRD() || trk.hasTOF())) {
646+
count_tracks++; // Increment network track counter only if track has TPC, and (not skipping TPConly) or (is not TPConly)
647+
}
648+
}
649+
}
650+
PROCESS_SWITCH(tpcPid, processStandard2, "Creating PID tables with Corrected dEdx", false);
555651
void processMcTuneOnData(CollMC const& collisionsMc, TrksMC const& tracksMc, aod::BCsWithTimestamps const& bcs, aod::McParticles const&)
556652
{
557653
gRandom->SetSeed(0); // Ensure unique seed from UUID for each process call

0 commit comments

Comments
 (0)