Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:23

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef JETVALIDATIONTC_H
0004 #define JETVALIDATIONTC_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 #include <jetbase/Jetv1.h>
0008 #include <jetbase/Jetv2.h>
0009 
0010 #include <string>
0011 #include <vector>
0012 
0013 #include <TFile.h>
0014 #include <TH1F.h>
0015 #include <TH2D.h>
0016 
0017 
0018 class PHCompositeNode;
0019 class TTree;
0020 class Fun4AllHistoManager;
0021 
0022 class JetValidationTC : public SubsysReco
0023 {
0024  public:
0025 
0026   JetValidationTC(const std::string &recojetname = "AntiKt_Tower_r04",
0027         const std::string &truthjetname = "AntiKt_Truth_r04",
0028         const std::string &outputfilename = "myjetanalysis.root");
0029 
0030   ~JetValidationTC() override;
0031 
0032   void
0033     setEtaRange(double low, double high)
0034   {
0035     m_etaRange.first = low;
0036     m_etaRange.second = high;
0037   }
0038  void
0039    setPtRange(double low, double high)
0040  {
0041    m_ptRange.first = low;
0042    m_ptRange.second = high;
0043  }
0044  void
0045    doTruth(int flag)
0046  {
0047    m_doTruthJets = flag;
0048  }
0049  void
0050    doSeeds(int flag)
0051  {
0052    m_doSeeds = flag;
0053  }
0054  void
0055    doUnsub(int flag)
0056  {
0057    m_doUnsubJet = flag;
0058  }
0059 
0060  void doClusters(int flag) 
0061  {
0062   m_doClusters = flag;
0063  }
0064 
0065 void setJetPtThreshold(float pt = 10.){
0066   m_pi0_jetThreshold = pt;
0067 }
0068 
0069 void setMinClusterE(float e) {
0070   m_minClusterE = e;
0071 }
0072 
0073 void setMinPhotonProb(float e) {
0074   m_minPhotonProb = e;
0075 }
0076 
0077 void setMinClusterDeltaR(float R = 0.08) {
0078   m_mindR = R;
0079 }
0080 
0081 void setHistoFileName(std::string name = "default_histos.root") {
0082   m_histoFileName = name;
0083 }
0084 
0085 void setMaxdR(float dR = 0.4) {
0086   m_maxdR = dR;
0087 }
0088 
0089 void setClusterType(std::string type = "TOPOCLUSTER_EMCAL"){
0090   m_clusterType = type;
0091 }
0092 
0093 void removeClustersInJets(int flag = 0){
0094   m_removeJetClusters = flag;
0095 }
0096 
0097 void findJetPions(Jet* jet);
0098 
0099 void reconstruct_pi0s(PHCompositeNode *topNode);
0100 
0101   /** Called during initialization.
0102       Typically this is where you can book histograms, and e.g.
0103       register them to Fun4AllServer (so they can be output to file
0104       using Fun4AllServer::dumpHistos() method).
0105    */
0106   int Init(PHCompositeNode *topNode) override;
0107 
0108   /** Called for first event when run number is known.
0109       Typically this is where you may want to fetch data from
0110       database, because you know the run number. A place
0111       to book histograms which have to know the run number.
0112    */
0113   int InitRun(PHCompositeNode *topNode) override;
0114 
0115   /** Called for each event.
0116       This is where you do the real work.
0117    */
0118   int process_event(PHCompositeNode *topNode) override;
0119 
0120   /// Clean up internals after each event.
0121   int ResetEvent(PHCompositeNode *topNode) override;
0122 
0123   /// Called at the end of each run.
0124   int EndRun(const int runnumber) override;
0125 
0126   /// Called at the end of all processing.
0127   int End(PHCompositeNode *topNode) override;
0128 
0129   /// Reset
0130   int Reset(PHCompositeNode * /*topNode*/) override;
0131 
0132   void Print(const std::string &what = "ALL") const override;
0133 
0134  private:
0135   Fun4AllHistoManager *hm;
0136   TFile *outfile{nullptr};
0137 
0138 
0139   std::string m_recoJetName;
0140   std::string m_truthJetName;
0141   std::string m_outputFileName;
0142   std::string m_histoFileName;
0143   std::pair<double, double> m_etaRange;
0144   std::pair<double, double> m_ptRange;
0145   int m_doTruthJets;
0146   int m_doSeeds;
0147   int m_doUnsubJet;
0148   int m_doClusters;
0149   int m_removeJetClusters;
0150 
0151 
0152   //! Output Tree variables
0153   TTree *m_T;
0154 
0155   //! eventwise quantities
0156   int m_event;
0157   int m_nTruthJet;
0158   int m_nJet;
0159   float m_totalCalo;
0160   int m_centrality;
0161   float m_impactparam;
0162   float m_zvtx;
0163   int m_hasJetAboveThreshold;
0164 
0165   //! reconstructed jets
0166   std::vector<int> m_id;
0167   std::vector<int> m_nComponent;
0168   std::vector<float> m_eta;
0169   std::vector<float> m_phi;
0170   std::vector<float> m_e;
0171   std::vector<float> m_pt;
0172   std::vector<float> m_zg;
0173   std::vector<float> m_rg;
0174   std::vector<float> m_Et;
0175 
0176   //pi0 reco quantities
0177   float m_minClusterE;
0178   float m_minPhotonProb;
0179   float m_mindR;
0180   std::string m_clusterType;
0181 
0182   TH1F *h_pi0M;
0183   TH1F *h_npions;
0184   TH2F *h_eta_phi_clusters; //eta phi dist. of clusters used for pi0 reco
0185   TH1F *h_jetPionMult;
0186   TH1F *h_photonEnergy;
0187 
0188 
0189   int nclus;
0190 
0191   std::vector<float> cluster_energy;
0192   std::vector<float> cluster_eta;
0193   std::vector<float> cluster_phi;
0194   std::vector<float> cluster_prob;
0195   std::vector<float> cluster_chi2;
0196 
0197   int m_npi0;
0198 
0199   std::vector<float> pi0cand_pt;
0200   std::vector<float> pi0cand_eta;
0201   std::vector<float> pi0cand_phi;
0202   std::vector<float> pi0cand_mass;
0203   std::vector<float> pi0cand_energy;
0204 
0205   float m_maxdR; // the maximum distance between candidate pions and jet axes
0206   int m_nPionJets; //the number of jets containing at least one pi0
0207   std::vector<int> m_jetPionMult; //how many pions in each jet?
0208   std::vector<float> m_pionZ; //fraction of jet pT carried by pions
0209   std::vector<float> m_jetPionPt;
0210   std::vector<float> m_jetPionMass;
0211   std::vector<float> m_jetPionEta;
0212   std::vector<float> m_jetPionPhi;
0213   std::vector<float> m_jetPionEnergy;
0214   //std::vector<float> m_pionMassJetsRemoved; //pi0 invariant mass after candidate within jets are removed
0215 
0216   std::vector<float> m_constE; //jet constituent energy, either inclusive, or split between emcal and hcal TCs
0217   std::vector<float> m_hcalE; 
0218   std::vector<float> m_ecalE;
0219 
0220   std::vector<std::vector<float>> m_constEt; //jet constituent transverse energy, either inclusive, or split between emcal and hcal TCs
0221   std::vector<std::vector<float>> m_cluster_hcalEt; 
0222   std::vector<std::vector<float>> m_cluster_ecalEt;
0223 
0224   //Topo-Cluster variables
0225   std::vector<float> m_fe; //EMCal signal ratio
0226   std::vector<float> m_fh; //HCal signal ratio
0227   std::vector<float> m_fEt_emcal; //same ratios but with transverse energy
0228   std::vector<float> m_fEt_hcal;
0229   std::vector<float> m_Et_emcal; //Summed transverse energy for each calorimeter
0230   std::vector<float> m_Et_hcal;
0231   std::vector<int> m_emcal_cluster_mult;
0232   std::vector<int> m_hcal_cluster_mult;
0233   std::vector<int> m_cluster_mult;
0234 
0235   float m_pi0_jetThreshold;
0236 
0237   //towers from clusters
0238   std::vector<float> m_ClusterTowE;
0239 
0240 
0241 
0242   //! unsubtracted jets
0243   std::vector<float> m_unsub_pt;
0244   std::vector<float> m_sub_et;
0245 
0246   //! truth jets
0247   std::vector<int> m_truthID;
0248   std::vector<int> m_truthNComponent;
0249   std::vector<float> m_truthEta;
0250   std::vector<float> m_truthPhi;
0251   std::vector<float> m_truthE;
0252   std::vector<float> m_truthPt;
0253   std::vector<float> m_truthdR;
0254 
0255   //! seed jets
0256   std::vector<float> m_eta_rawseed;
0257   std::vector<float> m_phi_rawseed;
0258   std::vector<float> m_pt_rawseed;
0259   std::vector<float> m_e_rawseed;
0260   std::vector<int> m_rawseed_cut;
0261   std::vector<float> m_eta_subseed;
0262   std::vector<float> m_phi_subseed;
0263   std::vector<float> m_pt_subseed;
0264   std::vector<float> m_e_subseed;
0265   std::vector<int> m_subseed_cut;
0266 
0267   std::vector <int> m_triggers;
0268 };
0269 
0270 #endif // JETVALIDATIONTC_H