rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
EventMixingFinalState.hh
1 // -*- C++ -*-
2 #ifndef RIVET_EventMixingFinalState_HH
3 #define RIVET_EventMixingFinalState_HH
4 
5 #include "Rivet/Projection.hh"
6 #include "Rivet/Projections/ParticleFinder.hh"
7 #include <deque>
8 #include <algorithm>
9 
10 
11 namespace Rivet {
12 
13  // @brief Projects out an event mixed of several events, given
14  // a mixing observable (eg. number of final state particles),
15  // defining what should qualify as a mixable event.
16  // Binning in the mixing observable is defined in the constructor,
17  // as is the number of events one wants to mix with.
18  // The protected method calculateMixingObs() can be overloaded
19  // in derived classes, to define other mixing observables, eg.
20  // centrality or something even more elaborate.
21  //
22  // !!!DISCLAIMER!!! The projection makes no attempt at correct handling
23  // of event weights - ie. what one should use as event weight for several
24  // mixed events. Proceed with caution if you do not use an MC with
25  // unit weights.
26  //
27  // @author Christian Bierlich <christian.bierlich@thep.lu.se>
28 
29  typedef map<double, deque<Particles> > MixMap;
31  public:
32  // Constructor
33  EventMixingFinalState(const ParticleFinder& fsp, const ParticleFinder& mix, size_t nMixIn,
34  double oMin, double oMax, double deltao ) : nMix(nMixIn){
35  setName("EventMixingFinalState");
36  addProjection(fsp,"FS");
37  addProjection(mix,"MIX");
38  MSG_WARNING("EventMixingFinalState is a naive implementation, not currently " <<
39  "validated. Use with caution.");
40 
41  // Set up the map for mixing events
42  for(double o = oMin; o < oMax; o+=deltao )
43  mixEvents[o] = deque<Particles>();
44 
45  }
46  // Clone on the heap
47  DEFAULT_RIVET_PROJ_CLONE(EventMixingFinalState);
48 
49 
50  // Return a vector of mixing events.
51  vector<Particles> getMixingEvents() const {
52  MixMap::const_iterator mixItr = mixEvents.lower_bound(mObs);
53  if(mixItr == mixEvents.end() || mixItr->second.size() < nMix + 1)
54  return vector<Particles>();
55  return vector<Particles>(mixItr->second.begin(), mixItr->second.end() - 1);
56  }
57 
58  protected:
59 
60  // Calulate mixing observable.
61  // Can be overloaded to define more elaborate observables.
62  virtual void calculateMixingObs(const Particles& parts){
63  mObs = parts.size();
64  }
65 
67  void project(const Event& e){
68  const Particles parts = applyProjection<ParticleFinder>(e, "FS").particles();
69 
70  calculateMixingObs(parts);
71 
72  MixMap::iterator mixItr = mixEvents.lower_bound(mObs);
73  if(mixItr == mixEvents.end()){
74  // We are out of bounds.
75  MSG_DEBUG("Mixing observable out of bounds.");
76  return;
77  }
78  const Particles mix = applyProjection<ParticleFinder>(e, "MIX").particles();
79 
80  mixItr->second.push_back(mix);
81  if(mixItr->second.size() > nMix + 1)
82  mixItr->second.pop_front();
83  }
84 
86  int compare(const Projection& p) const {
87  return mkNamedPCmp(p,"FS");
88  }
89 
90  private:
91  // The number of event to mix with
92  size_t nMix;
93  // The mixing observable of the current event
94  double mObs;
95  // The event map;
96  MixMap mixEvents;
97  };
98 }
99 #endif
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:133
Definition: ALICE_2010_I880049.cc:13
std::vector< GenParticle const * > particles(const GenEvent *ge)
Definition: RivetHepMC.hh:36
Base class for projections which return subsets of an event&#39;s particles.
Definition: ParticleFinder.hh:11
void project(const Event &e)
Perform the projection on the Event.
Definition: EventMixingFinalState.hh:67
Definition: Event.hh:22
Cmp< Projection > mkNamedPCmp(const Projection &otherparent, const std::string &pname) const
Definition: Projection.cc:51
const PROJ & addProjection(const PROJ &proj, const std::string &name)
Register a contained projection (user-facing version)
Definition: ProjectionApplier.hh:170
Definition: EventMixingFinalState.hh:30
Base class for all Rivet projections.
Definition: Projection.hh:29
int compare(const Projection &p) const
Compare with other projections.
Definition: EventMixingFinalState.hh:86