Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:15:04

0001 /**
0002  * @TruthConversionEval.h
0003  * @author Francesco Vassalli <Francesco.Vassalli@colorado.edu>
0004  * @version 1.0
0005  *
0006  * @section Uses truth particle information to find photon conversions. 
0007  * Infomation about the conversions is recored in a TTree.
0008  * Finally they are associated with clusters for later analysis
0009  */
0010 #ifndef TRUTHCONVERSIONEVAL_H__
0011 #define TRUTHCONVERSIONEVAL_H__
0012 
0013 #include <fun4all/SubsysReco.h>
0014 #include <calobase/RawClusterContainer.h>
0015 #include <g4main/PHG4Particle.h>
0016 #include <trackbase_historic/SvtxTrack.h>
0017 #include <TLorentzVector.h>
0018 #include <queue>
0019 
0020 class PHCompositeNode;
0021 class PHG4TruthInfoContainer;
0022 class PHG4VtxPoint;
0023 class SvtxTrackEval;
0024 class SvtxTrackMap;
0025 class SvtxVertex;
0026 class SvtxHitMap;
0027 class SvtxHit;
0028 class SvtxClusterMap;
0029 class SvtxCluster;
0030 class TrkrClusterContainer;
0031 class RawClusterContainer;
0032 class SVReco;
0033 class VtxRegressor;
0034 class Conversion;
0035 class TTree;
0036 class TFile;
0037 
0038 class TruthConversionEval: public SubsysReco
0039 {
0040 
0041   public:
0042     /**
0043      *
0044      * @param name name of the output file
0045      * @param runnumber printed in TTree for condor jobs
0046      * @param particleEmbed the embedID of particles embeded by Fun4All
0047      * @param pythiaEmbed the embedID for an embeded pythia event
0048      * @param makeTTree true-writes the TTree false-won't make TTree will still find clusters
0049      */
0050     TruthConversionEval(const std::string &name,unsigned int runnumber, 
0051         int particleEmbed, int pythiaEmbed,bool makeTTree,std::string TMVAName,std::string TMVAPath);
0052     ~TruthConversionEval();
0053     int InitRun(PHCompositeNode*);
0054     /**
0055      * Find the conversions pass them to numUnique.
0056      * Fill the TTree
0057      * @return event status */
0058     int process_event(PHCompositeNode*);
0059     int End(PHCompositeNode*);
0060     /** get the clusters associated with converions*/
0061     const RawClusterContainer* getClusters()const;
0062 
0063   private:
0064     //@return ownsership
0065     inline TLorentzVector tracktoTLV(SvtxTrack* track){
0066         TLorentzVector r;
0067         r.SetPtEtaPhiM(track->get_pt(),track->get_eta(),track->get_phi(),.0005109989461);//assume electron
0068         return r;
0069     }
0070     //@return ownsership
0071     inline TLorentzVector particletoTLV(PHG4Particle* particle){
0072         return TLorentzVector(particle->get_px(),particle->get_py(),particle->get_pz(),particle->get_e());
0073     }
0074     bool doNodePointers(PHCompositeNode* topNode);
0075     SvtxVertex* get_primary_vertex(PHCompositeNode* topNode)const;
0076     /** helper function for process_event
0077      * fills the member fields with information from the conversions 
0078      * finds the clusters associated with the truth conversions*/
0079     void numUnique(std::map<int,Conversion>* map,SvtxTrackEval* trackEval,RawClusterContainer* mainClusterContainer,std::vector<std::pair<SvtxTrack*,SvtxTrack*>>* tightBackground);
0080     ///fills the member fields for all the background trees
0081     void processTrackBackground(std::vector<SvtxTrack*>*v,SvtxTrackEval*);
0082     void recordConversion(Conversion *conversion,TLorentzVector *tlv_photon,TLorentzVector *tlv_electron, TLorentzVector *tlv_positron);
0083 
0084     int get_embed(PHG4Particle* particle, PHG4TruthInfoContainer* truthinfo) const;
0085     float vtoR(PHG4VtxPoint* vtx)const;
0086 
0087     const static int s_kMAXParticles=200; ///< increase this number if arrays go out of bounds
0088     const unsigned int _kRunNumber;
0089     const int _kParticleEmbed; ///< primary embedID
0090     const int _kPythiaEmbed; ///< background event embedID i.e. pythia or AA
0091     const bool _kMakeTTree;//< if false no TTrees are output
0092     int _runNumber; ///<for the TTree do not change
0093     TFile *_f=NULL; ///< output file
0094     TTree *_signalCutTree=NULL; ///<signal data for making track pair cuts
0095     TTree *_trackBackTree=NULL;///< background for all possible single tracks
0096     TTree *_pairBackTree=NULL;///< background for all possible track pairs
0097     TTree *_vtxBackTree=NULL;///< background that passes existing track pair cuts
0098     TTree *_vtxingTree=NULL; ///<data for training vtxing
0099     TTree *_observTree=NULL; ///<per event observables
0100     RawClusterContainer *_mainClusterContainer; //< clusters from the node
0101     PHG4TruthInfoContainer *_truthinfo;
0102     TrkrClusterContainer* _clusterMap;
0103     SvtxTrackMap* _allTracks;
0104     SvtxHitMap *_hitMap;
0105     std::string _foutname; ///< name of the output file
0106     SVReco *_vertexer=NULL; ///< for reco vertex finding
0107     VtxRegressor *_regressor=NULL; ///<for reco vertex correction with TMVA
0108 
0109     /** \defgroup  variables  for the TTrees
0110       @{*/
0111     /** # of clusters associated with each conversion that has 2 reco tracks
0112      * 1 indicates the reco tracks go to the same cluster ~15% of conversions*/
0113 
0114     float _b_refitdiffx;
0115     float _b_refitdiffy;
0116     float _b_refitdiffz;
0117     int   _b_nCluster; 
0118     int _bb_track1_pid;
0119     int _bb_track2_pid;
0120     int _bb_parent_pid;
0121     float _b_cluster_dphi ;
0122     float _b_cluster_deta;
0123     int   _bb_nCluster; 
0124     float _bb_cluster_dphi ;
0125     float _bb_cluster_deta;
0126     float _b_track1_pt;
0127     float _b_track1_eta;
0128     float _b_track1_phi;
0129     float _b_track2_pt;
0130     float _b_track2_eta;
0131     float _b_track2_phi;
0132     float _b_track_deta ;
0133     int _b_track_layer ;
0134     int _b_track_dlayer ;
0135     float _b_track_pT;
0136     float _b_track_dca;
0137     float _b_ttrack_pT;
0138     double _b_approach  ;
0139     float _b_vtx_radius ;
0140     float _b_vtx_phi ;
0141     float _b_vtx_eta ;
0142     float _b_vtx_x ;
0143     float _b_vtx_y ;
0144     float _b_vtx_z ;
0145     float _b_tvtx_eta ;
0146     float _b_tvtx_x ;
0147     float _b_tvtx_y ;
0148     float _b_tvtx_z ;
0149     float _b_tvtx_radius ;
0150     float _b_tvtx_phi ;
0151     float _b_vtxTrackRZ_dist;
0152     float _b_vtxTrackRPhi_dist;
0153     float _b_vtx_chi2;
0154     float _b_photon_m;
0155     float _b_tphoton_m;
0156     float _b_tphoton_pT;
0157     float _b_photon_pT;
0158     float _b_cluster_prob;
0159     float _b_track_dphi;
0160     //bb stands for background branch
0161     float _bb_track_deta ;
0162     float _bb_vtx_radius ;
0163     float _bb_track_dca ;
0164     int _bb_track_layer ;
0165     int _bb_track_dlayer ;
0166     float _bb_track_pT;
0167     double _bb_approach ;
0168     float _bb_vtxTrackRZ_dist;
0169     float _bb_vtxTrackRPhi_dist;
0170     float _bb_vtx_chi2;
0171     float _bb_photon_m;
0172     float _bb_photon_pT;
0173     float _bb_cluster_prob;
0174     float _bb_track_dphi;
0175     int _bb_pid;
0176     int  _b_nMatched=0;
0177     int _b_nUnmatched=0;
0178     std::vector<float> _b_truth_pT;
0179     std::vector<float> _b_reco_pT;
0180     std::vector<float> _b_alltrack_pT;
0181     std::vector<float> _b_allphoton_pT;
0182     /**@}*/
0183     /** RawClusters associated with truth conversions
0184      * processed by other modules currently empty*/
0185     RawClusterContainer _conversionClusters;
0186     //TODO check TPC radius
0187     const static int s_kTPCRADIUS=21; //in cm there is a way to get this from the simulation I should implement?
0188     ///<TPC radius currently hardcoded
0189     float _kRAPIDITYACCEPT=1; //<acceptance rapidity currently hard coded to |1|
0190     float _kTightPtMin=2.5; //< pt cut for making tight background
0191     float _kTightDetaMax=.0082;//< deta cut for making tight background
0192 };
0193 
0194 
0195 
0196 #endif // __TRUTHCONVERSIONEVAL_H__
0197 
0198 
0199