Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:32

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef CALOTREEGEN_H
0004 #define CALOTREEGEN_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <string>
0009 #include <vector>
0010 #include <TTree.h>
0011 #include <fstream>
0012 
0013 class TTree;
0014 class PHCompositeNode;
0015 class Fun4AllHistoManager;
0016 class TFile;
0017 class RawCluster;
0018 class TowerInfoContainer;
0019 
0020 class caloTreeGen : public SubsysReco
0021 {
0022  public:
0023 
0024   caloTreeGen(const std::string &name="caloTreeGen",
0025               const std::string &eventFile="test.json",
0026               const int eventNumber = 0,
0027               const int runid = 0,
0028               const float tow_cemc_min = 0,
0029               const float tow_hcalin_min = 0,
0030               const float tow_hcalout_min = 0);
0031 
0032   ~caloTreeGen() override;
0033 
0034   /** Called during initialization.
0035       Typically this is where you can book histograms, and e.g.
0036       register them to Fun4AllServer (so they can be output to file
0037       using Fun4AllServer::dumpHistos() method).
0038   */
0039   int Init(PHCompositeNode *topNode) override;
0040 
0041   /** Called for first event when run number is known.
0042       Typically this is where you may want to fetch data from
0043       database, because you know the run number. A place
0044       to book histograms which have to know the run number.
0045   */
0046   int InitRun(PHCompositeNode *topNode) override;
0047 
0048   /** Called for each event.
0049       This is where you do the real work.
0050   */
0051   int process_event(PHCompositeNode *topNode) override;
0052 
0053   /// Clean up internals after each event.
0054   int ResetEvent(PHCompositeNode *topNode) override;
0055 
0056   /// Called at the end of each run.
0057   int EndRun(const int runnumber) override;
0058 
0059   /// Called at the end of all processing.
0060   int End(PHCompositeNode *topNode) override;
0061 
0062   /// Reset
0063   int Reset(PHCompositeNode * /*topNode*/) override;
0064 
0065   void Print(const std::string &what = "ALL") const override;
0066 
0067  private:
0068 
0069   TTree *T;
0070   
0071   std::vector<float> m_emcTowPhi;
0072   std::vector<float> m_emcTowEta;
0073   std::vector<float> m_emcTowE;
0074   std::vector<float> m_emcTiming;
0075   std::vector<float> m_emciEta;
0076   std::vector<float> m_emciPhi;
0077 
0078   std::vector<float> m_ohciTowPhi;
0079   std::vector<float> m_ohciTowEta;
0080   std::vector<float> m_ohcTowE;
0081   
0082   std::vector<float> m_ihciTowPhi;
0083   std::vector<float> m_ihciTowEta;
0084   std::vector<float> m_ihcTowE;
0085   
0086   TFile *out;
0087   //Fun4AllHistoManager *hm = nullptr;
0088   std::string Outfile = "commissioning.root";
0089   std::string eventFile = "test.json";
0090 
0091   unsigned int getCaloTowerPhiBin(const unsigned int key);
0092   unsigned int getCaloTowerEtaBin(const unsigned int key);
0093   float getMaxTowerE(RawCluster *cluster, TowerInfoContainer *towerContainer);
0094   std::vector<float> returnClusterTowE(RawCluster *cluster, TowerInfoContainer *towerContainer);
0095   std::vector<int> returnClusterTowPhi(RawCluster *cluster, TowerInfoContainer *towerContainer);
0096   std::vector<int> returnClusterTowEta(RawCluster *cluster, TowerInfoContainer *towerContainer);
0097 
0098   float totalCaloE;
0099   int iEvent;
0100   int eventNumber;
0101   int runid;
0102   float tow_cemc_min;
0103   float tow_hcalin_min;
0104   float tow_hcalout_min;
0105 
0106   std::ofstream eventOutput;
0107 
0108   const float eta_map[24] = {-1.05417,  -0.9625, -0.870833, -0.779167, -0.6875, -0.595833, -0.504167, -0.4125, -0.320833, -0.229167, -0.1375, -0.0458333,
0109                               0.0458333, 0.1375,  0.229167,  0.320833,  0.4125,  0.504167,  0.595833,  0.6875,  0.779167,  0.870833,  0.9625,  1.05417};
0110 
0111   const float phi_map[64] = {0.0490874, 0.147262, 0.245437, 0.343612, 0.441786, 0.539961, 0.638136, 0.736311,
0112                              0.834486,  0.93266,  1.03084,  1.12901,  1.22718,  1.32536,  1.42353,  1.52171,
0113                              1.61988,   1.71806,  1.81623,  1.91441,  2.01258,  2.11076,  2.20893,  2.30711,
0114                              2.40528,   2.50346,  2.60163,  2.69981,  2.79798,  2.89616,  2.99433,  3.09251,
0115                              3.19068,   3.28885,  3.38703,  3.4852,   3.58338,  3.68155,  3.77973,  3.8779,
0116                              3.97608,   4.07425,  4.17243,  4.2706,   4.36878,  4.46695,  4.56513,  4.6633,
0117                              4.76148,   4.85965,  4.95783,  5.056,    5.15418,  5.25235,  5.35052,  5.4487,
0118                              5.54687,   5.64505,  5.74322,  5.8414,   5.93957,  6.03775,  6.13592,  6.2341};
0119 };
0120 
0121 #endif