Belle II Software prerelease-10-00-00a
arichToNtupleModule.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 <arich/modules/arichNtuple/ARICHNtupleStruct.h>
12#include <framework/core/Module.h>
13#include <analysis/VariableManager/Manager.h>
14#include <analysis/DecayDescriptor/DecayDescriptor.h>
15#include <framework/datastore/StoreObjPtr.h>
16#include <framework/dataobjects/EventMetaData.h>
17#include <framework/pcore/RootMergeable.h>
18
19
20#include <TTree.h>
21#include <TFile.h>
22
23#include <string>
24
25namespace Belle2 {
30
38 class arichToNtupleModule : public Module {
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
62 void addARICHBranches(const std::string& name);
63
67 void fillARICHTree(const Particle* particle);
68
70 std::string m_particleList;
72 std::string m_arichSelector;
74 std::vector<std::string> m_variables;
76 std::vector<std::string> m_arichVariables;
77
79 std::string m_fileName;
81 std::string m_treeName;
82
84 std::shared_ptr<TFile> m_file{nullptr};
87 // Counter branch addresses (event number, candidate number etc)
88 int m_event{ -1};
89 int m_run{ -1};
90 int m_experiment{ -1};
91 int m_candidate{ -1};
92 unsigned int m_ncandidates{0};
93
95 std::vector<ARICH::ARICHTree*> m_arich;
96
98 std::vector<double> m_branchAddresses;
100 std::vector<Variable::Manager::FunctionPtr> m_functions;
101
103 std::tuple<std::string, std::map<int, unsigned int>> m_sampling;
105 std::string m_sampling_name;
107 std::map<int, unsigned int> m_sampling_rates;
108
111
113 std::map<int, unsigned long int> m_sampling_counts;
115
116 };
117
118} // end namespace Belle2
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Module()
Constructor.
Definition Module.cc:30
Class to store reconstructed particles.
Definition Particle.h:76
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
std::vector< ARICH::ARICHTree * > m_arich
Vector of arich branch addresses.
void addARICHBranches(const std::string &name)
Add arich branches to the output TTree.
std::vector< std::string > m_variables
List of variables to save.
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.
void fillARICHTree(const Particle *particle)
Fill data to arich branches.
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::vector< double > m_branchAddresses
Variable branch addresses.
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.
int m_experiment
experiment number
std::vector< std::string > m_arichVariables
List of aliases of particles to which arich info will be appended (used for tree branch naming)
std::vector< Variable::Manager::FunctionPtr > m_functions
List of function pointers corresponding to given variables.
std::string m_arichSelector
Decay string with selected particles to which arich info should be appended.
std::string m_particleList
Name of particle list with reconstructed particles.
StoreObjPtr< RootMergeable< TTree > > m_tree
The ROOT TNtuple for output.
std::shared_ptr< TFile > m_file
ROOT file for output.
DecayDescriptor m_decaydescriptor
Decay descriptor for selected particles to append arich info.
std::string m_sampling_name
Variable name of sampling variable.
float getInverseSamplingRateWeight(const Particle *particle)
Calculate inverse sampling rate weight.
std::string m_treeName
Name of the TTree.
const Variable::Manager::Var * m_sampling_variable
Variable Pointer to target variable.
int m_candidate
candidate counter
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.
Definition Manager.h:145