Belle II Software development
SoftwareTriggerCut.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
10#include <mdst/dataobjects/SoftwareTriggerResult.h>
11#include <hlt/softwaretrigger/core/utilities.h>
12
13#include <framework/logging/Logger.h>
14
15namespace Belle2 {
20 namespace SoftwareTrigger {
21 std::unique_ptr<SoftwareTriggerCut> SoftwareTriggerCut::compile(const std::string& cut_string,
22 unsigned int prescaleFactor,
23 const bool rejectCut)
24 {
25 auto compiledGeneralCut = GeneralCut<SoftwareTriggerVariableManager>::compile(cut_string);
26 std::unique_ptr<SoftwareTriggerCut> compiledSoftwareTriggerCut(new SoftwareTriggerCut(std::move(compiledGeneralCut),
27 prescaleFactor, rejectCut));
28
29 return compiledSoftwareTriggerCut;
30 }
31
32 std::pair<SoftwareTriggerCutResult, SoftwareTriggerCutResult> SoftwareTriggerCut::check(const
33 SoftwareTriggerVariableManager::Object& prefilledObject, uint32_t* counter) const
34 {
35 if (not m_cut) {
36 B2FATAL("Software Trigger is not initialized!");
37 }
38 const bool cutCondition = m_cut->check(&prefilledObject);
39
40 // If the cut is a reject cut, return false if the cut is true and false if the cut is true.
41 if (isRejectCut()) {
42 if (cutCondition) {
44 } else {
46 }
47 } else {
48 // This is the "normal" accept case:
49 // First check if the cut gives a positive result. If not, we can definitely return "noResult".
50 if (cutCondition) {
51 // if yes, we have to use the prescale factor to see, if the result is really yes.
52 if (makePreScale(getPreScaleFactor(), counter)) {
54 } else {
55 // This is the only case were prescaled and non-prescaled results are different.
57 }
58 } else {
60 }
61 }
62 }
63
65 {
66 return check(prefilledObject).first;
67 }
68 }
70}
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:84
bool isRejectCut() const
Returns true, if the cut is a reject cut and false otherwise.
unsigned int getPreScaleFactor() const
Return the list of pre scale factors.
Software Trigger Cut to be used in the Software Trigger Modules.
SoftwareTriggerCutResult checkPreScaled(const SoftwareTriggerVariableManager::Object &prefilledObject) const
Main function of the SoftwareTriggerCut: check the cut condition.
std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > m_cut
Internal representation of the cut condition as a general cut.
std::pair< SoftwareTriggerCutResult, SoftwareTriggerCutResult > check(const SoftwareTriggerVariableManager::Object &prefilledObject, uint32_t *counter=nullptr) const
Return both the prescaled and the non-prescaled result.
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...
SoftwareTriggerObject Object
As an object handed in for every cut to be checked, use a map of variable name -> precompiled value.
SoftwareTriggerCutResult
Enumeration with all possible results of the SoftwareTriggerCut.
@ c_accept
Accept this event.
@ c_reject
Reject this event.
@ c_noResult
There were not enough information to decide on what to do with the event.
Abstract base class for different kinds of events.