Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:24

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef TRUTHJETTAGGING_H
0004 #define TRUTHJETTAGGING_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 #include <g4jets/Jet.h>
0008 #include <g4jets/Jetv1.h>
0009 #include <g4main/PHG4TruthInfoContainer.h>
0010 
0011 #pragma GCC diagnostic push
0012 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0013 #include <HepMC/GenEvent.h>
0014 #include <HepMC/GenVertex.h>
0015 #pragma GCC diagnostic pop
0016 #include <phhepmc/PHHepMCGenEvent.h>
0017 #include <phhepmc/PHHepMCGenEventMap.h>
0018 #include <string>
0019 #include <vector>
0020 class PHCompositeNode;
0021 
0022 class TruthJetTagging : public SubsysReco
0023 {
0024  public:
0025 
0026   TruthJetTagging(const std::string &name = "TruthJetTagging");
0027 
0028   ~TruthJetTagging() override;
0029 
0030   /** Called during initialization.
0031       Typically this is where you can book histograms, and e.g.
0032       register them to Fun4AllServer (so they can be output to file
0033       using Fun4AllServer::dumpHistos() method).
0034    */
0035   int Init(PHCompositeNode *topNode) override;
0036 
0037   /** Called for first event when run number is known.
0038       Typically this is where you may want to fetch data from
0039       database, because you know the run number. A place
0040       to book histograms which have to know the run number.
0041    */
0042   int InitRun(PHCompositeNode *topNode) override;
0043 
0044   /** Called for each event.
0045       This is where you do the real work.
0046    */
0047   int process_event(PHCompositeNode *topNode) override;
0048 
0049   /// Clean up internals after each event.
0050   int ResetEvent(PHCompositeNode *topNode) override;
0051 
0052   /// Called at the end of each run.
0053   int EndRun(const int runnumber) override;
0054 
0055   /// Called at the end of all processing.
0056   int End(PHCompositeNode *topNode) override;
0057 
0058   /// Reset
0059   int Reset(PHCompositeNode * /*topNode*/) override;
0060 
0061   void Print(const std::string &what = "ALL") const override;
0062   
0063 
0064 
0065   void add_algo(std::string algoname)
0066   {
0067     _algorithms.push_back(algoname);
0068   }
0069  
0070   void add_radius(float radius)
0071   {
0072     _radii.push_back(radius);
0073   } 
0074   void do_photon_tagging(bool dotag)
0075   {
0076     _do_photon_tagging = dotag;
0077   }
0078   void do_hf_tagging(bool dotag)
0079   {
0080     _do_hf_tagging = dotag;
0081   }
0082   void set_embedding_id(int id)
0083   {
0084     _embedding_id = id;
0085   }
0086 
0087  float
0088   deltaR(float eta1, float eta2, float phi1, float phi2)
0089   {
0090     float deta = eta1 - eta2;
0091     float dphi = phi1 - phi2;
0092     if (dphi > +3.14159)
0093       dphi -= 2 * 3.14159;
0094     if (dphi < -3.14159)
0095       dphi += 2 * 3.14159;
0096 
0097     return sqrt(pow(deta, 2) + pow(dphi, 2));
0098 
0099   }
0100 
0101 
0102 
0103   float TruthPhotonTagging(PHG4TruthInfoContainer* truthnode, Jet* tjet);
0104   int hadron_tagging(Jet* this_jet, HepMC::GenEvent* theEvent, const double match_radius);
0105 
0106 
0107  private:
0108 
0109   std::vector<std::string> _algorithms;
0110   std::vector<float> _radii;
0111   bool _do_photon_tagging;
0112   bool _do_hf_tagging;
0113   int _embedding_id;
0114 
0115 };
0116 
0117 #endif // TRUTHJETTAGGING_H