Rivet API documentation

Rivet 4.1.5
RHICCommon.hh
1// -*- C++ -*-
2#ifndef RIVET_RHIC_COMMON_HH
3#define RIVET_RHIC_COMMON_HH
4
5#include <unordered_map>
6#include <unordered_set>
7
8#include "Rivet/Projections/ChargedFinalState.hh"
9#include "Rivet/Projections/FinalState.hh"
10#include "Rivet/Projections/SingleValueProjection.hh"
11#include "Rivet/Projections/TriggerProjection.hh"
12
14namespace Rivet {
15
16
17 class STAR_BES_Centrality : public SingleValueProjection {
18 public:
19
20 STAR_BES_Centrality() {
21 declare(ChargedFinalState(Cuts::abseta < 0.5 && Cuts::absrap < 0.1 && Cuts::pT > 0.2*GeV),
22 "STAR_BES_Centrality");
23 }
24
25 // Destructor
26 virtual ~STAR_BES_Centrality() { }
27
29 RIVET_DEFAULT_PROJ_CLONE(STAR_BES_Centrality);
30
32 using Projection::operator=;
33
34 protected:
35
36 void project(const Event& e) {
37 clear();
38 double estimate = apply<FinalState>(e, "STAR_BES_Centrality").particles().size();
39 setValue(estimate);
40 }
41
43 virtual CmpState compare(const Projection& p) const {
44 return mkNamedPCmp(p, "STAR_BES_Centrality");
45 }
46 };
47
48
50 class BRAHMSCentrality : public SingleValueProjection {
51 public:
52
53 // Constructor
54 BRAHMSCentrality()
56 // Using here the BRAHMS reaction centrality from eg. 1602.01183, which
57 // might not be correct.
58 declare(ChargedFinalState(Cuts::pT > 0.1*GeV && Cuts::abseta < 2.2), "ChargedFinalState");
59 }
60
61 // Destructor
62 virtual ~BRAHMSCentrality() { }
63
64 // Clone on the heap.
65 RIVET_DEFAULT_PROJ_CLONE(BRAHMSCentrality);
66
68 using Projection::operator=;
69
70 protected:
71
72 // Do the projection. Count the number of charged particles in
73 // the specified range.
74 virtual void project(const Event& e) {
75 clear();
76 setValue(apply<ChargedFinalState>(e, "ChargedFinalState").particles().size());
77 }
78
79 // Compare to another projection.
80 virtual CmpState compare(const Projection& p) const {
81 return mkNamedPCmp(p, "ChargedFinalState");
82 }
83 };
84
85
90 class STARHadrons : public FinalState {
91 private:
92
93 std::unordered_set<PdgId> star_hadrons;
94
95 public:
96
97 STARHadrons(const Cut& c = Cuts::open())
98 : FinalState(c),
99 star_hadrons{PID::PI0, PID::PIPLUS, PID::ETA, PID::KPLUS, PID::K0S,
100 PID::K0L, PID::LAMBDA, PID::SIGMA0, PID::SIGMAMINUS, PID::SIGMAPLUS,
101 PID::XIMINUS, PID::XI0, PID::OMEGAMINUS} {
102 setName("STARHadrons");
103 }
104
105 RIVET_DEFAULT_PROJ_CLONE(STARHadrons);
106
108 using Projection::operator=;
109
110 protected:
111
112 virtual void project(const Event& e) {
113
114 _theParticles.clear();
115 std::unordered_map<int, ConstGenParticlePtr> found;
116 std::unordered_set<int> decay_products;
117
118 // Mark final state particles for use
119 for (ConstGenParticlePtr p : HepMCUtils::particles(e.genEvent())) {
120 if (p->status() == 1) {
121 found[HepMCUtils::uniqueId(p)] = p;
122 }
123 }
124
125 for (ConstGenParticlePtr p : HepMCUtils::particles(e.genEvent())) {
126 bool hasDecayed = p->status() == 2;
127 bool decayNotAllowed = star_hadrons.count(abs(p->pdg_id()));
128 if (hasDecayed && decayNotAllowed) {
129 // Mark the hadron for use
130 found[HepMCUtils::uniqueId(p)] = p;
131 // Mark all of its downstream particles as decay products
132 ConstGenVertexPtr pv = p->end_vertex();
133 if (pv) {
134 for (ConstGenParticlePtr d : HepMCUtils::particles(pv, Relatives::DESCENDANTS)) {
135 decay_products.insert(HepMCUtils::uniqueId(d));
136 }
137 }
138 }
139 }
140
141 // Provide all marked particles except those marked as decay products
142 for (const auto& pair : found) {
143 ConstGenParticlePtr p = pair.second;
144 if (!decay_products.count(HepMCUtils::uniqueId(p))) {
145 _theParticles.push_back(p);
146 }
147 }
148 }
149 };
150
151
152}
153
154#endif
virtual void project(const Event &e)
Definition RHICCommon.hh:74
virtual CmpState compare(const Projection &p) const
Definition RHICCommon.hh:80
Project only charged final state particles.
Definition ChargedFinalState.hh:11
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
const GenEvent * genEvent() const
The generated HepMC event pointer obtained from an external event generator.
Definition Event.hh:80
FinalState(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
std::enable_if_t< std::is_base_of< Projection, PROJ >::value, const PROJ & > apply(const Event &evt, const Projection &proj) const
Apply the supplied projection on event evt.
Definition ProjectionApplier.hh:124
const PROJ & declare(const PROJ &proj, const std::string &name) const
Register a contained projection (user-facing version).
Definition ProjectionApplier.hh:205
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:146
Cmp< Projection > mkNamedPCmp(const Projection &otherparent, const std::string &pname) const
virtual void project(const Event &e)
Apply the projection to the event.
Definition RHICCommon.hh:112
virtual CmpState compare(const Projection &p) const
Compare projections.
Definition RHICCommon.hh:43
RIVET_DEFAULT_PROJ_CLONE(STAR_BES_Centrality)
Clone on the heap.
void project(const Event &e)
Definition RHICCommon.hh:36
void setValue(double v)
Set the value.
Definition SingleValueProjection.hh:49
SingleValueProjection()
The default constructor.
Definition SingleValueProjection.hh:21
void clear()
Unset the value.
Definition SingleValueProjection.hh:55
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
const Cut & open()
Fully open cut singleton, accepts everything.
Definition LHCbCommon.hh:9