ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
top::KLFitterSelector Class Reference

#include <KLFitterSelector.h>

Inheritance diagram for top::KLFitterSelector:
Collaboration diagram for top::KLFitterSelector:

Public Types

enum  Sign {
  signNOIDEA, signEQ, signLT, signGT,
  signLTEQ, signGTEQ
}
 Many of the tools will be supplied with an equality (or inequality) by the user. More...
 

Public Member Functions

 KLFitterSelector (const std::string &params)
 
bool apply (const top::Event &) const override
 This does stuff based on the information in an event. More...
 
virtual std::string name () const override
 The name is generated in the constructor for this kind of tool. More...
 
virtual bool applyParticleLevel (const top::ParticleLevelEvent &) const
 This does stuff based on the information in a particle level event. More...
 

Protected Member Functions

void checkValueIsInteger ()
 Integers are annoying in C++. More...
 
void checkMultiplicityIsInteger ()
 Integers are annoying in C++. More...
 
Sign sign () const
 Get the sign setup in the constructor. More...
 
double value () const
 Get the cut value assigned in the constructor. More...
 
std::string valueString () const
 Get the cut value assigned in the constructor. More...
 
std::string valueStringDelimReplace () const
 valueString which is manipulated to replace delimiter with new string More...
 
double multiplicity () const
 Get the cut multiplicity assigned in the constructor. More...
 
Sign decodesign (std::string &params)
 Take the string params, look for one of the allowed inequalities (or equality) and return that. More...
 
bool checkFloat (double value, double cut) const
 Compare a cut supplied by the user with the value calculated in the event. More...
 
bool checkInt (int value, int cut) const
 Compare a cut supplied by the user with the value calculated in the event. More...
 
const std::string signstring () const
 Convert the sign enum back to a string for use in the name and print outs. More...
 

Private Attributes

std::string m_name
 Hold the name of the tool, filled by the constructor. More...
 
Sign m_sign
 The sign of the cut, filled by the constructor. More...
 
double m_cutvalue
 The value of the cut, filled by the constructor. More...
 
std::string m_cutvalueString
 The value of the cut in the case it's a string, filled by the constructor. More...
 
double m_multiplicity
 The multiplicity for cuts that take both a value and a multiplicity e.g. EL_N 25000 >= 2. More...
 
std::string m_cutvalueStringDelimReplace
 The value of the cut when it is a string, with replacement of delimiter with a replacement substring. More...
 

Detailed Description

Definition at line 19 of file KLFitterSelector.h.

Member Enumeration Documentation

◆ Sign

Many of the tools will be supplied with an equality (or inequality) by the user.

They're decoded from the text input and saved in this 'sign' format.

Enumerator
signNOIDEA 
signEQ 
signLT 
signGT 
signLTEQ 
signGTEQ 

Definition at line 23 of file SignValueSelector.h.

23  {
24  signNOIDEA, //the user clearly did something wrong, expect to exit / crash
25  signEQ, // ==
26  signLT, // <
27  signGT, // >
28  signLTEQ, // <=
29  signGTEQ // >=
30  };

Constructor & Destructor Documentation

◆ KLFitterSelector()

top::KLFitterSelector::KLFitterSelector ( const std::string &  params)
explicit

Definition at line 11 of file KLFitterSelector.cxx.

11  :
12  SignValueSelector("KLFitter", params) {
13  }

Member Function Documentation

◆ apply()

bool top::KLFitterSelector::apply ( const top::Event ) const
overridevirtual

This does stuff based on the information in an event.

The idea is that you implement this to return either true or false based on the information held within top::Event. If this returns true then the event is kept. If it returns false then the event is removed.

Parameters
top::EventThe current event.
Returns
true if the event should be kept, false otherwise.

Implements top::EventSelectorBase.

Definition at line 15 of file KLFitterSelector.cxx.

15  {
16  // check we have a xAOD::KLFitterResultContainer
17  if (event.m_KLFitterResults == nullptr) {
18  return false;
19  }
20 
21  for (auto result : *event.m_KLFitterResults) {
22  // check for errors
23  if (
24  result->minuitDidNotConverge() == 0 &&
25  result->fitAbortedDueToNaN() == 0 &&
26  result->atLeastOneFitParameterAtItsLimit() == 0 &&
27  result->invalidTransferFunctionAtConvergence() == 0
28  ) {
29  bool passPermutation = checkFloat(result->logLikelihood(), value());
30  if (passPermutation) {
31  return true;
32  }
33  } // check for errors
34  } // Loop over Permutations - if we get this far, all Permutations have failed :(
35  return false;
36  }

◆ applyParticleLevel()

virtual bool top::EventSelectorBase::applyParticleLevel ( const top::ParticleLevelEvent ) const
inlinevirtualinherited

This does stuff based on the information in a particle level event.

The idea is that you implement this to return either true or false, based on the information held within the top::ParticleLevelEvent. If this function returns true, then the event is kept, otherwise it is removed. The function has a default implementation (which returns true) because it is expected that many EventSelector objects do not operate on ParticleLevelEvent objects.

Parameters
top::ParticleLevelEventthe current particle level event.
trueif the event should be kept (i.e. it passed the selector criteria), false otherwise.

Reimplemented in top::JetNGhostSelector, top::PrintEventSelector, top::PseudoTopRecoRun, top::NElectronNMuonTightSelector, top::NElectronNMuonSelector, top::NFwdElectronSelector, top::HTSelector, top::OSLeptonTightSelector, top::MLLSelector, top::MWTSelector, top::NElectronTightSelector, top::NFwdElectronTightSelector, top::NMuonTightSelector, top::OSLeptonSelector, top::METMWTSelector, top::METSelector, top::MLLWindow, top::NElectronSelector, top::NJetSelector, top::NMuonSelector, top::NPhotonSelector, top::NSoftMuonSelector, top::NTauSelector, top::SSLeptonTightSelector, top::SSLeptonSelector, top::ParticleLevelSelector, top::RecoLevelSelector, top::NVarRCJetSelector, top::NLargeJetSelector, and top::NRCJetSelector.

Definition at line 73 of file EventSelectorBase.h.

73 {return true;}

◆ checkFloat()

bool top::SignValueSelector::checkFloat ( double  value,
double  cut 
) const
protectedinherited

Compare a cut supplied by the user with the value calculated in the event.

For floating point numbers.

Parameters
valueThe value from the event.
cutThe cut the user wants to apply.
Returns
True if the cut is passed.

Definition at line 133 of file SignValueSelector.cxx.

133  {
134  switch (m_sign) {
135  case signNOIDEA: {
136  throw std::runtime_error("SignValueSelector::checkFloat: Can't recognise the sign");
137  }
138 
139  case signEQ: {
140  throw std::runtime_error("SignValueSelector::checkFloat: Can't compare floats with ==");
141  }
142 
143  case signLT:
144  return value < cut;
145 
146  case signGT:
147  return value > cut;
148 
149  case signLTEQ:
150  return value <= cut;
151 
152  case signGTEQ:
153  return value >= cut;
154  }
155 
156  return false;
157  }

◆ checkInt()

bool top::SignValueSelector::checkInt ( int  value,
int  cut 
) const
protectedinherited

Compare a cut supplied by the user with the value calculated in the event.

For integer numbers.

Parameters
valueThe value from the event.
cutThe cut the user wants to apply.
Returns
True if the cut is passed.

Definition at line 159 of file SignValueSelector.cxx.

159  {
160  switch (m_sign) {
161  case signNOIDEA: {
162  throw std::runtime_error("SignValueSelector::checkInt: Can't recognise the sign");
163  }
164 
165  case signEQ:
166  return value == cut;
167 
168  case signLT:
169  return value < cut;
170 
171  case signGT:
172  return value > cut;
173 
174  case signLTEQ:
175  return value <= cut;
176 
177  case signGTEQ:
178  return value >= cut;
179  }
180 
181  return false;
182  }

◆ checkMultiplicityIsInteger()

void top::SignValueSelector::checkMultiplicityIsInteger ( )
protectedinherited

Integers are annoying in C++.

Your first thought when reading in an integer is probably just to read it in with cin to an integer variable. This seems to not work, as it'll just read the integer component and ignore the rest of the string. The approach here then is to read it in as a floating point number and ask that number if it is equal to itself rounded down (integers are, fractional numbers are not)

Since the user probably didn't mean to cut on njets >= 2.3 we should interrupt the job and print a useful error message if it doesn't work.

Definition at line 82 of file SignValueSelector.cxx.

82  {
83  if (multiplicity() != floor(multiplicity())) {
84  ATH_MSG_ERROR("The number " << multiplicity() << " is not an integer\n"
85  << "As defined in " << name() << "\n");
86  throw std::runtime_error("Failed parsing multiplicity cut for SignValueSelector");
87  }
88  }

◆ checkValueIsInteger()

void top::SignValueSelector::checkValueIsInteger ( )
protectedinherited

Integers are annoying in C++.

Mostly used by the NLargeJet selectors.

Definition at line 74 of file SignValueSelector.cxx.

74  {
75  if (value() != floor(value())) {
76  ATH_MSG_ERROR("The number " << value() << " is not an integer\n"
77  << "As defined in " << name() << "\n");
78  throw std::runtime_error("Failed parsing value for SignValueSelector");
79  }
80  }

◆ decodesign()

SignValueSelector::Sign top::SignValueSelector::decodesign ( std::string &  params)
protectedinherited

Take the string params, look for one of the allowed inequalities (or equality) and return that.

It also removes the text from the string so the string can then be passed on to some code to extract the numerical value.

Parameters
paramsThe string that contains something like ">= 2". It will return the " 2" via the params parameter.
Returns
For the above example, the sign ">=" will be configured.

Definition at line 110 of file SignValueSelector.cxx.

110  {
111  Sign tempsign(signNOIDEA);
112 
113  if (params.find("==") != std::string::npos) {
114  tempsign = signEQ;
115  params.erase(params.find("=="), 2);
116  } else if (params.find("<=") != std::string::npos) {
117  tempsign = signLTEQ;
118  params.erase(params.find("<="), 2);
119  } else if (params.find(">=") != std::string::npos) {
120  tempsign = signGTEQ;
121  params.erase(params.find(">="), 2);
122  } else if (params.find("<") != std::string::npos) {
123  tempsign = signLT;
124  params.erase(params.find("<"), 1);
125  } else if (params.find(">") != std::string::npos) {
126  tempsign = signGT;
127  params.erase(params.find(">"), 1);
128  }
129 
130  return tempsign;
131  }

◆ multiplicity()

double top::SignValueSelector::multiplicity ( ) const
protectedinherited

Get the cut multiplicity assigned in the constructor.

This is used for cuts that take a value and a multiplicity, for example EL_N 25000 >= 2 means at least two electrons with pT > 25 GeV. You can chain these together to make non-symmetric cuts. For example EL_N 25000 >= 2 EL_N 40000 >= 1

Returns
The multiplicity is actually integer, but it's stored in a double so that we can check it's an integer when we read it in.

Definition at line 106 of file SignValueSelector.cxx.

106  {
107  return m_multiplicity;
108  }

◆ name()

std::string top::SignValueSelector::name ( ) const
overridevirtualinherited

The name is generated in the constructor for this kind of tool.

Implements top::EventSelectorBase.

Reimplemented in top::JetNGhostSelector.

Definition at line 70 of file SignValueSelector.cxx.

70  {
71  return m_name;
72  }

◆ sign()

SignValueSelector::Sign top::SignValueSelector::sign ( ) const
protectedinherited

Get the sign setup in the constructor.

Definition at line 90 of file SignValueSelector.cxx.

90  {
91  return m_sign;
92  }

◆ signstring()

const std::string top::SignValueSelector::signstring ( ) const
protectedinherited

Convert the sign enum back to a string for use in the name and print outs.

Returns
A short string version of the name

Definition at line 184 of file SignValueSelector.cxx.

184  {
185  switch (m_sign) {
186  case signNOIDEA: {
187  ATH_MSG_ERROR("SignValueSelector is confused\n"
188  << "Check that your cuts have one of: "
189  << "==, >, >=, <, <=\n");
190  throw std::runtime_error("SignValueSelector::signstring: Can't recognise the comparison operator");
191  }
192 
193  case signEQ:
194  return "==";
195 
196  case signLT:
197  return "<";
198 
199  case signGT:
200  return ">";
201 
202  case signLTEQ:
203  return "<=";
204 
205  case signGTEQ:
206  return ">=";
207  }
208 
209  return "";
210  }

◆ value()

double top::SignValueSelector::value ( ) const
protectedinherited

Get the cut value assigned in the constructor.

Definition at line 94 of file SignValueSelector.cxx.

94  {
95  return m_cutvalue;
96  }

◆ valueString()

std::string top::SignValueSelector::valueString ( ) const
protectedinherited

Get the cut value assigned in the constructor.

This is for when the cut is a string

Definition at line 98 of file SignValueSelector.cxx.

98  {
99  return m_cutvalueString;
100  }

◆ valueStringDelimReplace()

std::string top::SignValueSelector::valueStringDelimReplace ( ) const
protectedinherited

valueString which is manipulated to replace delimiter with new string

Definition at line 102 of file SignValueSelector.cxx.

102  {
104  }

Member Data Documentation

◆ m_cutvalue

double top::SignValueSelector::m_cutvalue
privateinherited

The value of the cut, filled by the constructor.

Definition at line 174 of file SignValueSelector.h.

◆ m_cutvalueString

std::string top::SignValueSelector::m_cutvalueString
privateinherited

The value of the cut in the case it's a string, filled by the constructor.

Definition at line 177 of file SignValueSelector.h.

◆ m_cutvalueStringDelimReplace

std::string top::SignValueSelector::m_cutvalueStringDelimReplace
privateinherited

The value of the cut when it is a string, with replacement of delimiter with a replacement substring.

Definition at line 183 of file SignValueSelector.h.

◆ m_multiplicity

double top::SignValueSelector::m_multiplicity
privateinherited

The multiplicity for cuts that take both a value and a multiplicity e.g. EL_N 25000 >= 2.

Definition at line 180 of file SignValueSelector.h.

◆ m_name

std::string top::SignValueSelector::m_name
privateinherited

Hold the name of the tool, filled by the constructor.

Definition at line 168 of file SignValueSelector.h.

◆ m_sign

Sign top::SignValueSelector::m_sign
privateinherited

The sign of the cut, filled by the constructor.

Definition at line 171 of file SignValueSelector.h.


The documentation for this class was generated from the following files:
top::SignValueSelector::SignValueSelector
SignValueSelector(const std::string &name, std::string params, bool multiplicityMode=false, bool cutValueMode=false)
Constructor for tools that need a sign and a value.
Definition: SignValueSelector.cxx:12
get_generator_info.result
result
Definition: get_generator_info.py:21
top::SignValueSelector::multiplicity
double multiplicity() const
Get the cut multiplicity assigned in the constructor.
Definition: SignValueSelector.cxx:106
top::SignValueSelector::signLT
@ signLT
Definition: SignValueSelector.h:26
top::SignValueSelector::signGT
@ signGT
Definition: SignValueSelector.h:27
top::SignValueSelector::m_name
std::string m_name
Hold the name of the tool, filled by the constructor.
Definition: SignValueSelector.h:168
top::SignValueSelector::m_sign
Sign m_sign
The sign of the cut, filled by the constructor.
Definition: SignValueSelector.h:171
top::SignValueSelector::checkFloat
bool checkFloat(double value, double cut) const
Compare a cut supplied by the user with the value calculated in the event.
Definition: SignValueSelector.cxx:133
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
top::SignValueSelector::m_multiplicity
double m_multiplicity
The multiplicity for cuts that take both a value and a multiplicity e.g. EL_N 25000 >= 2.
Definition: SignValueSelector.h:180
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
top::SignValueSelector::signNOIDEA
@ signNOIDEA
Definition: SignValueSelector.h:24
top::SignValueSelector::m_cutvalue
double m_cutvalue
The value of the cut, filled by the constructor.
Definition: SignValueSelector.h:174
top::SignValueSelector::value
double value() const
Get the cut value assigned in the constructor.
Definition: SignValueSelector.cxx:94
top::SignValueSelector::signGTEQ
@ signGTEQ
Definition: SignValueSelector.h:29
top::SignValueSelector::Sign
Sign
Many of the tools will be supplied with an equality (or inequality) by the user.
Definition: SignValueSelector.h:23
top::SignValueSelector::signLTEQ
@ signLTEQ
Definition: SignValueSelector.h:28
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
top::SignValueSelector::signEQ
@ signEQ
Definition: SignValueSelector.h:25
top::SignValueSelector::m_cutvalueString
std::string m_cutvalueString
The value of the cut in the case it's a string, filled by the constructor.
Definition: SignValueSelector.h:177
top::SignValueSelector::m_cutvalueStringDelimReplace
std::string m_cutvalueStringDelimReplace
The value of the cut when it is a string, with replacement of delimiter with a replacement substring.
Definition: SignValueSelector.h:183
top::SignValueSelector::name
virtual std::string name() const override
The name is generated in the constructor for this kind of tool.
Definition: SignValueSelector.cxx:70