Belle II Software  release-05-02-19
SoftwareTriggerCut.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
12 #include <mdst/dataobjects/SoftwareTriggerResult.h>
13 #include <hlt/softwaretrigger/core/utilities.h>
14 
15 #include <framework/logging/Logger.h>
16 
17 namespace Belle2 {
22  namespace SoftwareTrigger {
23  std::unique_ptr<SoftwareTriggerCut> SoftwareTriggerCut::compile(const std::string& cut_string,
24  unsigned int prescaleFactor,
25  const bool rejectCut)
26  {
27  auto compiledGeneralCut = GeneralCut<SoftwareTriggerVariableManager>::compile(cut_string);
28  std::unique_ptr<SoftwareTriggerCut> compiledSoftwareTriggerCut(new SoftwareTriggerCut(std::move(compiledGeneralCut),
29  prescaleFactor, rejectCut));
30 
31  return compiledSoftwareTriggerCut;
32  }
33 
34  std::pair<SoftwareTriggerCutResult, SoftwareTriggerCutResult> SoftwareTriggerCut::check(const
35  SoftwareTriggerVariableManager::Object& prefilledObject, uint32_t* counter) const
36  {
37  if (not m_cut) {
38  B2FATAL("Software Trigger is not initialized!");
39  }
40  const bool cutCondition = m_cut->check(&prefilledObject);
41 
42  // If the cut is a reject cut, return false if the cut is true and false if the cut is true.
43  if (isRejectCut()) {
44  if (cutCondition) {
46  } else {
48  }
49  } else {
50  // This is the "normal" accept case:
51  // First check if the cut gives a positive result. If not, we can definitely return "noResult".
52  if (cutCondition) {
53  // if yes, we have to use the prescale factor to see, if the result is really yes.
54  if (makePreScale(getPreScaleFactor(), counter)) {
56  } else {
57  // This is the only case were prescaled and non-prescaled results are different.
59  }
60  } else {
62  }
63  }
64  }
65 
67  {
68  return check(prefilledObject).first;
69  }
70  }
72 }
Belle2::GeneralCut::compile
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead y...
Definition: GeneralCut.h:114
Belle2::SoftwareTriggerCutBase::isRejectCut
bool isRejectCut() const
Returns true, if the cut is a reject cut and false otherwise.
Definition: SoftwareTriggerCutBase.h:51
Belle2::SoftwareTrigger::SoftwareTriggerCut::checkPreScaled
SoftwareTriggerCutResult checkPreScaled(const SoftwareTriggerVariableManager::Object &prefilledObject) const
Main function of the SoftwareTriggerCut: check the cut condition.
Definition: SoftwareTriggerCut.cc:74
Belle2::SoftwareTrigger::SoftwareTriggerCut::check
std::pair< SoftwareTriggerCutResult, SoftwareTriggerCutResult > check(const SoftwareTriggerVariableManager::Object &prefilledObject, uint32_t *counter=nullptr) const
Return both the prescaled and the non-prescaled result.
Definition: SoftwareTriggerCut.cc:42
Belle2::SoftwareTriggerCutResult::c_accept
@ c_accept
Accept this event.
Belle2::SoftwareTriggerCutBase::getPreScaleFactor
unsigned int getPreScaleFactor() const
Return the list of pre scale factors.
Definition: SoftwareTriggerCutBase.h:44
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SoftwareTrigger::SoftwareTriggerVariableManager::Object
SoftwareTriggerObject Object
As an object handed in for every cut to be checked, use a map of variable name -> precompiled value.
Definition: SoftwareTriggerVariableManager.h:93
Belle2::SoftwareTrigger::SoftwareTriggerCut::m_cut
std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > m_cut
Internal representation of the cut condition as a general cut.
Definition: SoftwareTriggerCut.h:119
Belle2::SoftwareTrigger::SoftwareTriggerCut::SoftwareTriggerCut
SoftwareTriggerCut(std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager >> &&cut, unsigned int prescaleFactor, const bool rejectCut)
Make constructor private.
Definition: SoftwareTriggerCut.h:124
Belle2::SoftwareTriggerCutResult::c_reject
@ c_reject
Reject this event.
Belle2::SoftwareTrigger::SoftwareTriggerCut::compile
static std::unique_ptr< SoftwareTriggerCut > compile(const std::string &cut_string, const unsigned int prescaleFactor, const bool rejectCut=false)
Compile a new SoftwareTriggerCut from a cut string (by using the GeneralCut::compile function) and an...
Definition: SoftwareTriggerCut.cc:31
Belle2::SoftwareTriggerCutResult
SoftwareTriggerCutResult
Enumeration with all possible results of the SoftwareTriggerCut.
Definition: SoftwareTriggerResult.h:31
Belle2::SoftwareTriggerCutResult::c_noResult
@ c_noResult
There were not enough information to decide on what to do with the event.