Belle II Software development
SoftwareTriggerCalculation Class Referenceabstract

Base class for all calculation algorithms to be used when calculating the variables needed in the SoftwareTrigger modules for the cuts. More...

#include <SoftwareTriggerCalculation.h>

Inheritance diagram for SoftwareTriggerCalculation:
FilterCalculator SkimSampleCalculator

Public Member Functions

virtual void requireStoreArrays ()=0
 Function to be called in the initialize phase of the module, in which all later needed StoreArrays can be made a requirement.
 
void writeDebugOutput (const std::unique_ptr< TTree > &debugOutputTTree)
 Function to write out debug output into the given TTree.
 
void addDebugOutput (const StoreObjPtr< SoftwareTriggerVariables > &storeObject, const std::string &prefix)
 Function to write out debug output into the given StoreObject.
 
const SoftwareTriggerObject & fillInCalculations ()
 Main function of this class: calculate the needed variables using the overwritten doCalculation function and write out the values into the results object (with their names).
 
virtual void doCalculation (SoftwareTriggerObject &m_calculationResult)=0
 Override this function to implement your calculation.
 
virtual ~SoftwareTriggerCalculation ()=default
 Default but virtual desctructor.
 

Private Attributes

SoftwareTriggerObject m_calculationResult
 Internal storage of the result of the calculation.
 
bool m_debugPrepared = false
 Flag to not add the branches twice to the TTree.
 

Detailed Description

Base class for all calculation algorithms to be used when calculating the variables needed in the SoftwareTrigger modules for the cuts.

Override in your own calculation. Your override class must have a function requireStoreArray (which can be empty) and a function doCalculation getting the SoftwareTriggerObject as a reference.

Definition at line 29 of file SoftwareTriggerCalculation.h.

Member Function Documentation

◆ addDebugOutput()

void addDebugOutput ( const StoreObjPtr< SoftwareTriggerVariables > &  storeObject,
const std::string &  prefix 
)

Function to write out debug output into the given StoreObject.

Needs an already prefilled calculationResult for this (probably using the fillInCalculations function). All added variables are prefixed with the given prefix string.

Definition at line 34 of file SoftwareTriggerCalculation.cc.

35 {
36 for (auto& identifierWithValue : m_calculationResult) {
37 const std::string& identifier = identifierWithValue.first;
38 const double value = identifierWithValue.second;
39
40 storeObject->append(prefix + "_" + identifier, value);
41 }
42 }
SoftwareTriggerObject m_calculationResult
Internal storage of the result of the calculation.

◆ doCalculation()

virtual void doCalculation ( SoftwareTriggerObject &  m_calculationResult)
pure virtual

Override this function to implement your calculation.

Implemented in FilterCalculator, and SkimSampleCalculator.

◆ fillInCalculations()

const SoftwareTriggerObject & fillInCalculations ( )

Main function of this class: calculate the needed variables using the overwritten doCalculation function and write out the values into the results object (with their names).

Please make sure to override (or clear) the variables! Otherwise it can happen that their old values are still in the object.

What variables exactly are added to the result depends on the implementation details of the class.

Definition at line 44 of file SoftwareTriggerCalculation.cc.

45 {
46 const unsigned int sizeBeforeCheck = m_calculationResult.size();
48
49 if (m_calculationResult.size() != sizeBeforeCheck and sizeBeforeCheck > 0) {
50 B2WARNING("Calculator added more variables (" << m_calculationResult.size() <<
51 ") than there were before (" << sizeBeforeCheck << "). Probably something strange is going on!");
52 }
53
55 }
virtual void doCalculation(SoftwareTriggerObject &m_calculationResult)=0
Override this function to implement your calculation.

◆ requireStoreArrays()

virtual void requireStoreArrays ( )
pure virtual

Function to be called in the initialize phase of the module, in which all later needed StoreArrays can be made a requirement.

Override it in your class if you need special store arrays.

Implemented in FilterCalculator, and SkimSampleCalculator.

◆ writeDebugOutput()

void writeDebugOutput ( const std::unique_ptr< TTree > &  debugOutputTTree)

Function to write out debug output into the given TTree.

Needs an already prefilled calculationResult for this (probably using the fillInCalculations function).

Definition at line 19 of file SoftwareTriggerCalculation.cc.

20 {
21 if (not m_debugPrepared) {
22 for (auto& identifierWithValue : m_calculationResult) {
23 const std::string& identifier = identifierWithValue.first;
24 double& value = identifierWithValue.second;
25
26 debugOutputTTree->Branch(identifier.c_str(), &value);
27 }
28 m_debugPrepared = true;
29 }
30
31 debugOutputTTree->Fill();
32 }
bool m_debugPrepared
Flag to not add the branches twice to the TTree.

Member Data Documentation

◆ m_calculationResult

SoftwareTriggerObject m_calculationResult
private

Internal storage of the result of the calculation.

Definition at line 74 of file SoftwareTriggerCalculation.h.

◆ m_debugPrepared

bool m_debugPrepared = false
private

Flag to not add the branches twice to the TTree.

Definition at line 76 of file SoftwareTriggerCalculation.h.


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