Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef TUTORIAL_H
0004 #define TUTORIAL_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 #include <fun4all/Fun4AllReturnCodes.h>
0008 
0009 #include <phool/PHCompositeNode.h>
0010 #include <phool/getClass.h>
0011 
0012 #include <trackbase/TrkrClusterv4.h>
0013 #include <trackbase/TrkrClusterContainerv4.h>
0014 #include <trackbase/ActsGeometry.h>
0015 #include <ffaobjects/EventHeaderv1.h>
0016 
0017 #include <phool/getClass.h>
0018 
0019 #include <globalvertex/GlobalVertexMap.h>
0020 #include <globalvertex/SvtxVertexMap.h>
0021 #include <ffarawobjects/Gl1Packet.h>
0022 #include <trackbase_historic/SvtxPHG4ParticleMap_v1.h>
0023 #include <trackbase_historic/SvtxTrack.h>
0024 #include <trackbase_historic/SvtxTrack_v1.h>
0025 #include <trackbase_historic/SvtxTrack_v2.h>
0026 #include <trackbase_historic/SvtxTrackMap.h>
0027 #include <trackbase_historic/SvtxTrackMap_v1.h>
0028 #include <trackbase_historic/SvtxTrackState_v1.h>
0029 #include <trackbase_historic/TrackSeed.h>
0030 
0031 #include <trackbase/TrkrClusterv4.h>
0032 #include <trackbase/TrkrClusterContainerv4.h>
0033 #include <trackbase/TrkrDefs.h>
0034 #include <trackbase/ActsGeometry.h>
0035 
0036 #include <ffaobjects/EventHeaderv1.h>
0037 
0038 #include <calobase/RawCluster.h>
0039 #include <calobase/RawClusterContainer.h>
0040 #include <calobase/RawTower.h>
0041 #include <calobase/RawTowerContainer.h>
0042 #include <calobase/RawTowerGeom.h>
0043 #include <calobase/RawTowerGeomContainer.h>
0044 #include <calobase/TowerInfoContainer.h>
0045 #include <calobase/TowerInfoContainerv1.h>
0046 #include <calobase/TowerInfoContainerv2.h>
0047 #include <calobase/TowerInfoContainerv3.h>
0048 #include <calobase/TowerInfo.h>
0049 
0050 #include <g4main/PHG4Hit.h>
0051 #include <g4main/PHG4Particle.h>
0052 #include <g4main/PHG4TruthInfoContainer.h>
0053 #include <g4main/PHG4VtxPoint.h>
0054 #include <g4main/PHG4HitContainer.h>
0055 #include <g4main/PHG4TruthInfoContainer.h>
0056 #include <g4main/PHG4Shower.h>
0057 #include <g4main/PHG4HitDefs.h>
0058 
0059 #include <fun4all/SubsysReco.h>
0060 
0061 #include <globalvertex/GlobalVertexMap.h>
0062 
0063 #include <vector>
0064 #include <string>
0065 #include <iostream>
0066 #include <iomanip>
0067 
0068 #include <TDatabasePDG.h>
0069 #include <TFile.h>
0070 #include <TH1D.h>
0071 #include <TH2.h>
0072 #include <TH2F.h>
0073 #include <TTree.h>
0074 #include <TCanvas.h>
0075 #include <TGraph.h>
0076 #include <TString.h>
0077 #include <TPad.h>
0078 #include <TLorentzVector.h>
0079 
0080 class PHCompositeNode;
0081 
0082 class tutorial : public SubsysReco
0083 {
0084 public:
0085 
0086     tutorial(
0087         const std::string & name_in = "tutorial",
0088         std::string output_path_in = "",
0089         std::string output_rootfile_name_in = ""
0090     );
0091 
0092 
0093     ~tutorial() override;
0094 
0095     /** Called during initialization.
0096         Typically this is where you can book histograms, and e.g.
0097         register them to Fun4AllServer (so they can be output to file
0098         using Fun4AllServer::dumpHistos() method).
0099     */
0100     int Init(PHCompositeNode *topNode) override;
0101 
0102     /** Called for first event when run number is known.
0103         Typically this is where you may want to fetch data from
0104         database, because you know the run number. A place
0105         to book histograms which have to know the run number.
0106     */
0107     int InitRun(PHCompositeNode * /*topNode*/) override;
0108 
0109     /* Called for each event.
0110         This is where you do the real work.
0111     */
0112     int process_event(PHCompositeNode *topNode) override;
0113 
0114     /// Clean up internals after each event.
0115     int ResetEvent(PHCompositeNode *topNode) override;
0116 
0117     /// Called at the end of each run.
0118     int EndRun(const int runnumber) override;
0119 
0120     /// Called at the end of all processing.
0121     int End(PHCompositeNode *topNode) override;
0122 
0123     /// Reset
0124     int Reset(PHCompositeNode * /*topNode*/) override;
0125 
0126     void Print(const std::string &what = "ALL") const override;
0127 
0128     void SetOutputPath( std::string path ){ output_path = path; };
0129 
0130     void setTowerGeomNodeName(const std::string& name)
0131     {
0132         m_TowerGeomNodeName = name;
0133     }
0134  
0135 private:
0136     int prepareTracker(PHCompositeNode * topNode);
0137     int prepareEMCal(PHCompositeNode * topNode);
0138     int prepareiHCal(PHCompositeNode * topNode);
0139     int prepareoHCal(PHCompositeNode * topNode);
0140 
0141     int prepareEMCalClus(PHCompositeNode * topNode);
0142     int prepareiHCalClus(PHCompositeNode * topNode);
0143     int prepareoHCalClus(PHCompositeNode * topNode);
0144 
0145     int prepareG4Turth(PHCompositeNode * topNode);
0146     int prepareG4HIT(PHCompositeNode * topNode);
0147 
0148     int createTracksFromTruth(PHCompositeNode* topNode);
0149     int prepareTruthTrack(PHCompositeNode* topNode);
0150 
0151     bool checkTrack(SvtxTrack* track);
0152 
0153     std::string output_path;
0154     std::string output_rootfile_name;
0155 
0156     TFile* file_out;
0157     TTree* tree_out;
0158     TFile* output;
0159   
0160 
0161     TrkrClusterContainerv4 * node_cluster_map = nullptr;
0162     ActsGeometry * node_acts = nullptr;
0163     
0164     RawTowerGeomContainer * geomEM = nullptr;
0165     TowerInfoContainerv1 * EMCal_tower_sim_info = nullptr;
0166     RawTowerContainer * EMCal_tower_sim = nullptr;
0167     TowerInfoContainer * EMCal_tower_calib = nullptr;
0168     
0169     RawClusterContainer * EMCal_cluster_cont = nullptr;
0170     RawClusterContainer * EMCal_cluster_innr = nullptr;
0171     
0172     RawTowerGeomContainer * geomIH = nullptr;
0173     RawTowerContainer * iHCal_tower_sim = nullptr;
0174     TowerInfoContainer * iHCal_tower_calib = nullptr;
0175 
0176     RawClusterContainer * iHCal_cluster_cont = nullptr;
0177     
0178     RawTowerGeomContainer * geomOH = nullptr;
0179     RawTowerContainer * oHCal_tower_sim = nullptr;
0180     TowerInfoContainer * oHCal_tower_calib = nullptr;
0181 
0182     RawClusterContainer * oHCal_cluster_cont = nullptr;
0183     
0184     PHG4TruthInfoContainer *m_truth_info = nullptr;
0185     PHG4HitContainer *hits_CEMC = nullptr;
0186 
0187     SvtxTrackMap* trackMap = nullptr;
0188     SvtxTrack *truth_track = nullptr;
0189     SvtxTrackState *thisState = nullptr;
0190 
0191     long long eventID;
0192 
0193     int NClus;
0194     std::vector <int> clus_system;
0195     std::vector <int> clus_layer;
0196     std::vector <int> clus_adc;
0197     std::vector <double> clus_X;
0198     std::vector <double> clus_Y;
0199     std::vector <double> clus_Z;
0200     std::vector <int> clus_size;
0201     std::vector <int> clus_phi_size;
0202     std::vector <int> clus_z_size;
0203 
0204     int nTowers;
0205     std::vector <int> tower_system;
0206     std::vector <double> tower_X;
0207     std::vector <double> tower_Y;
0208     std::vector <double> tower_Z;
0209     std::vector <double> tower_R;
0210     std::vector <double> tower_Eta;
0211     std::vector <double> tower_Phi;
0212     std::vector <double> tower_Eta_test;
0213     std::vector <double> tower_Phi_test;
0214     std::vector <double> tower_Eta_bin;
0215     std::vector <double> tower_Phi_bin;
0216     std::vector <double> tower_edep;
0217 
0218     std::vector <double> tower_int_X;
0219     std::vector <double> tower_int_Y;
0220     std::vector <double> tower_int_Z;
0221     std::vector <double> tower_int_R;
0222 
0223     int nCaloClus;
0224     std::vector <int> caloClus_system;
0225     std::vector <double> caloClus_X;
0226     std::vector <double> caloClus_Y;
0227     std::vector <double> caloClus_Z;
0228     std::vector <double> caloClus_R;
0229     std::vector <double> caloClus_Phi;
0230     std::vector <double> caloClus_edep;
0231 
0232     std::vector <double> caloClus_innr_X;
0233     std::vector <double> caloClus_innr_Y;
0234     std::vector <double> caloClus_innr_Z;
0235     std::vector <double> caloClus_innr_R;
0236     std::vector <double> caloClus_innr_Phi;
0237     std::vector <double> caloClus_innr_edep;
0238 
0239     // note : Truth primary vertex information
0240     float TruthPV_trig_x_;
0241     float TruthPV_trig_y_;
0242     float TruthPV_trig_z_;
0243     int NTruthVtx_;
0244 
0245     // note : PHG4 information (from all PHG4Particles)
0246     int NPrimaryG4P_;
0247     int NPrimaryG4P_promptChargeHadron_;
0248     std::vector<float> PrimaryG4P_Pt_;
0249     std::vector<float> PrimaryG4P_Eta_;
0250     std::vector<float> PrimaryG4P_Phi_;
0251     std::vector<float> PrimaryG4P_E_;
0252     std::vector<int> PrimaryG4P_PID_;
0253     std::vector<TString> PrimaryG4P_ParticleClass_;
0254     std::vector<bool> PrimaryG4P_isStable_;
0255     std::vector<double> PrimaryG4P_Charge_;
0256     std::vector<bool> PrimaryG4P_isChargeHadron_;
0257 
0258     // note : PHG4hit information
0259     std::vector<float> _CEMC_Hit_Evis;
0260     std::vector<float> _CEMC_Hit_Edep;
0261     std::vector<float> _CEMC_Hit_ch;
0262     std::vector<float> _CEMC_Hit_x;
0263     std::vector<float> _CEMC_Hit_y;
0264     std::vector<float> _CEMC_Hit_z;
0265 
0266     std::vector<float> _CEMC_Pr_Hit_x;
0267     std::vector<float> _CEMC_Pr_Hit_y;
0268     std::vector<float> _CEMC_Pr_Hit_z;
0269     std::vector<float> _CEMC_Pr_Hit_R;
0270     std::vector<float> _CEMC_Pr_Hit_deltaT;
0271 
0272     std::vector<float> _PrG4_TTPRO_dD;
0273     std::vector<float> _PrG4_TTPRO_dR;
0274     std::vector<float> _PrG4_TTPRO_dphi;
0275 
0276     std::set<int> primary_electron_tracks;
0277 
0278     int nEMCal_chan = 24576;
0279     int niHCal_chan = 1536;
0280     int noHCal_chan = 1536;
0281     const std::string emcal_node_name = "TOWERINFO_CALIB_CEMC";
0282     const std::string ihcal_node_name = "TOWERINFO_CALIB_HCALIN";
0283     const std::string ohcal_node_name = "TOWERINFO_CALIB_HCALOUT";
0284 
0285     const std::string emcalClus_node_name = "CLUSTER_CEMC";
0286     const std::string emcalClus_inner_node_name = "CLUSTERINNER_CEMC";
0287     const std::string ihcalClus_node_name = "CLUSTER_HCALIN";
0288     const std::string ohcalClus_node_name = "CLUSTER_HCALOUT";
0289     
0290     std::string m_TowerGeomNodeName = "TOWERGEOM_CEMC";
0291 };
0292 
0293 #endif // TUTORIAL_H