00001
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 #include "Rivet/Tools/ParticleIdUtils.hh"
00007 #include "Rivet/Tools/Logging.hh"
00008 #include "Rivet/Cmp.hh"
00009
00010 namespace Rivet {
00011
00012
00013 ZFinder::ZFinder(double etaMin, double etaMax,
00014 double pTmin,
00015 PdgId pid,
00016 double minmass, double maxmass,
00017 double dRmax, bool clusterPhotons, bool trackPhotons,
00018 double masstarget,
00019 FinalState inputfs) {
00020 vector<pair<double, double> > etaRanges;
00021 etaRanges += std::make_pair(etaMin, etaMax);
00022 _init(etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget, inputfs);
00023 }
00024
00025
00026 ZFinder::ZFinder(const std::vector<std::pair<double, double> >& etaRanges,
00027 double pTmin,
00028 PdgId pid,
00029 double minmass, const double maxmass,
00030 double dRmax, bool clusterPhotons, bool trackPhotons,
00031 double masstarget,
00032 FinalState inputfs) {
00033 _init(etaRanges, pTmin, pid, minmass, maxmass, dRmax, clusterPhotons, trackPhotons, masstarget, inputfs);
00034 }
00035
00036
00037 void ZFinder::_init(const std::vector<std::pair<double, double> >& etaRanges,
00038 double pTmin, PdgId pid,
00039 double minmass, double maxmass,
00040 double dRmax, bool clusterPhotons, bool trackPhotons,
00041 double masstarget,
00042 FinalState inputfs)
00043 {
00044 setName("ZFinder");
00045
00046 _minmass = minmass;
00047 _maxmass = maxmass;
00048 _masstarget = masstarget;
00049 _pid = pid;
00050 _trackPhotons = trackPhotons;
00051
00052 IdentifiedFinalState bareleptons(inputfs);
00053 bareleptons.acceptIdPair(pid);
00054 LeptonClusters leptons(inputfs, bareleptons, dRmax,
00055 clusterPhotons,
00056 etaRanges, pTmin);
00057 addProjection(leptons, "LeptonClusters");
00058
00059 VetoedFinalState remainingFS;
00060 remainingFS.addVetoOnThisFinalState(*this);
00061 addProjection(remainingFS, "RFS");
00062 }
00063
00064
00065
00066
00067
00068 const FinalState& ZFinder::remainingFinalState() const
00069 {
00070 return getProjection<FinalState>("RFS");
00071 }
00072
00073
00074 int ZFinder::compare(const Projection& p) const {
00075 PCmp LCcmp = mkNamedPCmp(p, "LeptonClusters");
00076 if (LCcmp != EQUIVALENT) return LCcmp;
00077
00078 const ZFinder& other = dynamic_cast<const ZFinder&>(p);
00079 return (cmp(_minmass, other._minmass) || cmp(_maxmass, other._maxmass) ||
00080 cmp(_pid, other._pid) || cmp(_trackPhotons, other._trackPhotons));
00081 }
00082
00083
00084 void ZFinder::project(const Event& e) {
00085 clear();
00086
00087 const LeptonClusters& leptons = applyProjection<LeptonClusters>(e, "LeptonClusters");
00088
00089 InvMassFinalState imfs(std::make_pair(_pid, -_pid), _minmass, _maxmass, _masstarget);
00090 ParticleVector tmp;
00091 tmp.insert(tmp.end(), leptons.clusteredLeptons().begin(), leptons.clusteredLeptons().end());
00092 imfs.calc(tmp);
00093
00094 if (imfs.particlePairs().size() < 1) return;
00095 ParticlePair Zconstituents(imfs.particlePairs()[0]);
00096 Particle l1(Zconstituents.first), l2(Zconstituents.second);
00097 _constituents += l1, l2;
00098 FourMomentum pZ = l1.momentum() + l2.momentum();
00099 const int z3charge = PID::threeCharge(l1.pdgId()) + PID::threeCharge(l2.pdgId());
00100 assert(z3charge == 0);
00101
00102 stringstream msg;
00103 msg << "Z reconstructed from: \n"
00104 << " " << l1.momentum() << " " << l1.pdgId() << "\n"
00105 << " + " << l2.momentum() << " " << l2.pdgId();
00106 MSG_DEBUG(msg.str());
00107 _bosons.push_back(Particle(ZBOSON, pZ));
00108
00109
00110
00111 foreach (const Particle& p, _constituents) {
00112 foreach (const ClusteredLepton& l, leptons.clusteredLeptons()) {
00113 if (p.pdgId()==l.pdgId() && p.momentum()==l.momentum()) {
00114 _theParticles.push_back(l.constituentLepton());
00115 if (_trackPhotons) {
00116 _theParticles.insert(_theParticles.end(),
00117 l.constituentPhotons().begin(),
00118 l.constituentPhotons().end());
00119 }
00120 }
00121 }
00122 }
00123 }
00124
00125
00126 }