rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.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 
32 
33 public:
34 
37 
38 
39  DEFAULT_RIVET_PROJ_CLONE(CentralityProjection);
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  int compare(const Projection& p) const {
73  const CentralityProjection* other =
74  dynamic_cast<const CentralityProjection*>(&p);
75  if (other->_projNames.size() == 0) return UNDEFINED;
76  for (string pname : _projNames) {
77  bool hasPname = true;
78  for (string p2name : other->_projNames){
79  if (pname != p2name) hasPname = false;
80  }
81  if (!hasPname) return UNDEFINED;
82  }
83  return EQUIVALENT;
84  }
85 
87  vector<string> projections() const {
88  return _projNames;
89  }
90 
91 private:
92 
94  vector<string> _projNames;
95 
97  vector<double> _values;
98 
99 };
100 
101 }
102 
103 #endif
bool empty() const
Cheek if no internal projections have been added.
Definition: CentralityProjection.hh:60
Definition: ALICE_2010_I880049.cc:13
CentralityProjection is used together with the percentile-based analysis objects Percentile and Perce...
Definition: CentralityProjection.hh:31
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:18
void project(const Event &e)
Perform all internal projections.
Definition: CentralityProjection.hh:52
double operator[](int i) const
Definition: CentralityProjection.hh:67
int compare(const Projection &p) const
Definition: CentralityProjection.hh:72
Definition: Event.hh:22
CentralityProjection()
Default constructor.
Definition: CentralityProjection.hh:36
void add(const SingleValueProjection &p, string pname)
Definition: CentralityProjection.hh:46
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:87
Base class for all Rivet projections.
Definition: Projection.hh:29