Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFParticle_sPHENIX.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFParticle_sPHENIX.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_KFPARTICLESPHENIX_H
23 #define KFPARTICLESPHENIX_KFPARTICLESPHENIX_H
24 
26 
27 // There is something broken in this package. clang format puts
28 // #include "KFParticle_DST.h" first if there is no space but then
29 // loading KFParticle makes root barf. I have no time to track this down
30 // right now, it must be something in KFParticle_eventReconstruction.h and
31 // the include files it uses (some include guard misfiring?)
32 
33 #include "KFParticle_DST.h"
34 #include "KFParticle_nTuple.h"
35 
36 // sPHENIX stuff
37 #include <fun4all/SubsysReco.h>
38 
39 // KFParticle stuff
40 #include <KFParticle.h>
41 
42 #include <algorithm> // for max
43 #include <memory> // for allocator_traits<>::valu...
44 #include <string>
45 #include <utility> // for pair
46 #include <vector> // for vector
47 
48 class PHCompositeNode;
49 class TFile;
50 
52 {
53  public:
55 
56  explicit KFParticle_sPHENIX(const std::string &name);
57 
58  ~KFParticle_sPHENIX() override = default;
59 
60  int Init(PHCompositeNode *topNode) override;
61 
62  int InitRun(PHCompositeNode *topNode) override;
63 
64  int process_event(PHCompositeNode *topNode) override;
65 
66  int End(PHCompositeNode *topNode) override;
67 
73  void printParticles(const KFParticle &motherParticle,
74  const KFParticle &chosenVertex,
75  const std::vector<KFParticle> &daughterParticles,
76  const std::vector<KFParticle> &intermediateParticles,
77  const int numPVs, const int numTracks);
78 
80 
82 
84 
85  static const int max_particles = 99;
86 
87  void setMotherName(const std::string &mother_name)
88  {
89  m_mother_name = mother_name;
90  m_mother_name_Tools = mother_name;
91  }
92 
93  void useIntermediateName(bool use_intermediate_name) { m_use_intermediate_name = use_intermediate_name; }
94 
95  void hasIntermediateStates(bool has_intermediates)
96  {
97  m_has_intermediates = has_intermediates;
98  m_has_intermediates_nTuple = has_intermediates;
99  m_has_intermediates_sPHENIX = has_intermediates;
100  m_has_intermediates_DST = has_intermediates;
101  }
102 
103  void setNumberOfTracks(int num_tracks)
104  {
105  m_num_tracks = num_tracks;
106  m_num_tracks_nTuple = num_tracks;
107  }
108 
109  void setNumberTracksFromIntermeditateState(const std::vector<int> &num_tracks)
110  {
111  for (unsigned int i = 0; i < num_tracks.size(); ++i)
112  {
113  m_num_tracks_from_intermediate.push_back(num_tracks[i]);
114  m_num_tracks_from_intermediate_nTuple.push_back(num_tracks[i]);
115  }
116  }
117 
118  void setNumberOfIntermediateStates(int n_intermediates)
119  {
120  m_num_intermediate_states = n_intermediates;
121  m_num_intermediate_states_nTuple = n_intermediates;
122  }
123 
124  void getChargeConjugate(bool get_charge_conjugate)
125  {
126  m_get_charge_conjugate_nTuple = get_charge_conjugate;
127  m_get_charge_conjugate = get_charge_conjugate;
128  }
129 
130  void setDaughters(std::vector<std::pair<std::string, int> /*unused*/> daughter_list)
131  {
132  for (unsigned int i = 0; i < daughter_list.size(); ++i)
133  {
134  m_daughter_name.push_back(daughter_list[i].first);
135  m_daughter_charge.push_back(daughter_list[i].second);
136  }
137  }
138 
139  void setIntermediateStates(std::vector<std::pair<std::string, int> /*unused*/> intermediate_list)
140  {
141  for (unsigned int i = 0; i < intermediate_list.size(); ++i)
142  {
143  m_intermediate_name_ntuple.push_back(intermediate_list[i].first);
144  m_intermediate_name.push_back(intermediate_list[i].first);
145  m_intermediate_charge.push_back(intermediate_list[i].second);
146  }
147  }
148 
149  void setMinimumMass(float min_mass) { m_min_mass = min_mass; }
150 
151  void setMaximumMass(float max_mass) { m_max_mass = max_mass; }
152 
153  void setDecayTimeRange(float min_decayTime, float max_decayTime)
154  {
155  m_min_decayTime = min_decayTime;
156  m_max_decayTime = max_decayTime;
157  }
158 
159  void setDecayLengthRange(float min_decayLength, float max_decayLength)
160  {
161  m_min_decayLength = min_decayLength;
162  m_max_decayLength = max_decayLength;
163  }
164 
165  void setMinimumTrackPT(float pt) { m_track_pt = pt; }
166 
167  void setMaximumTrackPTchi2(float ptchi2) { m_track_ptchi2 = ptchi2; }
168 
169  void setMinimumTrackIP(float ip) { m_track_ip = ip; }
170 
171  void setMinimumTrackIPchi2(float ipchi2) { m_track_ipchi2 = ipchi2; }
172 
173  void setMaximumTrackchi2nDOF(float trackchi2ndof) { m_track_chi2ndof = trackchi2ndof; }
174 
175  void setMinMVTXhits(int nHits) { m_nMVTXHits = nHits; }
176 
177  void setMinTPChits(int nHits) { m_nTPCHits = nHits; }
178 
180 
181  void setMaximumVertexchi2nDOF(float vertexchi2nDOF) { m_vertex_chi2ndof = vertexchi2nDOF; }
182 
183  void setFlightDistancechi2(float fdchi2) { m_fdchi2 = fdchi2; }
184 
185  void setMinDIRA(float dira_min) { m_dira_min = dira_min; }
186 
187  void setMaxDIRA(float dira_max) { m_dira_max = dira_max; }
188 
189  void setMotherPT(float mother_pt) { m_mother_pt = mother_pt; }
190 
191  void setMotherIPchi2(float mother_ipchi2) { m_mother_ipchi2 = mother_ipchi2; }
192 
193  void setMaximumMotherVertexVolume(float vertexvol) { m_mother_vertex_volume = vertexvol; }
194 
195  void constrainToPrimaryVertex(bool constrain_to_vertex)
196  {
197  m_constrain_to_vertex = constrain_to_vertex;
198  m_constrain_to_vertex_nTuple = constrain_to_vertex;
199  m_constrain_to_vertex_sPHENIX = constrain_to_vertex;
200  }
201 
202  void useFakePrimaryVertex(bool use_fake) { m_use_fake_pv = use_fake; }
203 
204  void allowZeroMassTracks(bool allow) { m_allowZeroMassTracks = allow; }
205 
206  void extraolateTracksToSV(bool extrapolate)
207  {
208  m_extrapolateTracksToSV = extrapolate;
209  m_extrapolateTracksToSV_nTuple = extrapolate;
210  }
211 
212  void constrainIntermediateMasses(bool constrain_int_mass) { m_constrain_int_mass = constrain_int_mass; }
213 
214  void setIntermediateMassRange(std::vector<std::pair<float, float> /*unused*/> intermediate_mass_range)
215  {
216  for (unsigned int i = 0; i < intermediate_mass_range.size(); ++i) m_intermediate_mass_range.push_back(intermediate_mass_range[i]);
217  }
218 
219  void setIntermediateMinPT(const std::vector<float> &intermediate_min_pt)
220  {
221  m_intermediate_min_pt = intermediate_min_pt;
222  }
223 
224  void setIntermediateMinIP(const std::vector<float> &intermediate_min_IP)
225  {
226  for (unsigned int i = 0; i < intermediate_min_IP.size(); ++i) m_intermediate_min_ip.push_back(intermediate_min_IP[i]);
227  }
228 
229  void setIntermediateIPRange(const std::vector<std::pair<float, float> /*unused*/> &intermediate_IP_range)
230  {
231  for (unsigned int i = 0; i < intermediate_IP_range.size(); ++i)
232  {
233  m_intermediate_min_ip.push_back(intermediate_IP_range[i].first);
234  m_intermediate_max_ip.push_back(intermediate_IP_range[i].second);
235  }
236  }
237 
238  void setIntermediateMinIPchi2(const std::vector<float> &intermediate_min_IPchi2)
239  {
240  for (unsigned int i = 0; i < intermediate_min_IPchi2.size(); ++i) m_intermediate_min_ipchi2.push_back(intermediate_min_IPchi2[i]);
241  }
242 
243  void setIntermediateIPchi2Range(const std::vector<std::pair<float, float> /*unused*/> &intermediate_IPchi2_range)
244  {
245  for (unsigned int i = 0; i < intermediate_IPchi2_range.size(); ++i)
246  {
247  m_intermediate_min_ipchi2.push_back(intermediate_IPchi2_range[i].first);
248  m_intermediate_max_ipchi2.push_back(intermediate_IPchi2_range[i].second);
249  }
250  }
251 
252  void setIntermediateMinDIRA(const std::vector<float> &intermediate_min_DIRA)
253  {
254  for (unsigned int i = 0; i < intermediate_min_DIRA.size(); ++i) m_intermediate_min_dira.push_back(intermediate_min_DIRA[i]);
255  }
256 
257  void setIntermediateMinFDchi2(const std::vector<float> &intermediate_min_FDchi2)
258  {
259  for (unsigned int i = 0; i < intermediate_min_FDchi2.size(); ++i) m_intermediate_min_fdchi2.push_back(intermediate_min_FDchi2[i]);
260  }
261 
262  void setIntermediateMaxVertexVolume(const std::vector<float> &intermediate_max_vertexvol)
263  {
264  for (unsigned int i = 0; i < intermediate_max_vertexvol.size(); ++i) m_intermediate_vertex_volume.push_back(intermediate_max_vertexvol[i]);
265  }
266 
267  void useMVA(bool require_mva) { m_require_mva = require_mva; }
268 
269  void setNumMVAPars(unsigned int nPars) { m_nPars = nPars; }
270 
271  void setMVAVarList(std::vector<std::string> mva_variable_list)
272  {
273  for (unsigned int i = 0; i < mva_variable_list.size(); ++i) m_mva_variable_list.push_back(mva_variable_list[i]);
274  }
275 
276  void setMVAType(const std::string &mva_type) { m_mva_type = mva_type; }
277 
278  void setMVAWeightsPath(const std::string &mva_weights_path) { m_mva_path = mva_weights_path; }
279 
280  void setMVACutValue(float cut_value) { m_mva_cut_value = cut_value; }
281 
282  void saveDST(bool save) { m_save_dst = save; }
283 
285 
287 
289 
290  void saveOutput(bool save) { m_save_output = save; }
291 
292  void setOutputName(const std::string &name) { m_outfile_name = name; }
293 
294  void doTruthMatching(bool truth) { m_truth_matching = truth; }
295 
296  void getDetectorInfo(bool detinfo) { m_detector_info = detinfo; }
297 
298  void getCaloInfo(bool caloinfo) { m_calo_info = caloinfo; }
299 
300  void getAllPVInfo(bool pvinfo) { m_get_all_PVs = pvinfo; }
301 
303  void setVertexMapNodeName(const std::string &vtx_map_node_name) { m_vtx_map_node_name = m_vtx_map_node_name_nTuple = vtx_map_node_name; }
304 
306  void setTrackMapNodeName(const std::string &trk_map_node_name) { m_trk_map_node_name = m_trk_map_node_name_nTuple = trk_map_node_name; }
307 
308  private:
315  TFile *m_outfile;
317 };
318 
319 #endif // KFPARTICLESPHENIX_KFPARTICLESPHENIX_H