Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:13:41

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef ISOLATEDTRACKANALYSIS_H
0004 #define ISOLATEDTRACKANALYSIS_H
0005 
0006 
0007 #include <fun4all/SubsysReco.h>
0008 #include <centrality/CentralityInfo.h>
0009 
0010 #include <string>
0011 #include <vector>
0012 
0013 class TFile;
0014 class TTree;
0015 class PHCompositeNode;
0016 class RawClusterContainer;
0017 class RawCluster;
0018 class RawTowerContainer;
0019 class RawTower;
0020 class SvtxTrackMap;
0021 class SvtxTrack;
0022 class SvtxTrackState;
0023 class SvtxVertexMap;
0024 class SvtxEvalStack;
0025 class PHHepMCGenEventMap;
0026 class PHHepMCGenEvent;
0027 class P4G4TruthInfoContainer;
0028 class P4G4TruthInfo;
0029 class CentralityInfo;
0030 class TrkrCluster;
0031 class PHG4HitContainer;
0032 
0033 class IsolatedTrackAnalysis : public SubsysReco
0034 {
0035   public:
0036     IsolatedTrackAnalysis(const std::string &name = "IsolatedTrackAnalysis",
0037                           const std::string &fname = "IsolatedTrackAnalysis.root");
0038     ~IsolatedTrackAnalysis() override;
0039 
0040     int Init(PHCompositeNode *topNode) override;
0041     int InitRun(PHCompositeNode *topNode) override;
0042     int process_event(PHCompositeNode *topNode) override;
0043     int ResetEvent(PHCompositeNode *topNode) override;
0044     int End(PHCompositeNode *topNode) override;
0045 
0046     void setMinEMClusterEnergy(float minEMClusterEnergy) { m_minEMClusterEnergy = minEMClusterEnergy; }
0047     void setMinIHClusterEnergy(float minIHClusterEnergy) { m_minIHClusterEnergy = minIHClusterEnergy; }
0048     void setMinOHClusterEnergy(float minOHClusterEnergy) { m_minOHClusterEnergy = minOHClusterEnergy; }
0049     void setMinCemcTowerEnergy(float minCemcTowerEnergy) { m_minCemcTowerEnergy = minCemcTowerEnergy; }
0050     void setMinHcalTowerEnergy(float minHcalTowerEnergy) { m_minHcalTowerEnergy = minHcalTowerEnergy; }
0051     void setMinSimTowerEnergy(float minSimTowerEnergy) { m_minSimTowerEnergy = minSimTowerEnergy; }
0052 
0053     void analyzeTracks(bool doAnalyzeTracks) { m_analyzeTracks = doAnalyzeTracks; }
0054     void analyzeClusters(bool doAnalyzeClusters) { m_analyzeClusters = doAnalyzeClusters; }
0055     void analyzeTowers(bool doAnalyzeTowers) { m_analyzeTowers = doAnalyzeTowers; }
0056     void analyzeSimTowers(bool doAnalyzeSimTowers) { m_analyzeSimTowers = doAnalyzeSimTowers; }
0057     void analyzeHepMCTruth(bool doAnalyzeHepMCTruth) { m_analyzeHepMCTruth = doAnalyzeHepMCTruth; }
0058     void analyzeG4Truth(bool doAnalyzeG4Truth) { m_analyzeG4Truth = doAnalyzeG4Truth; }
0059     void analyzeCentrality(bool doAnalyzeCentrality) { m_analyzeCentrality = doAnalyzeCentrality; }
0060     void analyzeAddTruth(bool doAnalyzeAddTruth) { m_analyzeAddTruth = doAnalyzeAddTruth; }
0061 
0062   private:
0063     /// String to contain the outfile name containing the trees
0064     std::string m_outputFileName;
0065 
0066     /// A float for cutting on EMCal cluster energy
0067     float m_minEMClusterEnergy;
0068 
0069     /// A float for cutting on iHCal cluster energy 
0070     float m_minIHClusterEnergy;
0071 
0072     /// A float for cutting on oHCal cluster energy 
0073     float m_minOHClusterEnergy;
0074 
0075     /// A float for cutting on EMCal tower energy
0076     float m_minCemcTowerEnergy;
0077 
0078     /// A float for cutting on HCal tower energy 
0079     float m_minHcalTowerEnergy;
0080 
0081      /// A float for cutting on sim tower energy
0082     float m_minSimTowerEnergy;  
0083 
0084     /// A boolean for running over tracks
0085     bool m_analyzeTracks;
0086 
0087     /// A boolean for running over clusters
0088     bool m_analyzeClusters;
0089 
0090     /// A boolean for running over towers
0091     bool m_analyzeTowers;
0092  
0093     /// A boolean for running over sim towers
0094     bool m_analyzeSimTowers;
0095    
0096     /// A boolean for collecting hepmc information
0097     bool m_analyzeHepMCTruth;
0098 
0099     /// A boolean for collecting g4 information
0100     bool m_analyzeG4Truth;
0101 
0102     /// A boolean for collecting centrality information
0103     bool m_analyzeCentrality;
0104 
0105     /// A boolean for collecting additional truth information
0106     /// NOTE: this requires a large about of storage space
0107     bool m_analyzeAddTruth;
0108 
0109     /// TFile to hold the following TTrees and histograms
0110     TFile *m_outputFile;
0111     TTree *m_tracktree;
0112     TTree *m_clustertree;
0113     TTree *m_towertree;
0114     TTree *m_simtowertree;
0115     TTree *m_hepmctree;
0116     TTree *m_g4tree;
0117     TTree *m_centraltree;
0118     TTree *m_addtruthtree;
0119 
0120     SvtxEvalStack *m_svtxEvalStack = nullptr;
0121     CentralityInfo *central = nullptr;
0122 
0123     /// Counter
0124     int counter;
0125 
0126     /// Methods for grabbing the data
0127     void getTracks(PHCompositeNode *topNode);
0128     void getClusters(PHCompositeNode *topNode);
0129     void getTowers(PHCompositeNode *topNode);
0130     void getSimTowers(PHCompositeNode *topNode);
0131     void getHepMCTruth(PHCompositeNode *topNode);
0132     void getG4Truth(PHCompositeNode *topNode);
0133     void getCentrality(PHCompositeNode *topNode);
0134     void getAddTruth(PHCompositeNode *topNode);
0135 
0136     void initializeTrees(); 
0137     void initializeVariables(); 
0138 
0139     // Track helper functions
0140     float calculateProjectionEta(SvtxTrackState *projectedState);        
0141     float calculateProjectionPhi(SvtxTrackState *projectedState);        
0142     void calculateDCA(SvtxTrack* track, SvtxVertexMap* vertexmap, float& dca3dxy, float& dca3dz, float& dca3dxysigma, float& dca3dzsigma);
0143 
0144     // Calorimeter radii
0145     float m_cemcRadius;
0146     float m_ihcalRadius;
0147     float m_ohcalRadius;
0148 
0149     // Multiplicities
0150     int m_trkmult;
0151     int m_vtxmult;
0152     int m_clsmult_cemc;
0153     int m_clsmult_ihcal;
0154     int m_clsmult_ohcal;
0155     int m_twrmult_cemc;
0156     int m_twrmult_ihcal;
0157     int m_twrmult_ohcal;
0158     int m_simtwrmult_cemc;
0159     int m_simtwrmult_ihcal;
0160     int m_simtwrmult_ohcal;
0161     int m_g4;
0162     int m_hepmc;
0163 
0164     // Basic track properties
0165     float m_tr_p[2000];
0166     float m_tr_pt[2000];
0167     float m_tr_eta[2000];
0168     float m_tr_phi[2000];
0169     int m_tr_charge[2000];
0170     float m_tr_chisq[2000];
0171     int m_tr_ndf[2000];
0172     int m_tr_silicon_hits[2000];
0173 
0174     // Distance of closest approach
0175     float m_tr_dca_xy[2000];
0176     float m_tr_dca_xy_error[2000];
0177     float m_tr_dca_z[2000];
0178     float m_tr_dca_z_error[2000];
0179 
0180     // Initial point of track
0181     float m_tr_x[2000];
0182     float m_tr_y[2000];
0183     float m_tr_z[2000];
0184 
0185     // Vertex id of track
0186     int m_tr_vertex_id[2000];
0187 
0188     // Vertex ids and positions, also stored on track tree
0189     int m_vertex_id[100];
0190     float m_vx[100];
0191     float m_vy[100];
0192     float m_vz[100];
0193 
0194     // Projection of track to calorimeters
0195     // CEMC
0196     float m_tr_cemc_eta[2000];
0197     float m_tr_cemc_phi[2000];
0198     // Inner HCAL
0199     float m_tr_ihcal_eta[2000];
0200     float m_tr_ihcal_phi[2000];
0201     /// Outer HCAL
0202     float m_tr_ohcal_eta[2000];
0203     float m_tr_ohcal_phi[2000];
0204 
0205     // Matched truth track
0206     int m_tr_truth_is_primary[2000];
0207     int m_tr_truth_pid[2000];
0208     float m_tr_truth_e[2000];
0209     float m_tr_truth_pt[2000];
0210     float m_tr_truth_eta[2000];
0211     float m_tr_truth_phi[2000];
0212     int m_tr_truth_track_id[2000];
0213 
0214     //////////////////////////
0215     // Centrality variables //
0216     //////////////////////////
0217 
0218     // Event Centrality
0219     float centrality;
0220 
0221     ///////////////////////
0222     // Cluster variables //
0223     ///////////////////////
0224  
0225     // CEMC clusters
0226     float m_cl_cemc_e[5000];
0227     float m_cl_cemc_eta[5000];
0228     float m_cl_cemc_phi[5000];
0229     float m_cl_cemc_r[5000];
0230     float m_cl_cemc_z[5000];
0231 
0232     // Inner HCAL clusters
0233     float m_cl_ihcal_e[1000];
0234     float m_cl_ihcal_eta[1000];
0235     float m_cl_ihcal_phi[1000];
0236     float m_cl_ihcal_r[1000];
0237     float m_cl_ihcal_z[1000];
0238 
0239     // Outer HCAL clusters
0240     float m_cl_ohcal_e[1000];
0241     float m_cl_ohcal_eta[1000];
0242     float m_cl_ohcal_phi[1000];
0243     float m_cl_ohcal_r[1000];
0244     float m_cl_ohcal_z[1000];
0245 
0246     /////////////////////
0247     // Tower variables //
0248     /////////////////////
0249 
0250     float m_twr_cemc_e[25000];
0251     float m_twr_cemc_eta[25000];
0252     float m_twr_cemc_phi[25000];
0253     int m_twr_cemc_ieta[25000];
0254     int m_twr_cemc_iphi[25000];
0255 
0256     float m_twr_ihcal_e[2000];
0257     float m_twr_ihcal_eta[2000];
0258     float m_twr_ihcal_phi[2000];
0259     int m_twr_ihcal_ieta[2000];
0260     int m_twr_ihcal_iphi[2000];
0261 
0262     float m_twr_ohcal_e[2000];
0263     float m_twr_ohcal_eta[2000];
0264     float m_twr_ohcal_phi[2000];
0265     int m_twr_ohcal_ieta[2000];
0266     int m_twr_ohcal_iphi[2000];
0267 
0268     /////////////////////////
0269     // Sim tower variables //
0270     /////////////////////////
0271     
0272     float m_simtwr_cemc_e[25000];
0273     float m_simtwr_cemc_eta[25000];
0274     float m_simtwr_cemc_phi[25000];
0275     int m_simtwr_cemc_ieta[25000];
0276     int m_simtwr_cemc_iphi[25000];
0277 
0278     float m_simtwr_ihcal_e[2000];
0279     float m_simtwr_ihcal_eta[2000];
0280     float m_simtwr_ihcal_phi[2000];
0281     int m_simtwr_ihcal_ieta[2000];
0282     int m_simtwr_ihcal_iphi[2000];
0283 
0284     float m_simtwr_ohcal_e[2000];
0285     float m_simtwr_ohcal_eta[2000];
0286     float m_simtwr_ohcal_phi[2000];
0287     int m_simtwr_ohcal_ieta[2000];
0288     int m_simtwr_ohcal_iphi[2000];
0289 
0290     /////////////////////////
0291     // HepMC particle tree //
0292     /////////////////////////
0293   
0294     int m_hepmc_pid[20000];
0295     float m_hepmc_e[20000];
0296     float m_hepmc_pt[20000];
0297     float m_hepmc_eta[20000];
0298     float m_hepmc_phi[20000];
0299 
0300     //////////////////////
0301     // G4 particle tree //
0302     //////////////////////
0303 
0304     int m_g4_pid[20000];
0305     float m_g4_e[20000];
0306     float m_g4_pt[20000];
0307     float m_g4_eta[20000];
0308     float m_g4_phi[20000];
0309     int m_g4_track_id[20000];
0310     int m_g4_parent_id[20000];
0311 
0312     ///////////////////////////
0313     // Additional truth info //
0314     ///////////////////////////
0315 
0316     // Secondary truth particles
0317 
0318     int n_child = 0;
0319     int child_pid[100000];
0320     int child_parent_id[100000];
0321     int child_vertex_id[100000];
0322     float child_px[100000];
0323     float child_py[100000];
0324     float child_pz[100000];
0325     float child_energy[100000];
0326 
0327     // Truth particle vertices 
0328 
0329     int n_vertex = 0;
0330     int vertex_id[100000];
0331     float vertex_x[100000];
0332     float vertex_y[100000];
0333     float vertex_z[100000];
0334 
0335     // BH particles
0336 
0337     int _nBH = 0;
0338     float _BH_e[20000];
0339     float _BH_px[20000];
0340     float _BH_py[20000];
0341     float _BH_pz[20000];
0342     int _BH_track_id[20000];
0343 
0344 };
0345 
0346 #endif // ISOLATEDTRACKANALYSIS_H