rivet is hosted by Hepforge, IPPP Durham
InitialQuarks.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/InitialQuarks.hh"
00003 
00004 
00005 #define IS_PARTON_PDGID(id) ( abs(id) <= 100 && abs(id) != 22 && (abs(id) < 11 || abs(id) > 18) )
00006 
00007 
00008 namespace Rivet {
00009 
00010 
00011   int InitialQuarks::compare(const Projection& p) const {
00012     return EQUIVALENT;
00013   }
00014 
00015 
00016   void InitialQuarks::project(const Event& e) {
00017     _theParticles.clear();
00018 
00019     foreach (const GenParticle* p, Rivet::particles(e.genEvent())) {
00020       const GenVertex* pv = p->production_vertex();
00021       const GenVertex* dv = p->end_vertex();
00022       const PdgId pid = abs(p->pdg_id());
00023       bool passed = inRange((long)pid, 1, 6);
00024       if (passed) {
00025         if (pv != 0) {
00026           foreach (const GenParticle* pp, particles_in(pv)) {
00027             // Only accept if parent is electron or Z0
00028             const PdgId pid = abs(pp->pdg_id());
00029             passed = (pid == PID::ELECTRON || abs(pp->pdg_id()) == PID::ZBOSON || abs(pp->pdg_id()) == PID::GAMMA);
00030           }
00031         } else {
00032           passed = false;
00033         }
00034       }
00035 
00036       if (getLog().isActive(Log::TRACE)) {
00037         const int st = p->status();
00038         const double pT = p->momentum().perp();
00039         const double eta = p->momentum().eta();
00040         MSG_TRACE(std::boolalpha
00041                   << "ID = " << p->pdg_id() << ", status = " << st << ", pT = " << pT
00042                   << ", eta = " << eta << ": result = " << passed);
00043         if (pv != 0) {
00044           foreach (const GenParticle* pp, particles_in(pv)) {
00045             MSG_TRACE(std::boolalpha << " parent ID = " << pp->pdg_id());
00046           }
00047         }
00048         if (dv != 0) {
00049           foreach (const GenParticle* pp, particles_out(dv)) {
00050             MSG_TRACE(std::boolalpha << " child ID  = " << pp->pdg_id());
00051           }
00052         }
00053       }
00054       if (passed) _theParticles.push_back(Particle(*p));
00055     }
00056     MSG_DEBUG("Number of initial quarks = " << _theParticles.size());
00057     if (!_theParticles.empty()) {
00058       for (size_t i = 0; i < _theParticles.size(); i++) {
00059         MSG_DEBUG("Initial quark[" << i << "] = " << _theParticles[i].pid());
00060       }
00061     }
00062   }
00063 
00064 
00065 }