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