Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:48

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef GEANTTESTER_H
0004 #define GEANTTESTER_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <decayfinder/DecayFinderContainer_v1.h>  // for DecayFinderContainer_v1
0009 
0010 #include <g4main/PHG4Particle.h>
0011 #include <g4main/PHG4TruthInfoContainer.h>
0012 #include <g4main/PHG4VtxPoint.h>
0013 
0014 #include <TBranch.h>
0015 #include <TFile.h>
0016 #include <TTree.h>
0017 
0018 #include <string>
0019 
0020 class PHCompositeNode;
0021 class PHG4TruthInfoContainer;
0022 class PHG4Particle;
0023 class PHG4VtxPoint;
0024 
0025 class QAG4SimulationTruthDecay : public SubsysReco
0026 {
0027  public:
0028   QAG4SimulationTruthDecay(const std::string &name = "QAG4SimulationTruthDecay");
0029 
0030   virtual ~QAG4SimulationTruthDecay() = default;
0031 
0032   /** Called during initialization.
0033       Typically this is where you can book histograms, and e.g.
0034       register them to Fun4AllServer (so they can be output to file
0035       using Fun4AllServer::dumpHistos() method).
0036    */
0037   int Init(PHCompositeNode *topNode) override;
0038 
0039   /** Called for each event.
0040       This is where you do the real work.
0041    */
0042   int process_event(PHCompositeNode *topNode) override;
0043 
0044   std::string get_histo_prefix();
0045 
0046   /// Called at the end of all processing.
0047   int End(PHCompositeNode *topNode) override;
0048 
0049   void setMotherPDG(int PDGID) { m_decay_pdg_id = PDGID; }
0050 
0051   void setMotherPDGRange(int min, int max)
0052   {
0053     m_mother_PDG_ID_min = min;
0054     m_mother_PDG_ID_max = max;
0055   };
0056   void setDaughterPDGRange(int min, int max)
0057   {
0058     m_daughter_PDG_ID_min = min;
0059     m_daughter_PDG_ID_max = max;
0060   };
0061 
0062   void setMinPT(float value) { m_pt_min = value; }
0063 
0064   void setEtaRange(float min, float max)
0065   {
0066     m_eta_min = min;
0067     m_eta_max = max;
0068   }
0069 
0070   void setNBinsMass(int nBins) { m_mass_nBins = nBins; }
0071   void setMassRange(float min, float max)
0072   {
0073     m_mass_min = min;
0074     m_mass_max = max;
0075   }
0076 
0077   void setNBinsDecayLength(int nBins) { m_decayLength_nBins = nBins; }
0078   void setDecayLengthRange(float min, float max)
0079   {
0080     m_decayLength_min = min;
0081     m_decayLength_max = max;
0082   }
0083 
0084   void setNBinsDecayTime(int nBins) { m_decayTime_nBins = nBins; }
0085   void setDecayTimeRange(float min, float max)
0086   {
0087     m_decayTime_min = min;
0088     m_decayTime_max = max;
0089   }
0090 
0091   void setDFNodeName(const std::string &name) { m_df_module_name = name; }
0092   void setOutputName(const std::string &name) { m_outfile_name = name; }
0093   void writeTuple(bool write) { m_write_nTuple = write; }
0094 
0095  private:
0096   typedef std::vector<std::pair<std::pair<int, int>, int>> Decay;
0097 
0098   unsigned int m_nTracks;
0099   float m_pt_min;
0100   float m_eta_min;
0101   float m_eta_max;
0102   int m_decay_pdg_id;
0103 
0104   PHG4TruthInfoContainer *m_truth_info;
0105   PHG4Particle *m_g4particle;
0106   std::string m_df_module_name;
0107   std::string m_outfile_name;
0108   TFile *m_outfile;
0109   TTree *m_tree;
0110   bool m_write_nTuple;
0111   bool m_write_QAHists;
0112   DecayFinderContainer_v1 *m_decayMap = nullptr;
0113 
0114   void initializeBranches();
0115   void getMotherPDG(PHCompositeNode *topNode);
0116   std::vector<int> getDecayFinderMothers(PHCompositeNode *topNode);
0117   bool isInRange(float min, float value, float max);
0118   void resetValues();
0119 
0120   int m_mother_PDG_ID_min = -421;
0121   int m_mother_PDG_ID_max = 421;
0122   int m_daughter_PDG_ID_min = -321;
0123   int m_daughter_PDG_ID_max = 321;
0124 
0125   int m_mass_nBins = 100;
0126   float m_mass_min = 0;
0127   float m_mass_max = 2;
0128 
0129   int m_decayLength_nBins = 100;
0130   float m_decayLength_min = 0;
0131   float m_decayLength_max = 1;
0132 
0133   int m_decayTime_nBins = 100;
0134   float m_decayTime_min = 0;
0135   float m_decayTime_max = 0.1;
0136 
0137   static const int max_tracks = 20;
0138   unsigned int m_event_number = 0;
0139   float m_mother_mass = -99;
0140   float m_daughter_sum_mass = 0;
0141   float m_mother_decayLength = -99;
0142   float m_mother_decayTime = -99;
0143   int m_mother_pdg_id = -99;
0144   float m_mother_px = 0;
0145   float m_mother_py = 0;
0146   float m_mother_pz = 0;
0147   float m_mother_pE = 0;
0148   float m_mother_pT = 0;
0149   float m_mother_eta = 0;
0150   int m_mother_barcode = -99;
0151   int m_track_pdg_id[max_tracks] = {0};
0152   float m_track_px[max_tracks] = {0};
0153   float m_track_py[max_tracks] = {0};
0154   float m_track_pz[max_tracks] = {0};
0155   float m_track_pE[max_tracks] = {0};
0156   float m_track_pT[max_tracks] = {0};
0157   float m_track_eta[max_tracks] = {0};
0158   float m_track_mass[max_tracks] = {0};
0159   int m_track_mother_barcode[max_tracks] = {0};
0160   float m_delta_px = 0;
0161   float m_delta_py = 0;
0162   float m_delta_pz = 0;
0163   float m_delta_pE = 0;
0164   bool m_accept_px_1percent = false;
0165   bool m_accept_py_1percent = false;
0166   bool m_accept_pz_1percent = false;
0167   bool m_accept_pE_1percent = false;
0168   bool m_accept_px_5percent = false;
0169   bool m_accept_py_5percent = false;
0170   bool m_accept_pz_5percent = false;
0171   bool m_accept_pE_5percent = false;
0172   bool m_accept_px_15percent = false;
0173   bool m_accept_py_15percent = false;
0174   bool m_accept_pz_15percent = false;
0175   bool m_accept_pE_15percent = false;
0176   bool m_accept_eta = true;
0177   bool m_accept_pT = true;
0178 };
0179 
0180 #endif  // GEANTTESTER_H