Rivet  3.1.0
CentralityProjection.hh
1 // -*- C++ -*-
2 #ifndef RIVET_CENTRALITYPROJECTION_HH
3 #define RIVET_CENTRALITYPROJECTION_HH
4 
5 #include "Rivet/Projections/PercentileProjection.hh"
6 #include "Rivet/Tools/RivetYODA.hh"
7 #include <map>
8 
9 namespace Rivet {
10 
27 public:
28 
31 
32 
33  DEFAULT_RIVET_PROJ_CLONE(CentralityProjection);
34 
35 
41  void add(const SingleValueProjection & p, string pname) {
42  _projNames.push_back(pname);
43  declare(p, pname);
44  }
45 
47  void project(const Event& e) {
48  _values.clear();
49  for ( string pname : _projNames )
50  _values.push_back(apply<SingleValueProjection>(e, pname)());
51  if ( !_values.empty() ) set(_values[0]);
52  }
53 
55  bool empty() const {
56  return _projNames.empty();
57  }
58 
62  double operator[](int i) const {
63  return _values[i];
64  }
65 
66  // Standard comparison function.
67  CmpState compare(const Projection& p) const {
68  const CentralityProjection* other = dynamic_cast<const CentralityProjection*>(&p);
69  if (other->_projNames.size() == 0) return CmpState::NEQ;
70  for (string pname : _projNames) {
71  bool hasPname = true;
72  for (string p2name : other->_projNames){
73  if (pname != p2name) hasPname = false;
74  }
75  if (!hasPname) return CmpState::NEQ;
76  }
77  return CmpState::EQ;
78  }
79 
81  vector<string> projections() const {
82  return _projNames;
83  }
84 
85 private:
86 
88  vector<string> _projNames;
89 
91  vector<double> _values;
92 
93 };
94 
95 }
96 
97 #endif
bool empty() const
Cheek if no internal projections have been added.
Definition: CentralityProjection.hh:55
Definition: MC_Cent_pPb.hh:10
CmpState compare(const Projection &p) const
Definition: CentralityProjection.hh:67
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition: CentralityProjection.hh:26
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
void project(const Event &e)
Perform all internal projections.
Definition: CentralityProjection.hh:47
double operator[](int i) const
Definition: CentralityProjection.hh:62
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
CentralityProjection()
Default constructor.
Definition: CentralityProjection.hh:30
void add(const SingleValueProjection &p, string pname)
Add a new centrality estimate.
Definition: CentralityProjection.hh:41
const PROJ & declare(const PROJ &proj, const std::string &name)
Register a contained projection (user-facing version)
Definition: ProjectionApplier.hh:160
vector< string > projections() const
The list of names of the internal projections.
Definition: CentralityProjection.hh:81
Base class for all Rivet projections.
Definition: Projection.hh:29