Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:17:43

0001 #ifndef __ExampleAnalysisModule_H__
0002 #define __ExampleAnalysisModule_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 ExampleAnalysisModule to help you get started
0023 class ExampleAnalysisModule : public SubsysReco
0024 {
0025 
0026 public:
0027 
0028   //! constructor
0029   ExampleAnalysisModule(const std::string &filename = "ExampleAnalysis.root");
0030 
0031   //! destructor
0032   virtual
0033   ~ExampleAnalysisModule();
0034 
0035   //! Standard function called at initialization
0036   int
0037   Init(PHCompositeNode *topNode);
0038 
0039   //! Standard function called when a new run is processed
0040   int
0041   InitRun(PHCompositeNode *topNode);
0042 
0043   //! Standard function called at each event
0044   int
0045   process_event(PHCompositeNode *topNode);
0046 
0047   //! Standard function called at the end of processing. Save your stuff here.
0048   int
0049   End(PHCompositeNode *topNode);
0050 
0051   //! Is processing simulation files?
0052   void
0053   is_sim(bool b)
0054   {
0055     _is_sim = b;
0056   }
0057 
0058   class Eval_Run : public TObject
0059   {
0060   public:
0061     Eval_Run()
0062     {
0063       reset();
0064     }
0065     virtual
0066     ~Eval_Run()
0067     {
0068     }
0069 
0070     void
0071     reset()
0072     {
0073       run = -31454;
0074       event = -31454;
0075       beam_mom = -0;
0076       hodo_h = -31454;
0077       hodo_v = -31454;
0078       C2_sum = -31454;
0079       C1 = -31454;
0080 
0081       valid_hodo_v = false;
0082       valid_hodo_h = false;
0083       trigger_veto_pass = false;
0084       good_e = false;
0085       good_anti_e = false;
0086 
0087       beam_2CH_mm = -31454;
0088       beam_2CV_mm = -31454;
0089 
0090       truth_y = -31454;
0091       truth_z = -31454;
0092 
0093       sum_E_CEMC = -31454;
0094       sum_E_HCAL_OUT = -31454;
0095       sum_E_HCAL_IN = -31454;
0096     }
0097 
0098     int run;
0099     int event;
0100 
0101     //! beam momentum with beam charge
0102     float beam_mom;
0103 
0104     //! hodoscope index
0105     int hodo_h;
0106     int hodo_v;
0107 
0108     //! Cherenkov sums
0109     float C2_sum;
0110     float C1;
0111 
0112     //! has valid hodoscope?
0113     bool valid_hodo_v;
0114     bool valid_hodo_h;
0115 
0116     //! has valid veto counter?
0117     bool trigger_veto_pass;
0118 
0119     //! Good electrons?
0120     bool good_e;
0121 
0122     //! Good hadron and muons?
0123     bool good_anti_e;
0124 
0125     //! 2C motion table positions
0126     float beam_2CH_mm;
0127     float beam_2CV_mm;
0128 
0129     //! Turth beam position. Simulation only.
0130     float truth_y;
0131     float truth_z;
0132 
0133     //! Sum energy of all towers
0134     double sum_E_CEMC;
0135     double sum_E_HCAL_OUT;
0136     double sum_E_HCAL_IN;
0137 
0138   ClassDef(Eval_Run,10)
0139   };
0140 
0141   class Eval_Cluster : public TObject
0142   {
0143   public:
0144     Eval_Cluster()
0145     {
0146       reset();
0147     }
0148 
0149     virtual
0150     ~Eval_Cluster()
0151     {
0152     }
0153 
0154     void
0155     reset()
0156     {
0157       max_col = -1;
0158       max_row = -1;
0159       average_col = 0;
0160       average_row = 0;
0161 
0162       sum_E = 0;
0163     }
0164 
0165     void
0166     reweight_clus_pol()
0167     {
0168       if (sum_E > 0)
0169         {
0170           average_col /= sum_E;
0171           average_row /= sum_E;
0172         }
0173       else
0174         {
0175           average_col = -31454;
0176           average_row = -31454;
0177 
0178         }
0179     }
0180 
0181     //!max hit col
0182     int max_col;
0183     //!max hit row
0184     int max_row;
0185 
0186     //!energy weighted col
0187     float average_col;
0188     //!energy weighted row
0189     float average_row;
0190 
0191     //!sum cluster energy
0192     float sum_E;
0193 
0194   ClassDef(Eval_Cluster,10)
0195   };
0196 
0197 private:
0198 
0199   // calorimeter size
0200   enum
0201   {
0202     n_size = 8
0203   };
0204 
0205   //! is processing simulation files?
0206   bool _is_sim;
0207 
0208   //! get manager of histograms
0209   Fun4AllHistoManager *
0210   get_HistoManager();
0211 
0212   std::pair<int, int>
0213   find_max(RawTowerContainer* towers, int cluster_size);
0214 
0215   //! output root file name
0216   std::string _filename;
0217 
0218   //! simple event counter
0219   unsigned long _ievent;
0220 
0221   //! run infomation. To be copied to output TTree T
0222   Eval_Run _eval_run;
0223 
0224   //! clusters of max 5x5 EMCal cluster. To be copied to output TTree T
0225   Eval_Cluster _eval_5x5_CEMC;
0226 
0227 };
0228 
0229 #endif // __ExampleAnalysisModule_H__