Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:20

0001 #ifndef HepMCCandidate_GenParticle_h
0002 #define HepMCCandidate_GenParticle_h
0003 /** \class reco::GenParticle
0004  *
0005  * particle candidate with information from HepMC::GenParticle
0006  *
0007  * \author: Luca Lista, INFN
0008  *
0009  */
0010 #include "DataFormats/Candidate/interface/CompositeRefCandidateT.h"
0011 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0012 #include "DataFormats/HepMCCandidate/interface/GenStatusFlags.h"
0013 #include <vector>
0014 
0015 namespace HepMC {
0016   class GenParticle;
0017 }
0018 
0019 namespace reco {
0020 
0021   class GenParticle : public CompositeRefCandidateT<GenParticleRefVector> {
0022   public:
0023     /// default constructor
0024     GenParticle() {}
0025     /// default constructor
0026     GenParticle(const LeafCandidate &c) : CompositeRefCandidateT<GenParticleRefVector>(c) {}
0027     /// constrocturo from values
0028     GenParticle(Charge q, const LorentzVector &p4, const Point &vtx, int pdgId, int status, bool integerCharge);
0029     /// constrocturo from values
0030     GenParticle(Charge q, const PolarLorentzVector &p4, const Point &vtx, int pdgId, int status, bool integerCharge);
0031     /// destructor
0032     ~GenParticle() override;
0033     /// return a clone
0034     GenParticle *clone() const override;
0035     void setCollisionId(int s) { collisionId_ = s; }
0036     int collisionId() const { return collisionId_; }
0037 
0038     const GenStatusFlags &statusFlags() const { return statusFlags_; }
0039     GenStatusFlags &statusFlags() { return statusFlags_; }
0040 
0041     /////////////////////////////////////////////////////////////////////////////
0042     //basic set of gen status flags accessible directly here
0043     //the rest accessible through statusFlags()
0044     //(see GenStatusFlags.h for their meaning)
0045 
0046     /////////////////////////////////////////////////////////////////////////////
0047     //these are robust, generator-independent functions for categorizing
0048     //mainly final state particles, but also intermediate hadrons/taus
0049 
0050     //is particle prompt (not from hadron, muon, or tau decay) and final state
0051     bool isPromptFinalState() const { return status() == 1 && statusFlags_.isPrompt(); }
0052 
0053     //is particle prompt (not from hadron, muon, or tau decay) and decayed
0054     //such as a prompt tau
0055     bool isPromptDecayed() const { return statusFlags_.isDecayedLeptonHadron() && statusFlags_.isPrompt(); }
0056 
0057     //this particle is a direct decay product of a prompt tau and is final state
0058     //(eg an electron or muon from a leptonic decay of a prompt tau)
0059     bool isDirectPromptTauDecayProductFinalState() const {
0060       return status() == 1 && statusFlags_.isDirectPromptTauDecayProduct();
0061     }
0062 
0063     /////////////////////////////////////////////////////////////////////////////
0064     //these are generator history-dependent functions for tagging particles
0065     //associated with the hard process
0066     //Currently implemented for Pythia 6 and Pythia 8 status codes and history
0067     //and may not have 100% consistent meaning across all types of processes
0068     //Users are strongly encouraged to stick to the more robust flags above,
0069     //as well as the expanded set available in GenStatusFlags.h
0070 
0071     //this particle is part of the hard process
0072     bool isHardProcess() const { return statusFlags_.isHardProcess(); }
0073 
0074     //this particle is the final state direct descendant of a hard process particle
0075     bool fromHardProcessFinalState() const { return status() == 1 && statusFlags_.fromHardProcess(); }
0076 
0077     //this particle is the decayed direct descendant of a hard process particle
0078     //such as a tau from the hard process
0079     bool fromHardProcessDecayed() const {
0080       return statusFlags_.isDecayedLeptonHadron() && statusFlags_.fromHardProcess();
0081     }
0082 
0083     //this particle is a direct decay product of a hardprocess tau and is final state
0084     //(eg an electron or muon from a leptonic decay of a tau from the hard process)
0085     bool isDirectHardProcessTauDecayProductFinalState() const {
0086       return status() == 1 && statusFlags_.isDirectHardProcessTauDecayProduct();
0087     }
0088 
0089     //this particle is the direct descendant of a hard process particle of the same pdg id.
0090     //For outgoing particles the kinematics are those before QCD or QED FSR
0091     //This corresponds roughly to status code 3 in pythia 6
0092     //This is the most complex and error prone of all the flags and you are strongly encouraged
0093     //to consider using the others to fill your needs.
0094     bool fromHardProcessBeforeFSR() const { return statusFlags_.fromHardProcessBeforeFSR(); }
0095 
0096     //provided for convenience.  Use this one if you were using status 3 before and didn't know or care what it exactly meant
0097     bool isMostlyLikePythia6Status3() { return fromHardProcessBeforeFSR(); }
0098 
0099     //this particle is the last copy of the particle in the chain  with the same pdg id
0100     //(and therefore is more likely, but not guaranteed, to carry the final physical momentum)
0101     bool isLastCopy() const { return statusFlags_.isLastCopy(); }
0102 
0103     //this particle is the last copy of the particle in the chain with the same pdg id
0104     //before QED or QCD FSR
0105     //(and therefore is more likely, but not guaranteed, to carry the momentum after ISR)
0106     bool isLastCopyBeforeFSR() const { return statusFlags_.isLastCopyBeforeFSR(); }
0107 
0108   private:
0109     /// checp overlap with another candidate
0110     bool overlap(const Candidate &) const override;
0111     int collisionId_;
0112     GenStatusFlags statusFlags_;
0113   };
0114 
0115 }  // namespace reco
0116 
0117 #endif