Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:20:06

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef HFTRACKEFFICIENCY_H
0004 #define HFTRACKEFFICIENCY_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <limits>
0009 #include <string>
0010 #include <utility>
0011 #include <vector>
0012 
0013 class DecayFinderContainerBase;
0014 class PHCompositeNode;
0015 class PHG4TruthInfoContainer;
0016 class PHG4ParticleSvtxMap;
0017 class PHHepMCGenEvent;
0018 class PHHepMCGenEventMap;
0019 class SvtxTrack;
0020 class SvtxTrackMap;
0021 class TFile;
0022 class TTree;
0023 
0024 class HFTrackEfficiency : public SubsysReco
0025 {
0026  public:
0027   explicit HFTrackEfficiency(const std::string &name = "HFTrackEfficiency");
0028 
0029   ~HFTrackEfficiency() override = default;
0030 
0031   int Init(PHCompositeNode *topNode) override;
0032 
0033   int process_event(PHCompositeNode *topNode) override;
0034 
0035   int End(PHCompositeNode *topNode) override;
0036 
0037   void PrintEff();
0038 
0039   void setDFNodeName(const std::string &name) { m_df_module_name = name; }
0040   void setInputTrackMapName(const std::string &what) { m_input_track_map_node_name = what; }
0041   void setOutputTrackMapName(const std::string &what) { m_output_track_map_node_name = what; }
0042   void writeSelectedTrackMap(bool write) { m_write_track_map = write; }
0043   void writeOutputFile(bool write) { m_write_nTuple = write; }
0044   void setOutputFileName(const std::string &what) { m_outfile_name = what; }
0045   void triggerOnDecay(bool trigger) { m_triggerOnDecay = trigger; }
0046   void setTruthRecoMatchingPercentage(float value) { m_truthRecoMatchPercent = value; };
0047 
0048  private:
0049   using Decay = std::vector<std::pair<std::pair<int, int>, int>>;
0050 
0051   bool m_triggerOnDecay{false};
0052 
0053   PHG4TruthInfoContainer *m_truthInfo{nullptr};
0054   PHHepMCGenEventMap *m_geneventmap{nullptr};
0055   PHHepMCGenEvent *m_genevt{nullptr};
0056 
0057   PHG4ParticleSvtxMap *m_dst_truth_reco_map{nullptr};
0058 
0059   DecayFinderContainerBase *m_decayMap{nullptr};
0060   std::string m_df_module_name;
0061 
0062   SvtxTrackMap *m_input_trackMap{nullptr};
0063   SvtxTrackMap *m_output_trackMap{nullptr};
0064   SvtxTrack *m_dst_track{nullptr};
0065   std::string m_input_track_map_node_name;
0066   std::string m_output_track_map_node_name;
0067   std::string outputNodeName;
0068   bool m_write_track_map{false};
0069 
0070   std::string m_outfile_name;
0071   TFile *m_outfile{nullptr};
0072   TTree *m_tree{nullptr};
0073   bool m_write_nTuple{false};
0074 
0075   unsigned int m_counter_allDecays{0};
0076   unsigned int m_counter_acceptedDecays{0};
0077   float m_truthRecoMatchPercent;
0078 
0079   unsigned int m_nDaughters;
0080   std::string m_decay_descriptor;
0081 
0082   bool findTracks(PHCompositeNode *topNode, Decay decay);
0083   void initializeBranches();
0084   void resetBranches();
0085   void getDecayDescriptor();
0086   void getNDaughters();
0087   std::string getParticleName(const int PDGID);
0088   float getParticleMass(const int PDGID);
0089 
0090   static const int m_maxTracks{5};
0091   bool m_all_tracks_reconstructed{false};
0092   float m_true_mother_mass{std::numeric_limits<float>::quiet_NaN()};
0093   float m_reco_mother_mass{std::numeric_limits<float>::quiet_NaN()};
0094   float m_true_mother_pT{std::numeric_limits<float>::quiet_NaN()};
0095   float m_true_mother_p{std::numeric_limits<float>::quiet_NaN()};
0096   float m_true_mother_eta{std::numeric_limits<float>::quiet_NaN()};
0097   float m_min_true_track_pT{std::numeric_limits<float>::max()};
0098   float m_min_reco_track_pT{std::numeric_limits<float>::max()};
0099   float m_max_true_track_pT{std::numeric_limits<float>::min()};  // Apparently min() is still a +ve value
0100   float m_max_reco_track_pT{std::numeric_limits<float>::min()};
0101   bool m_reco_track_exists[m_maxTracks]{false};
0102   bool m_used_truth_reco_map[m_maxTracks]{false};
0103   float m_true_track_pT[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0104   float m_reco_track_pT[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0105   float m_true_track_eta[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0106   float m_reco_track_eta[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0107   float m_true_track_PID[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0108   float m_reco_track_chi2nDoF[m_maxTracks]{std::numeric_limits<float>::quiet_NaN()};
0109   int m_reco_track_silicon_seeds[m_maxTracks]{0};
0110   int m_reco_track_tpc_seeds[m_maxTracks]{0};
0111   float m_primary_vtx_x{std::numeric_limits<float>::quiet_NaN()};
0112   float m_primary_vtx_y{std::numeric_limits<float>::quiet_NaN()};
0113   float m_primary_vtx_z{std::numeric_limits<float>::quiet_NaN()};
0114   float m_secondary_vtx_x{std::numeric_limits<float>::quiet_NaN()};
0115   float m_secondary_vtx_y{std::numeric_limits<float>::quiet_NaN()};
0116   float m_secondary_vtx_z{std::numeric_limits<float>::quiet_NaN()};
0117 };
0118 
0119 #endif  // HFTRACKEFFICIENCY_H