Project
Loading...
Searching...
No Matches
MCUtils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef O2_MCUTILS_H
17#define O2_MCUTILS_H
18
19#include <string>
22#include "TPDGCode.h"
23#include "TParticle.h"
24
25namespace o2
26{
27namespace mcutils
28{
29
33{
34 public:
38 static bool isPhysicalPrimary(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
39
42 static bool isKeepPhysics(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
43 static bool isFromPrimaryDecayChain(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
44
45 // some convenience functions for navigation
46
50 static o2::MCTrack const& getFirstPrimary(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
51
53 static o2::MCTrack const* getMother(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
54
56 static o2::MCTrack const* getDaughter(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
57
59 static o2::MCTrack const* getDaughter0(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
61 static o2::MCTrack const* getDaughter1(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer);
62
65 // static void getParentChain(o2::MCTrack const& p, std::vector<o2::MCTrack> const& pcontainer, std::vector<o2::MCTrack> &ancestorchain);
66
72
74};
75
77{
78 public:
79 // Helper function for users which takes over encoding of status code as well as (re-)setting correct transport bit.
80 // Has to be in a class as a static methid. Just in a namespace it doesn't work to use this function in ROOT macros.
81 static void encodeParticleStatusAndTracking(TParticle& particle, bool wanttracking = true);
82 static void encodeParticleStatusAndTracking(TParticle& particle, int hepmcStatus, int genStatus, bool wanttracking = true);
83 ClassDefNV(MCGenHelper, 1)
84};
85
87inline bool isStable(int pdg)
88{
89 //
90 // Decide whether particle (pdg) is stable
91 //
92
93 // All ions/nucleons are considered as stable
94 // Nuclear code is 10LZZZAAAI
95 if (pdg > 1000000000) {
96 return true;
97 }
98
99 const int kNstable = 18;
100 int pdgStable[kNstable] = {
101 kGamma, // Photon
102 kElectron, // Electron
103 kMuonPlus, // Muon
104 kPiPlus, // Pion
105 kKPlus, // Kaon
106 kK0Short, // K0s
107 kK0Long, // K0l
108 kProton, // Proton
109 kNeutron, // Neutron
110 kLambda0, // Lambda_0
111 kSigmaMinus, // Sigma Minus
112 kSigmaPlus, // Sigma Plus
113 3312, // Xsi Minus
114 3322, // Xsi
115 3334, // Omega
116 kNuE, // Electron Neutrino
117 kNuMu, // Muon Neutrino
118 kNuTau // Tau Neutrino
119 };
120
121 // this is linear search ---> a hash map or binary search should be more appropriate??
122 for (int i = 0; i < kNstable; ++i) {
123 if (pdg == std::abs(pdgStable[i])) {
124 return true;
125 }
126 }
127 return false;
128}
129
130} // namespace mcutils
131} // namespace o2
132
133#endif // O2_MCUTILS_H
int32_t i
Definition of the MCTrack class.
static void encodeParticleStatusAndTracking(TParticle &particle, bool wanttracking=true)
Definition MCUtils.cxx:211
static o2::MCTrack const * getMother(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Given an MCTrack p; Return it's direct mother or nullptr. (we follow only first mother)
Definition MCUtils.cxx:22
static bool isPhysicalPrimary(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Definition MCUtils.cxx:73
ClassDefNV(MCTrackNavigator, 1)
static o2::MCTrack const & getFirstPrimary(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Definition MCUtils.cxx:58
static o2::MCTrack const * getDaughter1(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Given an MCTrack p; Return it's second direct daughter or nullptr.
Definition MCUtils.cxx:49
static bool isFromPrimaryDecayChain(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Definition MCUtils.cxx:171
static o2::MCTrack const * getDaughter(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Given an MCTrack p; Return it's direct daughter or nullptr. (we follow only first daughter)
Definition MCUtils.cxx:31
static o2::MCTrack const * getDaughter0(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Given an MCTrack p; Return it's first direct daughter or nullptr.
Definition MCUtils.cxx:40
static bool isKeepPhysics(o2::MCTrack const &p, std::vector< o2::MCTrack > const &pcontainer)
Definition MCUtils.cxx:189
bool isStable(int pdg)
Determine if a particle (identified by pdg) is stable.
Definition MCUtils.h:87
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...