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