Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef INTTANA_H__
0002 #define INTTANA_H__
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <string>
0006 
0007 #include <cmath>
0008 /// Cluster/Calorimeter includes
0009 
0010 /// Fun4All includes
0011 #include <fun4all/Fun4AllHistoManager.h>
0012 #include <fun4all/Fun4AllReturnCodes.h>
0013 #include <phool/PHCompositeNode.h>
0014 #include <phool/getClass.h>
0015 
0016 // #include <trackbase/TrkrClusterv4.h>
0017 // #include <trackbase/TrkrClusterContainerv3.h>
0018 #include <trackbase/TrkrCluster.h>
0019 #include <trackbase/TrkrClusterContainer.h>
0020 #include <trackbase/TrkrHit.h>
0021 #include <trackbase/TrkrHitSet.h>
0022 #include <trackbase/TrkrHitSetContainer.h>
0023 #include <trackbase/ActsGeometry.h>
0024 #include <trackbase/InttDefs.h>
0025 
0026 #include <trackbase/InttEventInfo.h>
0027 
0028 #include <globalvertex/GlobalVertexv1.h>
0029 #include <globalvertex/GlobalVertexMapv1.h>
0030 
0031 // #include <globalvertex/MbdVertexv1.h>
0032 // #include <globalvertex/MbdVertexMapv1.h>
0033 #include <mbd/MbdOut.h>
0034 #include <ffarawobjects/Gl1RawHit.h>
0035 #include <ffarawobjects/Gl1Packetv2.h>
0036 
0037 #include <ffarawobjects/InttRawHit.h>
0038 #include <ffarawobjects/InttRawHitContainer.h>
0039 
0040 // #include <inttxyvertexfinder/InttVertex.h>
0041 // #include <inttxyvertexfinder/InttVertexMapv1.h>
0042 // #include <inttxyvertexfinder/InttVertex3D.h>
0043 // #include <inttxyvertexfinder/InttVertex3DMap.h>
0044 #include <intt/InttVertexv1.h>
0045 #include <intt/InttVertexMapv1.h>
0046 // #include <inttxyvertexfinder/InttVertex3D.h>
0047 // #include <inttxyvertexfinder/InttVertex3DMap.h>
0048 
0049 #include <globalvertex/SvtxVertex.h>
0050 #include <globalvertex/SvtxVertexMap.h>
0051 #include <trackbase_historic/SvtxTrack.h>
0052 #include <trackbase_historic/SvtxTrackMap.h>
0053 
0054 #include <calobase/RawCluster.h>
0055 #include <calobase/RawClusterContainer.h>
0056 
0057 /// ROOT includes
0058 #include <TFile.h>
0059 #include <TH1.h>
0060 #include <TH2.h>
0061 #include <TNtuple.h>
0062 #include <TTree.h>
0063 #include <TVector3.h>
0064 
0065 /// C++ includes
0066 #include <cassert>
0067 #include <cmath>
0068 #include <sstream>
0069 #include <string>
0070 
0071 #include "InttEvent.h"
0072 #include "InttRawData.h"
0073 
0074 // truth
0075 //  To get vertex
0076 #include <globalvertex/GlobalVertexMap.h>
0077 #include <globalvertex/GlobalVertex.h>
0078 
0079 // TODO:
0080 /// HEPMC truth includes
0081 #pragma GCC diagnostic push
0082 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0083 #include <HepMC/GenEvent.h>
0084 #include <HepMC/GenVertex.h>
0085 #pragma GCC diagnostic pop
0086 
0087 #include <phhepmc/PHHepMCGenEvent.h>
0088 #include <phhepmc/PHHepMCGenEventMap.h>
0089 
0090 #include <g4main/PHG4InEvent.h>
0091 #include <g4main/PHG4VtxPoint.h> // for PHG4Particle
0092 #include <g4main/PHG4Particle.h> // for PHG4Particle
0093 // truth end
0094 
0095 /// Class declarations for use in the analysis module
0096 class PHCompositeNode;
0097 class TFile;
0098 class TH1;
0099 class TH2;
0100 class TNtuple;
0101 class TTree;
0102 class InttRawData;
0103 
0104 struct ClustInfo
0105 {
0106   int layer;
0107   Acts::Vector3 pos;
0108 };
0109 
0110 /// Definition of this analysis module class
0111 class InttAna : public SubsysReco
0112 {
0113  public:
0114   struct evtbco_info{
0115     int      evt_gl1 {-1};
0116     uint     evt_intt{ 0};
0117     int      evt_mbd {-1};
0118     uint64_t bco_gl1 {0};
0119     uint64_t bco_intt{0};
0120     uint64_t bco_mbd {0};
0121 
0122     void clear() {
0123       evt_gl1  = -1;
0124       evt_intt =  0;
0125       evt_mbd  = -1;
0126       bco_gl1  =  0;
0127       bco_intt =  0;
0128       bco_mbd  =  0;
0129     };
0130 
0131     void copy(const evtbco_info& info) {
0132       evt_gl1  = info.evt_gl1 ;
0133       evt_intt = info.evt_intt;
0134       evt_mbd  = info.evt_mbd ;
0135       bco_gl1  = info.bco_gl1 ;
0136       bco_intt = info.bco_intt;
0137       bco_mbd  = info.bco_mbd ;
0138     };
0139   };
0140   
0141  public:
0142   /// Constructor
0143   InttAna(const std::string &name = "InttAna",
0144           const std::string &fname = "AnaTutorial.root");
0145 
0146   // Destructor
0147   virtual ~InttAna();
0148 
0149   /// SubsysReco initialize processing method
0150   int Init(PHCompositeNode *) override;
0151  
0152   /// SubsysReco initialize processing method
0153   int InitRun(PHCompositeNode *) override;
0154 
0155   /// SubsysReco event processing method
0156   int process_event(PHCompositeNode *) override;
0157 
0158   /// Clean up internals after each event.
0159   int ResetEvent(PHCompositeNode *topNode) override;
0160 
0161   /// SubsysReco end processing method
0162   int End(PHCompositeNode *) override;
0163 
0164   //truth information
0165   // void getHEPMCTruth(PHCompositeNode *);
0166   // void getPHG4Particle(PHCompositeNode *);
0167   void getHEPMCTruth(PHCompositeNode *topNode);
0168   void getPHG4Particle(PHCompositeNode *topNode);
0169 
0170   void setInttRawData(InttRawData *rawModule) { _rawModule = rawModule; }
0171   void readRawHit(PHCompositeNode *);
0172 
0173   void setBeamCenter(float x=0, float y=0) {xbeam_=x; ybeam_=y;}
0174 
0175  private:
0176   InttRawData* _rawModule;
0177 
0178   std::string fname_;
0179   TFile* anafile_;
0180   TH1*   h_dca2d_zero; 
0181   TH2*   h2_dca2d_zero; 
0182   TH2*   h2_dca2d_len; 
0183   TH1*   h_zvtx;
0184   TH1*   h_eta;
0185   TH1*   h_phi;
0186   TH1*   h_theta;
0187 
0188   TNtuple*  h_ntp_clus; 
0189   TNtuple*  h_ntp_emcclus; 
0190   //TTree*  h_t_clus; 
0191   TNtuple*  h_ntp_cluspair; 
0192   TNtuple*  h_ntp_emccluspair{nullptr}; 
0193   TNtuple*  h_ntp_evt; 
0194   TTree*  h_t_evt_bco;
0195   TTree*  tree_event_;
0196 
0197   float xbeam_;
0198   float ybeam_;
0199   double xvtx_sim = -9999;
0200   double yvtx_sim = -9999;
0201   double zvtx_sim = -9999;
0202 
0203   evtbco_info m_evtbcoinfo;
0204   evtbco_info m_evtbcoinfo_prev;
0205 
0206   TH1* h_zvtxseed_;
0207   TTree *m_hepmctree;
0208 
0209   /// HEPMC Tree variables
0210   int m_evt=0;
0211   double m_xvtx = -9999;
0212   double m_yvtx = -9999;
0213   double m_zvtx = -9999;
0214   int m_partid1 = -9999;
0215   int m_partid2 = -9999;
0216   double m_x1 = -9999;
0217   double m_x2 = -9999;
0218   int m_mpi = -9999;
0219   int m_process_id = -9999;
0220   double m_truthenergy = -9999;
0221   double m_trutheta = -9999;
0222   double m_truththeta = -9999;
0223   double m_truthphi = -9999;
0224   int m_status = -9999;
0225   double m_truthpx = -9999;
0226   double m_truthpy = -9999;
0227   double m_truthpz = -9999;
0228   double m_truthpt = -9999;
0229   double m_truthp = -9999;
0230   int m_numparticlesinevent = -9999;
0231   int m_truthpid = -9999;
0232   double m_vertex = -9999;
0233   double vertex_[10][3]{ {-9999} };
0234 
0235   double mbdqn_ = 0;
0236   double mbdqs_ = 0;
0237   double mbdz_ = 0;
0238   uint64_t bco_ = 0;
0239   int evtseq_ = -1;
0240   double vtx_sim_[3]{ -9999 };
0241   int nclusmvtx_[3] = { 0 };
0242   int nclusadd_ = 0;
0243   int nclusadd2_ = 0;
0244   int nclus_inner_ = 0;
0245   int nclus_outer_ = 0;
0246   int nemc_ = -9999;
0247   int nemc1_ = -9999;
0248   double zvtx_ = -9999;
0249 
0250   TVector3* vertex_pos_intt_;
0251   double vertex_z_mbd_ = -9999;
0252 
0253   static int evtCount;
0254   static int ievt;
0255 
0256 
0257   std::vector < ClustInfo > clusters_[2]; // inner=0; outer=1
0258   
0259   void InitHists();
0260   void InitTrees();
0261   void InitTuples();
0262 
0263   int GetNodes( PHCompositeNode *topNode );
0264   InttRawHitContainer *inttrawmap;
0265   ActsGeometry *m_tGeometry;
0266   PHHepMCGenEventMap *hepmceventmap;
0267   PHG4InEvent *phg4inevent;
0268   TrkrClusterContainer *m_clusterMap;
0269   GlobalVertexMap *vertices;
0270   InttEventInfo *inttevthead;
0271   SvtxVertexMap *svtxvertexmap;
0272   MbdOut *mbdout;
0273   SvtxVertex *svtxvertex;
0274   //InttVertex3DMap *inttvertexmap;
0275   InttVertexMap *intt_vertex_map;
0276   SvtxTrackMap *svtxtrackmap;
0277   
0278   //Gl1RawHit *gl1raw_;
0279   Gl1Packet *gl1raw_;
0280   InttRawHit *inttraw_;
0281   //InttVertex3D *zvtxobj_;
0282   InttVertex *zvtxobj_;
0283   
0284   int process_event_gl1(PHCompositeNode *topNode );
0285 
0286   int process_event_mbd(PHCompositeNode *topNode );
0287   int process_event_global_vertex(PHCompositeNode *topNode );
0288   int process_event_svtx_vertex(PHCompositeNode *topNode );
0289   
0290   int process_event_intt_raw(PHCompositeNode *topNode );
0291   int process_event_intt_vertex(PHCompositeNode *topNode );
0292   int process_event_intt_cluster(PHCompositeNode *topNode );
0293   int process_event_intt_cluster_pair(PHCompositeNode *topNode );
0294   int process_event_mvtx(PHCompositeNode *topNode );
0295   int process_event_emcal(PHCompositeNode *topNode );
0296   int process_event_fill(PHCompositeNode *topNode );
0297 
0298 };
0299 
0300 #endif