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