Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Fatras/include/ActsFatras/Selectors/ParticleSelectors.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/PdgParticle.hpp"
0012 #include "ActsFatras/EventData/Particle.hpp"
0013 
0014 namespace ActsFatras {
0015 
0016 /// No-op particle selector that selects all particles.
0017 struct EveryParticle {
0018   /// Select all particles unconditionally
0019   /// @param particle The particle to evaluate (unused)
0020   /// @return Always true
0021   bool operator()(const Particle &particle) const {
0022     (void)particle;
0023     return true;
0024   }
0025 };
0026 
0027 /// Select neutral particles.
0028 struct NeutralSelector {
0029   /// Check if particle is neutral
0030   /// @param particle The particle to evaluate
0031   /// @return true if particle charge is zero
0032   bool operator()(const Particle &particle) const {
0033     return (particle.charge() == 0.);
0034   }
0035 };
0036 
0037 /// Select all charged particles.
0038 struct ChargedSelector {
0039   /// Check if particle is charged
0040   /// @param particle The particle to evaluate
0041   /// @return true if particle charge is non-zero
0042   bool operator()(const Particle &particle) const {
0043     return (particle.charge() != 0.);
0044   }
0045 };
0046 
0047 /// Select positively charged particles.
0048 struct PositiveSelector {
0049   /// Check if particle is positively charged
0050   /// @param particle The particle to evaluate
0051   /// @return true if particle charge is positive
0052   bool operator()(const Particle &particle) const {
0053     return (0. < particle.charge());
0054   }
0055 };
0056 
0057 /// Select negatively charged particles.
0058 struct NegativeSelector {
0059   /// Check if particle is negatively charged
0060   /// @param particle The particle to evaluate
0061   /// @return true if particle charge is negative
0062   bool operator()(const Particle &particle) const {
0063     return (particle.charge() < 0.);
0064   }
0065 };
0066 
0067 /// Select particles of one specific type.
0068 ///
0069 /// Particle and Antiparticle are treated as two separate types.
0070 template <Acts::PdgParticle Pdg>
0071 struct PdgSelector {
0072   /// Check if particle matches the specific PDG type
0073   /// @param particle The particle to evaluate
0074   /// @return true if particle PDG matches the template parameter
0075   bool operator()(const Particle &particle) const {
0076     return (particle.pdg() == Pdg);
0077   }
0078 };
0079 
0080 /// Select particles and antiparticles of one specific type.
0081 template <Acts::PdgParticle Pdg>
0082 struct AbsPdgSelector {
0083   /// Check if particle matches the specific PDG type (ignoring sign)
0084   /// @param particle The particle to evaluate
0085   /// @return true if absolute PDG type matches the template parameter
0086   bool operator()(const Particle &particle) const {
0087     return (makeAbsolutePdgParticle(particle.pdg()) ==
0088             makeAbsolutePdgParticle(Pdg));
0089   }
0090 };
0091 
0092 /// Select all particles except one specific type.
0093 ///
0094 /// Particle and Antiparticle are treated as two separate types.
0095 template <Acts::PdgParticle Pdg>
0096 struct PdgExcluder {
0097   /// Check if particle does not match the specific PDG type
0098   /// @param particle The particle to evaluate
0099   /// @return true if particle PDG does not match the template parameter
0100   bool operator()(const Particle &particle) const {
0101     return (particle.pdg() != Pdg);
0102   }
0103 };
0104 
0105 /// Select all particles except for (anti-)particles of one specific type.
0106 template <Acts::PdgParticle Pdg>
0107 struct AbsPdgExcluder {
0108   /// Check if particle does not match the specific PDG type (ignoring sign)
0109   /// @param particle The particle to evaluate
0110   /// @return true if absolute PDG type does not match the template parameter
0111   bool operator()(const Particle &particle) const {
0112     return (makeAbsolutePdgParticle(particle.pdg()) !=
0113             makeAbsolutePdgParticle(Pdg));
0114   }
0115 };
0116 
0117 }  // namespace ActsFatras