Rivet  3.1.4
AliceCommon.hh
1 #ifndef PROJECTIONS_ALICECOMMON_HH
2 #define PROJECTIONS_ALICECOMMON_HH
3 #include "Rivet/Tools/AliceCommon.hh"
4 #include "Rivet/Projections/FinalState.hh"
5 #include "Rivet/Projections/SingleValueProjection.hh"
6 #include "Rivet/Projections/TriggerProjection.hh"
7 #include "Rivet/Projections/PrimaryParticles.hh"
8 
9 namespace Rivet {
10  namespace ALICE {
11 
14 
15 
24  template <int MODE>
26  public:
28  setName(MODE<0 ? "ALICE::V0CMultiplicity":
29  MODE>0 ? "ALICE::V0AMultiplicity":
30  "ALICE::V0MMultiplicity");
31  Cut cut;
32  if (MODE < 0) cut = V0Cacceptance;
33  else if (MODE > 0) cut = V0Aacceptance;
34  else cut = (V0Aacceptance || V0Cacceptance);
35  // Declare our projection. Note, the cuts stipulate charged
36  // particles, so we just use a final state (rather than
37  // charged-final state) projection here.
38  const FinalState fs(cut);
39  this->declare(fs, "FinalState");
40  }
41 
43  virtual ~V0Multiplicity() {}
44 
50  virtual void project(const Event& e) {
51  clear();
52  set(apply<FinalState>(e,"FinalState").particles().size());
53  }
54 
58  virtual std::unique_ptr<Rivet::Projection> clone() const {
59  return std::unique_ptr<Projection>(new V0Multiplicity<MODE>(*this));
60  }
64  virtual CmpState compare(const Projection& p) const {
65  return dynamic_cast<const V0Multiplicity<MODE>*>(&p) ?
66  CmpState::EQ : CmpState::NEQ;
67  }
68 
69  };
70 
75 
80 
85 
86 
87 
95  template <bool INNER>
97  public:
98 
101  setName("ALICE::CLMultiplicity");
102  Cut cut;
103  if (INNER) cut = CL0acceptance;
104  else cut = CL1acceptance;
105  // Declare our projection. Note, the cuts stipulate charged
106  // particles, so we just use a final state (rather than
107  // charged-final state) projection here.
108  const FinalState fs(cut);
109  this->declare(fs, "FinalState");
110  }
111 
113  virtual ~CLMultiplicity() {}
114 
120  virtual void project(const Event& e) {
121  clear();
122  set(apply<FinalState>(e,"FinalState").particles().size());
123  }
124 
128  virtual std::unique_ptr<Rivet::Projection> clone() const {
129  return std::unique_ptr<Projection>(new CLMultiplicity<INNER>(*this));
130  }
131 
135  virtual CmpState compare(const Projection& p) const {
136  return dynamic_cast<const CLMultiplicity<INNER>*>(&p) ?
137  CmpState::EQ : CmpState::NEQ;
138  }
139 
140  };
141 
142 
147 
152 
153 
154 
162  template <int MODE>
163  class V0Trigger : public TriggerProjection {
164  public:
165 
168  setName("ALICE::V0Trigger");
169  // Declare our projection. Note, the cuts stipulate charged
170  // particles, so we just use a final state (rather than
171  // charged-final state) projection here.
172  const V0Multiplicity<MODE> fs;
173  this->declare(fs, "FinalState");
174  }
175 
177  virtual ~V0Trigger() {}
178 
183  virtual void project(const Event& e) {
184  fail(); // Assume failure
185  if (apply<V0Multiplicity<MODE>>(e, "FinalState")() > 0) pass();
186  }
187 
191  virtual std::unique_ptr<Rivet::Projection> clone() const {
192  return std::unique_ptr<Projection>(new V0Trigger<MODE>(*this));
193  }
194 
201  virtual CmpState compare(const Projection& p) const {
202  return dynamic_cast<const V0Trigger<MODE>*>(&p) ?
203  CmpState::EQ : CmpState::NEQ;
204  }
205 
206  };
207 
211  using V0ATrigger = V0Trigger<-1>;
212 
217 
222 
223 
224 
227  public:
228 
231  const V0ATrigger v0a;
232  const V0CTrigger v0c;
233  this->declare(v0a, "V0A");
234  this->declare(v0c, "V0C");
235  }
236 
238  virtual ~V0AndTrigger() {}
239 
244  virtual void project(const Event& e) {
245  fail(); // Assume failure
246  if (apply<V0ATrigger>(e,"V0A")() && apply<V0CTrigger>(e,"V0C")()) pass();
247  }
248 
252  virtual CmpState compare(const Projection& p) const
253  {
254  return dynamic_cast<const V0AndTrigger*>(&p) ?
255  CmpState::EQ : CmpState::NEQ;
256  }
257 
261  virtual std::unique_ptr<Rivet::Projection> clone() const {
262  return std::unique_ptr<Projection>(new V0AndTrigger(*this));
263  }
264 
265  };
266 
267 
275  public:
276 
277  PrimaryParticles(const Cut& c=Cuts::open())
279  { }
280 
288  virtual CmpState compare(const Projection& p) const {
289  const PrimaryParticles* o = dynamic_cast<const PrimaryParticles*>(&p);
290  if (_cuts != o->_cuts) return CmpState::NEQ;
291  return mkPCmp(*o,"PrimaryParticles");
292  }
293 
295  virtual std::unique_ptr<Rivet::Projection> clone() const {
296  return std::unique_ptr<Projection>(new PrimaryParticles(*this));
297  }
298 
299  protected:
300 
314  bool isPrimaryPID(ConstGenParticlePtr p) const {
315  const int pdg = abs(p->pdg_id());
316  // Check for nucleus
317  if (pdg > 1000000000) return true;
318 
319  switch (pdg) {
320  case Rivet::PID::MUON:
321  case Rivet::PID::ELECTRON:
322  case Rivet::PID::GAMMA:
323  case Rivet::PID::PIPLUS:
324  case Rivet::PID::KPLUS:
325  case Rivet::PID::K0S:
326  case Rivet::PID::K0L:
327  case Rivet::PID::PROTON:
328  case Rivet::PID::NEUTRON:
329  case Rivet::PID::LAMBDA:
330  case Rivet::PID::SIGMAMINUS:
331  case Rivet::PID::SIGMAPLUS:
332  case Rivet::PID::XIMINUS:
333  case Rivet::PID::XI0:
334  case Rivet::PID::OMEGAMINUS:
335  case Rivet::PID::NU_E:
336  case Rivet::PID::NU_MU:
337  case Rivet::PID::NU_TAU:
338  return true;
339  }
340  return false;
341  }
342 
343  };
344 
345 
346  }
347 }
348 
349 #endif
V0Multiplicity<-1 > V0CMultiplicity
Definition: AliceCommon.hh:79
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:142
Definition: MC_Cent_pPb.hh:10
virtual ~CLMultiplicity()
Destructor.
Definition: AliceCommon.hh:113
V0AndTrigger()
Constructor.
Definition: AliceCommon.hh:230
virtual void project(const Event &e)
Definition: AliceCommon.hh:50
virtual void project(const Event &e)
Definition: AliceCommon.hh:183
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
CLMultiplicity< false > CL1Multiplicity
Definition: AliceCommon.hh:151
virtual ~V0Multiplicity()
Destructor.
Definition: AliceCommon.hh:43
Project out primary particles according to definition.
Definition: PrimaryParticles.hh:19
Definition: AliceCommon.hh:163
virtual CmpState compare(const Projection &p) const
Definition: AliceCommon.hh:64
const Cut & open()
Fully open cut singleton, accepts everything.
virtual CmpState compare(const Projection &p) const
Definition: AliceCommon.hh:252
CLMultiplicity()
Constructor.
Definition: AliceCommon.hh:100
const Cut V0Aacceptance
Definition: AliceCommon.hh:24
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
Base class for projections returning a bool corresponding to a trigger.
Definition: TriggerProjection.hh:19
bool isPrimaryPID(ConstGenParticlePtr p) const
Definition: AliceCommon.hh:314
virtual CmpState compare(const Projection &p) const
Definition: AliceCommon.hh:135
void fail()
Set the projection in an unvalid state.
Definition: Projection.hh:147
Definition: AliceCommon.hh:25
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 (user-facing alias).
Definition: ProjectionApplier.hh:89
virtual ~V0AndTrigger()
Destructor.
Definition: AliceCommon.hh:238
virtual CmpState compare(const Projection &p) const
Definition: AliceCommon.hh:201
Project out all final-state particles in an event. Probably the most important projection in Rivet! ...
Definition: FinalState.hh:12
const PROJ & declare(const PROJ &proj, const std::string &name)
Register a contained projection (user-facing version)
Definition: ProjectionApplier.hh:170
Trigger projection for the ALICE V0-AND (a.k.a. CINT7) requirement.
Definition: AliceCommon.hh:226
virtual void project(const Event &e)
Definition: AliceCommon.hh:120
virtual CmpState compare(const Projection &p) const
Definition: AliceCommon.hh:288
const Cut CL0acceptance
Definition: AliceCommon.hh:36
virtual std::unique_ptr< Rivet::Projection > clone() const
Definition: AliceCommon.hh:191
V0Trigger()
Constructor.
Definition: AliceCommon.hh:167
SingleValueProjection()
The default constructor.
Definition: SingleValueProjection.hh:21
const Cut CL1acceptance
Definition: AliceCommon.hh:42
virtual void project(const Event &e)
Definition: AliceCommon.hh:244
virtual std::unique_ptr< Rivet::Projection > clone() const
Definition: AliceCommon.hh:128
virtual std::unique_ptr< Rivet::Projection > clone() const
Clone this projection.
Definition: AliceCommon.hh:295
Definition: AliceCommon.hh:96
V0Multiplicity<+1 > V0AMultiplicity
Definition: AliceCommon.hh:74
Base class for all Rivet projections.
Definition: Projection.hh:29
CLMultiplicity< true > CL0Multiplicity
Definition: AliceCommon.hh:146
virtual std::unique_ptr< Rivet::Projection > clone() const
Definition: AliceCommon.hh:58
Standard ALICE primary particle definition.
Definition: AliceCommon.hh:274
virtual ~V0Trigger()
Destructor.
Definition: AliceCommon.hh:177
virtual std::unique_ptr< Rivet::Projection > clone() const
Definition: AliceCommon.hh:261
V0Multiplicity< 0 > V0MMultiplicity
Definition: AliceCommon.hh:84
void clear()
Unset the value.
Definition: SingleValueProjection.hh:54
const Cut V0Cacceptance
Definition: AliceCommon.hh:30