File indexing completed on 2025-07-14 08:52:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include <Gaudi/Decays/Nodes.h>
0014 #include <Gaudi/Interfaces/IParticlePropertySvc.h>
0015 #include <Gaudi/ParticleProperty.h>
0016 #include <Gaudi/cxx/SynchronizedValue.h>
0017 #include <GaudiKernel/MsgStream.h>
0018 #include <algorithm>
0019
0020
0021
0022
0023
0024
0025
0026 namespace Gaudi::Decays {
0027 namespace Nodes {
0028
0029
0030
0031
0032
0033
0034 class GAUDI_API Any : public Decays::iNode {
0035 public:
0036
0037 Any* clone() const override;
0038
0039 bool operator()( const Gaudi::ParticleID& ) const override;
0040
0041 std::ostream& fillStream( std::ostream& s ) const override;
0042
0043 bool valid() const override;
0044
0045 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0046 };
0047
0048
0049
0050
0051
0052
0053
0054 class GAUDI_API Pid : public Decays::iNode {
0055 public:
0056
0057 Pid( const Decays::Decay::Item& item );
0058
0059 Pid( const Gaudi::ParticleProperty* item );
0060
0061 Pid( const Gaudi::ParticleID& item );
0062
0063 Pid( const std::string& item );
0064
0065 Pid* clone() const override;
0066
0067 bool operator()( const Gaudi::ParticleID& pid ) const override { return check( pid ); }
0068
0069 std::ostream& fillStream( std::ostream& s ) const override;
0070
0071 bool valid() const override;
0072
0073 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0074
0075 public:
0076 bool check( Gaudi::ParticleID pid ) const { return pid == m_item.pid(); }
0077
0078
0079 const Decays::Decay::Item& item() const { return m_item; }
0080
0081 operator const Decays::Decay::Item&() const { return item(); }
0082
0083 private:
0084
0085 Decays::Decay::Item m_item;
0086 };
0087
0088
0089
0090
0091
0092
0093
0094 class GAUDI_API CC : public Pid {
0095 public:
0096
0097 CC( const Decays::Decay::Item& item );
0098
0099 CC( const Gaudi::ParticleProperty* item );
0100
0101 CC( Gaudi::ParticleID item );
0102
0103 CC( const std::string& item );
0104
0105 CC( const Decays::Nodes::Pid& pid );
0106
0107 CC* clone() const override;
0108
0109 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.abspid() == item().pid().abspid(); }
0110
0111 std::ostream& fillStream( std::ostream& s ) const override;
0112 };
0113
0114
0115
0116
0117
0118
0119 class GAUDI_API Lepton : public Any {
0120 public:
0121
0122 Lepton* clone() const override;
0123
0124 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.isLepton(); }
0125
0126 std::ostream& fillStream( std::ostream& s ) const override;
0127 };
0128
0129
0130
0131
0132
0133
0134 class GAUDI_API Nu : public Lepton {
0135 public:
0136
0137 Nu* clone() const override;
0138
0139 bool operator()( const Gaudi::ParticleID& pid ) const override {
0140 return pid.isLepton() && ( 0 == pid.threeCharge() );
0141 }
0142
0143 std::ostream& fillStream( std::ostream& s ) const override;
0144 };
0145
0146
0147
0148
0149
0150
0151 class GAUDI_API Ell : public Lepton {
0152 public:
0153
0154 Ell* clone() const override;
0155
0156 bool operator()( const Gaudi::ParticleID& pid ) const override {
0157 return pid.isLepton() && ( 0 != pid.threeCharge() );
0158 }
0159
0160 std::ostream& fillStream( std::ostream& s ) const override;
0161 };
0162
0163
0164
0165
0166
0167
0168 class GAUDI_API EllPlus : public Ell {
0169 public:
0170
0171 EllPlus* clone() const override;
0172
0173 bool operator()( const Gaudi::ParticleID& pid ) const override {
0174 return pid.isLepton() && ( 0 < pid.threeCharge() );
0175 }
0176
0177 std::ostream& fillStream( std::ostream& s ) const override;
0178 };
0179
0180
0181
0182
0183
0184 class GAUDI_API EllMinus : public Ell {
0185 public:
0186
0187 EllMinus* clone() const override;
0188
0189 bool operator()( const Gaudi::ParticleID& pid ) const override {
0190 return pid.isLepton() && ( 0 > pid.threeCharge() );
0191 }
0192
0193 std::ostream& fillStream( std::ostream& s ) const override;
0194 };
0195
0196
0197
0198
0199
0200
0201 class GAUDI_API Hadron : public Any {
0202 public:
0203
0204 Hadron* clone() const override;
0205
0206 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.isHadron(); }
0207
0208 std::ostream& fillStream( std::ostream& s ) const override;
0209 };
0210
0211
0212
0213
0214
0215
0216 class GAUDI_API Meson : public Hadron {
0217 public:
0218
0219 Meson* clone() const override;
0220
0221 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.isMeson(); }
0222
0223 std::ostream& fillStream( std::ostream& s ) const override;
0224 };
0225
0226
0227
0228
0229
0230
0231 class GAUDI_API Baryon : public Hadron {
0232 public:
0233
0234 Baryon* clone() const override;
0235
0236 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.isBaryon(); }
0237
0238 std::ostream& fillStream( std::ostream& s ) const override;
0239 };
0240
0241
0242
0243
0244
0245
0246 class GAUDI_API Charged : public Any {
0247 public:
0248
0249 Charged* clone() const override;
0250
0251 bool operator()( const Gaudi::ParticleID& pid ) const override { return 0 != pid.threeCharge(); }
0252
0253 std::ostream& fillStream( std::ostream& s ) const override;
0254 };
0255
0256
0257
0258
0259
0260
0261 class GAUDI_API Positive : public Charged {
0262 public:
0263
0264 Positive* clone() const override;
0265
0266 bool operator()( const Gaudi::ParticleID& pid ) const override { return 0 < pid.threeCharge(); }
0267
0268 std::ostream& fillStream( std::ostream& s ) const override;
0269 };
0270
0271
0272
0273
0274
0275
0276 class GAUDI_API Negative : public Charged {
0277 public:
0278
0279 Negative* clone() const override;
0280
0281 bool operator()( const Gaudi::ParticleID& pid ) const override { return 0 > pid.threeCharge(); }
0282
0283 std::ostream& fillStream( std::ostream& s ) const override;
0284 };
0285
0286
0287
0288
0289
0290
0291 class GAUDI_API Neutral : public Charged {
0292 public:
0293
0294 Neutral* clone() const override;
0295
0296 bool operator()( const Gaudi::ParticleID& pid ) const override { return 0 == pid.threeCharge(); }
0297
0298 std::ostream& fillStream( std::ostream& s ) const override;
0299 };
0300
0301
0302
0303
0304
0305
0306 class GAUDI_API Nucleus : public Any {
0307 public:
0308
0309 Nucleus* clone() const override;
0310
0311 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.isNucleus(); }
0312
0313 std::ostream& fillStream( std::ostream& s ) const override;
0314 };
0315
0316
0317
0318
0319
0320
0321 class GAUDI_API HasQuark : public Any {
0322 public:
0323
0324 HasQuark( Gaudi::ParticleID::Quark quark );
0325
0326 HasQuark* clone() const override;
0327
0328 bool operator()( const Gaudi::ParticleID& pid ) const override { return pid.hasQuark( m_quark ); }
0329
0330 std::ostream& fillStream( std::ostream& s ) const override;
0331
0332 private:
0333
0334 Gaudi::ParticleID::Quark m_quark;
0335 };
0336
0337
0338
0339
0340
0341
0342 class GAUDI_API JSpin : public Any {
0343 public:
0344 enum { InvalidSpin = 501 };
0345
0346
0347 JSpin( const int spin );
0348
0349 JSpin* clone() const override;
0350
0351 bool operator()( const Gaudi::ParticleID& pid ) const override { return spin() == pid.jSpin(); }
0352
0353 std::ostream& fillStream( std::ostream& s ) const override;
0354
0355
0356 bool valid() const override;
0357
0358 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* ) const override;
0359
0360 int spin() const { return m_spin; }
0361
0362 private:
0363
0364 int m_spin;
0365 };
0366
0367
0368
0369
0370
0371
0372 class GAUDI_API SSpin : public JSpin {
0373 public:
0374
0375 SSpin( const int spin );
0376
0377 SSpin* clone() const override;
0378
0379 bool operator()( const Gaudi::ParticleID& pid ) const override { return spin() == pid.sSpin(); }
0380
0381 std::ostream& fillStream( std::ostream& s ) const override;
0382 };
0383
0384
0385
0386
0387
0388
0389 class GAUDI_API LSpin : public SSpin {
0390 public:
0391
0392 LSpin( const int spin );
0393
0394 LSpin* clone() const override;
0395
0396 bool operator()( const Gaudi::ParticleID& pid ) const override { return spin() == pid.lSpin(); }
0397
0398 std::ostream& fillStream( std::ostream& s ) const override;
0399 };
0400
0401
0402
0403
0404
0405
0406 class GAUDI_API CTau : public Decays::iNode {
0407 public:
0408
0409 CTau( const double low, const double high, const Gaudi::Interfaces::IParticlePropertySvc* svc = nullptr );
0410
0411 CTau* clone() const override;
0412
0413
0414 bool operator()( const Gaudi::ParticleID& pid ) const override;
0415
0416 std::ostream& fillStream( std::ostream& s ) const override;
0417
0418 bool valid() const override;
0419
0420 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0421
0422 const Gaudi::Interfaces::IParticlePropertySvc* ppSvc() const { return m_ppSvc; }
0423
0424
0425 double low() const { return m_low; }
0426
0427 double high() const { return m_high; }
0428
0429 StatusCode setService( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const;
0430
0431 protected:
0432 template <typename F, typename = std::is_invocable_r<bool, F, Gaudi::ParticleID>>
0433 bool classify( Gaudi::ParticleID pid, F&& f ) const {
0434 enum struct Classification { Accepted = +1, Rejected = -1, Unknown = 0 };
0435 auto r = m_pids.with_lock(
0436 []( const auto& pids, Gaudi::ParticleID pid ) {
0437 return std::binary_search( pids.accepted.begin(), pids.accepted.end(), pid ) ? Classification::Accepted
0438 : std::binary_search( pids.rejected.begin(), pids.rejected.end(), pid ) ? Classification::Rejected
0439 : Classification::Unknown;
0440 },
0441 pid );
0442 switch ( r ) {
0443 case Classification::Accepted:
0444 return true;
0445 case Classification::Rejected:
0446 return false;
0447 case Classification::Unknown:
0448 return add_( pid, std::invoke( std::forward<F>( f ), pid ) );
0449 }
0450 __builtin_unreachable();
0451 }
0452
0453 private:
0454 bool add_( Gaudi::ParticleID pid, bool acc ) const;
0455
0456 public:
0457 MsgStream& printAcceptedAsTable( MsgStream& s ) const {
0458 return m_pids.with_lock(
0459 [&]( const KnownPids& pids, MsgStream& s, auto const& ppSvc ) -> decltype( auto ) {
0460 return Gaudi::ParticleProperties::printAsTable( pids.accepted, s, ppSvc );
0461 },
0462 s, m_ppSvc );
0463 }
0464
0465 private:
0466 typedef SmartIF<Gaudi::Interfaces::IParticlePropertySvc> Service;
0467
0468 mutable Service m_ppSvc;
0469
0470 public:
0471 struct KnownPids {
0472 std::vector<Gaudi::ParticleID> accepted;
0473 std::vector<Gaudi::ParticleID> rejected;
0474 };
0475
0476 private:
0477 mutable Gaudi::cxx::SynchronizedValue<KnownPids> m_pids;
0478
0479
0480 double m_low;
0481
0482 double m_high;
0483 };
0484
0485
0486
0487
0488
0489
0490 class GAUDI_API ShortLived_ : public CTau {
0491 public:
0492
0493 ShortLived_( const double high, const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0494
0495 ShortLived_( const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0496
0497 ShortLived_* clone() const override;
0498
0499 std::ostream& fillStream( std::ostream& s ) const override;
0500 };
0501
0502
0503
0504
0505
0506
0507 struct GAUDI_API LongLived_ : CTau {
0508
0509 LongLived_( const double high, const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0510
0511 LongLived_( const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0512
0513 LongLived_* clone() const override;
0514
0515 std::ostream& fillStream( std::ostream& s ) const override;
0516 };
0517
0518
0519
0520
0521
0522
0523 class GAUDI_API Stable : public LongLived_ {
0524 public:
0525
0526 Stable( const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0527
0528 Stable* clone() const override;
0529
0530 std::ostream& fillStream( std::ostream& s ) const override;
0531 };
0532
0533
0534
0535
0536
0537
0538 class GAUDI_API StableCharged : public Stable {
0539 public:
0540
0541 StableCharged( const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0542
0543 StableCharged* clone() const override;
0544
0545 bool operator()( const Gaudi::ParticleID& pid ) const override;
0546
0547 std::ostream& fillStream( std::ostream& s ) const override;
0548 };
0549
0550
0551
0552
0553
0554
0555 class GAUDI_API Mass : public CTau {
0556 public:
0557
0558 Mass( const double low, const double high, const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0559
0560 Mass* clone() const override;
0561
0562
0563 bool operator()( const Gaudi::ParticleID& pid ) const override;
0564
0565 std::ostream& fillStream( std::ostream& s ) const override;
0566 };
0567
0568
0569
0570
0571
0572
0573 class GAUDI_API Light : public Mass {
0574 public:
0575
0576 Light( const double high, const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0577
0578 Light* clone() const override;
0579
0580
0581 std::ostream& fillStream( std::ostream& s ) const override;
0582 };
0583
0584
0585
0586
0587
0588
0589 class GAUDI_API Heavy : public Mass {
0590 public:
0591
0592 Heavy( const double low, const Gaudi::Interfaces::IParticlePropertySvc* svc = 0 );
0593
0594 Heavy* clone() const override;
0595
0596
0597 std::ostream& fillStream( std::ostream& s ) const override;
0598 };
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608 class GAUDI_API PosID : public Decays::iNode {
0609 public:
0610
0611 PosID* clone() const override;
0612
0613 bool operator()( const Gaudi::ParticleID& ) const override;
0614
0615 std::ostream& fillStream( std::ostream& s ) const override;
0616
0617 bool valid() const override;
0618
0619 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0620 };
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630 class GAUDI_API NegID : public Decays::iNode {
0631 public:
0632
0633 NegID* clone() const override;
0634
0635 bool operator()( const Gaudi::ParticleID& ) const override;
0636
0637 std::ostream& fillStream( std::ostream& s ) const override;
0638
0639 bool valid() const override;
0640
0641 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0642 };
0643
0644 class GAUDI_API Symbol : public Decays::iNode {
0645 public:
0646
0647 Symbol( const std::string& sym );
0648
0649 Symbol* clone() const override;
0650
0651
0652 bool operator()( const Gaudi::ParticleID& pid ) const override;
0653
0654 std::ostream& fillStream( std::ostream& s ) const override;
0655
0656 bool valid() const override;
0657
0658 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override;
0659
0660 private:
0661
0662 Decays::Node m_symbol;
0663 };
0664 }
0665 }