a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
ParticleCode.hpp
Go to the documentation of this file.
1/*
2 * ParticleCode.hpp
3 *
4 * Created on: Jan 26, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#ifndef PARTICLECODE_HPP_
15#define PARTICLECODE_HPP_
16
17#include <vector>
18#include "../FilterRule.hpp"
19
20namespace LHPC
21{
22 namespace LHEF
23 {
24 namespace FilterRuleClass
25 {
26 // this class returns acceptRatherThanReject if it finds that
27 // lineToCheck.getParticleCode() matches an int in acceptableValues.
28 class ParticleCode : public FilterRule
29 {
30 public:
31 ParticleCode( std::vector< int > const& acceptableValues,
32 bool const acceptRatherThanReject = true );
33 ParticleCode( int const acceptableValue,
34 bool const acceptRatherThanReject = true );
35 virtual
37
38 virtual bool
39 operator()( ParticleLine const& lineToCheck ) const;
40
41
42 protected:
43 std::vector< int > acceptableValues;
44 };
45
46
47
48 inline bool
49 ParticleCode::operator()( ParticleLine const& lineToCheck ) const
50 {
51 bool returnValue( !acceptRatherThanReject );
52 for( int valueIndex( acceptableValues.size() - 1 );
53 0 <= valueIndex;
54 --valueIndex )
55 {
56 if( lineToCheck.getParticleCode() == acceptableValues[ valueIndex ] )
57 {
58 returnValue = acceptRatherThanReject;
59 valueIndex = -1;
60 }
61 }
62 return returnValue;
63 }
64
65 }
67
68 }
69
70}
71
72#endif /* PARTICLECODE_HPP_ */
virtual bool operator()(ParticleLine const &lineToCheck) const
ParticleCode(std::vector< int > const &acceptableValues, bool const acceptRatherThanReject=true)
bool const acceptRatherThanReject
Definition: FilterRule.hpp:36
FilterRuleClass::ParticleCode FilterOnParticleCode