rivet is hosted by Hepforge, IPPP Durham
LeptonClusters.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/LeptonClusters.hh"
00003 
00004 namespace Rivet {
00005 
00006 
00007   LeptonClusters::LeptonClusters(const FinalState& photons, const FinalState& signal,
00008                  double dRmax, bool cluster,
00009                  const std::vector<std::pair<double, double> >& etaRanges,
00010                  double pTmin) :
00011     FinalState(etaRanges, pTmin),
00012     _dRmax(dRmax), _cluster(cluster)
00013   {
00014     setName("LeptonClusters");
00015 
00016     IdentifiedFinalState photonfs(photons);
00017     photonfs.acceptId(PID::PHOTON);
00018     addProjection(photonfs, "Photons");
00019     addProjection(signal, "Signal");
00020   }
00021 
00022 
00023   int LeptonClusters::compare(const Projection& p) const {
00024     // Compare the two as final states (for pT and eta cuts)
00025     const LeptonClusters& other = dynamic_cast<const LeptonClusters&>(p);
00026     int fscmp = FinalState::compare(other);
00027     if (fscmp != EQUIVALENT) return fscmp;
00028 
00029     const PCmp phcmp = mkNamedPCmp(p, "Photons");
00030     if (phcmp != EQUIVALENT) return phcmp;
00031 
00032     const PCmp sigcmp = mkNamedPCmp(p, "Signal");
00033     if (sigcmp != EQUIVALENT) return sigcmp;
00034 
00035     return (cmp(_dRmax, other._dRmax) || cmp(_cluster, other._cluster));
00036   }
00037 
00038 
00039   void LeptonClusters::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     const FinalState& photons = applyProjection<FinalState>(e, "Photons");
00053     foreach (const Particle& photon, photons.particles()) {
00054       const FourMomentum p_P = photon.momentum();
00055       double dRmin=_dRmax;
00056       int idx = -1;
00057       for (size_t i = 0; i < bareleptons.size(); ++i) {
00058         FourMomentum p_l = bareleptons[i].momentum();
00059         // Only cluster photons around *charged* signal particles
00060         if (PID::threeCharge(bareleptons[i].pdgId()) == 0) continue;
00061         // Geometrically match momentum vectors
00062         double dR = deltaR(p_l, p_P);
00063         if (dR < dRmin) {
00064           dRmin = dR;
00065           idx = i;
00066         }
00067       }
00068       if (idx > -1) {
00069         if (_cluster) allClusteredLeptons[idx].addPhoton(photon, _cluster);
00070       }
00071     }
00072 
00073     foreach (const ClusteredLepton& lepton, allClusteredLeptons) {
00074       if (accept(lepton)) {
00075         _clusteredLeptons.push_back(lepton);
00076         _theParticles.push_back(lepton.constituentLepton());
00077         _theParticles.insert(_theParticles.end(),
00078                              lepton.constituentPhotons().begin(),
00079                              lepton.constituentPhotons().end());
00080       }
00081     }
00082   }
00083 }