Belle II Software development
VariablesToEventBasedTreeModule.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
13#include <framework/core/Module.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/dataobjects/EventMetaData.h>
16#include <framework/dataobjects/EventExtraInfo.h>
17#include <framework/pcore/RootMergeable.h>
18
19#include <TFile.h>
20
21#include <string>
22
23namespace Belle2 {
29 class StringWrapper;
30
36 public:
39
44 virtual void initialize() override;
46 virtual void event() override;
48 virtual void terminate() override;
49
50 private:
55
57 std::string m_particleList;
59 std::vector<std::string> m_variables;
61 std::vector<std::string> m_event_variables;
63 unsigned int m_maxCandidates;
65 std::string m_fileName;
67 std::string m_treeName;
69 std::string m_fileNameSuffix;
70
72 std::shared_ptr<TFile> m_file{nullptr};
76 std::vector<Variable::Manager::FunctionPtr> m_functions;
78 std::vector<Variable::Manager::FunctionPtr> m_event_functions;
79 int m_event{ -1};
80 int m_run{ -1};
81 int m_experiment{ -1};
82 int m_production{ -1};
83 unsigned int m_ncandidates{ 0};
84 float m_weight{0.0};
86 std::vector<std::vector<double>> m_valuesDouble;
88 std::vector<std::vector<int>> m_valuesInt;
90 std::vector<double> m_event_valuesDouble;
92 std::vector<int> m_event_valuesInt;
93
95 std::tuple<std::string, std::map<int, unsigned int>> m_sampling;
97 std::string m_sampling_name;
99 std::map<int, unsigned int> m_sampling_rates;
100
102 std::map<int, unsigned long int> m_sampling_counts;
106
107 std::string m_MCDecayString;
112 std::string m_eventType;
115 };
117} // end namespace Belle2
Base class for Modules.
Definition: Module.h:72
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 TTr...
std::vector< std::string > m_variables
List of variables to save.
unsigned int m_maxCandidates
maximum number of candidates which is written out
std::vector< std::string > m_event_variables
List of event variables to save.
virtual void initialize() override
Initialises the module.
std::map< int, unsigned int > m_sampling_rates
Inverse sampling rates.
std::vector< int > m_event_valuesInt
Values of type int corresponding to given event variables.
virtual void event() override
Method called for each event.
unsigned int m_ncandidates
number of candidates in this event
virtual void terminate() override
Write TTree to file, and close file if necessary.
StoreObjPtr< EventMetaData > m_eventMetaData
event metadata (get event number etc)
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::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< std::vector< double > > m_valuesDouble
Values of type double corresponding to given variables.
float getInverseSamplingRateWeight()
Calculate inverse sampling rate weight.
int m_production
production ID (to distinguish MC samples)
StoreObjPtr< StringWrapper > m_stringWrapper
string wrapper storing the MCDecayString
bool m_storeEventType
If true, the branch eventType is added.
std::vector< Variable::Manager::FunctionPtr > m_functions
List of function pointers corresponding to given variables.
std::string m_particleList
Name of particle list with reconstructed particles.
bool m_ignoreCommandLineOverride
if true, ignore override of filename
StoreObjPtr< RootMergeable< TTree > > m_tree
The ROOT TNtuple for output.
std::shared_ptr< TFile > m_file
ROOT file for output.
std::string m_sampling_name
Variable name of sampling variable.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
pointer to EventExtraInfo
std::vector< std::vector< int > > m_valuesInt
Values of type int corresponding to given variables.
std::vector< double > m_event_valuesDouble
Values of type double corresponding to given event variables.
const Variable::Manager::Var * m_sampling_variable
Variable Pointer to target variable.
std::vector< Variable::Manager::FunctionPtr > m_event_functions
List of function pointers corresponding to given event variables.
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