LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProcessFlag.h
Go to the documentation of this file.
1 #ifndef ProcessFlag_h
2 #define ProcessFlag_h
3 
4 #include <map>
5 #include <iostream>
6 
7 namespace EVENT{
8  class LCCollection ;
9 }
10 
11 
12 namespace UTIL{
13 
15  enum struct ProcessorFlagBits{
16  electrons,
17  muons,
18  taus,
19  neutrinos,
20  photons,
21  dquarks,
22  uquarks,
23  squarks,
24  cquarks,
25  bquarks,
26  higgsbb,
27  higgscc,
28  higgsdu,
29  higgsss,
30  higgsgg,
31  higgstautau,
32  higgsmumu,
33  higgsWW,
34  higgsZZ,
35  higgsgaga,
36  higgsgaZ,
37  higgsinv,
38  higgsother,
39  exotic,
40  unknown
41  } ;
42 
45 
58  class ProcessFlag {
59 
60  public:
61 
62  ProcessFlag() = default ;
63  ~ProcessFlag() = default ;
64 
65  ProcessFlag(const ProcessFlag& f) = default ;
66  ProcessFlag& operator=(const ProcessFlag& f) = default ;
67 
69  ProcessFlag(int flag) : _flag(flag) {}
70 
71 
76  for( auto bit : bits ) add(bit) ;
77  }
78 
80  void add( PF bit ){
81  _flag = _flag | ( 1 << (int) bit ) ;
82  }
83 
85  bool addFSParticles(int pdg){
86  auto m = _mapFS.find( pdg ) ;
87  if( m != _mapFS.end() ){
88  add( m->second ) ;
89  return true ;
90  }
91  return false ;
92  }
94  bool addHiggsDecay(int pdg){
95  auto m = _mapH.find( pdg ) ;
96  if( m != _mapH.end() ){
97  add( m->second ) ;
98  return true ;
99  }
100  return false ;
101  }
102 
104  ProcessFlag& operator=( int flag) { _flag = flag ; return *this ;}
105 
107  bool operator==(const ProcessFlag& f) const { return _flag == f._flag ; }
108 
110  bool contains(const ProcessFlag& f) const { return ( _flag & f._flag ) == f._flag ; }
111 
112 
114  operator int() const { return _flag ; }
115 
117  bool has(PF bit) const { return (_flag & (1<< (int) bit) ) ? true : false ; }
118 
119  private:
120  int _flag=0 ;
121 
123  {
124  { 11, PF::electrons },
125  { 13, PF::muons },
126  { 15, PF::taus },
127  { 12, PF::neutrinos },
128  { 14, PF::neutrinos },
129  { 16, PF::neutrinos },
130  { 22, PF::photons },
131  { 1, PF::dquarks },
132  { 2, PF::uquarks },
133  { 3, PF::squarks },
134  { 4, PF::cquarks },
135  { 5, PF::bquarks }
136  } ;
138  {
139  { 5, PF::higgsbb },
140  { 1, PF::higgsdu },
141  { 2, PF::higgsdu },
142  { 3, PF::higgsss },
143  { 4, PF::higgscc },
144  { 15, PF::higgstautau },
145  { 13, PF::higgsmumu },
146  { 24, PF::higgsWW },
147  { 23, PF::higgsZZ },
148  { 22, PF::higgsgaga },
149  { 12, PF::higgsinv },
150  { 14, PF::higgsinv },
151  { 16, PF::higgsinv },
152  { 1000022, PF::higgsinv }
153  } ;
154 
155  } ;
156 
157 
159 
160  os << std::hex << "0x" << (int) flag << std::dec << " -> |" ;
161 
162  if( flag.has( PF::electrons ) ) os << "electrons|" ;
163  if( flag.has( PF::muons ) ) os << "muons|" ;
164  if( flag.has( PF::taus ) ) os << "taus|" ;
165  if( flag.has( PF::neutrinos ) ) os << "neutrinos|" ;
166  if( flag.has( PF::photons ) ) os << "photons|" ;
167  if( flag.has( PF::dquarks ) ) os << "dquarks|" ;
168  if( flag.has( PF::uquarks ) ) os << "uquarks|" ;
169  if( flag.has( PF::squarks ) ) os << "squarks|" ;
170  if( flag.has( PF::cquarks ) ) os << "cquarks|" ;
171  if( flag.has( PF::bquarks ) ) os << "bquarks|" ;
172  if( flag.has( PF::higgsbb ) ) os << "higgsbb|" ;
173  if( flag.has( PF::higgsdu ) ) os << "higgsdu|" ;
174  if( flag.has( PF::higgsss ) ) os << "higgsss|" ;
175  if( flag.has( PF::higgscc ) ) os << "higgscc|" ;
176  if( flag.has( PF::higgstautau ) ) os << "higgstautau|" ;
177  if( flag.has( PF::higgsmumu ) ) os << "higgsmumu|" ;
178  if( flag.has( PF::higgsWW ) ) os << "higgsWW|" ;
179  if( flag.has( PF::higgsZZ ) ) os << "higgsZZ|" ;
180  if( flag.has( PF::higgsgaga ) ) os << "higgsgaga|" ;
181  if( flag.has( PF::higgsgaZ ) ) os << "higgsgaZ|" ;
182  if( flag.has( PF::higgsinv ) ) os << "higgsinv|" ;
183  if( flag.has( PF::higgsother ) ) os << "higgsother|" ;
184  if( flag.has( PF::exotic ) ) os << "exotic|" ;
185  if( flag.has( PF::unknown ) ) os << "unknown|" ;
186 
187  return os;
188  }
189 
190 
208  ProcessFlag decodeMCTruthProcess(const EVENT::LCCollection* mcps , int maxParticle=10);
209 
210 }
211 #endif
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
uquarks in final state
Higss to ccbar decay.
std::ostream & operator<<(std::ostream &os, const BitField64 &b)
Operator for dumping BitField64 to streams.
Definition: BitField64.cc:251
cquarks in final state
void add(PF bit)
add an individual bit
Definition: ProcessFlag.h:80
electrons in final state
ProcessFlag & operator=(int flag)
assign complete int flag
Definition: ProcessFlag.h:104
Higss to ddbar or uubar decay.
ProcessorFlagBits
enum class for flag bits in ProcessFlag
Definition: ProcessFlag.h:15
bool addHiggsDecay(int pdg)
add the bit for the Higgs decaying to a particles with given PDG code - false if not known ...
Definition: ProcessFlag.h:94
Higss to invisible decay.
T end(T...args)
bquarks in final state
ProcessFlag(int flag)
construct from int
Definition: ProcessFlag.h:69
ProcessFlag()=default
dquarks in final state
neutrinos in final state
bool has(PF bit) const
check if this bit is present
Definition: ProcessFlag.h:117
ProcessFlag decodeMCTruthProcess(const EVENT::LCCollection *mcps, int maxParticle=10)
Helper function that decodes the MC truth process from an LCCollection with MCParticles.
Definition: ProcessFlag.cc:12
exotic process (SUSY etc)
~ProcessFlag()=default
Higss to bbbar decay.
Higss to gamma Z decay.
ProcessFlag & operator=(const ProcessFlag &f)=default
ProcessorFlagBits PF
Short name for ProcessorFlagBits.
Definition: ProcessFlag.h:44
bool addFSParticles(int pdg)
add the bit for the final state particles with given PDG code - false if not known ...
Definition: ProcessFlag.h:85
bool contains(const ProcessFlag &f) const
true if this ProcessFlag contains everything in f
Definition: ProcessFlag.h:110
muons in final state
T find(T...args)
squarks in final state
std::map< int, PF > _mapFS
Definition: ProcessFlag.h:122
The generic collection used in LCIO.
Definition: LCCollection.h:29
Higss to ssbar decay.
photons in final state
std::map< int, PF > _mapH
Definition: ProcessFlag.h:137
ProcessFlag(const std::initializer_list< PF > &bits)
c&#39;tor that takes a list of bit enums in an initialiser list, e.g.
Definition: ProcessFlag.h:75
T hex(T...args)
Helper class for defining the generated Monte Carlo physics process.
Definition: ProcessFlag.h:58
Higss to gamma gamma decay.
bool operator==(const ProcessFlag &f) const
conparison - true if identical processes
Definition: ProcessFlag.h:107
STL class.
taus in final state