Belle II Software development
SoftwareTriggerCut Class Reference

Software Trigger Cut to be used in the Software Trigger Modules. More...

#include <SoftwareTriggerCut.h>

Inheritance diagram for SoftwareTriggerCut:
SoftwareTriggerCutBase

Public Member Functions

std::string decompile () const
 Decompile the internal General Cut back into a string.
 
SoftwareTriggerCutResult checkPreScaled (const SoftwareTriggerVariableManager::Object &prefilledObject) const
 Main function of the SoftwareTriggerCut: check the cut condition.
 
std::pair< SoftwareTriggerCutResult, SoftwareTriggerCutResultcheck (const SoftwareTriggerVariableManager::Object &prefilledObject, uint32_t *counter=nullptr) const
 Return both the prescaled and the non-prescaled result.
 
unsigned int getPreScaleFactor () const
 Return the list of pre scale factors.
 
bool isRejectCut () const
 Returns true, if the cut is a reject cut and false otherwise.
 

Static Public Member Functions

static std::unique_ptr< SoftwareTriggerCutcompile (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 optional prescale factor.
 

Private Member Functions

 SoftwareTriggerCut (std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > &&cut, unsigned int prescaleFactor, const bool rejectCut)
 Make constructor private.
 

Private Attributes

std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > m_cut = nullptr
 Internal representation of the cut condition as a general cut.
 
std::vector< unsigned int > m_preScaleFactor = {1}
 The internal storage of the prescale factor of the cut. In former times, this was a vector but is not used anymore (only single entry)
 
bool m_isRejectCut = false
 The internal storage if it is a reject cut.
 

Detailed Description

Software Trigger Cut to be used in the Software Trigger Modules.

This cut can be down- and uploaded from the database or compiled from a string. It is basically a GeneralCut using the SoftwareTriggerVariableManager with a prescale factor.

For database interactions, use the SoftwareTriggerDBHandler.

Definition at line 30 of file SoftwareTriggerCut.h.

Constructor & Destructor Documentation

◆ SoftwareTriggerCut()

SoftwareTriggerCut ( std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > &&  cut,
unsigned int  prescaleFactor,
const bool  rejectCut 
)
inlineprivate

Make constructor private.

You should only download a SoftwareCut from the database or compile a new one from a string.

Definition at line 114 of file SoftwareTriggerCut.h.

116 : SoftwareTriggerCutBase(prescaleFactor, rejectCut),
117 m_cut(std::move(cut))
118 {
119 }
SoftwareTriggerCutBase(unsigned int preScaleFactor=1, const bool &isRejectCut=false)
Create a new base instance. This should rarely be called by yourself.
std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > m_cut
Internal representation of the cut condition as a general cut.

Member Function Documentation

◆ check()

std::pair< SoftwareTriggerCutResult, SoftwareTriggerCutResult > check ( const SoftwareTriggerVariableManager::Object prefilledObject,
uint32_t *  counter = nullptr 
) const

Return both the prescaled and the non-prescaled result.

This function should only be use experts, you basically always want to use the checkPreScaled function. Returns a pair [prescaled, non-prescaled]

Definition at line 32 of file SoftwareTriggerCut.cc.

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 }
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.
@ 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.

◆ checkPreScaled()

SoftwareTriggerCutResult checkPreScaled ( const SoftwareTriggerVariableManager::Object prefilledObject) const

Main function of the SoftwareTriggerCut: check the cut condition.

See the constructor of this class for more information on when which result is returned.

Definition at line 64 of file SoftwareTriggerCut.cc.

65 {
66 return check(prefilledObject).first;
67 }
std::pair< SoftwareTriggerCutResult, SoftwareTriggerCutResult > check(const SoftwareTriggerVariableManager::Object &prefilledObject, uint32_t *counter=nullptr) const
Return both the prescaled and the non-prescaled result.

◆ compile()

std::unique_ptr< SoftwareTriggerCut > compile ( const std::string &  cut_string,
const unsigned int  prescaleFactor,
const bool  rejectCut = false 
)
static

Compile a new SoftwareTriggerCut from a cut string (by using the GeneralCut::compile function) and an optional prescale factor.

This together with the downloadFromDatabase function is the only possibility to create a new SoftwareTriggerCut.

Parameters
cut_stringThe string from which the cut should be compiled. Must be in a format, the GeneralCut::compile function understands.
prescaleFactorAn optional prescale factor which will be used whenever the cut is checked. The prescale factor is a integer value. If the prescale is e.g. 10, the cut will only result in a "accept" result (although the cut condition itself is true) in 1 of 10 cases on average for accept cuts (for reject cuts, the prescale is not used). Defaults to 1, which means that the prescale has no impact on the cut check.
rejectCutTurn this cut into a reject cut and not a accept cut. The result of the SoftwareTriggerModules is defined by these two cut types. See the SoftwareTriggerModule for more information. Please note that the condition is turned the other way round if it is a reject cut. See the example below.
Returns
a unique_ptr on a SoftwareTriggerCut with the given cut condition and prescale.

To summarize: the cut has the following result:

  • if the cut is an accept cut:
    • if the cut condition is true, it returns accept in 1 out of prescaleFactor cases and noResult otherwise.
    • if the cut condition is false, it returns noResult.
  • if the cut is a reject cut:
    • if the cut condition is true, it returns dismiss.
    • if the cut condition is false, it returns noResult.

Let us look into two examples. The first is an accept cut for gg events. It may have the following parameters:

cut condition = something which is only true for gg events prescaleFactor = 100 rejectCut = false

If the event is a gg event (and the cut conditions is then true), the cut will return "accept" in 1% of the cases, and "noResult" in all other cases. If the event is not a gg event, the cut will always return "noResult". The SoftwareTriggerModule will keep the event if this trigger results in "accept", in all other cases it depends on the other loaded cuts.

The second cut is an reject cut for ee events. It may have the following parameters:

cut condition = something which is only true for ee events rejectCut = true prescaleFactor will not be used

If the event is an ee event (and the cut condition is true), the cut will result in "dismiss". In all other cases it returns "noResult". The SoftwareTriggerModule will not pass this event if the result is "dismiss", in all other cases it depends on the other loaded cuts.

Definition at line 21 of file SoftwareTriggerCut.cc.

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 }
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
SoftwareTriggerCut(std::unique_ptr< GeneralCut< SoftwareTriggerVariableManager > > &&cut, unsigned int prescaleFactor, const bool rejectCut)
Make constructor private.

◆ decompile()

std::string decompile ( ) const
inline

Decompile the internal General Cut back into a string.

This function is needed for streaming the SoftwareTriggerCut into the database.

Definition at line 87 of file SoftwareTriggerCut.h.

88 {
89 return m_cut->decompile();
90 }

◆ getPreScaleFactor()

unsigned int getPreScaleFactor ( ) const
inlineinherited

Return the list of pre scale factors.

Definition at line 34 of file SoftwareTriggerCutBase.h.

35 {
36 B2ASSERT("Prescale factor should only have a single entry!", m_preScaleFactor.size() == 1);
37 return m_preScaleFactor[0];
38 }
std::vector< unsigned int > m_preScaleFactor
The internal storage of the prescale factor of the cut. In former times, this was a vector but is not...

◆ isRejectCut()

bool isRejectCut ( ) const
inlineinherited

Returns true, if the cut is a reject cut and false otherwise.

Definition at line 41 of file SoftwareTriggerCutBase.h.

42 {
43 return m_isRejectCut;
44 }
bool m_isRejectCut
The internal storage if it is a reject cut.

Member Data Documentation

◆ m_cut

std::unique_ptr<GeneralCut<SoftwareTriggerVariableManager> > m_cut = nullptr
private

Internal representation of the cut condition as a general cut.

Definition at line 109 of file SoftwareTriggerCut.h.

◆ m_isRejectCut

bool m_isRejectCut = false
privateinherited

The internal storage if it is a reject cut.

Definition at line 55 of file SoftwareTriggerCutBase.h.

◆ m_preScaleFactor

std::vector<unsigned int> m_preScaleFactor = {1}
privateinherited

The internal storage of the prescale factor of the cut. In former times, this was a vector but is not used anymore (only single entry)

Definition at line 53 of file SoftwareTriggerCutBase.h.


The documentation for this class was generated from the following files: