File indexing completed on 2025-08-06 08:17:39
0001
0002
0003 #ifndef HFTRACKEFFICIENCY_H
0004 #define HFTRACKEFFICIENCY_H
0005
0006 #include <decayfinder/DecayFinderContainer_v1.h> // for DecayFinderContainer_v1
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 #include <fun4all/SubsysReco.h>
0009 #include <g4main/PHG4Particle.h>
0010 #include <g4main/PHG4TruthInfoContainer.h>
0011 #include <g4main/PHG4VtxPoint.h>
0012 #include <phhepmc/PHHepMCGenEvent.h>
0013 #include <phhepmc/PHHepMCGenEventMap.h>
0014 #include <phool/PHCompositeNode.h>
0015 #include <phool/PHNodeIterator.h>
0016 #include <phool/getClass.h>
0017 #include <trackbase_historic/PHG4ParticleSvtxMap_v1.h>
0018 #include <trackbase_historic/SvtxTrack.h>
0019 #include <trackbase_historic/SvtxTrackMap.h>
0020 #include <trackbase_historic/SvtxTrackMap_v2.h>
0021
0022 #include <CLHEP/Vector/LorentzVector.h>
0023 #include <CLHEP/Vector/ThreeVector.h>
0024
0025 #pragma GCC diagnostic push
0026 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0027 #include <HepMC/GenEvent.h>
0028 #include <HepMC/GenVertex.h> // for GenVertex::particle_iterator
0029 #pragma GCC diagnostic pop
0030
0031 #include <HepMC/GenParticle.h>
0032 #include <HepMC/IteratorRange.h>
0033 #include <HepMC/SimpleVector.h>
0034
0035 #include <TBranch.h>
0036 #include <TDatabasePDG.h>
0037 #include <TFile.h>
0038 #include <TTree.h>
0039
0040 #include <string>
0041
0042 class PHCompositeNode;
0043 class PHG4TruthInfoContainer;
0044 class PHG4Particle;
0045 class PHHepMCGenEvent;
0046 class PHHepMCGenEventMap;
0047
0048 namespace CLHEP
0049 {
0050 class HepLorentzVector;
0051 }
0052
0053 namespace HepMC
0054 {
0055 class GenParticle;
0056 }
0057
0058 class HFTrackEfficiency : public SubsysReco
0059 {
0060 public:
0061 explicit HFTrackEfficiency(const std::string &name = "HFTrackEfficiency");
0062
0063 ~HFTrackEfficiency() override;
0064
0065 int Init(PHCompositeNode *topNode) override;
0066
0067 int process_event(PHCompositeNode *topNode) override;
0068
0069 int End(PHCompositeNode *topNode) override;
0070
0071 void PrintEff();
0072
0073 void setDFNodeName(const std::string &name) { m_df_module_name = name; }
0074 void setInputTrackMapName(const std::string &what) { m_input_track_map_node_name = what; }
0075 void setOutputTrackMapName(const std::string &what) { m_output_track_map_node_name = what; }
0076 void writeSelectedTrackMap(bool write) { m_write_track_map = write; }
0077 void writeOutputFile(bool write) { m_write_nTuple = write; }
0078 void setOutputFileName(const std::string &what) { m_outfile_name = what; }
0079 void triggerOnDecay(bool trigger) { m_triggerOnDecay = trigger; }
0080 void setTruthRecoMatchingPercentage(float value) { m_truthRecoMatchPercent = value; };
0081
0082 private:
0083 using Decay = std::vector<std::pair<std::pair<int, int>, int>>;
0084
0085 bool m_triggerOnDecay;
0086
0087 PHG4TruthInfoContainer *m_truthInfo = nullptr;
0088 PHHepMCGenEventMap *m_geneventmap = nullptr;
0089 PHHepMCGenEvent *m_genevt = nullptr;
0090
0091 PHG4ParticleSvtxMap_v1 *m_dst_truth_reco_map = nullptr;
0092
0093 DecayFinderContainer_v1 *m_decayMap = nullptr;
0094 std::string m_df_module_name;
0095
0096 SvtxTrackMap *m_input_trackMap = nullptr;
0097 SvtxTrackMap *m_output_trackMap = nullptr;
0098 SvtxTrack *m_dst_track = nullptr;
0099 std::string m_input_track_map_node_name;
0100 std::string m_output_track_map_node_name;
0101 std::string outputNodeName;
0102 bool m_write_track_map;
0103
0104 std::string m_outfile_name;
0105 TFile *m_outfile;
0106 TTree *m_tree;
0107 bool m_write_nTuple;
0108
0109 unsigned int m_counter_allDecays = 0;
0110 unsigned int m_counter_acceptedDecays = 0;
0111 float m_truthRecoMatchPercent;
0112
0113 unsigned int m_nDaughters;
0114 std::string m_decay_descriptor;
0115
0116 bool findTracks(PHCompositeNode *topNode, Decay decay);
0117 void initializeBranches();
0118 void resetBranches();
0119 void getDecayDescriptor();
0120 void getNDaughters();
0121 std::string getParticleName(const int PDGID);
0122 float getParticleMass(const int PDGID);
0123
0124 static const int m_maxTracks = 5;
0125 bool m_all_tracks_reconstructed = false;
0126 float m_true_mother_mass = std::numeric_limits<float>::quiet_NaN();
0127 float m_reco_mother_mass = std::numeric_limits<float>::quiet_NaN();
0128 float m_true_mother_pT = std::numeric_limits<float>::quiet_NaN();
0129 float m_true_mother_p = std::numeric_limits<float>::quiet_NaN();
0130 float m_true_mother_eta = std::numeric_limits<float>::quiet_NaN();
0131 float m_min_true_track_pT = std::numeric_limits<float>::max();
0132 float m_min_reco_track_pT = std::numeric_limits<float>::max();
0133 float m_max_true_track_pT = -1. * std::numeric_limits<float>::max();
0134 float m_max_reco_track_pT = -1. * std::numeric_limits<float>::max();
0135 bool m_reco_track_exists[m_maxTracks] = {false};
0136 bool m_used_truth_reco_map[m_maxTracks] = {false};
0137 float m_true_track_pT[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0138 float m_reco_track_pT[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0139 float m_true_track_eta[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0140 float m_reco_track_eta[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0141 float m_true_track_PID[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0142 float m_reco_track_chi2nDoF[m_maxTracks] = {std::numeric_limits<float>::quiet_NaN()};
0143 int m_reco_track_silicon_seeds[m_maxTracks] = {0};
0144 int m_reco_track_tpc_seeds[m_maxTracks] = {0};
0145 float m_primary_vtx_x = std::numeric_limits<float>::quiet_NaN();
0146 float m_primary_vtx_y = std::numeric_limits<float>::quiet_NaN();
0147 float m_primary_vtx_z = std::numeric_limits<float>::quiet_NaN();
0148 float m_secondary_vtx_x = std::numeric_limits<float>::quiet_NaN();
0149 float m_secondary_vtx_y = std::numeric_limits<float>::quiet_NaN();
0150 float m_secondary_vtx_z = std::numeric_limits<float>::quiet_NaN();
0151 };
0152
0153 #endif