Belle II Software development
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 {
35 class arichToNtupleModule : public Module {
36 public:
39
44 virtual void initialize() override;
46 virtual void event() override;
48 virtual void terminate() override;
49
50 private:
54 float getInverseSamplingRateWeight(const Particle* particle);
55
59 void addARICHBranches(const std::string& name);
60
64 void fillARICHTree(const Particle* particle);
65
67 std::string m_particleList;
69 std::string m_arichSelector;
71 std::vector<std::string> m_variables;
73 std::vector<std::string> m_arichVariables;
74
76 std::string m_fileName;
78 std::string m_treeName;
79
81 std::shared_ptr<TFile> m_file{nullptr};
84 // Counter branch addresses (event number, candidate number etc)
85 int m_event{ -1};
86 int m_run{ -1};
87 int m_experiment{ -1};
88 int m_candidate{ -1};
89 unsigned int m_ncandidates{0};
92 std::vector<ARICH::ARICHTree*> m_arich;
93
95 std::vector<double> m_branchAddresses;
97 std::vector<Variable::Manager::FunctionPtr> m_functions;
98
100 std::tuple<std::string, std::map<int, unsigned int>> m_sampling;
102 std::string m_sampling_name;
104 std::map<int, unsigned int> m_sampling_rates;
105
108
110 std::map<int, unsigned long int> m_sampling_counts;
113 };
115} // end namespace Belle2
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
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
This module extends existing variablesToNtuple to append detailed arich information to candidates in ...
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 appendend.
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:146