LeptonClusters.cc

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