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