Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFParticle_Tools.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFParticle_Tools.h
1 /*
2  * This file is part of KFParticle package
3  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4  * 2007-2019 Goethe University of Frankfurt
5  * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6  * 2007-2019 Maksym Zyzak
7  *
8  * KFParticle is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * KFParticle is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef KFPARTICLESPHENIX_KFPARTICLETOOLS_H
23 #define KFPARTICLESPHENIX_KFPARTICLETOOLS_H
24 
25 #include "KFParticle_MVA.h"
26 
27 #include <KFParticle.h>
28 
29 #include <cfloat>
30 #include <string> // for string
31 #include <tuple> // for tuple
32 #include <utility> // for pair
33 #include <vector>
34 
35 class PHCompositeNode;
36 
37 class SvtxVertexMap;
38 class SvtxTrackMap;
39 class SvtxVertex;
40 class SvtxTrack;
41 
43 {
44  public:
46 
47  ~KFParticle_Tools() override = default;
48 
50 
51  std::vector<KFParticle> makeAllPrimaryVertices(PHCompositeNode *topNode, const std::string &vertexMapName);
52 
54 
55  std::vector<KFParticle> makeAllDaughterParticles(PHCompositeNode *topNode);
56 
57  int getTracksFromVertex(PHCompositeNode *topNode, const KFParticle &vertex, const std::string &vertexMapName);
58 
59  /*const*/ bool isGoodTrack(const KFParticle &particle, const std::vector<KFParticle> &primaryVertices);
60 
61  int calcMinIP(const KFParticle &track, const std::vector<KFParticle> &PVs, float &minimumIP, float &minimumIPchi2);
62 
63  std::vector<int> findAllGoodTracks(std::vector<KFParticle> daughterParticles, const std::vector<KFParticle> &primaryVertices);
64 
65  std::vector<std::vector<int>> findTwoProngs(std::vector<KFParticle> daughterParticles, std::vector<int> goodTrackIndex, int nTracks);
66 
67  std::vector<std::vector<int>> findNProngs(std::vector<KFParticle> daughterParticles,
68  const std::vector<int> &goodTrackIndex,
69  std::vector<std::vector<int>> goodTracksThatMeet,
70  int nRequiredTracks, unsigned int nProngs);
71 
72  std::vector<std::vector<int>> appendTracksToIntermediates(KFParticle intermediateResonances[], std::vector<KFParticle> daughterParticles, const std::vector<int> &goodTrackIndex, int num_remaining_tracks);
73 
75  float eventDIRA(const KFParticle &particle, const KFParticle &vertex);
76 
77  float flightDistanceChi2(const KFParticle &particle, const KFParticle &vertex);
78 
79  std::tuple<KFParticle, bool> buildMother(KFParticle vDaughters[], std::string daughterOrder[], bool isIntermediate, int intermediateNumber, int nTracks, bool constrainMass, float required_vertexID);
80 
81  void constrainToVertex(KFParticle &particle, bool &goodCandidate, KFParticle &vertex);
82 
83  std::tuple<KFParticle, bool> getCombination(KFParticle vDaughters[], std::string daughterOrder[], KFParticle vertex,
84  bool constrain_to_vertex, bool isIntermediate, int intermediateNumber, int nTracks, bool constrainMass, float required_vertexID);
85 
86  std::vector<std::vector<std::string>> findUniqueDaughterCombinations(int start, int end);
87 
88  double calculateEllipsoidRadius(int posOrNeg, double sigma_ii, double sigma_jj, double sigma_ij);
89 
90  float calculateEllipsoidVolume(const KFParticle &particle);
91 
92  float calculateJT(const KFParticle &mother, const KFParticle &daughter);
93 
94  bool isInRange(float min, float value, float max);
95 
96  bool findParticle(const std::string &particle);
97 
98  int getParticleID(const std::string &particle);
99 
100  float getParticleMass(const std::string &particle);
101  float getParticleMass(const int PDGID);
102 
103  void identify(const KFParticle &particle);
104 
105  protected:
109  std::vector<std::string> m_daughter_name;
110  std::vector<int> m_daughter_charge;
111  int m_num_tracks = -1;
112 
114  std::vector<std::string> m_intermediate_name;
115  std::vector<int> m_intermediate_charge;
116  std::vector<std::pair<float, float>> m_intermediate_mass_range;
117  std::vector<float> m_intermediate_min_pt;
118  std::vector<float> m_intermediate_min_dira;
119  std::vector<float> m_intermediate_min_fdchi2;
120  std::vector<float> m_intermediate_min_ip;
121  std::vector<float> m_intermediate_max_ip;
122  std::vector<float> m_intermediate_min_ipchi2;
123  std::vector<float> m_intermediate_max_ipchi2;
124  std::vector<float> m_intermediate_vertex_volume;
125 
126  float m_min_mass = -1;
127 
128  float m_max_mass = -1;
129 
130  float m_min_decayTime = -1;
131 
132  float m_max_decayTime = FLT_MAX;
133 
134  float m_min_decayLength = -1;
135 
136  float m_max_decayLength = FLT_MAX;
137 
138  float m_track_pt = -1;
139 
140  float m_track_ptchi2 = FLT_MAX;
141 
142  float m_track_ip = -1;
143 
144  float m_track_ipchi2 = -1;
145 
146  float m_track_chi2ndof = FLT_MAX;
147 
148  int m_nMVTXHits = 3;
149 
150  int m_nTPCHits = 20;
151 
152  float m_comb_DCA = FLT_MAX;
153 
154  float m_vertex_chi2ndof = FLT_MAX;
155 
156  float m_fdchi2 = -1;
157 
158  float m_dira_min = -1;
159 
160  float m_dira_max = 1;
161 
162  float m_mother_pt = -1;
163 
164  float m_mother_ipchi2 = FLT_MAX;
165 
166  float m_mother_vertex_volume = FLT_MAX;
167 
168  float m_mva_cut_value = -1;
169 
171 
173 
174  bool m_allowZeroMassTracks = false;
175 
181  SvtxTrack *m_dst_track = nullptr;
182 
183  private:
184  void removeDuplicates(std::vector<double> &v);
185  void removeDuplicates(std::vector<int> &v);
186  void removeDuplicates(std::vector<std::vector<int>> &v);
187  void removeDuplicates(std::vector<std::vector<std::string>> &v);
188 };
189 
190 #endif // KFPARTICLESPHENIX_KFPARTICLETOOLS_H