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