Rivet  1.8.3
LossyFinalState.hh
1 // -*- C++ -*-
2 #ifndef RIVET_LossyFinalState_HH
3 #define RIVET_LossyFinalState_HH
4 
5 #include "Rivet/Tools/Logging.hh"
6 #include "Rivet/Rivet.hh"
7 #include "Rivet/Particle.hh"
8 #include "Rivet/Event.hh"
9 #include "Rivet/Projection.hh"
10 #include "Rivet/Projections/FinalState.hh"
11 
12 namespace Rivet {
13 
14 
16  template <typename FILTER>
17  class LossyFinalState : public FinalState {
18  public:
19 
21 
22 
24  LossyFinalState(const FinalState& fsp, FILTER filter)
25  : _filter(filter)
26  {
27  setName("LossyFinalState");
28  addProjection(fsp, "FS");
29  }
30 
32  LossyFinalState(FILTER filter,
33  double mineta = -MAXRAPIDITY,
34  double maxeta = MAXRAPIDITY,
35  double minpt = 0.0)
36  : _filter(filter)
37  {
38  setName("LossyFinalState");
39  addProjection(FinalState(mineta, maxeta, minpt), "FS");
40  }
41 
43  virtual ~LossyFinalState() { }
44 
46  virtual const Projection* clone() const {
47  return new LossyFinalState<FILTER>(*this);
48  }
49 
51 
52 
53  protected:
54 
56  void project(const Event& e) {
57  const FinalState& fs = applyProjection<FinalState>(e, "FS");
58  getLog() << Log::DEBUG << "Pre-loss number of FS particles = " << fs.particles().size() << endl;
59  _theParticles.clear();
60  std::remove_copy_if(fs.particles().begin(), fs.particles().end(),
61  std::back_inserter(_theParticles), _filter);
62  getLog() << Log::DEBUG << "Filtered number of FS particles = " << _theParticles.size() << endl;
63  }
64 
65 
67  int compare(const Projection& p) const {
68  const LossyFinalState<FILTER>& other = pcast< LossyFinalState<FILTER> >(p);
69  const int fscmp = mkNamedPCmp(other, "FS");
70  if (fscmp) return fscmp;
71  return _filter.compare(other._filter);
72  }
73 
74 
75  protected:
76 
78  FILTER _filter;
79 
80  };
81 
82 
83 }
84 
85 #endif