Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:16

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef CALORIMETERTOWERENC_H
0004 #define CALORIMETERTOWERENC_H
0005 
0006 #include <fun4all/Fun4AllBase.h>
0007 #include <fun4all/SubsysReco.h>
0008 #include <fun4all/Fun4AllReturnCodes.h>
0009 
0010 #include <phool/PHCompositeNode.h>
0011 #include <phool/getClass.h>
0012 
0013 #include <g4eval/JetTruthEval.h>
0014 
0015 #include <calobase/TowerInfoContainer.h>
0016 #include <calobase/TowerInfoContainerv1.h>
0017 #include <calobase/TowerInfoContainerv2.h>
0018 #include <calobase/TowerInfov2.h>
0019 #include <calobase/TowerInfov1.h>
0020 #include <calobase/TowerInfo.h>
0021 #include <calobase/RawTowerDefs.h>
0022 #include <calobase/RawTowerContainer.h>
0023 #include <calobase/RawTowerGeomContainer.h>
0024 #include <calobase/RawTowerGeomContainer_Cylinderv1.h>
0025 //#include <calobase/DeadHotMapLoader.h>
0026 
0027 #include <g4main/PHG4Particle.h>
0028 #include <g4main/PHG4Hit.h>
0029 #include <g4main/PHG4TruthInfoContainer.h>
0030 
0031 #include <jetbase/JetContainer.h>
0032 #include <jetbase/JetContainerv1.h>
0033 #include <jetbase/JetMapv1.h>
0034 #include <jetbase/JetMap.h>
0035 #include <jetbase/Jetv1.h>
0036 #include <jetbase/Jetv2.h>
0037 #include <jetbase/Jet.h> 
0038 
0039 #include <TH1.h>
0040 #include <TTree.h>
0041 #include <TH2.h>
0042 #include <TFile.h>
0043 
0044 #include <string>
0045 #include <cstdio>
0046 #include <vector>
0047 #include <map>
0048 #include <utility>
0049 #include <unordered_set>
0050 #include <set>
0051 #include <thread>
0052 #include <cfloat>
0053 #include <cmath>
0054 
0055 #include "MethodHistograms.h" 
0056 
0057 class PHCompositeNode;
0058 class Jet; 
0059 class JetContainer; 
0060 class PHG4Hit;
0061 class PHG4Particle; 
0062 class PHG4Shower;
0063 class PHG4TruthInfoContainer;
0064 class JetTruthEval; 
0065 
0066 #define PI 3.1415926535
0067 class CalorimeterTowerENC : public SubsysReco
0068 {
0069  public:
0070 
0071     CalorimeterTowerENC(int n_run, int n_segment, float jet_min=1.0, const std::string &name = "CalorimeterTowerENC");
0072 
0073     ~CalorimeterTowerENC() override {};
0074 
0075   /** Called during initialization.
0076       Typically this is where you can book histograms, and e.g.
0077       register them to Fun4AllServer (so they can be output to file
0078       using Fun4AllServer::dumpHistos() method).
0079    */
0080     int Init(PHCompositeNode *topNode) override;
0081 
0082   /** Called for first event when run number is known.
0083       Typically this is where you may want to fetch data from
0084       database, because you know the run number. A place
0085       to book histograms which have to know the run number.
0086    */
0087     int InitRun(PHCompositeNode *topNode) override {return 0;};
0088 
0089   /** Called for each event.
0090       This is where you do the real work.
0091    */
0092     int process_event(PHCompositeNode *topNode) override;
0093     std::pair<std::map<float, std::map<float, int>>, std::pair<float, float>> GetTowerMaps(RawTowerGeomContainer_Cylinderv1*, RawTowerDefs::CalorimeterId, TowerInfoContainer*);
0094     float getPt(PHG4Particle*);
0095     float getR(std::pair<float, float>, std::pair<float, float>);
0096     void GetENCCalo(std::map<int, float>, RawTowerGeomContainer_Cylinderv1*, TowerInfoContainer*, MethodHistograms*, float);
0097     void GetENCCalo(PHCompositeNode*, std::unordered_set<int>, TowerInfoContainer*, RawTowerGeomContainer_Cylinderv1*, RawTowerDefs::CalorimeterId, float,  std::string, int, float, std::map<int, float>*); 
0098     void GetE2C(PHCompositeNode*, std::unordered_set<int>, std::unordered_set<int>, std::unordered_set<int>, float);
0099     void GetE2C(PHCompositeNode*, std::map<PHG4Particle*, std::pair<float, float>>);
0100     void GetE3C(PHCompositeNode*, std::unordered_set<int>, std::unordered_set<int>, std::unordered_set<int>, std::map<int, float>*, bool, float);
0101     void GetE3C(PHCompositeNode*, std::map<PHG4Particle*, std::pair<float, float>>);
0102     int GetTowerNumber(std::pair<float, float>, std::map<float, std::map<float, int>>, std::pair<float, float>);
0103     int RecordHits(PHCompositeNode* topNode, Jet*, std::vector<std::unordered_set<int>>);   
0104     std::map<std::pair<float, float>, std::vector<std::unordered_set<int>>> FindAntiKTTowers(PHCompositeNode*);
0105     std::map<Jet*, std::pair<float, float>> MatchKtTowers(std::map<std::pair<float, float>, std::vector<std::unordered_set<int>>>, JetContainer*); 
0106     //This is returning a map of jet axes with a set of towers that correspond to that jet for each calo, EM, IH, OH
0107   /// Clean up internals after each event.
0108     int ResetEvent(PHCompositeNode *topNode) override {return 0;};
0109 
0110   /// Called at the end of each run.
0111     int EndRun(const int runnumber) override {return 0;};
0112 
0113   /// Called at the end of all processing.
0114     int End(PHCompositeNode *topNode) override;
0115 
0116   /// Reset
0117     int Reset(PHCompositeNode * /*topNode*/) override {return 0;};
0118 
0119     void Print(const std::string &what = "ALL") const override;
0120     std::string outfilename="";
0121 
0122  private:
0123     int n_evts=0, Nj=1;
0124     float jet_cutoff=1.0; 
0125     TH2F *jethits, *comptotows, *calojethits; //phi-eta hit map and correlation plots for cross checks
0126     //JetTruthEval* truth_evaluater;
0127     MethodHistograms *Particles, *EMCal, *IHCal, *OHCal, *EMCalKT, *IHCalKT, *OHCalKT, *AllCal, *AllCalKT;
0128     TH1F* number_of_jets, *EM_energy, *OH_energy, *IH_energy;
0129     std::map<std::string, MethodHistograms*> histogram_map; 
0130     std::pair< std::map<float, std::map<float, int>>, std::pair<float, float>> EMCALMAP, IHCALMAP, OHCALMAP;
0131     std::map<int, int> emcal_lookup;
0132     std::map<int, std::vector<int>> hcal_lookup;
0133 };
0134 
0135 #endif // CALORIMETERTOWERENC_H