rivet is hosted by Hepforge, IPPP Durham
UnstableFinalState.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/UnstableFinalState.hh"
00003 #include "Rivet/Tools/ParticleIdUtils.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Cmp.hh"
00006 
00007 #define IS_PARTON_PDGID(id) ( abs(id) <= 100 && abs(id) != 22 && (abs(id) < 11 || abs(id) > 18) )
00008 
00009 namespace Rivet {
00010 
00011 
00012   void UnstableFinalState::project(const Event& e) {
00013     _theParticles.clear();
00014 
00015     // @todo We should really implement the FinalState algorithm here instead
00016     double etamin, etamax;
00017     if ( _etaRanges.empty() ) {
00018       etamin = -MAXRAPIDITY;
00019       etamax = MAXRAPIDITY;
00020     } else {
00021       // With our current constructor choice, we can only ever have one entry
00022       assert( _etaRanges.size() == 1 );
00023       etamin = _etaRanges[0].first;
00024       etamax = _etaRanges[0].second;
00025     }
00026 
00027     vector<PdgId> vetoIds;
00028     vetoIds += 22; // status 2 photons don't count!
00029     vetoIds += 110; vetoIds += 990; vetoIds += 9990; // Reggeons
00030     //vetoIds += 9902210; // something weird from PYTHIA6
00031     foreach (GenParticle* p, Rivet::particles(e.genEvent())) {
00032       const int st = p->status();
00033       bool passed =
00034         (st == 1 || (st == 2 && find(vetoIds.begin(), vetoIds.end(), abs(p->pdg_id())) == vetoIds.end())) &&
00035         !IS_PARTON_PDGID(p->pdg_id()) && //< Always veto partons?
00036         !isZero(p->momentum().perp()) && p->momentum().perp() >= _ptmin &&
00037         inRange(p->momentum().eta(), etamin, etamax);
00038 
00039       // Avoid double counting by re-marking as unpassed if particle ID == parent ID
00040       const GenVertex* pv = p->production_vertex();
00041       const GenVertex* dv = p->end_vertex();
00042       if (passed && pv) {
00043         for (GenVertex::particles_in_const_iterator pp = pv->particles_in_const_begin() ;
00044              pp != pv->particles_in_const_end() ; ++pp) {
00045           if ( p->pdg_id() == (*pp)->pdg_id() ) {
00046             passed = false;
00047             break;
00048           }
00049         }
00050       }
00051 
00052       // Add to output particles collection
00053       if (passed) {
00054         _theParticles.push_back(Particle(*p));
00055       }
00056 
00057       // Log parents and children
00058       if (getLog().isActive(Log::TRACE)) {
00059         MSG_TRACE("ID = " << p->pdg_id()
00060                   << ", status = " << st
00061                   << ", pT = " << p->momentum().perp()
00062                   << ", eta = " << p->momentum().eta()
00063                   << ": result = " << std::boolalpha << passed);
00064         if (pv) {
00065           for (GenVertex::particles_in_const_iterator pp = pv->particles_in_const_begin() ;
00066                pp != pv->particles_in_const_end() ; ++pp) {
00067             MSG_TRACE("  parent ID = " << (*pp)->pdg_id());
00068           }
00069         }
00070         if (dv) {
00071           for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin() ;
00072                pp != dv->particles_out_const_end() ; ++pp) {
00073             MSG_TRACE("  child ID  = " << (*pp)->pdg_id());
00074           }
00075         }
00076       }
00077     }
00078     MSG_DEBUG("Number of unstable final-state particles = " << _theParticles.size());
00079   }
00080 
00081 
00082 }