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