Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

VetoedFinalState.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/RivetCLHEP.hh"
00004 #include "Rivet/Projections/VetoedFinalState.hh"
00005 #include "Rivet/Cmp.hh"
00006 #include <algorithm>
00007 
00008 
00009 namespace Rivet {
00010 
00011   int VetoedFinalState::compare(const Projection& p) const {
00012     const VetoedFinalState& other = dynamic_cast<const VetoedFinalState&>(p);
00013     const int fscmp = pcmp(_fsproj, other._fsproj);
00014     if (fscmp != 0) return fscmp;
00015     if (_vetoCodes == other._vetoCodes) return 0;
00016     if (_vetoCodes < other._vetoCodes) return -1; else return 1;
00017   }
00018 
00019 
00020   void VetoedFinalState::project(const Event& e) {
00021     Log log = getLog();
00022     const FinalState& fs = e.applyProjection(_fsproj);
00023     _theParticles.clear();
00024     _theParticles.reserve(fs.particles().size());
00025     const ParticleVector& fsps = fs.particles();
00026     for (ParticleVector::const_iterator p = fsps.begin(); p != fsps.end(); ++p) {
00027       if (log.isActive(Log::DEBUG)) {
00028         stringstream codes; 
00029         codes << "{";
00030         for (VetoDetails::const_iterator code = _vetoCodes.begin(); code != _vetoCodes.end(); ++code) {
00031           codes << " " << code->first;
00032         }
00033         codes << " }";
00034         log << Log::DEBUG << p->getPdgId() << " vs. veto codes = " 
00035             << codes.str() << " (" << _vetoCodes.size() << ")" << endl;
00036       }
00037       const long pdgid = p->getPdgId();
00038       VetoDetails::iterator iter = _vetoCodes.find(pdgid);
00039       if ( (iter == _vetoCodes.end())) {
00040         log << Log::DEBUG << "Storing with PDG code " << pdgid << " pt " << p->getMomentum().perp() << endl;
00041         _theParticles.push_back(*p);
00042       } else {
00043         // This particle code is listed as a possible veto... check pT.
00044         pair<double, double> ptrange = iter->second;
00045         // Make sure that the pT range is sensible.
00046         assert(ptrange.first <= ptrange.second);
00047         double pt = p->getMomentum().perp();
00048         stringstream rangess;
00049         if (ptrange.first < numeric_limits<double>::max()) rangess << ptrange.first;
00050         rangess << " - ";
00051         if (ptrange.second < numeric_limits<double>::max()) rangess << ptrange.second;
00052         log << Log::DEBUG << "ID = " << pdgid << ", pT range = " << rangess.str();
00053         stringstream debugline;
00054         debugline << "with PDG code = " << pdgid << " pT = " << p->getMomentum().perp();
00055         if (pt < ptrange.first || pt > ptrange.second) { 
00056           log << Log::DEBUG << "Storing " << debugline << endl;
00057           _theParticles.push_back(*p);
00058         } else {
00059           log << Log::DEBUG << "Vetoing " << debugline << endl;
00060         }
00061       }
00062     }
00063   } 
00064   
00065 }