Belle II Software development
VariablesToNtupleModule.h
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#pragma once
10
11#include <analysis/VariableManager/Manager.h>
12#include <analysis/dataobjects/RestOfEvent.h>
13
14#include <framework/core/Module.h>
15#include <framework/datastore/StoreObjPtr.h>
16#include <framework/dataobjects/EventMetaData.h>
17#include <framework/dataobjects/EventExtraInfo.h>
18#include <framework/pcore/RootMergeable.h>
19
20#include <TTree.h>
21#include <TFile.h>
22
23#include <string>
24
25namespace Belle2 {
31 class StringWrapper;
32
39 public:
42
47 virtual void initialize() override;
49 virtual void event() override;
51 virtual void terminate() override;
52
53 private:
57 float getInverseSamplingRateWeight(const Particle* particle);
58
60 std::string m_particleList;
62 std::vector<std::string> m_variables;
64 std::string m_fileName;
66 std::string m_treeName;
68 std::string m_fileNameSuffix;
73
75 std::shared_ptr<TFile> m_file{nullptr};
78 // Counter branch addresses (event number, candidate number etc)
79 int m_event{ -1};
80 int m_run{ -1};
81 int m_experiment{ -1};
82 int m_production{ -1};
83 int m_candidate{ -1};
84 unsigned int m_ncandidates{0};
87 std::vector<float> m_branchAddressesFloat;
88
90 std::vector<double> m_branchAddressesDouble;
91
93 std::vector<int> m_branchAddressesInt;
95 std::vector<std::pair<Variable::Manager::FunctionPtr, Variable::Manager::VariableDataType>> m_functions;
96
98 std::tuple<std::string, std::map<int, unsigned int>> m_sampling;
100 std::string m_sampling_name;
102 std::map<int, unsigned int> m_sampling_rates;
103
105 std::map<int, unsigned long int> m_sampling_counts;
108 std::string m_MCDecayString;
113 unsigned int m_nSignalSideCandidates{0};
118 std::string m_eventType;
122 };
124} // end namespace Belle2
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:75
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Module to calculate variables specified by the user for a given ParticleList and save them into a ROO...
StoreObjPtr< RestOfEvent > m_roe
ROE object.
bool m_useFloat
Use float type for floating-point numbers.
std::vector< std::string > m_variables
List of variables to save.
std::vector< float > m_branchAddressesFloat
Branch addresses of variables of type float.
virtual void initialize() override
Initialises the module.
std::map< int, unsigned int > m_sampling_rates
Inverse sampling rates.
virtual void event() override
Method called for each event.
unsigned int m_ncandidates
total n candidates
virtual void terminate() override
Write TTree to file, and close file if necessary.
StoreObjPtr< EventMetaData > m_eventMetaData
the event information
std::map< int, unsigned long int > m_sampling_counts
Current number of samples with this value.
std::string m_fileName
Name of ROOT file for output.
std::vector< std::pair< Variable::Manager::FunctionPtr, Variable::Manager::VariableDataType > > m_functions
List of pairs of function pointers and respective data type corresponding to given variables.
std::tuple< std::string, std::map< int, unsigned int > > m_sampling
Tuple of variable name and a map of integer values and inverse sampling rate.
std::vector< int > m_branchAddressesInt
Branch addresses of variables of type int (or bool)
int m_basketsize
Size of TBaskets in the output ROOT file in bytes.
int m_production
production ID (to distinguish MC samples)
unsigned int m_nSignalSideCandidates
total n signal-side candidates
StoreObjPtr< StringWrapper > m_stringWrapper
string wrapper storing the MCDecayString
bool m_storeEventType
If true, the branch eventType is added.
std::string m_particleList
Name of particle list with reconstructed particles.
bool m_ignoreCommandLineOverride
if true, ignore override of filename
std::string m_eventType
EventType to be filled.
StoreObjPtr< RootMergeable< TTree > > m_tree
The ROOT TNtuple for output.
std::shared_ptr< TFile > m_file
ROOT file for output.
std::vector< double > m_branchAddressesDouble
Branch addresses of variables of type double.
std::string m_sampling_name
Variable name of sampling variable.
float getInverseSamplingRateWeight(const Particle *particle)
Calculate inverse sampling rate weight.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
pointer to EventExtraInfo
std::string m_treeName
Name of the TTree.
std::string m_signalSideParticleList
Name of signal-side particle list
const Variable::Manager::Var * m_sampling_variable
Variable Pointer to target variable.
int m_signalSideCandidate
signal-side candidate counter
std::string m_fileNameSuffix
Suffix to be appended to the output file name.
std::string m_MCDecayString
MC decay string to be filled.
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.
Definition: Manager.h:146