Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:21:37

0001 #ifndef MYJETANALYSIS_H
0002 #define MYJETANALYSIS_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 
0006 #include <g4eval/JetEvalStack.h>
0007 
0008 #include <array>
0009 #include <limits>
0010 #include <memory>
0011 #include <string>
0012 #include <utility>  // std::pair, std::make_pair
0013 
0014 class PHCompositeNode;
0015 class TTree;
0016 class TH1;
0017 
0018 /// \class MyJetAnalysis
0019 class MyJetAnalysis : public SubsysReco
0020 {
0021  public:
0022   MyJetAnalysis(
0023       const std::string &recojetname = "AntiKt_Tower_r04",
0024       const std::string &truthjetname = "AntiKt_Truth_r04",
0025       const std::string &outputfilename = "myjetanalysis.root");
0026 
0027   ~MyJetAnalysis() override = default;
0028 
0029   //! set eta range
0030   void
0031   setEtaRange(double low, double high)
0032   {
0033     m_etaRange.first = low;
0034     m_etaRange.second = high;
0035   }
0036   //! set eta range
0037   void
0038   setPtRange(double low, double high)
0039   {
0040     m_ptRange.first = low;
0041     m_ptRange.second = high;
0042   }
0043   void use_initial_vertex(const bool b = true) {initial_vertex = b;}
0044   int Init(PHCompositeNode *topNode) override;
0045   int InitRun(PHCompositeNode *topNode) override;
0046   int process_event(PHCompositeNode *topNode) override;
0047   int End(PHCompositeNode *topNode) override;
0048 
0049  private:
0050   //! cache the jet evaluation modules
0051   std::shared_ptr<JetEvalStack> m_jetEvalStack;
0052 
0053   std::string m_recoJetName;
0054   std::string m_truthJetName;
0055   std::string m_outputFileName;
0056 
0057   //! eta range
0058   std::pair<double, double> m_etaRange;
0059 
0060   //! pT range
0061   std::pair<double, double> m_ptRange;
0062 
0063   //! flag to use initial vertex in track evaluator
0064   bool initial_vertex = false;
0065 
0066   //! max track-jet matching radius
0067   double m_trackJetMatchingRadius = std::numeric_limits<float>::signaling_NaN();
0068 
0069   //! Output histograms
0070   TH1 *m_hInclusiveE = nullptr;
0071   TH1 *m_hInclusiveEta = nullptr;
0072   TH1 *m_hInclusivePhi = nullptr;
0073 
0074   //! Output Tree variables
0075   TTree *m_T = nullptr;
0076 
0077   int m_event = -1;
0078   int m_id = -1;
0079   int m_nComponent = -1;
0080   float m_eta = std::numeric_limits<float>::signaling_NaN();
0081   float m_phi = std::numeric_limits<float>::signaling_NaN();
0082   float m_e = std::numeric_limits<float>::signaling_NaN();
0083   float m_pt = std::numeric_limits<float>::signaling_NaN();
0084 
0085   int m_truthID = -1;
0086   int m_truthNComponent = -1;
0087   float m_truthEta = std::numeric_limits<float>::signaling_NaN();
0088   float m_truthPhi = std::numeric_limits<float>::signaling_NaN();
0089   float m_truthE = std::numeric_limits<float>::signaling_NaN();
0090   float m_truthPt = std::numeric_limits<float>::signaling_NaN();
0091 
0092   //! number of matched tracks
0093   int m_nMatchedTrack = -1;
0094 
0095   enum
0096   {
0097     //! max number of tracks
0098     kMaxMatchedTrack = 1000
0099   };
0100   std::array<float, kMaxMatchedTrack> m_trackdR;
0101   std::array<float, kMaxMatchedTrack> m_trackpT;
0102 };
0103 
0104 #endif  // MYJETANALYSIS_H