Belle II Software development
HandleRoot.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#ifndef HANDLEROOT_H
9#define HANDLEROOT_H
10
11#include <TTree.h>
12#include <TFile.h>
13#include <TClonesArray.h>
14#include <TVectorD.h>
15#include <map>
16#include <string>
17
18namespace HandleRoot {
19 // Write functions.
20 void initializeEvent(
21 std::map<std::string, TVectorD*>& eventMapTVectorD,
22 std::map<std::string, TClonesArray*>& trackMapTVectorD
23 );
24 void initializeEvent(
25 std::map<std::string, TClonesArray*>& trackMapTVectorD
26 );
27 void initializeRoot(const std::string& prefix, TTree** runTree, TTree** eventTree,
28 std::map<std::string, TVectorD*>& runMapTVectorD,
29 std::map<std::string, TVectorD*>& eventMapTVectorD,
30 std::map<std::string, TClonesArray*>& trackMapTVectorD,
31 std::map<std::string, double>& constMapD, std::map<std::string, std::vector<double> >& constMapV,
32 std::map<std::string, double>& eventMapD, std::map<std::string, std::vector<double> >& eventMapV,
33 std::map<std::string, double>& trackMapD, std::map<std::string, std::vector<double> >& trackMapV
34 );
35 void initializeRoot(const std::string& prefix, TTree** runTree, TTree** eventTree,
36 std::map<std::string, TVectorD*>& runMapTVectorD,
37 std::map<std::string, TClonesArray*>& trackMapTVectorD,
38 std::map<std::string, double>& constMapD, std::map<std::string, std::vector<double> >& constMapV,
39 std::map<std::string, double>& trackMapD, std::map<std::string, std::vector<double> >& trackMapV
40 );
41 // Requries trackMapD to have key "iSave".
42 void saveTrackValues(const std::string& prefix,
43 const std::map<std::string, TClonesArray*>& trackMapTVectorD,
44 std::map<std::string, double>& trackMapD, std::map<std::string, std::vector<double> >& trackMapV
45 );
46 void saveEventValues(const std::string& prefix,
47 std::map<std::string, TVectorD*>& eventMapTVectorD,
48 std::map<std::string, double>& eventMapD, std::map<std::string, std::vector<double> >& eventMapV
49 );
50 void writeRoot(TFile* file);
51
52 // Read functions.
53 void initializeBranches(const std::string& prefix, TFile* file, TTree** runTree, TTree** eventTree,
54 std::map<std::string, TVectorD*>& runMapTVectorD,
55 std::map<std::string, TVectorD*>& eventMapTVectorD,
56 std::map<std::string, TClonesArray*>& trackMapTVectorD
57 );
58 void initializeBranches(const std::string& prefix, TFile* file, TTree** runTree, TTree** eventTree,
59 std::map<std::string, TVectorD*>& runMapTVectorD,
60 std::map<std::string, TClonesArray*>& trackMapTVectorD
61 );
62 void getRunValues(std::string prefix,
63 std::map<std::string, TVectorD*>& runMapTVectorD,
64 std::map<std::string, double>& constMapD, std::map<std::string, std::vector<double> >& constMapV
65 );
66 void getEventValues(const std::string& prefix,
67 std::map<std::string, TVectorD*>& eventMapTVectorD,
68 std::map<std::string, double>& eventMapD, std::map<std::string, std::vector<double> >& eventMapV
69 );
70 void getTrackValues(const std::string& prefix, int iTrack,
71 std::map<std::string, TClonesArray*>& trackMapTVectorD,
72 std::map<std::string, double>& trackMapD, std::map<std::string, std::vector<double> >& trackMapV
73 );
74
75 // Common functions
76 void terminateRoot(
77 std::map<std::string, TVectorD*>& runMapTVectorD,
78 std::map<std::string, TVectorD*>& eventMapTVectorD,
79 std::map<std::string, TClonesArray*>& trackMapTVectorD
80 );
81 void terminateRoot(
82 std::map<std::string, TVectorD*>& runMapTVectorD,
83 std::map<std::string, TClonesArray*>& trackMapTVectorD
84 );
85
86 // Utility functions
87 void convertSignalValuesToMaps(std::vector<std::tuple<std::string, double, int, double, double, int> > const& inValues,
88 std::map<std::string, double>& trackMapD, std::map<std::string, std::vector<double> >& trackMapV
89 );
90
91};
92
93#endif