Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:26:13

0001 // -*- C++ -*-
0002 #ifndef RIVET_VetoedFinalState_HH
0003 #define RIVET_VetoedFinalState_HH
0004 
0005 #include "Rivet/Projections/FinalState.hh"
0006 
0007 namespace Rivet {
0008 
0009 
0010   /// @brief FS modifier to exclude classes of particles from the final state.
0011   class VetoedFinalState : public FinalState {
0012   public:
0013 
0014     /// @name Constructors
0015     /// @{
0016 
0017     /// Constructor with a specific FinalState and a cuts list to veto
0018     VetoedFinalState(const FinalState& fsp, const vector<Cut>& cuts)
0019       : FinalState(), _vetoCuts(cuts)
0020     {
0021       setName("VetoedFinalState");
0022       declare(fsp, "FS");
0023     }
0024 
0025     /// Constructor with a specific FinalState and a single cut to veto
0026     VetoedFinalState(const FinalState& fsp, const Cut& cut)
0027       : VetoedFinalState(fsp, vector<Cut>{cut})
0028     {   }
0029 
0030     /// Constructor with a default FinalState and a cuts list to veto
0031     VetoedFinalState(const vector<Cut>& cuts)
0032       : VetoedFinalState(FinalState(), cuts)
0033     {   }
0034 
0035     /// Constructor with a default FinalState and a single cut to veto
0036     VetoedFinalState(const Cut& cut)
0037       : VetoedFinalState(FinalState(), vector<Cut>{cut})
0038     {   }
0039 
0040     /// Constructor with a specific FinalState and a PID list to veto
0041     VetoedFinalState(const FinalState& fsp, const vector<PdgId>& vetopids)
0042       : VetoedFinalState(fsp, {})
0043     {
0044       _vetoCuts.reserve(vetopids.size());
0045       for (PdgId pid : vetopids) addVeto(pid);
0046     }
0047 
0048     /// Constructor with a specific FinalState and a PID to veto
0049     VetoedFinalState(const FinalState& fsp, PdgId vetopid)
0050       : VetoedFinalState(fsp, vector<Cut>{Cuts::pid == vetopid})
0051     {   }
0052 
0053     /// Constructor with a default FinalState and a PID list to veto
0054     VetoedFinalState(const vector<PdgId>& vetopids)
0055       : VetoedFinalState(FinalState(), {})
0056     {
0057       _vetoCuts.reserve(vetopids.size());
0058       for (PdgId pid : vetopids) addVeto(pid);
0059     }
0060 
0061     /// Constructor with a default FinalState and a PID to veto
0062     VetoedFinalState(PdgId vetopid)
0063       : VetoedFinalState(FinalState(), vector<Cut>{Cuts::pid == vetopid})
0064     {   }
0065 
0066     /// Constructor with specific FinalState but no cuts
0067     VetoedFinalState(const FinalState& fsp)
0068       : VetoedFinalState(fsp, vector<Cut>())
0069     {   }
0070 
0071     /// Default constructor with default FinalState and no cuts
0072     VetoedFinalState()
0073       : VetoedFinalState(FinalState(), vector<Cut>())
0074     {   }
0075 
0076 
0077     /// Clone on the heap.
0078     RIVET_DEFAULT_PROJ_CLONE(VetoedFinalState);
0079 
0080     /// @}
0081 
0082     /// Import to avoid warnings about overload-hiding
0083     using Projection::operator =;
0084 
0085 
0086     /// Get the list of particle IDs and \f$ p_T \f$ ranges to veto.
0087     const vector<Cut>& vetoDetails() const {
0088       return _vetoCuts;
0089     }
0090     //using vetos = vetoDetails;
0091 
0092 
0093     /// Add a particle selection to be vetoed from the final state
0094     VetoedFinalState& addVeto(const Cut& cut) {
0095       _vetoCuts.push_back(cut);
0096       return *this;
0097     }
0098 
0099     /// Add a particle selection to be vetoed from the final state
0100     VetoedFinalState& addVeto(PdgId pid, const Cut& cut=Cuts::OPEN) {
0101       _vetoCuts.push_back(Cuts::pid == pid && cut);
0102       return *this;
0103     }
0104 
0105     /// Add a particle/antiparticle selection to be vetoed from the final state
0106     VetoedFinalState& addVetoPair(PdgId pid, const Cut& cut=Cuts::OPEN) {
0107       _vetoCuts.push_back(Cuts::abspid == pid && cut);
0108       return *this;
0109     }
0110 
0111 
0112     /// @brief Add a particle ID and \f$ p_T \f$ range to veto
0113     ///
0114     /// Particles with \f$ p_T \f$ IN the given range will be rejected.
0115     VetoedFinalState& addVetoDetail(PdgId pid, double ptmin, double ptmax=std::numeric_limits<double>::max()) {
0116       return addVeto(pid, Cuts::ptIn(ptmin, ptmax));
0117     }
0118     //const auto addVeto = addVetoDetail;
0119 
0120     /// @brief Add a particle/antiparticle pair to veto in a given \f$ p_T \f$ range
0121     ///
0122     /// Given a single ID, both the particle and its conjugate antiparticle will
0123     /// be rejected if their \f$ p_T \f$ is IN the given range.
0124     VetoedFinalState& addVetoPairDetail(PdgId pid, double ptmin, double ptmax=std::numeric_limits<double>::max()) {
0125       return addVetoPair(pid, Cuts::ptIn(ptmin, ptmax));
0126     }
0127     //using addVetoPair = addVetoPairDetail;
0128 
0129     /// @brief Add a particle ID to veto (all \f$ p_T \f$ range will be vetoed)
0130     VetoedFinalState& addVetoId(PdgId pid) {
0131       return addVeto(pid);
0132     }
0133     //using addVeto = addVetoId;
0134 
0135     ///  @brief Add a particle/antiparticle pair to veto
0136     ///
0137     /// Given a single ID, both the particle and its corresponding antiparticle
0138     /// (for all \f$ p_T \f$ values) will be vetoed.
0139     VetoedFinalState& addVetoPairId(PdgId pid) {
0140       return addVetoPair(pid);
0141     }
0142     //using addVetoPair = addVetoPairId;
0143 
0144 
0145     /// Set the list of particle selections to veto
0146     VetoedFinalState& setVetoDetails(const vector<Cut>& cuts) {
0147       _vetoCuts = cuts;
0148       return *this;
0149     }
0150     //const auto setVetos = setVetoDetails;
0151 
0152 
0153     /// Veto all neutrinos (convenience method)
0154     VetoedFinalState& vetoNeutrinos() {
0155       addVetoPairId(PID::NU_E);
0156       addVetoPairId(PID::NU_MU);
0157       addVetoPairId(PID::NU_TAU);
0158       return *this;
0159     }
0160 
0161 
0162     /// Add a veto on composite masses within a given width.
0163     /// The composite mass is composed of nProducts decay products
0164     /// @ todo might we want to specify a range of pdg ids for the decay products?
0165     VetoedFinalState& addCompositeMassVeto(double mass, double width, int nProducts=2) {
0166       const double halfWidth = 0.5*width;
0167       pair<double,double> massRange(mass-halfWidth, mass+halfWidth);
0168       _compositeVetoes.insert(make_pair(nProducts, massRange));
0169       _nCompositeDecays.insert(nProducts);
0170       return *this;
0171     }
0172 
0173 
0174     /// Veto the decay products of particle with PDG code @a pid
0175     /// @todo Need HepMC to sort themselves out and keep vector bosons from
0176     /// the hard vtx in the event record before this will work reliably for all pdg ids
0177     VetoedFinalState& addDecayProductsVeto(PdgId pid) {
0178       _parentVetoes.insert(pid);
0179       return *this;
0180     }
0181 
0182     /// Veto particles from a supplied final state
0183     VetoedFinalState& vetoFinalState(const ParticleFinder& fs) {
0184       const string name = "FS_" + to_str(_vetofsnames.size());
0185       declare(fs, name);
0186       _vetofsnames.insert(name);
0187       return *this;
0188     }
0189     /// Alias
0190     ///
0191     /// @deprecated Prefer the shorter version
0192     VetoedFinalState& addVetoOnThisFinalState(const ParticleFinder& fs) {
0193       return vetoFinalState(fs);
0194     }
0195 
0196 
0197     /// Clear the list of particle IDs and ranges to veto.
0198     VetoedFinalState& reset() {
0199       _vetoCuts.clear();
0200       return *this;
0201     }
0202 
0203 
0204     /// Apply the projection on the supplied event.
0205     void project(const Event& e);
0206 
0207     /// Compare projections.
0208     CmpState compare(const Projection& p) const;
0209 
0210 
0211   protected:
0212 
0213     /// The veto cuts
0214     vector<Cut> _vetoCuts;
0215 
0216     /// Composite particle masses to veto
0217     /// @todo Also generalise to use Cuts
0218     multimap<PdgId, pair<double,double> > _compositeVetoes;
0219     set<int> _nCompositeDecays;
0220 
0221     /// Set of decaying particle IDs to veto
0222     set<PdgId> _parentVetoes;
0223 
0224     /// Set of finalstate to be vetoed
0225     set<string> _vetofsnames;
0226 
0227   };
0228 
0229 
0230 }
0231 
0232 
0233 #endif