Rivet: /Users/chrisg/software/rivet/include/Rivet/Projections/CentralityProjection.hh Source File

| Rivet 3.1.9

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