Skip to content

Commit 277de2d

Browse files
njacazioginnocen
andauthored
PWGHF: Add full table writing tasks for D0 and Lc (#5295)
* PWGHF: Add full table writing tasks for D0 and Lc - Add full table to be written to file - Add task dedicated to 2 prong tree writing - Add task dedicated to 3 prong tree writing - Use naming of tasks as in HFSecondaryVertex - Update selector for HF tracks - Use lambda functions for Tree Filling * Update HFTreeCreatorD0ToKPi.cxx * Update HFTreeCreatorLcToPKPi.cxx Co-authored-by: Gian Michele Innocenti <gminnocen@gmail.com>
1 parent 157977f commit 277de2d

File tree

5 files changed

+598
-6
lines changed

5 files changed

+598
-6
lines changed

Analysis/Tasks/PWGHF/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,21 @@ o2_add_dpl_workflow(hf-candidate-creator-2prong
3333
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG
3434
COMPONENT_NAME Analysis)
3535

36+
o2_add_dpl_workflow(hf-tree-creator-d0-tokpi
37+
SOURCES HFTreeCreatorD0ToKPi.cxx
38+
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG
39+
COMPONENT_NAME Analysis)
40+
3641
o2_add_dpl_workflow(hf-candidate-creator-3prong
3742
SOURCES HFCandidateCreator3Prong.cxx
3843
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG
3944
COMPONENT_NAME Analysis)
4045

46+
o2_add_dpl_workflow(hf-tree-creator-lc-topkpi
47+
SOURCES HFTreeCreatorLcToPKPi.cxx
48+
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing ROOT::EG
49+
COMPONENT_NAME Analysis)
50+
4151
o2_add_dpl_workflow(hf-d0-candidate-selector
4252
SOURCES HFD0CandidateSelector.cxx
4353
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel O2::AnalysisCore O2::DetectorsVertexing

Analysis/Tasks/PWGHF/HFD0CandidateSelector.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct HFD0CandidateSelector {
6767
Configurable<double> d_pidTOFMaxpT{"d_pidTOFMaxpT", 5., "Upper bound of track pT for TOF PID"};
6868

6969
Configurable<double> d_TPCNClsFindablePIDCut{"d_TPCNClsFindablePIDCut", 50., "Lower bound of TPC findable clusters for good PID"};
70+
Configurable<bool> b_requireTPC{"b_requireTPC", true, "Flag to require a positive Number of found clusters in TPC"};
7071
Configurable<double> d_nSigmaTPC{"d_nSigmaTPC", 3., "Nsigma cut on TPC only"};
7172
Configurable<double> d_nSigmaTPCCombined{"d_nSigmaTPCCombined", 5., "Nsigma cut on TPC combined with TOF"};
7273
Configurable<double> d_nSigmaTOF{"d_nSigmaTOF", 3., "Nsigma cut on TOF only"};
@@ -100,7 +101,7 @@ struct HFD0CandidateSelector {
100101
if (track.charge() == 0) {
101102
return false;
102103
}
103-
if (track.tpcNClsFound() == 0) {
104+
if (b_requireTPC.value && track.tpcNClsFound() == 0) {
104105
return false; //is it clusters findable or found - need to check
105106
}
106107
return true;
@@ -231,7 +232,7 @@ struct HFD0CandidateSelector {
231232
/// \note nPDG=211 pion nPDG=321 kaon
232233
/// \return true if track satisfies TPC PID hypothesis for given Nsigma cut
233234
template <typename T>
234-
bool selectionPIDTPC(const T& track, int nPDG, int nSigmaCut)
235+
bool selectionPIDTPC(const T& track, int nPDG, double nSigmaCut)
235236
{
236237
double nSigma = 100.0; //arbitarily large value
237238
nPDG = TMath::Abs(nPDG);
@@ -252,7 +253,7 @@ struct HFD0CandidateSelector {
252253
/// \note nPDG=211 pion nPDG=321 kaon
253254
/// \return true if track satisfies TOF PID hypothesis for given NSigma cut
254255
template <typename T>
255-
bool selectionPIDTOF(const T& track, int nPDG, int nSigmaCut)
256+
bool selectionPIDTOF(const T& track, int nPDG, double nSigmaCut)
256257
{
257258
double nSigma = 100.0; //arbitarily large value
258259
nPDG = TMath::Abs(nPDG);

Analysis/Tasks/PWGHF/HFTrackIndexSkimsCreator.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct SelectTracks {
7474
int status_prong = 3; // selection flag , 2 bits on
7575

7676
auto trackPt = track.pt();
77-
if (b_dovalplots) {
77+
if (b_dovalplots.value) {
7878
registry.get<TH1>(HIST("hpt_nocuts"))->Fill(trackPt);
7979
}
8080

@@ -96,9 +96,9 @@ struct SelectTracks {
9696
}
9797

9898
// quality cut
99-
if (doCutQuality && status_prong > 0) { // FIXME to make a more complete selection e.g track.flags() & o2::aod::track::TPCrefit && track.flags() & o2::aod::track::GoldenChi2 &&
99+
if (doCutQuality.value && status_prong > 0) { // FIXME to make a more complete selection e.g track.flags() & o2::aod::track::TPCrefit && track.flags() & o2::aod::track::GoldenChi2 &&
100100
UChar_t clustermap = track.itsClusterMap();
101-
if (!(track.tpcNClsFound() >= d_tpcnclsfound &&
101+
if (!(track.tpcNClsFound() >= d_tpcnclsfound.value &&
102102
track.flags() & o2::aod::track::ITSrefit &&
103103
(TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) {
104104
status_prong = 0;
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file HFTreeCreator2Prong.cxx
12+
/// \brief Writer of the 2 prong candidates in the form of flat tables to be stored in TTrees.
13+
/// Intended for debug or for the local optimization of analysis on small samples.
14+
/// In this file are defined and filled the output tables
15+
///
16+
/// \author Nicolo' Jacazio <nicolo.jacazio@cern.ch>, CERN
17+
18+
#include "Framework/runDataProcessing.h"
19+
#include "Framework/AnalysisTask.h"
20+
#include "DetectorsVertexing/DCAFitterN.h"
21+
#include "AnalysisDataModel/HFSecondaryVertex.h"
22+
#include "AnalysisDataModel/HFCandidateSelectionTables.h"
23+
#include "AnalysisCore/trackUtilities.h"
24+
#include "ReconstructionDataFormats/DCA.h"
25+
26+
using namespace o2;
27+
using namespace o2::framework;
28+
using namespace o2::aod::hf_cand_prong2;
29+
30+
namespace o2::aod
31+
{
32+
namespace full
33+
{
34+
DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float);
35+
DECLARE_SOA_COLUMN(PtProng0, ptProng0, float);
36+
DECLARE_SOA_COLUMN(PProng0, pProng0, float);
37+
DECLARE_SOA_COLUMN(ImpactParameterNormalised0, impactParameterNormalised0, float);
38+
DECLARE_SOA_COLUMN(PtProng1, ptProng1, float);
39+
DECLARE_SOA_COLUMN(PProng1, pProng1, float);
40+
DECLARE_SOA_COLUMN(ImpactParameterNormalised1, impactParameterNormalised1, float);
41+
DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t);
42+
DECLARE_SOA_COLUMN(M, m, float);
43+
DECLARE_SOA_COLUMN(Pt, pt, float);
44+
DECLARE_SOA_COLUMN(P, p, float);
45+
DECLARE_SOA_COLUMN(Eta, eta, float);
46+
DECLARE_SOA_COLUMN(Phi, phi, float);
47+
DECLARE_SOA_COLUMN(Y, y, float);
48+
DECLARE_SOA_COLUMN(E, e, float);
49+
DECLARE_SOA_COLUMN(NSigTPCPi0, nsigTPCPi0, float);
50+
DECLARE_SOA_COLUMN(NSigTPCKa0, nsigTPCKa0, float);
51+
DECLARE_SOA_COLUMN(NSigTOFPi0, nsigTOFPi0, float);
52+
DECLARE_SOA_COLUMN(NSigTOFKa0, nsigTOFKa0, float);
53+
DECLARE_SOA_COLUMN(NSigTPCPi1, nsigTPCPi1, float);
54+
DECLARE_SOA_COLUMN(NSigTPCKa1, nsigTPCKa1, float);
55+
DECLARE_SOA_COLUMN(NSigTOFPi1, nsigTOFPi1, float);
56+
DECLARE_SOA_COLUMN(NSigTOFKa1, nsigTOFKa1, float);
57+
DECLARE_SOA_COLUMN(DecayLength, decayLength, float);
58+
DECLARE_SOA_COLUMN(DecayLengthXY, decayLengthXY, float);
59+
DECLARE_SOA_COLUMN(DecayLengthNormalised, decayLengthNormalised, float);
60+
DECLARE_SOA_COLUMN(DecayLengthXYNormalised, decayLengthXYNormalised, float);
61+
DECLARE_SOA_COLUMN(CPA, cpa, float);
62+
DECLARE_SOA_COLUMN(CPAXY, cpaXY, float);
63+
DECLARE_SOA_COLUMN(Ct, ct, float);
64+
DECLARE_SOA_COLUMN(ImpactParameterProduct, impactParameterProduct, float);
65+
DECLARE_SOA_COLUMN(CosThetaStar, cosThetaStar, float);
66+
DECLARE_SOA_COLUMN(MCflag, mcflag, int8_t);
67+
// Events
68+
DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int);
69+
DECLARE_SOA_COLUMN(RunNumber, runNumber, int);
70+
} // namespace full
71+
72+
DECLARE_SOA_TABLE(HfCandProng2Full, "AOD", "HFCANDP2Full",
73+
collision::BCId,
74+
collision::NumContrib,
75+
collision::PosX,
76+
collision::PosY,
77+
collision::PosZ,
78+
hf_cand::XSecondaryVertex,
79+
hf_cand::YSecondaryVertex,
80+
hf_cand::ZSecondaryVertex,
81+
hf_cand::ErrorDecayLength,
82+
hf_cand::ErrorDecayLengthXY,
83+
hf_cand::Chi2PCA,
84+
full::RSecondaryVertex,
85+
full::DecayLength,
86+
full::DecayLengthXY,
87+
full::DecayLengthNormalised,
88+
full::DecayLengthXYNormalised,
89+
full::ImpactParameterNormalised0,
90+
full::PtProng0,
91+
full::PProng0,
92+
full::ImpactParameterNormalised1,
93+
full::PtProng1,
94+
full::PProng1,
95+
hf_cand::PxProng0,
96+
hf_cand::PyProng0,
97+
hf_cand::PzProng0,
98+
hf_cand::PxProng1,
99+
hf_cand::PyProng1,
100+
hf_cand::PzProng1,
101+
hf_cand::ImpactParameter0,
102+
hf_cand::ImpactParameter1,
103+
hf_cand::ErrorImpactParameter0,
104+
hf_cand::ErrorImpactParameter1,
105+
full::NSigTPCPi0,
106+
full::NSigTPCKa0,
107+
full::NSigTOFPi0,
108+
full::NSigTOFKa0,
109+
full::NSigTPCPi1,
110+
full::NSigTPCKa1,
111+
full::NSigTOFPi1,
112+
full::NSigTOFKa1,
113+
full::CandidateSelFlag,
114+
full::M,
115+
full::ImpactParameterProduct,
116+
full::CosThetaStar,
117+
full::Pt,
118+
full::P,
119+
full::CPA,
120+
full::CPAXY,
121+
full::Ct,
122+
full::Eta,
123+
full::Phi,
124+
full::Y,
125+
full::E,
126+
full::MCflag);
127+
128+
DECLARE_SOA_TABLE(HfCandProng2FullEvents, "AOD", "HFCANDP2FullE",
129+
collision::BCId,
130+
collision::NumContrib,
131+
collision::PosX,
132+
collision::PosY,
133+
collision::PosZ,
134+
full::IsEventReject,
135+
full::RunNumber);
136+
137+
DECLARE_SOA_TABLE(HfCandProng2FullParticles, "AOD", "HFCANDP2FullP",
138+
collision::BCId,
139+
full::Pt,
140+
full::Eta,
141+
full::Phi,
142+
full::Y,
143+
full::MCflag);
144+
145+
} // namespace o2::aod
146+
147+
/// Writes the full information in an output TTree
148+
struct CandidateTreeWriter {
149+
Produces<o2::aod::HfCandProng2Full> rowCandidateFull;
150+
Produces<o2::aod::HfCandProng2FullEvents> rowCandidateFullEvents;
151+
Produces<o2::aod::HfCandProng2FullParticles> rowCandidateFullParticles;
152+
void init(InitContext const&)
153+
{
154+
}
155+
using CandType = soa::Join<aod::HfCandProng2, aod::HfCandProng2MCRec, aod::HFSelD0Candidate>;
156+
void process(aod::Collisions const& collisions,
157+
aod::McCollisions const& mccollisions,
158+
CandType const& candidates,
159+
soa::Join<aod::McParticles, aod::HfCandProng2MCGen> const& particles,
160+
aod::BigTracksPID const& tracks)
161+
{
162+
163+
// Filling event properties
164+
rowCandidateFullEvents.reserve(collisions.size());
165+
for (auto& collision : collisions) {
166+
rowCandidateFullEvents(
167+
collision.bcId(),
168+
collision.numContrib(),
169+
collision.posX(),
170+
collision.posY(),
171+
collision.posZ(),
172+
0,
173+
1);
174+
}
175+
176+
// Filling candidate properties
177+
rowCandidateFull.reserve(candidates.size());
178+
for (auto& candidate : candidates) {
179+
auto fillTable = [&](int CandFlag,
180+
int FunctionSelection,
181+
double FunctionInvMass,
182+
double FunctionCosThetaStar,
183+
double FunctionCt,
184+
double FunctionY,
185+
double FunctionE) {
186+
if (FunctionSelection >= 1) {
187+
rowCandidateFull(
188+
candidate.index0_as<aod::BigTracksPID>().collision().bcId(),
189+
candidate.index0_as<aod::BigTracksPID>().collision().numContrib(),
190+
candidate.posX(),
191+
candidate.posY(),
192+
candidate.posZ(),
193+
candidate.xSecondaryVertex(),
194+
candidate.ySecondaryVertex(),
195+
candidate.zSecondaryVertex(),
196+
candidate.errorDecayLength(),
197+
candidate.errorDecayLengthXY(),
198+
candidate.chi2PCA(),
199+
candidate.rSecondaryVertex(),
200+
candidate.decayLength(),
201+
candidate.decayLengthXY(),
202+
candidate.decayLengthNormalised(),
203+
candidate.decayLengthXYNormalised(),
204+
candidate.impactParameterNormalised0(),
205+
candidate.ptProng0(),
206+
RecoDecay::P(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()),
207+
candidate.impactParameterNormalised1(),
208+
candidate.ptProng1(),
209+
RecoDecay::P(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()),
210+
candidate.pxProng0(),
211+
candidate.pyProng0(),
212+
candidate.pzProng0(),
213+
candidate.pxProng1(),
214+
candidate.pyProng1(),
215+
candidate.pzProng1(),
216+
candidate.impactParameter0(),
217+
candidate.impactParameter1(),
218+
candidate.errorImpactParameter0(),
219+
candidate.errorImpactParameter1(),
220+
candidate.index0_as<aod::BigTracksPID>().tpcNSigmaPi(),
221+
candidate.index0_as<aod::BigTracksPID>().tpcNSigmaKa(),
222+
candidate.index0_as<aod::BigTracksPID>().tofNSigmaPi(),
223+
candidate.index0_as<aod::BigTracksPID>().tofNSigmaKa(),
224+
candidate.index1_as<aod::BigTracksPID>().tpcNSigmaPi(),
225+
candidate.index1_as<aod::BigTracksPID>().tpcNSigmaKa(),
226+
candidate.index1_as<aod::BigTracksPID>().tofNSigmaPi(),
227+
candidate.index1_as<aod::BigTracksPID>().tofNSigmaKa(),
228+
1 << CandFlag,
229+
FunctionInvMass,
230+
candidate.impactParameterProduct(),
231+
FunctionCosThetaStar,
232+
candidate.pt(),
233+
candidate.p(),
234+
candidate.cpa(),
235+
candidate.cpaXY(),
236+
FunctionCt,
237+
candidate.eta(),
238+
candidate.phi(),
239+
FunctionY,
240+
FunctionE,
241+
candidate.flagMCMatchRec());
242+
}
243+
};
244+
245+
fillTable(0, candidate.isSelD0(), InvMassD0(candidate), CosThetaStarD0(candidate), CtD0(candidate), YD0(candidate), ED0(candidate));
246+
fillTable(1, candidate.isSelD0bar(), InvMassD0bar(candidate), CosThetaStarD0bar(candidate), CtD0(candidate), YD0(candidate), ED0(candidate));
247+
}
248+
249+
// Filling particle properties
250+
rowCandidateFullParticles.reserve(particles.size());
251+
for (auto& particle : particles) {
252+
if (std::abs(particle.flagMCMatchGen()) == 1 << D0ToPiK) {
253+
rowCandidateFullParticles(
254+
particle.mcCollision().bcId(),
255+
particle.pt(),
256+
particle.eta(),
257+
particle.phi(),
258+
RecoDecay::Y(array{particle.px(), particle.py(), particle.pz()}, RecoDecay::getMassPDG(particle.pdgCode())),
259+
particle.flagMCMatchGen());
260+
}
261+
}
262+
}
263+
};
264+
265+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
266+
{
267+
WorkflowSpec workflow;
268+
workflow.push_back(adaptAnalysisTask<CandidateTreeWriter>("hf-tree-creator-d0-tokpi"));
269+
return workflow;
270+
}

0 commit comments

Comments
 (0)