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