Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DecayFinder.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DecayFinder.h
1 #ifndef DECAYFINDER_DECAYFINDER_H
2 #define DECAYFINDER_DECAYFINDER_H
3 
4 // sPHENIX stuff
5 #include <fun4all/SubsysReco.h>
6 
7 #include <g4main/PHG4Particle.h>
8 #include <g4main/PHG4VtxPoint.h>
9 
10 #include <cstddef> // for NULL
11 #include <string>
12 #include <utility> // for pair
13 #include <vector>
14 
16 class PHCompositeNode;
18 class PHHepMCGenEvent;
19 class PHHepMCGenEventMap;
20 namespace HepMC
21 {
22  class GenParticle;
23 }
24 
25 class DecayFinder : public SubsysReco
26 {
27  public:
28  using Decay = std::vector<std::pair<std::pair<int, int>, int>>;
29 
30  DecayFinder();
31 
32  explicit DecayFinder(const std::string &name);
33 
34  ~DecayFinder() override = default;
35 
36  int Init(PHCompositeNode *topNode) override;
37 
38  int process_event(PHCompositeNode *topNode) override;
39 
40  int End(PHCompositeNode *topNode) override;
41 
43 
44  bool findDecay(PHCompositeNode *topNode);
45 
46  bool findParticle(const std::string &particle);
47 
48  void searchHepMCRecord(HepMC::GenParticle *particle, std::vector<int> decayProducts,
49  bool &breakLoop, bool &hasPhoton, bool &hasPi0, bool &failedPT, bool &failedETA,
50  std::vector<int> &correctDecayProducts);
51 
52  void searchGeant4Record(int barcode, int pid, std::vector<int> decayProducts,
53  bool &breakLoop, bool &hasPhoton, bool &hasPi0, bool &failedPT, bool &failedETA,
54  std::vector<int> &correctDecayProducts);
55 
56  bool checkIfCorrectHepMCParticle(HepMC::GenParticle *particle, bool &trackFailedPT, bool &trackFailedETA);
57 
58  bool checkIfCorrectGeant4Particle(PHG4Particle *particle, bool &hasPhoton, bool &hasPi0, bool &trackFailedPT, bool &trackFailedETA);
59 
60  bool compareDecays(std::vector<int> required, std::vector<int> actual);
61 
62  int deleteElement(int arr[], int n, int x);
63 
64  void multiplyVectorByScalarAndSort(std::vector<int> &v, int k);
65 
66  int get_pdgcode(const std::string &name);
67 
68  int get_charge(const std::string &name);
69 
70  bool isInRange(float min, float value, float max);
71 
72  int createDecayNode(PHCompositeNode *topNode);
73 
74  void fillDecayNode(PHCompositeNode *topNode, Decay &decay);
75 
76  void printInfo();
77 
78  void printNode(PHCompositeNode *topNode);
79 
80  // User configuration
108  void triggerOnDecay(bool trigger) { m_triggerOnDecay = trigger; }
112  void allowPhotons(bool allow) { m_allowPhotons = allow; }
116  void allowPi0(bool allow) { m_allowPi0 = allow; }
121  void saveDST(bool save) { m_save_dst = save; }
127 
133  void setEtaRange(float min, float max)
134  {
135  m_eta_low_req = min;
136  m_eta_high_req = max;
137  }
138 
143  void setPTmin(float pt) { m_pt_req = pt; }
144 
152 
153  private:
157 
158  void recalculateEta(double py, double vertex[3]);
159  void calculateEffectiveTPCradius(double vertex[3], double &effective_top_r, double &effective_bottom_r);
161  double m_tpc_r = 78.0;
162  double m_tpc_z = 105.0;
165 
166  double m_eta_high_req = 1.1;
167  double m_eta_low_req = -1.1;
168  double m_pt_req = 0.2;
169 
170  int m_counter = 0;
172  int m_nCandFail_pT = 0;
177  int m_nCandHas_Pi0 = 0;
180 
181  bool m_getChargeConjugate = false;
182 
184  bool m_triggerOnDecay = false;
185  bool m_allowPi0 = false;
186  bool m_allowPhotons = false;
187 
188  int m_mother_ID = 0;
189  std::vector<int> m_intermediates_ID;
190  std::vector<int> m_daughters_ID;
191 
193  std::vector<int> m_nTracksFromIntermediates;
194 
195  std::vector<int> m_motherDecayProducts;
196 
202 };
203 
204 #endif // DECAYFINDER_DECAYFINDER_H