diff --git a/Analysis/Tasks/pidTPC_tiny.cxx b/Analysis/Tasks/pidTPC_tiny.cxx index 9ddccfe29dea3..8906fc5cbdc5f 100644 --- a/Analysis/Tasks/pidTPC_tiny.cxx +++ b/Analysis/Tasks/pidTPC_tiny.cxx @@ -27,10 +27,11 @@ using namespace o2::track; void customize(std::vector& workflowOptions) { std::vector options{ - {"pid-el", VariantType::Int, 1, {"Produce PID information for the electron mass hypothesis"}}, - {"pid-mu", VariantType::Int, 1, {"Produce PID information for the muon mass hypothesis"}}, - {"pid-pikapr", VariantType::Int, 1, {"Produce PID information for the Pion, Kaon, Proton mass hypothesis"}}, - {"pid-nuclei", VariantType::Int, 1, {"Produce PID information for the Deuteron, Triton, Alpha mass hypothesis"}}}; + {"pid-all", VariantType::Int, 1, {"Produce PID information for all mass hypotheses"}}, + {"pid-el", VariantType::Int, 0, {"Produce PID information for the electron mass hypothesis"}}, + {"pid-mu", VariantType::Int, 0, {"Produce PID information for the muon mass hypothesis"}}, + {"pid-pikapr", VariantType::Int, 0, {"Produce PID information for the Pion, Kaon, Proton mass hypothesis"}}, + {"pid-nuclei", VariantType::Int, 0, {"Produce PID information for the Deuteron, Triton, Alpha mass hypothesis"}}}; std::swap(workflowOptions, options); } @@ -90,25 +91,123 @@ struct pidTPCTaskTiny { } }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow; - if (cfgc.options().get("pid-el")) { - workflow.push_back(adaptAnalysisTask>("pidTPCEl-task")); +struct pidTPCTaskTinyFull { + using Trks = soa::Join; + using Coll = aod::Collisions; + + Produces tpcpidEl; + Produces tpcpidMu; + Produces tpcpidPi; + Produces tpcpidKa; + Produces tpcpidPr; + Produces tpcpidDe; + Produces tpcpidTr; + Produces tpcpidHe; + Produces tpcpidAl; + + DetectorResponse resp; + Service ccdb; + Configurable paramfile{"param-file", "", "Path to the parametrization object, if emtpy the parametrization is not taken from file"}; + Configurable signalname{"param-signal", "BetheBloch", "Name of the parametrization for the expected signal, used in both file and CCDB mode"}; + Configurable sigmaname{"param-sigma", "TPCReso", "Name of the parametrization for the expected sigma, used in both file and CCDB mode"}; + Configurable url{"ccdb-url", "http://ccdb-test.cern.ch:8080", "url of the ccdb repository"}; + Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + + void init(o2::framework::InitContext&) + { + ccdb->setURL(url.value); + ccdb->setTimestamp(timestamp.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + // Not later than now objects + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + // + const std::string fname = paramfile.value; + if (!fname.empty()) { // Loading the parametrization from file + resp.LoadParamFromFile(fname.data(), signalname.value, DetectorResponse::kSignal); + resp.LoadParamFromFile(fname.data(), sigmaname.value, DetectorResponse::kSigma); + } else { // Loading it from CCDB + const std::string path = "Analysis/PID/TPC"; + resp.LoadParam(DetectorResponse::kSignal, ccdb->getForTimeStamp(path + "/" + signalname.value, timestamp.value)); + resp.LoadParam(DetectorResponse::kSigma, ccdb->getForTimeStamp(path + "/" + sigmaname.value, timestamp.value)); + } } - if (cfgc.options().get("pid-mu")) { - workflow.push_back(adaptAnalysisTask>("pidTPCMu-task")); + + void process(Coll const& collisions, Trks const& tracks) + { + + constexpr tpc::ELoss resp_El = tpc::ELoss(); + constexpr tpc::ELoss resp_Mu = tpc::ELoss(); + constexpr tpc::ELoss resp_Pi = tpc::ELoss(); + constexpr tpc::ELoss resp_Ka = tpc::ELoss(); + constexpr tpc::ELoss resp_Pr = tpc::ELoss(); + constexpr tpc::ELoss resp_De = tpc::ELoss(); + constexpr tpc::ELoss resp_Tr = tpc::ELoss(); + constexpr tpc::ELoss resp_He = tpc::ELoss(); + constexpr tpc::ELoss resp_Al = tpc::ELoss(); + + tpcpidEl.reserve(tracks.size()); + tpcpidMu.reserve(tracks.size()); + tpcpidPi.reserve(tracks.size()); + tpcpidKa.reserve(tracks.size()); + tpcpidPr.reserve(tracks.size()); + tpcpidDe.reserve(tracks.size()); + tpcpidTr.reserve(tracks.size()); + tpcpidHe.reserve(tracks.size()); + tpcpidAl.reserve(tracks.size()); + for (auto const& trk : tracks) { +#define FILL_PID_TABLE(PID_TABLE, PID_RESPONSE) \ + { \ + const float exp_sigma = PID_RESPONSE.GetExpectedSigma(resp, trk.collision(), trk); \ + const float separation = PID_RESPONSE.GetSeparation(resp, trk.collision(), trk); \ + if (separation <= o2::aod::pidtpc_tiny::binned_min) { \ + PID_TABLE(exp_sigma, o2::aod::pidtpc_tiny::lower_bin); \ + } else if (separation >= o2::aod::pidtpc_tiny::binned_max) { \ + PID_TABLE(exp_sigma, o2::aod::pidtpc_tiny::upper_bin); \ + } else if (separation >= 0) { \ + PID_TABLE(exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width + 0.5f); \ + } else { \ + PID_TABLE(exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width - 0.5f); \ + } \ } - if (cfgc.options().get("pid-pikapr")) { - workflow.push_back(adaptAnalysisTask>("pidTPCPi-task")); - workflow.push_back(adaptAnalysisTask>("pidTPCKa-task")); - workflow.push_back(adaptAnalysisTask>("pidTPCPr-task")); + + FILL_PID_TABLE(tpcpidEl, resp_El); + FILL_PID_TABLE(tpcpidMu, resp_Mu); + FILL_PID_TABLE(tpcpidPi, resp_Pi); + FILL_PID_TABLE(tpcpidKa, resp_Ka); + FILL_PID_TABLE(tpcpidPr, resp_Pr); + FILL_PID_TABLE(tpcpidDe, resp_De); + FILL_PID_TABLE(tpcpidTr, resp_Tr); + FILL_PID_TABLE(tpcpidHe, resp_He); + FILL_PID_TABLE(tpcpidAl, resp_Al); +#undef FILL_PID_TABLE + } } - if (cfgc.options().get("pid-nuclei")) { - workflow.push_back(adaptAnalysisTask>("pidTPCDe-task")); - workflow.push_back(adaptAnalysisTask>("pidTPCTr-task")); - workflow.push_back(adaptAnalysisTask>("pidTPCHe-task")); - workflow.push_back(adaptAnalysisTask>("pidTPCAl-task")); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow; + if (cfgc.options().get("pid-all")) { + workflow.push_back(adaptAnalysisTask("pidTPCFull-task")); + } else { + if (cfgc.options().get("pid-el")) { + workflow.push_back(adaptAnalysisTask>("pidTPCEl-task")); + } + if (cfgc.options().get("pid-mu")) { + workflow.push_back(adaptAnalysisTask>("pidTPCMu-task")); + } + if (cfgc.options().get("pid-pikapr")) { + workflow.push_back(adaptAnalysisTask>("pidTPCPi-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCKa-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCPr-task")); + } + if (cfgc.options().get("pid-nuclei")) { + workflow.push_back(adaptAnalysisTask>("pidTPCDe-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCTr-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCHe-task")); + workflow.push_back(adaptAnalysisTask>("pidTPCAl-task")); + } } return workflow; }