Belle II Software  release-05-02-19
SoftwareTriggerCalculation.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/calculations/SoftwareTriggerCalculation.h>
12 
13 #include <framework/logging/Logger.h>
14 
15 namespace Belle2 {
20  namespace SoftwareTrigger {
21  void SoftwareTriggerCalculation::writeDebugOutput(const std::unique_ptr<TTree>& debugOutputTTree)
22  {
23  if (not m_debugPrepared) {
24  for (auto& identifierWithValue : m_calculationResult) {
25  const std::string& identifier = identifierWithValue.first;
26  double& value = identifierWithValue.second;
27 
28  debugOutputTTree->Branch(identifier.c_str(), &value);
29  }
30  m_debugPrepared = true;
31  }
32 
33  debugOutputTTree->Fill();
34  }
35 
36  void SoftwareTriggerCalculation::addDebugOutput(const StoreObjPtr<SoftwareTriggerVariables>& storeObject, const std::string& prefix)
37  {
38  for (auto& identifierWithValue : m_calculationResult) {
39  const std::string& identifier = identifierWithValue.first;
40  const double value = identifierWithValue.second;
41 
42  storeObject->append(prefix + "_" + identifier, value);
43  }
44  }
45 
46  const SoftwareTriggerObject& SoftwareTriggerCalculation::fillInCalculations()
47  {
48  const unsigned int sizeBeforeCheck = m_calculationResult.size();
50 
51  if (m_calculationResult.size() != sizeBeforeCheck and sizeBeforeCheck > 0) {
52  B2WARNING("Calculator added more variables (" << m_calculationResult.size() <<
53  ") than there were before (" << sizeBeforeCheck << "). Probably something strange is going on!");
54  }
55 
56  return m_calculationResult;
57  }
58  }
60 }
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::addDebugOutput
void addDebugOutput(const StoreObjPtr< SoftwareTriggerVariables > &storeObject, const std::string &prefix)
Function to write out debug output into the given StoreObject.
Definition: SoftwareTriggerCalculation.cc:44
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::m_debugPrepared
bool m_debugPrepared
Flag to not add the branches twice to the TTree.
Definition: SoftwareTriggerCalculation.h:86
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::doCalculation
virtual void doCalculation(SoftwareTriggerObject &m_calculationResult)=0
Override this function to implement your calculation.
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::m_calculationResult
SoftwareTriggerObject m_calculationResult
Internal storage of the result of the calculation.
Definition: SoftwareTriggerCalculation.h:84
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::fillInCalculations
const SoftwareTriggerObject & fillInCalculations()
Main function of this class: calculate the needed variables using the overwritten doCalculation funct...
Definition: SoftwareTriggerCalculation.cc:54
Belle2::SoftwareTrigger::SoftwareTriggerCalculation::writeDebugOutput
void writeDebugOutput(const std::unique_ptr< TTree > &debugOutputTTree)
Function to write out debug output into the given TTree.
Definition: SoftwareTriggerCalculation.cc:29