Belle II Software  release-05-02-19
SoftwareTriggerModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - 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 #pragma once
12 
13 #include <framework/core/Module.h>
14 
15 #include <hlt/softwaretrigger/calculations/SoftwareTriggerCalculation.h>
16 #include <mdst/dataobjects/SoftwareTriggerResult.h>
17 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
18 
19 #include <stdint.h>
20 #include <string>
21 #include <vector>
22 
23 namespace Belle2 {
28  namespace SoftwareTrigger {
61  class SoftwareTriggerModule : public Module {
62  public:
65 
67  virtual ~SoftwareTriggerModule() = default;
68 
70  void initialize() override;
71 
73  void event() override;
74 
76  void beginRun() override;
77 
79  void terminate() override;
80 
81  private:
82  // Parameters
84  std::string m_param_baseIdentifier = "";
86  std::string m_param_resultStoreArrayName = "";
92  std::string m_param_debugOutputFileName = "software_trigger_debug.root";
97 
98  // Object pools
102  std::unique_ptr<SoftwareTriggerDBHandler> m_dbHandler;
104  std::unique_ptr<SoftwareTriggerCalculation> m_calculation;
106  std::unique_ptr<TFile> m_debugOutputFile;
108  std::unique_ptr<TTree> m_debugTTree;
111 
113  std::vector<uint32_t> m_counters;
114 
117  void initializeCalculation();
118 
122 
124  void initializeCounters();
125 
127  void makeCut(const SoftwareTriggerObject& prefilledObject);
128 
130  void makeDebugOutput();
131  };
132  }
134 }
Belle2::SoftwareTrigger::SoftwareTriggerModule::beginRun
void beginRun() override
Check if the cut representations in the database have changed and download newer ones if needed.
Definition: SoftwareTriggerModule.cc:81
Belle2::SoftwareTrigger::SoftwareTriggerModule::initialize
void initialize() override
Initialize/Require the DB object pointers and any needed store arrays.
Definition: SoftwareTriggerModule.cc:72
Belle2::SoftwareTrigger::SoftwareTriggerModule::terminate
void terminate() override
Store and delete the ttree if it was created.
Definition: SoftwareTriggerModule.cc:90
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_debugTTree
std::unique_ptr< TTree > m_debugTTree
TTree to store the debug output (or a nullptr if we do not save the debug output).
Definition: SoftwareTriggerModule.h:116
Belle2::SoftwareTrigger::SoftwareTriggerModule::~SoftwareTriggerModule
virtual ~SoftwareTriggerModule()=default
default virtaual constructor because this is a derived class using virtual methods
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_resultStoreObjectPointer
StoreObjPtr< SoftwareTriggerResult > m_resultStoreObjectPointer
Store Object for storing the trigger decision.
Definition: SoftwareTriggerModule.h:108
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_preScaleStoreDebugOutputToDataStore
unsigned int m_param_preScaleStoreDebugOutputToDataStore
Prescale with which to save the results of the calculations into the DataStore.
Definition: SoftwareTriggerModule.h:98
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_resultStoreArrayName
std::string m_param_resultStoreArrayName
Store Object Pointer name for storing the trigger decision.
Definition: SoftwareTriggerModule.h:94
Belle2::SoftwareTrigger::SoftwareTriggerModule::event
void event() override
Run over all cuts and check them. If one of the cuts yields true, give a positive return value of the...
Definition: SoftwareTriggerModule.cc:101
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::SoftwareTrigger::SoftwareTriggerModule::initializeCalculation
void initializeCalculation()
Helper function to initialize the calculation by creating a new calculation object and requiring all ...
Definition: SoftwareTriggerModule.cc:119
Belle2::SoftwareTrigger::SoftwareTriggerModule::SoftwareTriggerModule
SoftwareTriggerModule()
Create a new module instance and set the parameters.
Definition: SoftwareTriggerModule.cc:25
Belle2::SoftwareTrigger::SoftwareTriggerModule::initializeCounters
void initializeCounters()
Helper function to initialize the internal counters used for each cut identifier.
Definition: SoftwareTriggerModule.cc:150
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_storeDebugOutputToROOTFile
bool m_param_storeDebugOutputToROOTFile
Flag to also store the result of the calculations into a root file.
Definition: SoftwareTriggerModule.h:96
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_debugOutputFileName
std::string m_param_debugOutputFileName
Output file name for the debug output. Is only used if debug is turned on.
Definition: SoftwareTriggerModule.h:100
Belle2::SoftwareTrigger::SoftwareTriggerModule::initializeDebugOutput
void initializeDebugOutput()
Helper function to initliaze debug output creation by creating a TTree and an object in the data stor...
Definition: SoftwareTriggerModule.cc:132
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_debugOutputFile
std::unique_ptr< TFile > m_debugOutputFile
TFile to store the debug TTree (or a nullptr if we do not save the debug output).
Definition: SoftwareTriggerModule.h:114
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_baseIdentifier
std::string m_param_baseIdentifier
Base identifier for all cuts downloaded from database.
Definition: SoftwareTriggerModule.h:92
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_debugOutputStoreObject
StoreObjPtr< SoftwareTriggerVariables > m_debugOutputStoreObject
TTree living in the datastore for debug reasons.
Definition: SoftwareTriggerModule.h:118
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_dbHandler
std::unique_ptr< SoftwareTriggerDBHandler > m_dbHandler
Internal handler object for the DB interface.
Definition: SoftwareTriggerModule.h:110
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_calculation
std::unique_ptr< SoftwareTriggerCalculation > m_calculation
Internal handler for the Calculations (will be set in initialize to the correct one).
Definition: SoftwareTriggerModule.h:112
Belle2::SoftwareTrigger::SoftwareTriggerModule::makeDebugOutput
void makeDebugOutput()
Helper function to store the calculated variables from the calculation either in the TTree or in the ...
Definition: SoftwareTriggerModule.cc:194
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_debugOutputStoreObjName
std::string m_param_debugOutputStoreObjName
Output store object name for the debug output. Is only used if debug is turned on.
Definition: SoftwareTriggerModule.h:102
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_param_useRandomNumbersForPreScale
bool m_param_useRandomNumbersForPreScale
Flag to use random numbers or a counter for applying a prescale.
Definition: SoftwareTriggerModule.h:104
Belle2::SoftwareTrigger::SoftwareTriggerModule::m_counters
std::vector< uint32_t > m_counters
Vector of the internal counters used to apply a prescale.
Definition: SoftwareTriggerModule.h:121
Belle2::SoftwareTrigger::SoftwareTriggerModule::makeCut
void makeCut(const SoftwareTriggerObject &prefilledObject)
Helper function to perform the actual cut on the prefilled object and set the return value of the mod...
Definition: SoftwareTriggerModule.cc:159