StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FastJet3.h
1 // FastJet3.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2012 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // This header file written by Gavin Salam.
7 
8 #ifndef Pythia8_FastJet3_H
9 #define Pythia8_FastJet3_H
10 
11 //----------------------------------------------------------------------
76 // ----------------------------------------------------------------------
77 // Copyright 2011 by Matteo Cacciari, Gavin Salam and Gregory
78 // Soyez. Permission is granted to redistribute this file and modify
79 // it, as long as this notice is retained and any changes are clearly
80 // marked. No warranties are provided!
81 // ----------------------------------------------------------------------
82 
83 #include "fastjet/config.h" // will allow a test for FJ3
84 #include "fastjet/ClusterSequence.hh" // also gives PseudoJet & JetDefinition
85 #include "fastjet/Selector.hh"
86 #include "Event.h" // this is what we need from Pythia8
87 
88 // FASTJET_VERSION is only defined from version 3 onwards so we can
89 // use it to test that we have a sufficiently recent version
90 #ifndef FASTJET_VERSION
91 #error "FastJet 3 is required in order to obtain the features of this interface"
92 #endif
93 
94 FASTJET_BEGIN_NAMESPACE // place the code here inside the FJ namespace
95 
102  public PseudoJet::UserInfoBase {
103 public:
104  Py8Particle(const Pythia8::Particle & particle) : Particle(particle) {}
105 };
106 
109 template<>
110 inline PseudoJet::PseudoJet(const Pythia8::Particle & particle) {
111  reset(particle.px(),particle.py(),particle.pz(), particle.e());
112  set_user_info(new Py8Particle(particle));
113 }
114 
117 template<>
118 inline PseudoJet::PseudoJet(const Pythia8::Vec4 & particle) {
119  reset(particle.px(),particle.py(),particle.pz(), particle.e());
120 }
121 
122 
134 template<class T> class SelectorWorkerPy8 : public SelectorWorker {
135 public:
137  typedef T (Pythia8::Particle::*Py8ParticleFnPtr)() const;
138 
141  SelectorWorkerPy8(Py8ParticleFnPtr member_fn_ptr, T value) :
142  _member_fn_ptr(member_fn_ptr), _value(value) {};
143 
148  bool pass(const PseudoJet & p) const {
149  const Pythia8::Particle * py8_particle
150  = dynamic_cast<const Pythia8::Particle *>(p.user_info_ptr());
151  if (py8_particle == 0) {
152  return false; // no info, so false
153  } else {
154  return (py8_particle->*_member_fn_ptr)() == _value;
155  }
156  }
157 private:
158  Py8ParticleFnPtr _member_fn_ptr;
159  T _value;
160 };
161 
169 inline Selector SelectorIsFinal () {return
170  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isFinal , true));}
171 inline Selector SelectorIsCharged () {return
172  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isCharged , true));}
173 inline Selector SelectorIsNeutral () {return
174  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isNeutral , true));}
175 inline Selector SelectorIsResonance() {return
176  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isResonance, true));}
177 inline Selector SelectorIsVisible () {return
178  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isVisible , true));}
179 inline Selector SelectorIsLepton () {return
180  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isLepton , true));}
181 inline Selector SelectorIsQuark () {return
182  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isQuark , true));}
183 inline Selector SelectorIsGluon () {return
184  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isGluon , true));}
185 inline Selector SelectorIsDiquark () {return
186  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isDiquark , true));}
187 inline Selector SelectorIsParton () {return
188  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isParton , true));}
189 inline Selector SelectorIsHadron () {return
190  Selector(new SelectorWorkerPy8<bool>(&Pythia8::Particle::isHadron , true));}
192 
200 inline Selector SelectorId (int i) {return
201  Selector(new SelectorWorkerPy8<int>(&Pythia8::Particle::id , i));}
202 inline Selector SelectorIdAbs (int i) {return
203  Selector(new SelectorWorkerPy8<int>(&Pythia8::Particle::idAbs , i));}
204 inline Selector SelectorStatus (int i) {return
205  Selector(new SelectorWorkerPy8<int>(&Pythia8::Particle::status , i));}
206 inline Selector SelectorStatusAbs(int i) {return
207  Selector(new SelectorWorkerPy8<int>(&Pythia8::Particle::statusAbs, i));}
209 
210 
211 FASTJET_END_NAMESPACE
212 
213 #endif // Pythia8_FastJet3_H
SelectorWorkerPy8(Py8ParticleFnPtr member_fn_ptr, T value)
Definition: FastJet3.h:141
bool pass(const PseudoJet &p) const
Definition: FastJet3.h:148
T(Pythia8::Particle::* Py8ParticleFnPtr)() const
the typedef helps with the notation for member function pointers
Definition: FastJet3.h:137