Belle II Software  release-05-02-19
arichToNtupleModule.h
1 /*************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2013-2018 Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Luka Santelj *
7 * (arich extension of variablesToNtuple module) *
8 * Christian Pulvermacher *
9 * Thomas Keck *
10 * Simon Wehle *
11 * Sam Cunliffe *
12 * *
13 * This software is provided "as is" without any warranty. *
14 **************************************************************************/
15 
16 #pragma once
17 
18 #include <arich/modules/arichNtuple/ARICHNtupleStruct.h>
19 #include <framework/core/Module.h>
20 #include <analysis/VariableManager/Manager.h>
21 #include <analysis/DecayDescriptor/DecayDescriptor.h>
22 #include <framework/datastore/StoreObjPtr.h>
23 #include <framework/dataobjects/EventMetaData.h>
24 #include <framework/pcore/RootMergeable.h>
25 
26 
27 #include <TTree.h>
28 #include <TFile.h>
29 
30 #include <string>
31 
32 namespace Belle2 {
42  class arichToNtupleModule : public Module {
43  public:
46 
51  virtual void initialize() override;
53  virtual void event() override;
55  virtual void terminate() override;
56 
57  private:
61  float getInverseSamplingRateWeight(const Particle* particle);
62 
66  void addARICHBranches(const std::string& name);
67 
71  void fillARICHTree(const Particle* particle);
72 
74  std::string m_particleList;
76  std::string m_arichSelector;
78  std::vector<std::string> m_variables;
80  std::vector<std::string> m_arichVariables;
81 
83  std::string m_fileName;
85  std::string m_treeName;
86 
88  std::shared_ptr<TFile> m_file{nullptr};
91  // Counter branch addresses (event number, candidate number etc)
92  int m_event{ -1};
93  int m_run{ -1};
94  int m_experiment{ -1};
95  int m_candidate{ -1};
96  unsigned int m_ncandidates{0};
99  std::vector<ARICH::ARICHTree*> m_arich;
100 
102  std::vector<double> m_branchAddresses;
104  std::vector<Variable::Manager::FunctionPtr> m_functions;
105 
107  std::tuple<std::string, std::map<int, unsigned int>> m_sampling;
109  std::string m_sampling_name;
111  std::map<int, unsigned int> m_sampling_rates;
112 
115 
117  std::map<int, unsigned long int> m_sampling_counts;
120  };
122 } // end namespace Belle2
Belle2::arichToNtupleModule::m_fileName
std::string m_fileName
Name of ROOT file for output.
Definition: arichToNtupleModule.h:96
Belle2::Variable::Manager::Var
A variable returning a floating-point value for a given Particle.
Definition: Manager.h:137
Belle2::arichToNtupleModule::getInverseSamplingRateWeight
float getInverseSamplingRateWeight(const Particle *particle)
Calculate inverse sampling rate weight.
Definition: arichToNtupleModule.cc:192
Belle2::arichToNtupleModule::m_arich
std::vector< ARICH::ARICHTree * > m_arich
Vector of arich branch addresses.
Definition: arichToNtupleModule.h:112
Belle2::arichToNtupleModule::terminate
virtual void terminate() override
Write TTree to file, and close file if necessary.
Definition: arichToNtupleModule.cc:246
Belle2::arichToNtupleModule::m_run
int m_run
run number
Definition: arichToNtupleModule.h:106
Belle2::arichToNtupleModule::m_decaydescriptor
DecayDescriptor m_decaydescriptor
Decay descriptor for selected particles to append arich info.
Definition: arichToNtupleModule.h:127
Belle2::arichToNtupleModule::m_tree
StoreObjPtr< RootMergeable< TTree > > m_tree
The ROOT TNtuple for output.
Definition: arichToNtupleModule.h:103
Belle2::arichToNtupleModule::m_experiment
int m_experiment
experiment number
Definition: arichToNtupleModule.h:107
Belle2::arichToNtupleModule::m_sampling_variable
const Variable::Manager::Var * m_sampling_variable
Variable Pointer to target variable.
Definition: arichToNtupleModule.h:129
Belle2::arichToNtupleModule::fillARICHTree
void fillARICHTree(const Particle *particle)
Fill data to arich branches.
Definition: arichToNtupleModule.cc:276
Belle2::arichToNtupleModule::m_treeName
std::string m_treeName
Name of the TTree.
Definition: arichToNtupleModule.h:98
Belle2::arichToNtupleModule::m_sampling_rates
std::map< int, unsigned int > m_sampling_rates
Inverse sampling rates.
Definition: arichToNtupleModule.h:124
Belle2::arichToNtupleModule::m_ncandidates
unsigned int m_ncandidates
total n candidates
Definition: arichToNtupleModule.h:109
Belle2::arichToNtupleModule::m_sampling_name
std::string m_sampling_name
Variable name of sampling variable.
Definition: arichToNtupleModule.h:122
Belle2::arichToNtupleModule::m_sampling_counts
std::map< int, unsigned long int > m_sampling_counts
Current number of samples with this value.
Definition: arichToNtupleModule.h:130
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::arichToNtupleModule::arichToNtupleModule
arichToNtupleModule()
Constructor.
Definition: arichToNtupleModule.cc:52
Belle2::arichToNtupleModule::m_particleList
std::string m_particleList
Name of particle list with reconstructed particles.
Definition: arichToNtupleModule.h:87
Belle2::arichToNtupleModule::m_functions
std::vector< Variable::Manager::FunctionPtr > m_functions
List of function pointers corresponding to given variables.
Definition: arichToNtupleModule.h:117
Belle2::arichToNtupleModule::initialize
virtual void initialize() override
Initialises the module.
Definition: arichToNtupleModule.cc:81
Belle2::arichToNtupleModule::event
virtual void event() override
Method called for each event.
Definition: arichToNtupleModule.cc:210
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::arichToNtupleModule::m_candidate
int m_candidate
candidate counter
Definition: arichToNtupleModule.h:108
Belle2::arichToNtupleModule::m_variables
std::vector< std::string > m_variables
List of variables to save.
Definition: arichToNtupleModule.h:91
Belle2::arichToNtupleModule::m_file
std::shared_ptr< TFile > m_file
ROOT file for output.
Definition: arichToNtupleModule.h:101
Belle2::DecayDescriptor
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Definition: DecayDescriptor.h:43
Belle2::arichToNtupleModule::m_arichVariables
std::vector< std::string > m_arichVariables
List of aliases of particles to which arich info will be appended (used for tree branch naming)
Definition: arichToNtupleModule.h:93
Belle2::arichToNtupleModule::addARICHBranches
void addARICHBranches(const std::string &name)
Add arich branches to the output TTree.
Definition: arichToNtupleModule.cc:261
Belle2::arichToNtupleModule::m_sampling
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.
Definition: arichToNtupleModule.h:120
Belle2::arichToNtupleModule::m_eventMetaData
StoreObjPtr< EventMetaData > m_eventMetaData
the event information
Definition: arichToNtupleModule.h:131
Belle2::arichToNtupleModule::m_arichSelector
std::string m_arichSelector
Decay string with selected particles to which arich info should be appendend.
Definition: arichToNtupleModule.h:89
Belle2::arichToNtupleModule::m_event
int m_event
event number
Definition: arichToNtupleModule.h:105
Belle2::arichToNtupleModule::m_branchAddresses
std::vector< double > m_branchAddresses
Variable branch addresses.
Definition: arichToNtupleModule.h:115