Belle II Software development
SoftwareTriggerCalculation.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/calculations/SoftwareTriggerCalculation.h>
10
11#include <framework/logging/Logger.h>
12
13namespace Belle2 {
18 namespace SoftwareTrigger {
19 void SoftwareTriggerCalculation::writeDebugOutput(const std::unique_ptr<TTree>& debugOutputTTree)
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 }
33
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 }
43
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 }
56 }
58}
SoftwareTriggerObject m_calculationResult
Internal storage of the result of the calculation.
virtual void doCalculation(SoftwareTriggerObject &m_calculationResult)=0
Override this function to implement your calculation.
void addDebugOutput(const StoreObjPtr< SoftwareTriggerVariables > &storeObject, const std::string &prefix)
Function to write out debug output into the given StoreObject.
bool m_debugPrepared
Flag to not add the branches twice to the TTree.
void writeDebugOutput(const std::unique_ptr< TTree > &debugOutputTTree)
Function to write out debug output into the given TTree.
const SoftwareTriggerObject & fillInCalculations()
Main function of this class: calculate the needed variables using the overwritten doCalculation funct...
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.