Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:14:47

0001 #ifndef __Proto4ShowerCalib_H__
0002 #define __Proto4ShowerCalib_H__
0003 
0004 #include <TFile.h>
0005 #include <TNtuple.h>
0006 #include <fun4all/SubsysReco.h>
0007 #include <stdint.h>
0008 #include <fstream>
0009 #include <string>
0010 
0011 class PHCompositeNode;
0012 class PHG4HitContainer;
0013 class Fun4AllHistoManager;
0014 class TH1F;
0015 class TTree;
0016 class SvtxEvalStack;
0017 class PHG4Particle;
0018 class RawTowerGeom;
0019 class RawTowerContainer;
0020 class SvtxTrack;
0021 
0022 /// \class Proto4ShowerCalib
0023 class Proto4ShowerCalib : public SubsysReco
0024 {
0025  public:
0026   Proto4ShowerCalib(const std::string &filename = "cemc_ana.root");
0027   virtual ~Proto4ShowerCalib();
0028 
0029   int Init(PHCompositeNode *topNode);
0030   int InitRun(PHCompositeNode *topNode);
0031   int process_event(PHCompositeNode *topNode);
0032   int End(PHCompositeNode *topNode);
0033 
0034   int LoadRecalibMap(const std::string &file);
0035 
0036   void
0037   is_sim(bool b) { _is_sim = b; }
0038   class Eval_Run : public TObject
0039   {
0040    public:
0041     Eval_Run()
0042     {
0043       reset();
0044     }
0045     virtual ~Eval_Run()
0046     {
0047     }
0048 
0049     void
0050     reset()
0051     {
0052       run = -31454;
0053       event = -31454;
0054       beam_mom = -0;
0055       hodo_h = -31454;
0056       hodo_v = -31454;
0057       C2_sum = -31454;
0058 
0059       sum_energy_T = -31454;
0060       EoP = -31454;
0061       truth_y = -31454;
0062       truth_z = -31454;
0063 
0064       valid_hodo_v = false;
0065       valid_hodo_h = false;
0066       trigger_veto_pass = false;
0067       good_temp = false;
0068       good_e = false;
0069       good_data = false;
0070     }
0071 
0072     int run;
0073     int event;
0074 
0075     float beam_mom;
0076 
0077     int hodo_h;
0078     int hodo_v;
0079 
0080     float C2_sum;
0081 
0082     //! sum tower energy after temp correction
0083     float sum_energy_T;
0084     //! sum tower E over P after temp correction
0085     float EoP;
0086 
0087     bool valid_hodo_v;
0088     bool valid_hodo_h;
0089     bool trigger_veto_pass;
0090     bool good_temp;
0091     bool good_e;
0092     bool good_data;
0093 
0094     float truth_y;
0095     float truth_z;
0096 
0097     float beam_2CH_mm;
0098     float beam_2CV_mm;
0099 
0100     ClassDef(Eval_Run, 4)
0101   };
0102 
0103   class Eval_Cluster : public TObject
0104   {
0105    public:
0106     Eval_Cluster()
0107     {
0108       reset();
0109     }
0110 
0111     virtual ~Eval_Cluster()
0112     {
0113     }
0114 
0115     void
0116     reset()
0117     {
0118       max_col = -1;
0119       max_row = -1;
0120       average_col = 0;
0121       average_row = 0;
0122 
0123       sum_E = 0;
0124     }
0125 
0126     void
0127     reweight_clus_pol()
0128     {
0129       if (sum_E > 0)
0130       {
0131         average_col /= sum_E;
0132         average_row /= sum_E;
0133       }
0134       else
0135       {
0136         average_col = -31454;
0137         average_row = -31454;
0138       }
0139     }
0140 
0141     int max_col;
0142     int max_row;
0143 
0144     float average_col;
0145     float average_row;
0146     float sum_E;
0147 
0148     ClassDef(Eval_Cluster, 2)
0149   };
0150 
0151  private:
0152   // calorimeter size
0153   enum
0154   {
0155     n_size = 8
0156   };
0157 
0158   bool _is_sim;
0159 
0160   Fun4AllHistoManager *
0161   get_HistoManager();
0162 
0163   static
0164   std::pair<int, int>
0165   find_max(RawTowerContainer *towers, int cluster_size);
0166 
0167   std::string _filename;
0168 
0169   unsigned long _ievent;
0170 
0171   fstream fdata;
0172 
0173   Eval_Run _eval_run;
0174 
0175   Eval_Cluster _eval_3x3_raw;
0176   Eval_Cluster _eval_5x5_raw;
0177 
0178   Eval_Cluster _eval_1x1_prod;
0179   Eval_Cluster _eval_3x3_prod;
0180   Eval_Cluster _eval_5x5_prod;
0181 
0182   Eval_Cluster _eval_3x3_temp;
0183   Eval_Cluster _eval_5x5_temp;
0184 
0185   Eval_Cluster _eval_3x3_recalib;
0186   Eval_Cluster _eval_5x5_recalib;
0187 
0188   std::map<std::pair<int, int>, double> _recalib_const;
0189 };
0190 
0191 #endif  // __Proto4ShowerCalib_H__