File indexing completed on 2025-04-19 09:06:47
0001 #ifndef PROJECTIONS_ALICECOMMON_HH
0002 #define PROJECTIONS_ALICECOMMON_HH
0003
0004 #include "Rivet/Tools/AliceCommon.hh"
0005 #include "Rivet/Projections/FinalState.hh"
0006 #include "Rivet/Projections/SingleValueProjection.hh"
0007 #include "Rivet/Projections/TriggerProjection.hh"
0008 #include "Rivet/Projections/PrimaryParticles.hh"
0009
0010 namespace Rivet {
0011 namespace ALICE {
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 template <int MODE>
0023 class V0Multiplicity : public SingleValueProjection {
0024 public:
0025 using SingleValueProjection::operator=;
0026 V0Multiplicity() : SingleValueProjection() {
0027 setName(MODE<0 ? "ALICE::V0CMultiplicity":
0028 MODE>0 ? "ALICE::V0AMultiplicity":
0029 "ALICE::V0MMultiplicity");
0030 Cut cut;
0031 if (MODE < 0) cut = V0Cacceptance;
0032 else if (MODE > 0) cut = V0Aacceptance;
0033 else cut = (V0Aacceptance || V0Cacceptance);
0034
0035
0036
0037 const FinalState fs(cut);
0038 this->declare(fs, "FinalState");
0039 }
0040
0041
0042 virtual ~V0Multiplicity() {}
0043
0044
0045
0046
0047
0048
0049 virtual void project(const Event& e) {
0050 clear();
0051 setValue(apply<FinalState>(e,"FinalState").particles().size());
0052 }
0053
0054
0055
0056
0057 virtual std::unique_ptr<Rivet::Projection> clone() const {
0058 return std::unique_ptr<Projection>(new V0Multiplicity<MODE>(*this));
0059 }
0060
0061
0062 using Projection::operator =;
0063
0064
0065
0066
0067 virtual CmpState compare(const Projection& p) const {
0068 return dynamic_cast<const V0Multiplicity<MODE>*>(&p) ?
0069 CmpState::EQ : CmpState::NEQ;
0070 }
0071
0072 };
0073
0074
0075
0076
0077
0078 typedef V0Multiplicity<+1> V0AMultiplicity;
0079
0080
0081
0082
0083 typedef V0Multiplicity<-1> V0CMultiplicity;
0084
0085
0086
0087
0088 typedef V0Multiplicity<0> V0MMultiplicity;
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 template <bool INNER>
0100 class CLMultiplicity : public SingleValueProjection {
0101 public:
0102
0103
0104 CLMultiplicity() : SingleValueProjection() {
0105 setName("ALICE::CLMultiplicity");
0106 Cut cut;
0107 if (INNER) cut = CL0acceptance;
0108 else cut = CL1acceptance;
0109
0110
0111
0112 const FinalState fs(cut);
0113 this->declare(fs, "FinalState");
0114 }
0115
0116
0117 virtual ~CLMultiplicity() {}
0118
0119
0120
0121
0122
0123
0124 virtual void project(const Event& e) {
0125 clear();
0126 set(apply<FinalState>(e,"FinalState").particles().size());
0127 }
0128
0129
0130
0131
0132 virtual std::unique_ptr<Rivet::Projection> clone() const {
0133 return std::unique_ptr<Projection>(new CLMultiplicity<INNER>(*this));
0134 }
0135
0136
0137 using Projection::operator =;
0138
0139
0140
0141
0142 virtual CmpState compare(const Projection& p) const {
0143 return dynamic_cast<const CLMultiplicity<INNER>*>(&p) ?
0144 CmpState::EQ : CmpState::NEQ;
0145 }
0146
0147 };
0148
0149
0150
0151
0152
0153 typedef CLMultiplicity<true> CL0Multiplicity;
0154
0155
0156
0157
0158 typedef CLMultiplicity<false> CL1Multiplicity;
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 template <int MODE>
0170 class V0Trigger : public TriggerProjection {
0171 public:
0172
0173
0174 V0Trigger() : TriggerProjection() {
0175 setName("ALICE::V0Trigger");
0176
0177
0178
0179 const V0Multiplicity<MODE> fs;
0180 this->declare(fs, "FinalState");
0181 }
0182
0183
0184 virtual ~V0Trigger() {}
0185
0186
0187
0188
0189
0190 virtual void project(const Event& e) {
0191 fail();
0192 if (apply<V0Multiplicity<MODE>>(e, "FinalState")() > 0) pass();
0193 }
0194
0195
0196
0197
0198 virtual std::unique_ptr<Rivet::Projection> clone() const {
0199 return std::unique_ptr<Projection>(new V0Trigger<MODE>(*this));
0200 }
0201
0202
0203 using Projection::operator =;
0204
0205
0206
0207
0208
0209
0210
0211 virtual CmpState compare(const Projection& p) const {
0212 return dynamic_cast<const V0Trigger<MODE>*>(&p) ?
0213 CmpState::EQ : CmpState::NEQ;
0214 }
0215
0216 };
0217
0218
0219
0220
0221
0222 using V0ATrigger = V0Trigger<-1>;
0223
0224
0225
0226
0227 using V0CTrigger = V0Trigger<+1>;
0228
0229
0230
0231
0232 using V0OrTrigger = V0Trigger<0>;
0233
0234
0235
0236
0237 class V0AndTrigger : public TriggerProjection {
0238 public:
0239
0240
0241 V0AndTrigger() : TriggerProjection() {
0242 const V0ATrigger v0a;
0243 const V0CTrigger v0c;
0244 this->declare(v0a, "V0A");
0245 this->declare(v0c, "V0C");
0246 }
0247
0248
0249 virtual ~V0AndTrigger() {}
0250
0251
0252
0253
0254
0255 virtual void project(const Event& e) {
0256 fail();
0257 if (apply<V0ATrigger>(e,"V0A")() && apply<V0CTrigger>(e,"V0C")()) pass();
0258 }
0259
0260
0261
0262
0263 virtual CmpState compare(const Projection& p) const
0264 {
0265 return dynamic_cast<const V0AndTrigger*>(&p) ?
0266 CmpState::EQ : CmpState::NEQ;
0267 }
0268
0269
0270
0271
0272 virtual std::unique_ptr<Rivet::Projection> clone() const {
0273 return std::unique_ptr<Projection>(new V0AndTrigger(*this));
0274 }
0275
0276
0277 using Projection::operator =;
0278
0279 };
0280
0281
0282
0283
0284
0285
0286
0287
0288 class PrimaryParticles : public Rivet::PrimaryParticles {
0289 public:
0290
0291 PrimaryParticles(const Cut& c=Cuts::open())
0292 : Rivet::PrimaryParticles({}, c)
0293 { }
0294
0295
0296
0297
0298
0299
0300
0301
0302 virtual CmpState compare(const Projection& p) const {
0303 const PrimaryParticles* o = dynamic_cast<const PrimaryParticles*>(&p);
0304 if (_cuts != o->_cuts) return CmpState::NEQ;
0305 return mkPCmp(*o,"PrimaryParticles");
0306 }
0307
0308
0309 virtual std::unique_ptr<Rivet::Projection> clone() const {
0310 return std::unique_ptr<Projection>(new PrimaryParticles(*this));
0311 }
0312
0313
0314 using Projection::operator =;
0315
0316
0317 protected:
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332 bool isPrimaryPID(ConstGenParticlePtr p) const {
0333 const int pdg = abs(p->pdg_id());
0334
0335 if (pdg > 1000000000) return true;
0336
0337 switch (pdg) {
0338 case Rivet::PID::MUON:
0339 case Rivet::PID::ELECTRON:
0340 case Rivet::PID::GAMMA:
0341 case Rivet::PID::PIPLUS:
0342 case Rivet::PID::KPLUS:
0343 case Rivet::PID::K0S:
0344 case Rivet::PID::K0L:
0345 case Rivet::PID::PROTON:
0346 case Rivet::PID::NEUTRON:
0347 case Rivet::PID::LAMBDA:
0348 case Rivet::PID::SIGMAMINUS:
0349 case Rivet::PID::SIGMAPLUS:
0350 case Rivet::PID::XIMINUS:
0351 case Rivet::PID::XI0:
0352 case Rivet::PID::OMEGAMINUS:
0353 case Rivet::PID::NU_E:
0354 case Rivet::PID::NU_MU:
0355 case Rivet::PID::NU_TAU:
0356 return true;
0357 }
0358 return false;
0359 }
0360
0361 };
0362
0363
0364 }
0365 }
0366
0367 #endif