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   int UnstableFinalState::compare(const Projection& p) const {
00013     const UnstableFinalState& other = dynamic_cast<const UnstableFinalState&>(p);
00014     return \
00015       cmp(_etamin, other._etamin) ||
00016       cmp(_etamax, other._etamax) ||
00017       cmp(_ptmin, other._ptmin);
00018   }
00019 
00020 
00021   void UnstableFinalState::project(const Event& e) {
00022     _theParticles.clear();
00023 
00024     foreach (GenParticle* p, Rivet::particles(e.genEvent())) {
00025       const int st = p->status();
00026       bool passed = \
00027         ( st == 1 || (st == 2 && abs(p->pdg_id()) != 22) ) &&
00028         !isZero(p->momentum().perp()) && p->momentum().perp() >= _ptmin &&
00029         p->momentum().eta() > _etamin && p->momentum().eta() < _etamax &&
00030         !IS_PARTON_PDGID(p->pdg_id());
00031 
00032       // DEBUGGING PRINTOUTS FOR HERWIG
00033       // if (p->status() == 2) {
00034       //   std::cout << "* "
00035       //             << "pid=" << p->pdg_id()
00036       //             << ", st=" << st
00037       //             << ", passed=" << std::boolalpha << passed
00038       //             << ", isparton=" << std::boolalpha << (IS_PARTON_PDGID(p->pdg_id())) << std::endl;
00039       // }
00040       // if (abs(p->pdg_id()) > 3000) {
00041       //   std::cout << "% "
00042       //             << "pid=" << p->pdg_id()
00043       //             << ", st=" << st
00044       //             << ", passed=" << std::boolalpha << passed
00045       //             << ", isparton=" << std::boolalpha << (IS_PARTON_PDGID(p->pdg_id())) << std::endl;
00046       // }
00047 
00048       // Avoid double counting by re-marking as unpassed if particle ID == parent ID
00049       const GenVertex* pv = p->production_vertex();
00050       const GenVertex* dv = p->end_vertex();
00051       if (passed && pv) {
00052         for (GenVertex::particles_in_const_iterator pp = pv->particles_in_const_begin() ;
00053              pp != pv->particles_in_const_end() ; ++pp) {
00054           if ( p->pdg_id() == (*pp)->pdg_id() ) {
00055             passed = false;
00056             break;
00057           }
00058         }
00059       }
00060 
00061       // Add to output particles collection
00062       if (passed) {
00063         _theParticles.push_back(Particle(*p));
00064       }
00065 
00066       // Log parents and children
00067       if (getLog().isActive(Log::TRACE)) {
00068         MSG_TRACE("ID = " << p->pdg_id()
00069                   << ", status = " << st
00070                   << ", pT = " << p->momentum().perp()
00071                   << ", eta = " << p->momentum().eta()
00072                   << ": result = " << std::boolalpha << passed);
00073         if (pv) {
00074           for (GenVertex::particles_in_const_iterator pp = pv->particles_in_const_begin() ;
00075                pp != pv->particles_in_const_end() ; ++pp) {
00076             MSG_TRACE("  parent ID = " << (*pp)->pdg_id());
00077           }
00078         }
00079         if (dv) {
00080           for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin() ;
00081                pp != dv->particles_out_const_end() ; ++pp) {
00082             MSG_TRACE("  child ID  = " << (*pp)->pdg_id());
00083           }
00084         }
00085       }
00086     }
00087     MSG_DEBUG("Number of final-state particles = " << _theParticles.size());
00088   }
00089 
00090 
00091 }