Back to home page

sPhenix code displayed by LXR

 
 

    


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

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