Project
Loading...
Searching...
No Matches
CalibTreeDump.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_TPC_CALIBTREEDUMP_H_
13#define ALICEO2_TPC_CALIBTREEDUMP_H_
14
15#include <vector>
16#include <string>
17#include <unordered_map>
18
19#include <boost/variant.hpp>
20
23
24// forward declarations
25class TTree;
26
27namespace o2
28{
29namespace tpc
30{
31
32// forward declarations
33template <class T>
34class CalDet;
35
36template <class T>
37class CalArray;
38
47
49{
50 public:
51 using DataTypes = CalDet<float>; // boost::variant<CalDet<int>, CalDet<float>, CalDet<double>, CalDet<bool>, CalDet<unsigned int>>;
52 using CalPadMapType = std::unordered_map<std::string, DataTypes>;
53
54 CalibTreeDump() = default;
55 ~CalibTreeDump() = default;
56
58 template <typename T>
59 void add(CalDet<T>* calDet)
60 {
61 mCalDetObjects.emplace_back(calDet);
62 }
63 // void add(const CalDet<DataTypes>& calDet) { mCalDetObjects.push_back(calDet); }
64
66 template <typename T>
67 void add(CalArray<T>* calArray)
68 {
69 mCalArrayObjects.emplace_back(calArray);
70 }
74 void add(CalPadMapType& calibs);
75
77 void setAddFEEInfo(bool add = true) { mAddFEEInfo = add; }
78
80 void addCalPads(const std::string_view file, const std::string_view calPadNames);
81
83 void dumpToFile(const std::string filename = "CalibTree.root");
84
86 void addInfo(const std::string_view name, float value) { mAddInfo[name.data()] = value; }
87
88 private:
89 std::unordered_map<std::string, float> mAddInfo{};
90 std::vector<DataTypes*> mCalDetObjects{};
91 std::vector<DataTypes*> mCalArrayObjects{};
92 bool mAddFEEInfo{false};
93 std::vector<float> mTraceLengthIROC;
94 std::vector<float> mTraceLengthOROC;
95
97 void addDefaultMapping(TTree* tree);
98
100 void addFEEMapping(TTree* tree);
101
104 void addCalDetObjects(TTree* tree);
105
107 void setDefaultAliases(TTree* tree);
108
110 template <class Result, class Func>
111 struct forwarding_visitor : boost::static_visitor<Result> {
112 Func func;
113 forwarding_visitor(const Func& f) : func(f) {}
114 forwarding_visitor(Func&& f) : func(std::move(f)) {}
115 template <class Arg>
116 Result operator()(Arg&& arg) const
117 {
118 return func(std::forward<Arg>(arg));
119 }
120 };
121
123 template <class Result, class Func>
124 forwarding_visitor<Result, std::decay_t<Func>> make_forwarding_visitor(Func&& func)
125 {
126 return {std::forward<Func>(func)};
127 }
128};
129} // namespace tpc
130
131} // namespace o2
132#endif
class to dump calibration data to a ttree for simple visualisation
void addCalPads(const std::string_view file, const std::string_view calPadNames)
Add CalPad objects from a file.
void setAddFEEInfo(bool add=true)
Set adding of FEE mapping to the tree.
std::unordered_map< std::string, DataTypes > CalPadMapType
void dumpToFile(const std::string filename="CalibTree.root")
Dump the registered calibration data to file.
void add(CalDet< T > *calDet)
Add CalDet object.
void add(CalArray< T > *calArray)
Add CalArray objects.
void addInfo(const std::string_view name, float value)
Add complementary information.
GLenum func
Definition glcorearb.h:778
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
GLsizei const GLfloat * value
Definition glcorearb.h:819
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
std::string filename()
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))