rivet is hosted by Hepforge, IPPP Durham
ZFinder.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/ZFinder.hh"
00003 #include "Rivet/Projections/InvMassFinalState.hh"
00004 #include "Rivet/Projections/LeptonClusters.hh"
00005 #include "Rivet/Projections/VetoedFinalState.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   ZFinder::ZFinder(const FinalState& inputfs,
00011                    double etaMin, double etaMax,
00012                    double pTmin,
00013                    PdgId pid,
00014                    double minmass, double maxmass,
00015                    double dRmax, bool clusterPhotons, bool trackPhotons,
00016                    double masstarget) {
00017     vector<pair<double, double> > etaRanges;
00018     etaRanges += std::make_pair(etaMin, etaMax);
00019     _init(inputfs, etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget);
00020   }
00021 
00022 
00023   ZFinder::ZFinder(const FinalState& inputfs,
00024                    const std::vector<std::pair<double, double> >& etaRanges,
00025                    double pTmin,
00026                    PdgId pid,
00027                    double minmass, const double maxmass,
00028                    double dRmax, bool clusterPhotons, bool trackPhotons,
00029                    double masstarget) {
00030     _init(inputfs, etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget);
00031   }
00032 
00033 
00034   ZFinder::ZFinder(double etaMin, double etaMax,
00035                    double pTmin,
00036                    PdgId pid,
00037                    double minmass, double maxmass,
00038                    double dRmax, bool clusterPhotons, bool trackPhotons,
00039                    double masstarget) {
00040     vector<pair<double, double> > etaRanges;
00041     etaRanges += std::make_pair(etaMin, etaMax);
00042     FinalState inputfs;
00043     _init(inputfs, etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget);
00044   }
00045 
00046 
00047   ZFinder::ZFinder(const std::vector<std::pair<double, double> >& etaRanges,
00048                    double pTmin,
00049                    PdgId pid,
00050                    double minmass, const double maxmass,
00051                    double dRmax, bool clusterPhotons, bool trackPhotons,
00052                    double masstarget) {
00053     FinalState inputfs;
00054     _init(inputfs, etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget);
00055   }
00056   void ZFinder::_init(const FinalState& inputfs,
00057                       const std::vector<std::pair<double, double> >& etaRanges,
00058                       double pTmin,  PdgId pid,
00059                       double minmass, double maxmass,
00060                       double dRmax, bool clusterPhotons, bool trackPhotons,
00061                       double masstarget)
00062   {
00063     setName("ZFinder");
00064 
00065     _minmass = minmass;
00066     _maxmass = maxmass;
00067     _masstarget = masstarget;
00068     _pid = pid;
00069     _trackPhotons = trackPhotons;
00070 
00071     IdentifiedFinalState bareleptons(inputfs);
00072     bareleptons.acceptIdPair(pid);
00073     LeptonClusters leptons(inputfs, bareleptons, dRmax,
00074                            clusterPhotons,
00075                            etaRanges, pTmin);
00076     addProjection(leptons, "LeptonClusters");
00077 
00078     VetoedFinalState remainingFS;
00079     remainingFS.addVetoOnThisFinalState(*this);
00080     addProjection(remainingFS, "RFS");
00081   }
00082 
00083 
00084   /////////////////////////////////////////////////////
00085 
00086 
00087   const FinalState& ZFinder::remainingFinalState() const
00088   {
00089     return getProjection<FinalState>("RFS");
00090   }
00091 
00092 
00093   int ZFinder::compare(const Projection& p) const {
00094     PCmp LCcmp = mkNamedPCmp(p, "LeptonClusters");
00095     if (LCcmp != EQUIVALENT) return LCcmp;
00096 
00097     const ZFinder& other = dynamic_cast<const ZFinder&>(p);
00098     return (cmp(_minmass, other._minmass) || cmp(_maxmass, other._maxmass) ||
00099             cmp(_pid, other._pid) || cmp(_trackPhotons, other._trackPhotons));
00100   }
00101 
00102 
00103   void ZFinder::project(const Event& e) {
00104     clear();
00105 
00106     const LeptonClusters& leptons = applyProjection<LeptonClusters>(e, "LeptonClusters");
00107 
00108     InvMassFinalState imfs(std::make_pair(_pid, -_pid), _minmass, _maxmass, _masstarget);
00109     Particles tmp;
00110     tmp.insert(tmp.end(), leptons.clusteredLeptons().begin(), leptons.clusteredLeptons().end());
00111     imfs.calc(tmp);
00112 
00113     if (imfs.particlePairs().size() < 1) return;
00114     ParticlePair Zconstituents(imfs.particlePairs()[0]);
00115     Particle l1(Zconstituents.first), l2(Zconstituents.second);
00116     if (PID::threeCharge(l1)>0.0) {
00117       _constituents += l1, l2;
00118     }
00119     else {
00120       _constituents += l2, l1;
00121     }
00122     FourMomentum pZ = l1.momentum() + l2.momentum();
00123     const int z3charge = PID::threeCharge(l1.pdgId()) + PID::threeCharge(l2.pdgId());
00124     assert(z3charge == 0);
00125 
00126     stringstream msg;
00127     msg << "Z reconstructed from: \n"
00128         << "   " << l1.momentum() << " " << l1.pdgId() << "\n"
00129         << " + " << l2.momentum() << " " << l2.pdgId();
00130     MSG_DEBUG(msg.str());
00131     _bosons.push_back(Particle(PID::ZBOSON, pZ));
00132 
00133     // Find the LeptonClusters which survived the IMFS cut such that we can
00134     // extract their original particles
00135     foreach (const Particle& p, _constituents) {
00136       foreach (const ClusteredLepton& l, leptons.clusteredLeptons()) {
00137         if (p.pdgId()==l.pdgId() && p.momentum()==l.momentum()) {
00138           _theParticles.push_back(l.constituentLepton());
00139           if (_trackPhotons) {
00140             _theParticles.insert(_theParticles.end(),
00141                                  l.constituentPhotons().begin(), l.constituentPhotons().end());
00142           }
00143         }
00144       }
00145     }
00146   }
00147 
00148 
00149 }