@@ -27,10 +27,11 @@ using namespace o2::track;
2727void customize (std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2828{
2929 std::vector<ConfigParamSpec> options{
30- {" pid-el" , VariantType::Int, 1 , {" Produce PID information for the electron mass hypothesis" }},
31- {" pid-mu" , VariantType::Int, 1 , {" Produce PID information for the muon mass hypothesis" }},
32- {" pid-pikapr" , VariantType::Int, 1 , {" Produce PID information for the Pion, Kaon, Proton mass hypothesis" }},
33- {" pid-nuclei" , VariantType::Int, 1 , {" Produce PID information for the Deuteron, Triton, Alpha mass hypothesis" }}};
30+ {" pid-all" , VariantType::Int, 1 , {" Produce PID information for all mass hypotheses" }},
31+ {" pid-el" , VariantType::Int, 0 , {" Produce PID information for the electron mass hypothesis" }},
32+ {" pid-mu" , VariantType::Int, 0 , {" Produce PID information for the muon mass hypothesis" }},
33+ {" pid-pikapr" , VariantType::Int, 0 , {" Produce PID information for the Pion, Kaon, Proton mass hypothesis" }},
34+ {" pid-nuclei" , VariantType::Int, 0 , {" Produce PID information for the Deuteron, Triton, Alpha mass hypothesis" }}};
3435 std::swap (workflowOptions, options);
3536}
3637
@@ -90,25 +91,123 @@ struct pidTPCTaskTiny {
9091 }
9192};
9293
93- WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
94- {
95- WorkflowSpec workflow;
96- if (cfgc.options ().get <int >(" pid-el" )) {
97- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Electron, o2::aod::pidRespTPCTEl>>(" pidTPCEl-task" ));
94+ struct pidTPCTaskTinyFull {
95+ using Trks = soa::Join<aod::Tracks, aod::TracksExtra>;
96+ using Coll = aod::Collisions;
97+
98+ Produces<o2::aod::pidRespTPCTEl> tpcpidEl;
99+ Produces<o2::aod::pidRespTPCTMu> tpcpidMu;
100+ Produces<o2::aod::pidRespTPCTPi> tpcpidPi;
101+ Produces<o2::aod::pidRespTPCTKa> tpcpidKa;
102+ Produces<o2::aod::pidRespTPCTPr> tpcpidPr;
103+ Produces<o2::aod::pidRespTPCTDe> tpcpidDe;
104+ Produces<o2::aod::pidRespTPCTTr> tpcpidTr;
105+ Produces<o2::aod::pidRespTPCTHe> tpcpidHe;
106+ Produces<o2::aod::pidRespTPCTAl> tpcpidAl;
107+
108+ DetectorResponse resp;
109+ Service<o2::ccdb::BasicCCDBManager> ccdb;
110+ Configurable<std::string> paramfile{" param-file" , " " , " Path to the parametrization object, if emtpy the parametrization is not taken from file" };
111+ Configurable<std::string> signalname{" param-signal" , " BetheBloch" , " Name of the parametrization for the expected signal, used in both file and CCDB mode" };
112+ Configurable<std::string> sigmaname{" param-sigma" , " TPCReso" , " Name of the parametrization for the expected sigma, used in both file and CCDB mode" };
113+ Configurable<std::string> url{" ccdb-url" , " http://ccdb-test.cern.ch:8080" , " url of the ccdb repository" };
114+ Configurable<long > timestamp{" ccdb-timestamp" , -1 , " timestamp of the object" };
115+
116+ void init (o2::framework::InitContext&)
117+ {
118+ ccdb->setURL (url.value );
119+ ccdb->setTimestamp (timestamp.value );
120+ ccdb->setCaching (true );
121+ ccdb->setLocalObjectValidityChecking ();
122+ // Not later than now objects
123+ ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
124+ //
125+ const std::string fname = paramfile.value ;
126+ if (!fname.empty ()) { // Loading the parametrization from file
127+ resp.LoadParamFromFile (fname.data (), signalname.value , DetectorResponse::kSignal );
128+ resp.LoadParamFromFile (fname.data (), sigmaname.value , DetectorResponse::kSigma );
129+ } else { // Loading it from CCDB
130+ const std::string path = " Analysis/PID/TPC" ;
131+ resp.LoadParam (DetectorResponse::kSignal , ccdb->getForTimeStamp <Parametrization>(path + " /" + signalname.value , timestamp.value ));
132+ resp.LoadParam (DetectorResponse::kSigma , ccdb->getForTimeStamp <Parametrization>(path + " /" + sigmaname.value , timestamp.value ));
133+ }
98134 }
99- if (cfgc.options ().get <int >(" pid-mu" )) {
100- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Muon, o2::aod::pidRespTPCTMu>>(" pidTPCMu-task" ));
135+
136+ void process (Coll const & collisions, Trks const & tracks)
137+ {
138+
139+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Electron> resp_El = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Electron>();
140+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Muon> resp_Mu = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Muon>();
141+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Pion> resp_Pi = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Pion>();
142+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Kaon> resp_Ka = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Kaon>();
143+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Proton> resp_Pr = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Proton>();
144+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Deuteron> resp_De = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Deuteron>();
145+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Triton> resp_Tr = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Triton>();
146+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Helium3> resp_He = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Helium3>();
147+ constexpr tpc::ELoss<Coll::iterator, Trks::iterator, PID::Alpha> resp_Al = tpc::ELoss<Coll::iterator, Trks::iterator, PID::Alpha>();
148+
149+ tpcpidEl.reserve (tracks.size ());
150+ tpcpidMu.reserve (tracks.size ());
151+ tpcpidPi.reserve (tracks.size ());
152+ tpcpidKa.reserve (tracks.size ());
153+ tpcpidPr.reserve (tracks.size ());
154+ tpcpidDe.reserve (tracks.size ());
155+ tpcpidTr.reserve (tracks.size ());
156+ tpcpidHe.reserve (tracks.size ());
157+ tpcpidAl.reserve (tracks.size ());
158+ for (auto const & trk : tracks) {
159+ #define FILL_PID_TABLE (PID_TABLE, PID_RESPONSE ) \
160+ { \
161+ const float exp_sigma = PID_RESPONSE.GetExpectedSigma (resp, trk.collision (), trk); \
162+ const float separation = PID_RESPONSE.GetSeparation (resp, trk.collision (), trk); \
163+ if (separation <= o2::aod::pidtpc_tiny::binned_min) { \
164+ PID_TABLE (exp_sigma, o2::aod::pidtpc_tiny::lower_bin); \
165+ } else if (separation >= o2::aod::pidtpc_tiny::binned_max) { \
166+ PID_TABLE (exp_sigma, o2::aod::pidtpc_tiny::upper_bin); \
167+ } else if (separation >= 0 ) { \
168+ PID_TABLE (exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width + 0 .5f ); \
169+ } else { \
170+ PID_TABLE (exp_sigma, separation / o2::aod::pidtpc_tiny::bin_width - 0 .5f ); \
171+ } \
101172 }
102- if (cfgc.options ().get <int >(" pid-pikapr" )) {
103- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Pion, o2::aod::pidRespTPCTPi>>(" pidTPCPi-task" ));
104- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Kaon, o2::aod::pidRespTPCTKa>>(" pidTPCKa-task" ));
105- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Proton, o2::aod::pidRespTPCTPr>>(" pidTPCPr-task" ));
173+
174+ FILL_PID_TABLE (tpcpidEl, resp_El);
175+ FILL_PID_TABLE (tpcpidMu, resp_Mu);
176+ FILL_PID_TABLE (tpcpidPi, resp_Pi);
177+ FILL_PID_TABLE (tpcpidKa, resp_Ka);
178+ FILL_PID_TABLE (tpcpidPr, resp_Pr);
179+ FILL_PID_TABLE (tpcpidDe, resp_De);
180+ FILL_PID_TABLE (tpcpidTr, resp_Tr);
181+ FILL_PID_TABLE (tpcpidHe, resp_He);
182+ FILL_PID_TABLE (tpcpidAl, resp_Al);
183+ #undef FILL_PID_TABLE
184+ }
106185 }
107- if (cfgc.options ().get <int >(" pid-nuclei" )) {
108- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Deuteron, o2::aod::pidRespTPCTDe>>(" pidTPCDe-task" ));
109- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Triton, o2::aod::pidRespTPCTTr>>(" pidTPCTr-task" ));
110- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Helium3, o2::aod::pidRespTPCTHe>>(" pidTPCHe-task" ));
111- workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Alpha, o2::aod::pidRespTPCTAl>>(" pidTPCAl-task" ));
186+ };
187+
188+ WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
189+ {
190+ WorkflowSpec workflow;
191+ if (cfgc.options ().get <int >(" pid-all" )) {
192+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTinyFull>(" pidTPCFull-task" ));
193+ } else {
194+ if (cfgc.options ().get <int >(" pid-el" )) {
195+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Electron, o2::aod::pidRespTPCTEl>>(" pidTPCEl-task" ));
196+ }
197+ if (cfgc.options ().get <int >(" pid-mu" )) {
198+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Muon, o2::aod::pidRespTPCTMu>>(" pidTPCMu-task" ));
199+ }
200+ if (cfgc.options ().get <int >(" pid-pikapr" )) {
201+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Pion, o2::aod::pidRespTPCTPi>>(" pidTPCPi-task" ));
202+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Kaon, o2::aod::pidRespTPCTKa>>(" pidTPCKa-task" ));
203+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Proton, o2::aod::pidRespTPCTPr>>(" pidTPCPr-task" ));
204+ }
205+ if (cfgc.options ().get <int >(" pid-nuclei" )) {
206+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Deuteron, o2::aod::pidRespTPCTDe>>(" pidTPCDe-task" ));
207+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Triton, o2::aod::pidRespTPCTTr>>(" pidTPCTr-task" ));
208+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Helium3, o2::aod::pidRespTPCTHe>>(" pidTPCHe-task" ));
209+ workflow.push_back (adaptAnalysisTask<pidTPCTaskTiny<PID::Alpha, o2::aod::pidRespTPCTAl>>(" pidTPCAl-task" ));
210+ }
112211 }
113212 return workflow;
114213}
0 commit comments