Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:18:09

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef SILICONSEEDSANA_H
0004 #define SILICONSEEDSANA_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 #include <fun4all/Fun4AllHistoManager.h>
0008 #include <fun4all/Fun4AllReturnCodes.h>
0009 
0010 //track include
0011 #include <trackbase/ActsGeometry.h>
0012 #include <trackbase/TrkrDefs.h>
0013 #include <trackbase/TrkrClusterContainer.h>
0014 #include <trackbase/TrackFitUtils.h>
0015 
0016 //track map include
0017 #include <trackbase_historic/SvtxTrack.h>
0018 #include <trackbase_historic/SvtxTrackMap.h>
0019 #include <trackbase_historic/TrackAnalysisUtils.h>
0020 #include <trackbase_historic/SvtxTrackState.h>
0021 
0022 // vertex include
0023 #include <globalvertex/SvtxVertex.h>
0024 #include <globalvertex/SvtxVertexMap.h>
0025 
0026 //calo include
0027 #include <calobase/RawCluster.h>
0028 #include <calobase/RawClusterContainer.h>
0029 #include <calobase/RawTower.h>
0030 #include <calobase/RawTowerContainer.h>
0031 #include <calobase/RawTowerGeom.h>
0032 #include <calobase/RawTowerGeomContainer.h>
0033 #include <calobase/TowerInfoContainer.h>
0034 #include <calobase/TowerInfoContainerv1.h>
0035 #include <calobase/TowerInfoContainerv2.h>
0036 #include <calobase/TowerInfoContainerv3.h>
0037 #include <calobase/TowerInfo.h>
0038 
0039 //truth include
0040 #include <g4main/PHG4Hit.h>
0041 #include <g4main/PHG4Particle.h>
0042 #include <g4main/PHG4TruthInfoContainer.h>
0043 #include <g4main/PHG4VtxPoint.h>
0044 #include <TLorentzVector.h>
0045 #include <string>
0046 #include <vector>
0047 
0048 class SvtxTrack;
0049 class PHCompositeNode;
0050 class TH1;
0051 class TH2;
0052 class TProfile2D;
0053 class TFile;
0054 class TTree;
0055 
0056 class SiliconSeedsAna : public SubsysReco
0057 {
0058 public:
0059   SiliconSeedsAna(const std::string &name = "SiliconSeedsAna");
0060 
0061   ~SiliconSeedsAna() override = default;
0062 
0063   int InitRun(PHCompositeNode *topNode) override;
0064   int process_event(PHCompositeNode *topNode) override;
0065   int EndRun(const int runnumber) override;
0066   int End(PHCompositeNode *topNode) override;
0067   void setTrackMapName(const std::string &name) { m_trackMapName = name; }
0068   void setVertexMapName(const std::string &name) { m_vertexMapName = name; }
0069   void setOutputFileName(const std::string &name) { m_outputfilename = name; }
0070   void setStartEventNumber(int start)
0071   {
0072     evt = start;
0073     calo_evt = start;
0074   }
0075   void setClusterContainerName(const std::string &name) { m_clusterContainerName = name; }
0076   void setEMCalClusterContainerName(const std::string &name) { m_emcalClusName = name; }
0077   void setEMcalRadius(float radius) { _caloRadiusEMCal = radius; }
0078   void setTopoCluster(bool topo)
0079   {
0080     if (topo)
0081     {
0082       setClusterContainerName("TOPOCLUSTER_EMCAL");
0083     }
0084   }
0085   void setMC(bool input) { isMC = input; }
0086   void setVtxSkip(bool input) { b_skipvtx = input; }
0087   void setCaloSkip(bool input) { b_skipcalo = input; }
0088 
0089 protected:
0090   //std::tuple<float, float, float> getClusterPos(TrkrDefs::cluskey cluskey, TrkrClusterContainer *clusterContainer);
0091 
0092   void createTree();
0093   void createHistos();
0094   std::string getHistoPrefix() const;
0095 
0096   void fillTruthTree(PHCompositeNode *topNode);
0097   void processTrackMap(PHCompositeNode *topNode);
0098   void processSiCluster(PHCompositeNode *topNode);
0099   void processCaloClusters(PHCompositeNode *topNode);
0100   void processVertexMap(PHCompositeNode *topNode);
0101 
0102   // Utility functions for track vector management and EMCal state
0103   void clearTrackVectors();
0104   void fillEMCalState(SvtxTrackState* state, SvtxTrackState* ostate);
0105   void initTrackTreeBranches();
0106   void clearCaloVectors();
0107   void initCaloTreeBranches();
0108 
0109   std::string m_clusterContainerName = "TRKR_CLUSTER";
0110   std::string m_actsgeometryName     = "ActsGeometry";
0111   std::string m_trackMapName         = "SvtxTrackMap";
0112   std::string m_vertexMapName        = "SvtxVertexMap";
0113   std::string m_emcalClusName        = "CLUSTER_CEMC";
0114   std::string m_outputfilename       = "output_histograms.root";
0115 
0116   // std::string m_emcal_node_name = "TOWERINFO_CALIB_CEMC";
0117   // std::string m_ihcal_node_name = "TOWERINFO_CALIB_HCALIN";
0118   // std::string m_ohcal_node_name = "TOWERINFO_CALIB_HCALOUT";
0119   // std::string m_ihcalClus_node_name = "CLUSTER_HCALIN";
0120   // std::string m_ohcalClus_node_name = "CLUSTER_HCALOUT";
0121   SvtxTrackMap *trackmap    = nullptr;
0122   SvtxTrack    *track       = nullptr;
0123   TrackSeed    *si_seed     = nullptr;
0124   TrkrCluster  *trkrCluster = nullptr;
0125 
0126   TFile *m_outfile = nullptr;
0127 
0128   // Truth info tree and vectors
0129   TTree *truthTree = nullptr;
0130   std::vector<int>   truth_pid;
0131   std::vector<float> truth_px, truth_py, truth_pz, truth_e;
0132   std::vector<float> truth_pt, truth_eta, truth_phi;
0133   std::vector<int>   truth_vtxid;
0134   std::vector<float> truth_vtx_x, truth_vtx_y, truth_vtx_z;
0135 
0136 
0137   // SiSeed info tree and vectors
0138   TTree *trackTree = nullptr;
0139   int evt = 0;
0140   std::vector<unsigned int> track_id;
0141   std::vector<float> track_px, track_py, track_pz;
0142   std::vector<float> track_x, track_y, track_z;
0143   std::vector<float> track_pt,track_eta,track_phi;
0144   std::vector<float> track_chi2ndf;
0145   std::vector<short int> track_crossing;
0146   std::vector<int> track_charge;
0147   std::vector<int> track_nmaps;
0148   std::vector<int> track_nintt;
0149   std::vector<int> track_innerintt;
0150   std::vector<int> track_outerintt;
0151 
0152   std::vector<float> track_px_emc, track_py_emc, track_pz_emc;
0153   std::vector<float> track_x_emc;
0154   std::vector<float> track_y_emc;
0155   std::vector<float> track_z_emc;
0156   std::vector<float> track_eta_emc;
0157   std::vector<float> track_phi_emc;
0158   std::vector<float> track_pt_emc;
0159   std::vector<float> track_x_oemc;
0160   std::vector<float> track_y_oemc;
0161   std::vector<float> track_z_oemc;
0162 
0163   // SiCluster associated to SiSeed info tree and vectors
0164   TTree *SiClusTree    = nullptr;
0165   TTree *SiClusAllTree = nullptr;
0166   std::vector<int>   SiClus_trackid;
0167   std::vector<int>   SiClus_layer;
0168   std::vector<float> SiClus_x;
0169   std::vector<float> SiClus_y;
0170   std::vector<float> SiClus_z;
0171   std::vector<int>   SiClus_t;
0172 
0173   // EMC cluster info tree and vectors
0174   TTree *caloTree = nullptr;
0175   int calo_evt = 0;
0176   std::vector<float> calo_x;
0177   std::vector<float> calo_y;
0178   std::vector<float> calo_z;
0179   std::vector<float> calo_r;
0180   std::vector<float> calo_phi;
0181   std::vector<float> calo_eta;
0182   std::vector<float> calo_energy;
0183   std::vector<float> calo_chi2;
0184   std::vector<float> calo_prob;
0185 
0186   // Event based variable info tree 
0187   TTree *evtTree = nullptr;
0188   //int trk_evt = 0;
0189   //int calo_evt = 0;
0190   long long evt_bco;
0191   int       evt_crossing;
0192   int       evt_nintt;
0193   int       evt_nintt50;
0194   int       evt_nmaps;
0195   int       evt_nemc;
0196   int       evt_nemc02;
0197   int       evt_nsiseed;
0198   int       evt_nsiseed0;
0199   float     evt_xvtx;
0200   float     evt_yvtx;
0201   float     evt_zvtx;
0202 
0203 
0204   double m_emcal_low_cut = 0.3;
0205   float _caloRadiusEMCal = 93.5;
0206   float _caloThicknessEMCal = 20.4997;
0207 
0208   bool isMC = false;
0209   bool b_skipvtx = false;
0210   bool b_skipcalo = false;
0211   TH1 *h_ntrack1d = nullptr;
0212   TH2 *h_ntrack = nullptr;
0213   TH1 *h_nmaps = nullptr;
0214   TH1 *h_nintt = nullptr;
0215   TH1 *h_nlayer = nullptr;
0216   TH2 *h_nmaps_nintt = nullptr;
0217   TProfile2D *h_avgnclus_eta_phi = nullptr;
0218   TH1 *h_trackcrossing = nullptr;
0219   TH1 *h_trackchi2ndf = nullptr;
0220   TH2 *h_dcaxyorigin_phi = nullptr;
0221   TH2 *h_dcaxyvtx_phi = nullptr;
0222   TH2 *h_dcazorigin_phi = nullptr;
0223   TH2 *h_dcazvtx_phi = nullptr;
0224   TH1 *h_ntrack_isfromvtx = nullptr;
0225   TH1 *h_trackpt_inclusive = nullptr;
0226   TH1 *h_trackpt_pos = nullptr;
0227   TH1 *h_trackpt_neg = nullptr;
0228   TH1 *h_ntrack_IsPosCharge = nullptr;
0229 
0230   TH1 *h_nvertex = nullptr;
0231   TH1 *h_vx = nullptr;
0232   TH1 *h_vy = nullptr;
0233   TH1 *h_vz = nullptr;
0234   TH2 *h_vx_vy = nullptr;
0235   TH1 *h_vt = nullptr;
0236   TH1 *h_vcrossing = nullptr;
0237   TH1 *h_vchi2dof = nullptr;
0238   TH1 *h_ntrackpervertex = nullptr;
0239 };
0240 
0241 #endif  // SILICONSEEDSANA_H
0242 
0243   // --- Matched EMCal cluster info for each track ---
0244   std::vector<float> matched_calo_x;
0245   std::vector<float> matched_calo_y;
0246   std::vector<float> matched_calo_z;
0247   std::vector<float> matched_calo_r;
0248   std::vector<float> matched_calo_phi;
0249   std::vector<float> matched_calo_eta;
0250   std::vector<float> matched_calo_energy;
0251   std::vector<float> matched_calo_dR;