rivet is hosted by Hepforge, IPPP Durham
DressedLeptons.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/DressedLeptons.hh"
00003 
00004 namespace Rivet {
00005 
00006 
00007   DressedLeptons::DressedLeptons(const FinalState& photons, const FinalState& signal,
00008                                  double dRmax, bool cluster,
00009                                  const vector<pair<double, double> >& etaRanges,
00010                                  double pTmin, bool useDecayPhotons)
00011     : FinalState(etaRanges, pTmin),
00012       _dRmax(dRmax), _cluster(cluster), _fromDecay(useDecayPhotons)
00013   {
00014     setName("DressedLeptons");
00015     IdentifiedFinalState photonfs(photons);
00016     photonfs.acceptId(PID::PHOTON);
00017     addProjection(photonfs, "Photons");
00018     addProjection(signal, "Signal");
00019   }
00020 
00021 
00022   int DressedLeptons::compare(const Projection& p) const {
00023     // Compare the two as final states (for pT and eta cuts)
00024     const DressedLeptons& other = dynamic_cast<const DressedLeptons&>(p);
00025     int fscmp = FinalState::compare(other);
00026     if (fscmp != EQUIVALENT) return fscmp;
00027 
00028     const PCmp phcmp = mkNamedPCmp(p, "Photons");
00029     if (phcmp != EQUIVALENT) return phcmp;
00030 
00031     const PCmp sigcmp = mkNamedPCmp(p, "Signal");
00032     if (sigcmp != EQUIVALENT) return sigcmp;
00033 
00034     return (cmp(_dRmax, other._dRmax) ||
00035             cmp(_cluster, other._cluster) ||
00036             cmp(_fromDecay, other._fromDecay));
00037   }
00038 
00039 
00040   void DressedLeptons::project(const Event& e) {
00041     _theParticles.clear();
00042     _clusteredLeptons.clear();
00043 
00044     const FinalState& signal = applyProjection<FinalState>(e, "Signal");
00045     Particles bareleptons = signal.particles();
00046     if (bareleptons.empty()) return;
00047 
00048     vector<ClusteredLepton> allClusteredLeptons;
00049     for (size_t i = 0; i < bareleptons.size(); ++i) {
00050       allClusteredLeptons.push_back(ClusteredLepton(bareleptons[i]));
00051     }
00052 
00053     // Match each photon to its closest charged lepton within the dR cone
00054     const FinalState& photons = applyProjection<FinalState>(e, "Photons");
00055     foreach (const Particle& photon, photons.particles()) {
00056       // Ignore photon if it's from a hadron/tau decay and we're avoiding those
00057       if (!_fromDecay && photon.fromDecay()) continue;
00058       const FourMomentum p_P = photon.momentum();
00059       double dRmin = _dRmax;
00060       int idx = -1;
00061       for (size_t i = 0; i < bareleptons.size(); ++i) {
00062         // Only cluster photons around *charged* signal particles
00063         if (PID::threeCharge(bareleptons[i].pdgId()) == 0) continue;
00064         // Find the closest lepton
00065         const FourMomentum& p_l = bareleptons[i].momentum();
00066         double dR = deltaR(p_l, p_P);
00067         if (dR < dRmin) {
00068           dRmin = dR;
00069           idx = i;
00070         }
00071       }
00072       if (idx > -1) {
00073         if (_cluster) allClusteredLeptons[idx].addPhoton(photon, _cluster);
00074       }
00075     }
00076 
00077     foreach (const ClusteredLepton& lepton, allClusteredLeptons) {
00078       if (accept(lepton)) {
00079         _clusteredLeptons.push_back(lepton);
00080         _theParticles.push_back(lepton.constituentLepton());
00081         _theParticles.insert(_theParticles.end(),
00082                              lepton.constituentPhotons().begin(),
00083                              lepton.constituentPhotons().end());
00084       }
00085     }
00086   }
00087 }