|
| 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