File indexing completed on 2025-12-17 09:20:17
0001 #ifndef KFPARTICLESPHENIX_KFPARTICLETRUTHANDDETTOOLS_H
0002 #define KFPARTICLESPHENIX_KFPARTICLETRUTHANDDETTOOLS_H
0003
0004
0005 #include <calobase/RawCluster.h>
0006 #include <calobase/RawClusterContainer.h>
0007 #include <calobase/RawClusterDefs.h>
0008
0009 #include <calobase/RawTower.h>
0010 #include <calobase/RawTowerContainer.h>
0011 #include <calobase/RawTowerDefs.h>
0012 #include <calobase/RawTowerGeom.h>
0013 #include <calobase/RawTowerGeomContainer.h>
0014 #include <calobase/TowerInfo.h>
0015 #include <calobase/TowerInfoContainer.h>
0016 #include <calobase/TowerInfoContainerv4.h>
0017 #include <calobase/TowerInfoDefs.h>
0018 #include <calobase/TowerInfov4.h>
0019
0020
0021 #include <trackbase/ActsGeometry.h>
0022
0023
0024
0025 #include <limits>
0026 #include <string>
0027 #include <vector>
0028
0029 class ActsGeometry;
0030 class PHCompositeNode;
0031 class PHG4Particle;
0032 class PHG4VtxPoint;
0033 class PHG4TruthInfoContainer;
0034 class PHHepMCGenEvent;
0035 class PHHepMCGenEventMap;
0036 class MbdVertexMap;
0037 class MbdVertex;
0038 class SvtxClusterEval;
0039 class SvtxEvalStack;
0040 class SvtxHitEval;
0041 class SvtxTrack;
0042 class SvtxTrackEval;
0043 class SvtxTrackMap;
0044 class SvtxTruthEval;
0045 class SvtxVertexMap;
0046 class SvtxVertex;
0047 class SvtxVertexEval;
0048 class TrkrClusterContainer;
0049 class TTree;
0050 class KFParticle;
0051 class GlobalVertex;
0052 class GlobalVertexMap;
0053
0054 namespace HepMC
0055 {
0056 class GenParticle;
0057 }
0058
0059 class KFParticle_truthAndDetTools
0060 {
0061 public:
0062 KFParticle_truthAndDetTools() = default;
0063
0064 virtual ~KFParticle_truthAndDetTools() = default;
0065
0066 static SvtxTrack *getTrack(unsigned int track_id, SvtxTrackMap *trackmap);
0067 static GlobalVertex *getVertex(unsigned int vertex_id, GlobalVertexMap *vertexmap);
0068 PHG4Particle *getTruthTrack(SvtxTrack *thisTrack, PHCompositeNode *topNode);
0069
0070 void initializeTruthBranches(TTree *m_tree, int daughter_id, const std::string &daughter_number, bool m_constrain_to_vertex_truthMatch);
0071 void fillTruthBranch(PHCompositeNode *topNode, TTree *m_tree, const KFParticle &daughter, int daughter_id, const KFParticle &vertex, bool m_constrain_to_vertex_truthMatch);
0072
0073 void fillGeant4Branch(PHG4Particle *particle, int daughter_id);
0074 void fillHepMCBranch(HepMC::GenParticle *particle, int daughter_id);
0075 int getHepMCInfo(PHCompositeNode *topNode, TTree *m_tree, const KFParticle &daughter, int daughter_id);
0076
0077 void initializeCaloBranches(TTree *m_tree, int daughter_id, const std::string &daughter_number);
0078 void fillCaloBranch(PHCompositeNode *topNode, TTree *m_tree, const KFParticle &daughter, int daughter_id, bool &isTrackEMCalmatch);
0079 void Get5x5CellInfo(RawClusterDefs::keytype key_in, int daughter_id);
0080
0081 void initializeDetectorBranches(TTree *m_tree, int daughter_id, const std::string &daughter_number);
0082 void initializeSubDetectorBranches(TTree *m_tree, const std::string &detectorName, int daughter_id, const std::string &daughter_number);
0083 void fillDetectorBranch(PHCompositeNode *topNode, TTree *m_tree, const KFParticle &daughter, int daughter_id);
0084
0085 int getPVID(PHCompositeNode *topNode, const KFParticle &vertex);
0086 void allPVInfo(PHCompositeNode *topNode, TTree *m_tree,
0087 const KFParticle &motherParticle,
0088 std::vector<KFParticle> daughters,
0089 std::vector<KFParticle> intermediates);
0090
0091 void clearVectors();
0092
0093 float get_e3x3(RawCluster *cluster, RawTowerContainer *Towers, int layer);
0094 float get_e5x5(RawCluster *cluster, RawTowerContainer *Towers, int layer);
0095
0096 float PiRange(float deltaPhi)
0097 {
0098 if (deltaPhi > M_PI) deltaPhi -= 2 * M_PI;
0099 if (deltaPhi < -M_PI) deltaPhi += 2 * M_PI;
0100 return deltaPhi;
0101 }
0102
0103
0104 void set_emcal_radius_user(float set_variable) { m_emcal_radius_user = set_variable; }
0105 void set_emcal_e_low_cut(float set_variable) { m_emcal_e_low_cut = set_variable; }
0106 void set_dphi_cut_low(float set_variable) { m_dphi_cut_low = set_variable; }
0107 void set_dphi_cut_high(float set_variable) { m_dphi_cut_high = set_variable; }
0108 void set_dz_cut_low(float set_variable) { m_dz_cut_low = set_variable; }
0109 void set_dz_cut_high(float set_variable) { m_dz_cut_high = set_variable; }
0110
0111
0112 protected:
0113 bool m_get_detailed_tracking{true};
0114 bool m_get_detailed_calorimetry{false};
0115 bool m_use_mbd_vertex_truth{false};
0116 bool m_dont_use_global_vertex_truth{false};
0117
0118 std::string m_trk_map_node_name_nTuple{"SvtxTrackMap"};
0119 std::string m_vtx_map_node_name_nTuple{"SvtxVertexMap"};
0120
0121 SvtxEvalStack *m_svtx_evalstack{nullptr};
0122 SvtxClusterEval *clustereval{nullptr};
0123 SvtxHitEval *hiteval{nullptr};
0124 SvtxTrackEval *trackeval{nullptr};
0125 SvtxTruthEval *trutheval{nullptr};
0126 SvtxVertexEval *vertexeval{nullptr};
0127
0128 ActsGeometry *geometry{nullptr};
0129
0130 SvtxTrackMap *dst_trackmap{nullptr};
0131 SvtxTrack *track{nullptr};
0132
0133 PHG4Particle *g4particle{nullptr};
0134 PHG4VtxPoint *g4vertex_point{nullptr};
0135
0136 MbdVertexMap *dst_mbdvertexmap{nullptr};
0137
0138 SvtxVertexMap *dst_vertexmap{nullptr};
0139 SvtxVertex *vertex{nullptr};
0140
0141 TrkrClusterContainer *dst_clustermap{nullptr};
0142
0143 int m_num_tracks_nTuple{0};
0144 int m_num_intermediate_states_nTuple{0};
0145
0146 static const int max_tracks{20};
0147
0148 float m_emcal_radius_user{100.70};
0149 float m_ihcal_radius_user{117};
0150 float m_ohcal_radius_user{177.423};
0151
0152 float m_emcal_e_low_cut{0.2};
0153 float m_ihcal_e_low_cut{0.01};
0154 float m_ohcal_e_low_cut{0.01};
0155 float m_dphi_cut_low{-0.15};
0156 float m_dphi_cut_high{0.15};
0157 float m_dz_cut_low{-10};
0158 float m_dz_cut_high{10};
0159
0160 float m_true_daughter_vertex_x[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0161 float m_true_daughter_vertex_y[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0162 float m_true_daughter_vertex_z[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0163 float m_true_daughter_ip[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0164 float m_true_daughter_ip_xy[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0165 float m_true_daughter_px[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0166 float m_true_daughter_py[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0167 float m_true_daughter_pz[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0168 float m_true_daughter_p[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0169 float m_true_daughter_pt[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0170 int m_true_daughter_id[max_tracks]{std::numeric_limits<int>::quiet_NaN()};
0171 float m_true_daughter_pv_x[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0172 float m_true_daughter_pv_y[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0173 float m_true_daughter_pv_z[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0174
0175 std::vector<int> m_true_daughter_track_history_PDG_ID[max_tracks];
0176 std::vector<float> m_true_daughter_track_history_PDG_mass[max_tracks];
0177 std::vector<float> m_true_daughter_track_history_px[max_tracks];
0178 std::vector<float> m_true_daughter_track_history_py[max_tracks];
0179 std::vector<float> m_true_daughter_track_history_pz[max_tracks];
0180 std::vector<float> m_true_daughter_track_history_pE[max_tracks];
0181 std::vector<float> m_true_daughter_track_history_pT[max_tracks];
0182
0183 float detector_emcal_deltaphi[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0184 float detector_emcal_deltaeta[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0185 float detector_emcal_deltaz[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0186 float detector_emcal_energy_3x3[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0187 float detector_emcal_energy_5x5[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0188 float detector_emcal_cluster_energy[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0189 float detector_ihcal_deltaphi[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0190 float detector_ihcal_deltaeta[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0191 float detector_ihcal_energy_3x3[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0192 float detector_ihcal_energy_5x5[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0193 float detector_ihcal_cluster_energy[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0194 float detector_ohcal_deltaphi[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0195 float detector_ohcal_deltaeta[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0196 float detector_ohcal_energy_3x3[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0197 float detector_ohcal_energy_5x5[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0198 float detector_ohcal_cluster_energy[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0199
0200 std::vector<unsigned int> detector_emcal_5x5Cell_Phi[max_tracks];
0201 std::vector<unsigned int> detector_emcal_5x5Cell_Eta[max_tracks];
0202 std::vector<float> detector_emcal_5x5Cell_E[max_tracks];
0203 unsigned int detector_emcal_ntowers[max_tracks]{std::numeric_limits<unsigned int>::quiet_NaN()};
0204 float detector_emcal_chi2[max_tracks]{std::numeric_limits<float>::quiet_NaN()};
0205
0206 RawTowerGeomContainer *EMCalGeo{nullptr};
0207 RawClusterContainer *clustersEM{nullptr};
0208 TowerInfoContainer *_towersEM{nullptr};
0209 RawTowerGeomContainer *IHCalGeo{nullptr};
0210 RawClusterContainer *clustersIH{nullptr};
0211 RawTowerContainer *_towersIH{nullptr};
0212 RawTowerGeomContainer *OHCalGeo{nullptr};
0213 RawClusterContainer *clustersOH{nullptr};
0214 RawTowerContainer *_towersOH{nullptr};
0215
0216 unsigned int detector_nHits_MVTX[max_tracks]{0};
0217 unsigned int detector_nHits_INTT[max_tracks]{0};
0218 unsigned int detector_nHits_TPC[max_tracks]{0};
0219 unsigned int detector_nHits_TPOT[max_tracks]{0};
0220 unsigned int detector_nStates_MVTX[max_tracks]{0};
0221 unsigned int detector_nStates_INTT[max_tracks]{0};
0222 unsigned int detector_nStates_TPC[max_tracks]{0};
0223 unsigned int detector_nStates_TPOT[max_tracks]{0};
0224 std::vector<float> residual_x[max_tracks];
0225 std::vector<float> residual_y[max_tracks];
0226 std::vector<float> residual_z[max_tracks];
0227 std::vector<int> detector_layer[max_tracks];
0228 std::vector<int> mvtx_staveID[max_tracks];
0229 std::vector<int> mvtx_chipID[max_tracks];
0230 std::vector<int> intt_ladderZID[max_tracks];
0231 std::vector<int> intt_ladderPhiID[max_tracks];
0232 std::vector<int> tpc_sectorID[max_tracks];
0233 std::vector<int> tpc_side[max_tracks];
0234
0235 std::vector<float> allPV_x;
0236 std::vector<float> allPV_y;
0237 std::vector<float> allPV_z;
0238 std::vector<float> allPV_mother_IP;
0239 std::vector<float> allPV_mother_IPchi2;
0240 std::vector<float> allPV_daughter_IP[max_tracks];
0241 std::vector<float> allPV_daughter_IPchi2[max_tracks];
0242 std::vector<float> allPV_intermediates_IP[max_tracks];
0243 std::vector<float> allPV_intermediates_IPchi2[max_tracks];
0244
0245 PHG4TruthInfoContainer *m_truthinfo{nullptr};
0246 PHHepMCGenEventMap *m_geneventmap{nullptr};
0247 PHHepMCGenEvent *m_genevt{nullptr};
0248 };
0249
0250 #endif