rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.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
9namespace Rivet {
10
11
28 public:
29
30 using SingleValueProjection::operator=;
31
33 CentralityProjection() { setName("CentralityProjection"); }
34
35
36 RIVET_DEFAULT_PROJ_CLONE(CentralityProjection);
37
38
40 using Projection::operator =;
41
42
48 void add(const SingleValueProjection & p, string pname) {
49 _projNames.push_back(pname);
50 declare(p, pname);
51 }
52
54 void project(const Event& e) {
55 _values.clear();
56 for ( string pname : _projNames )
57 _values.push_back(apply<SingleValueProjection>(e, pname)());
58 if ( !_values.empty() ) setValue(_values[0]);
59 }
60
62 bool empty() const {
63 return _projNames.empty();
64 }
65
69 double operator[](int i) const {
70 return _values[i];
71 }
72
73 // Standard comparison function.
74 CmpState compare(const Projection& p) const {
75 const CentralityProjection* other = dynamic_cast<const CentralityProjection*>(&p);
76 if (other->_projNames.size() == 0) return CmpState::NEQ;
77 // cholm: This is not enough. The contained projections may be
78 // different but have the same names. We need to compare the
79 // projections directly.
80 for (string pname : _projNames) {
81 auto& proj = getProjection(pname);
82 bool hasPname = true;
83 for (string p2name : other->_projNames){
84 if (pname != p2name) hasPname = false;
85 }
86 if (!hasPname) return CmpState::NEQ;
87
88 auto& oth = other->getProjection(pname);
89 if (proj.compare(oth) != CmpState::EQ) return CmpState::NEQ;
90 }
91 return CmpState::EQ;
92 }
93
95 vector<string> projections() const {
96 return _projNames;
97 }
98
99
100 protected:
101
103 vector<string> _projNames;
104
106 vector<double> _values;
107
108 };
109
110
111}
112
113#endif
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition CentralityProjection.hh:27
CentralityProjection()
Default constructor.
Definition CentralityProjection.hh:33
CmpState compare(const Projection &p) const
Definition CentralityProjection.hh:74
vector< string > projections() const
The list of names of the internal projections.
Definition CentralityProjection.hh:95
double operator[](int i) const
Definition CentralityProjection.hh:69
bool empty() const
Cheek if no internal projections have been added.
Definition CentralityProjection.hh:62
void project(const Event &e)
Perform all internal projections.
Definition CentralityProjection.hh:54
void add(const SingleValueProjection &p, string pname)
Add a new centrality estimate.
Definition CentralityProjection.hh:48
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
const PROJ & getProjection(const std::string &name) const
Definition ProjectionApplier.hh:62
const PROJ & declare(const PROJ &proj, const std::string &name) const
Register a contained projection (user-facing version)
Definition ProjectionApplier.hh:175
Base class for all Rivet projections.
Definition Projection.hh:29
void setName(const std::string &name)
Used by derived classes to set their name.
Definition Projection.hh:148
Base class for projections returning a single floating point value.
Definition SingleValueProjection.hh:17
void setValue(double v)
Set the value.
Definition SingleValueProjection.hh:48
Definition MC_CENT_PPB_Projections.hh:10