Belle II Software development
RootParameterTracker Class Reference

Production notes for RootParameterTracker: More...

#include <RootParameterTracker.h>

Public Member Functions

 RootParameterTracker ()
 constructor setting standard values
 
void initialize (std::string fileName, std::string fileTreatment)
 creates rootFile, first parameter is fileName, second one specifies how the file shall be treated.
 
void addParameters4DoubleAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one double per TC:
 
void addParameters4IntAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one int per TC:
 
void addParameters4VecDoubleAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one vector of double per TC:
 
void collectData (const std::vector< AnalizerTCInfo > &tcVector)
 take vector and fill for each tcType stored in rootParameterTracker
 
void fillRoot ()
 fills tree/branches with their stuff, clear intermediate results afterwards
 
void terminate ()
 final cleanup and closing rootFile
 

Protected Types

template<class ValueType >
using StringKeyBox = KeyValBox< std::string, ValueType >
 short-cut since strings are always used as keys here:
 
template<class DataType >
using AnalyzingAlgorithm = AnalyzingAlgorithmBase< DataType, AnalizerTCInfo, ROOT::Math::XYZVector >
 short-cut for typical algorithm-types used
 
template<class DataType >
using AlgoDataBox = StringKeyBox< StringKeyBox< std::pair< AnalyzingAlgorithm< DataType > *, std::vector< DataType > * > > >
 contains algorithms and its raw data to be streamed into ttrees.
 

Protected Member Functions

TTree * prepareTTree (std::string tcTypeName)
 checks if ttree for given tcTypeName exists and creates it if not.
 
void collectData4DoubleAlgorithms (std::string tcTypeName, const AnalizerTCInfo &aTC)
 takes aTC with tcTypeName and applies the algorithms for it
 
void collectData4IntAlgorithms (std::string tcTypeName, const AnalizerTCInfo &aTC)
 takes aTC with tcTypeName and applies the algorithms for it
 
void collectData4VecDoubleAlgorithms (std::string tcTypeName, const AnalizerTCInfo &aTC)
 takes aTC with tcTypeName and applies the algorithms for it
 

Protected Attributes

StringKeyBox< TTree * > m_treeBox
 contains all the trees for rootFile-filling later-on.
 
AlgoDataBox< double > m_algoDataDouble
 contains all algorithms and its data storing one double per TC
 
AlgoDataBox< int > m_algoDataInt
 contains all algorithms and its data storing one int per TC
 
AlgoDataBox< std::vector< double > > m_algoDataVecDouble
 contains all algorithms and its data storing one vector of double per TC
 
TFile * m_file
 stores pointer to file
 

Detailed Description

Production notes for RootParameterTracker:

internalTreeContainer, internalAlgorithmContainer, internalLinkContainer are all a vector< pair < key, value> >. .find returns a link to the entry (.second only) searched for and takes a key and compares only with the key (like a map) .push_back simply push_back a pair .clearAll() for each entry.second .clear();

shall be a simple class just containing this vector and a find function doing what one wants to do

reread pseudo code down below to be sure that the container does what it shall do. takes care of collecting data of track candidates and storing it to root branches.

Definition at line 49 of file RootParameterTracker.h.

Member Typedef Documentation

◆ AlgoDataBox

using AlgoDataBox = StringKeyBox<StringKeyBox<std::pair<AnalyzingAlgorithm<DataType>*, std::vector<DataType>*> >>
protected

contains algorithms and its raw data to be streamed into ttrees.

key of AlgoDataBox is tcType, val is another box with: key is algorithmType val is pair: .first is the algorithm to be applied onto the AnalizerTCInfo-instances. .second is the data collected for .first to be streamed into ttrees.

Definition at line 68 of file RootParameterTracker.h.

◆ AnalyzingAlgorithm

using AnalyzingAlgorithm = AnalyzingAlgorithmBase<DataType, AnalizerTCInfo, ROOT::Math::XYZVector>
protected

short-cut for typical algorithm-types used

Definition at line 57 of file RootParameterTracker.h.

◆ StringKeyBox

using StringKeyBox = KeyValBox<std::string, ValueType>
protected

short-cut since strings are always used as keys here:

Definition at line 53 of file RootParameterTracker.h.

Constructor & Destructor Documentation

◆ RootParameterTracker()

constructor setting standard values

Definition at line 140 of file RootParameterTracker.h.

140: m_file(nullptr) {}
TFile * m_file
stores pointer to file

Member Function Documentation

◆ addParameters4DoubleAlgorithms()

void addParameters4DoubleAlgorithms ( std::string  tcTypeName,
std::string  algorithmName 
)

relevant for all algorithms storing one double per TC:

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

Production notes - pseudo code:

want to have one ttree for each tcType.

if TCType.convertToString (tcTypeName) not in internalTreeContainer: internalTreeContainer.push_back(tcTypeName, new TTree(tcTypeName, ("collects data collected to tcType" + tcTypeName).c_str());

if TCType.convertToString (tcTypeName) not in internalAlgorithmContainer: internalAlgorithmContainer.push_back(tcTypeName, {} ); // .second contains all the algorithms in the end

if algorithmName already in internalAlgorithmContainer: B2WARNING return;

internalAlgorithmContainer.find(tcTypeName).push_back(newAlgorithm); internalLinkContainer.find(tcTypeName).push_back( { algorithmName, {} ); // .second (empty curly braces) contains the collected data in the end

auto linkToData = internalLinkContainer.find(tcTypeName).find(algorithmName);

internalTreeContainer.find(tcTypeName)->Branch("algorithmName", &linkToData);

make sure that container for algorithms of given tcType exists:

make sure that algorithm and its dataStuff exists:

make sure that there is a branch linked to the raw data stored for this tcType <-> algorithm combination:

Definition at line 155 of file RootParameterTracker.cc.

156{
178 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), given parameters are tcTypeName/algorithmName: " << tcTypeName
179 << "/" <<
180 algorithmName);
181
182 TTree* tree4tcType = prepareTTree(tcTypeName);
183
185 auto* algorithms4tcType = m_algoDataDouble.find(tcTypeName);
186 if (algorithms4tcType == nullptr) {
187 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), tcType " << tcTypeName <<
188 " not yet added to m_algoDataDouble, doing it now...");
189 m_algoDataDouble.push_back({
190 tcTypeName,
191 StringKeyBox<std::pair<AnalyzingAlgorithm<double>*, std::vector<double>*> >()
192 });
193 algorithms4tcType = m_algoDataDouble.find(tcTypeName);
194 }
195 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataDouble has " << m_algoDataDouble.size() <<
196 " tcTypes stored");
197
199 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
200 if (data4AlgorithmOftcType == nullptr) {
201 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), algorithm " << algorithmName <<
202 " not yet added to m_algoDataDouble[tcType], doing it now...");
203 AnalyzingAlgorithm<double>* newAlgorithm = AnalyzingAlgorithmFactoryDouble<double, AnalizerTCInfo, ROOT::Math::XYZVector>
204 (AlgoritmType::getTypeEnum(algorithmName));
205 algorithms4tcType->push_back({
206 algorithmName,
207 {
208 newAlgorithm,
209 new std::vector<double>()
210 }
211 });
212 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
213
215 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
216 if (newBranch == nullptr) B2ERROR("Could not create Branch " << algorithmName); // mainly to suppress compiler warning
217 // newBranch->Print();
218 } else {
219 B2WARNING("RootParameterTracker::addParameters4DoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
220 "/" << algorithmName <<
221 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
222 }
223 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataDouble[tcType] has " << algorithms4tcType->size() <<
224 " algorithms stored");
225}
static AlgoritmType::Type getTypeEnum(std::string type)
for given string name of a AlgoritmType the corresponding AlgoritmType will be returned.
Definition: AlgoritmType.h:98
TTree * prepareTTree(std::string tcTypeName)
checks if ttree for given tcTypeName exists and creates it if not.
AlgoDataBox< double > m_algoDataDouble
contains all algorithms and its data storing one double per TC

◆ addParameters4IntAlgorithms()

void addParameters4IntAlgorithms ( std::string  tcTypeName,
std::string  algorithmName 
)

relevant for all algorithms storing one int per TC:

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

make sure that container for algorithms of given tcType exists:

make sure that algorithm and its dataStuff exists:

make sure that there is a branch linked to the raw data stored for this tcType <-> algorithm combination:

Definition at line 234 of file RootParameterTracker.cc.

235{
236 B2DEBUG(5, "RootParameterTracker::addParameters4IntAlgorithms(), given parameters are tcTypeName/algorithmName: " << tcTypeName <<
237 "/" <<
238 algorithmName);
239
240 TTree* tree4tcType = prepareTTree(tcTypeName);
241
243 auto* algorithms4tcType = m_algoDataInt.find(tcTypeName);
244 if (algorithms4tcType == nullptr) {
245 B2DEBUG(5, "RootParameterTracker::addParameters4IntAlgorithms(), tcType " << tcTypeName <<
246 " not yet added to m_algoDataInt, doing it now...");
247 m_algoDataInt.push_back({
248 tcTypeName,
249 StringKeyBox<std::pair<AnalyzingAlgorithm<int>*, std::vector<int>*> >()
250 });
251 algorithms4tcType = m_algoDataInt.find(tcTypeName);
252 }
253 B2DEBUG(5, "RootParameterTracker::addParameters4IntAlgorithms(), m_algoDataInt has " << m_algoDataInt.size() << " tcTypes stored");
254
256 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
257 if (data4AlgorithmOftcType == nullptr) {
258 B2DEBUG(5, "RootParameterTracker::addParameters4IntAlgorithms(), algorithm " << algorithmName <<
259 " not yet added to m_algoDataInt[tcType], doing it now...");
260 AnalyzingAlgorithm<int>* newAlgorithm =
261 AnalyzingAlgorithmFactoryInt<int, AnalizerTCInfo, ROOT::Math::XYZVector>(AlgoritmType::getTypeEnum(algorithmName));
262
263 algorithms4tcType->push_back({
264 algorithmName,
265 {
266 newAlgorithm,
267 new std::vector<int>()
268 }
269 });
270 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
271
273 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
274 if (newBranch == nullptr) B2ERROR("Could not create Branch " << algorithmName); // mainly to suppress compiler warning
275 // newBranch->Print();
276 } else {
277 B2WARNING("RootParameterTracker::addParameters4DoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
278 "/" << algorithmName <<
279 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
280 }
281 B2DEBUG(5, "RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataInt[tcType] has " << algorithms4tcType->size() <<
282 " algorithms stored");
283}
AlgoDataBox< int > m_algoDataInt
contains all algorithms and its data storing one int per TC

◆ addParameters4VecDoubleAlgorithms()

void addParameters4VecDoubleAlgorithms ( std::string  tcTypeName,
std::string  algorithmName 
)

relevant for all algorithms storing one vector of double per TC:

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

for given tcTypename <-> algorithmName-combination, this tracker will be prepared for tracking them in a root-file.

make sure that container for algorithms of given tcType exists:

make sure that algorithm and its dataStuff exists:

make sure that there is a branch linked to the raw data stored for this tcType <-> algorithm combination:

Definition at line 292 of file RootParameterTracker.cc.

293{
294 B2DEBUG(5, "RootParameterTracker::addParameters4VecDoubleAlgorithms(), given parameters are tcTypeName/algorithmName: " <<
295 tcTypeName << "/" <<
296 algorithmName);
297
298 TTree* tree4tcType = prepareTTree(tcTypeName);
299
301 auto* algorithms4tcType = m_algoDataVecDouble.find(tcTypeName);
302 if (algorithms4tcType == nullptr) {
303 B2DEBUG(5, "RootParameterTracker::addParameters4VecDoubleAlgorithms(), tcType " << tcTypeName <<
304 " not yet added to m_algoDataVecDouble, doing it now...");
305 m_algoDataVecDouble.push_back({
306 tcTypeName,
307 StringKeyBox<std::pair<AnalyzingAlgorithm<std::vector<double>>*, std::vector<std::vector<double>>*> >()
308 });
309 algorithms4tcType = m_algoDataVecDouble.find(tcTypeName);
310 }
311 B2DEBUG(5, "RootParameterTracker::addParameters4VecDoubleAlgorithms(), m_algoDataVecDouble has " << m_algoDataVecDouble.size() <<
312 " tcTypes stored");
313
315 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
316 if (data4AlgorithmOftcType == nullptr) {
317 B2DEBUG(5, "RootParameterTracker::addParameters4VecDoubleAlgorithms(), algorithm " << algorithmName <<
318 " not yet added to m_algoDataVecDouble[tcType], doing it now...");
319 AnalyzingAlgorithm<std::vector<double>>* newAlgorithm =
320 AnalyzingAlgorithmFactoryVecDouble<std::vector<double>, AnalizerTCInfo, ROOT::Math::XYZVector>
321 (AlgoritmType::getTypeEnum(algorithmName));
322 algorithms4tcType->push_back({
323 algorithmName,
324 {
325 newAlgorithm,
326 new std::vector<std::vector<double>>()
327 }
328 });
329 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
330
332 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
333 if (newBranch == nullptr) B2ERROR("Could not create Branch " << algorithmName); // mainly to suppress compiler warning
334 // newBranch->Print();
335 } else {
336 B2WARNING("RootParameterTracker::addParameters4VecDoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
337 "/" << algorithmName <<
338 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
339 }
340 B2DEBUG(5, "RootParameterTracker::addParameters4VecDoubleAlgorithms(), m_algoDataVecDouble[tcType] has " <<
341 algorithms4tcType->size() << " algorithms stored");
342}
simple class storing infos relevant for a TC for analizing it.
AlgoDataBox< std::vector< double > > m_algoDataVecDouble
contains all algorithms and its data storing one vector of double per TC

◆ collectData()

void collectData ( const std::vector< AnalizerTCInfo > &  tcVector)
inline

take vector and fill for each tcType stored in rootParameterTracker

Production notes: take internal container where all the requested parameters are tracked: for currenttcType in internalAlgorithmContainer: for tc in tcVector if tc.tctype == currenttcType fill internalLinkContainer with result of applied algorithm

Definition at line 183 of file RootParameterTracker.h.

184 {
192 B2DEBUG(21, "RootParameterTracker::collectData(), size of given tcVector is: " << tcVector.size());
193
194 for (const AnalizerTCInfo& tc : tcVector) {
195 std::string tcTypeName = TCType::getTypeName(tc.getType());
196 B2DEBUG(22, "RootParameterTracker::collectData(), executing TC of type: " << tcTypeName);
197
198 collectData4DoubleAlgorithms(tcTypeName, tc);
199 collectData4IntAlgorithms(tcTypeName, tc);
200 collectData4VecDoubleAlgorithms(tcTypeName, tc);
201 } // looping over TCs
202 }
void collectData4DoubleAlgorithms(std::string tcTypeName, const AnalizerTCInfo &aTC)
takes aTC with tcTypeName and applies the algorithms for it
void collectData4IntAlgorithms(std::string tcTypeName, const AnalizerTCInfo &aTC)
takes aTC with tcTypeName and applies the algorithms for it
void collectData4VecDoubleAlgorithms(std::string tcTypeName, const AnalizerTCInfo &aTC)
takes aTC with tcTypeName and applies the algorithms for it
static std::string getTypeName(TCType::Type type)
for given TCType the corresponding string-name will be returned.
Definition: TCType.h:62

◆ collectData4DoubleAlgorithms()

void collectData4DoubleAlgorithms ( std::string  tcTypeName,
const AnalizerTCInfo aTC 
)
protected

takes aTC with tcTypeName and applies the algorithms for it

Definition at line 14 of file RootParameterTracker.cc.

15{
16 auto* foundTCTypeData = m_algoDataDouble.find(tcTypeName); // a KeyValBox with all algorithms and data collected to given tcTypeName
17
18 // skip if there is nothing stored for this tcType:
19 if (foundTCTypeData == nullptr) { return; }
20
21 // looping over algorithms:
22 for (auto& entry : *foundTCTypeData) {
23 // increase readability:
24 auto* anAlgorithm = entry.second.first;
25 auto* dataVector = entry.second.second;
26 // sanity check: key has to be compatible with stored algorithm:
27 std::string algoName = anAlgorithm->getIDName();
28 if (entry.first != algoName) {
29 B2ERROR("RootParameterTracker::collectData4DoubleAlgorithms() key (" << entry.first <<
30 ") of container does not match to its content (" << algoName <<
31 ") - skipping entry! ");
32 continue;
33 }
34 B2DEBUG(21, "RootParameterTracker::collectData4DoubleAlgorithms(), executing algorithm of type: " << algoName <<
35 " with collected data-entries of " << dataVector->size());
36
37 try {
38 double calcVal = anAlgorithm->calcData(aTC);
39 dataVector->push_back(calcVal);
40 B2DEBUG(20, "RootParameterTracker::collectData4DoubleAlgorithms(), tc with type " << tcTypeName <<
41 " and applied algorithm " << algoName <<
42 " and got " << calcVal << " as a result!");
43 } catch (AnalyzingAlgorithm<double>::No_refTC_Attached& anException) {
44 B2WARNING("RootParameterTracker::collectData4DoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
45 " and applied algorithm " << algoName <<
46 ". Failed with exception: " << anException.what() <<
47 " -> skipping tc!");
48 }
49 }// looping over algorithms
50}

◆ collectData4IntAlgorithms()

void collectData4IntAlgorithms ( std::string  tcTypeName,
const AnalizerTCInfo aTC 
)
protected

takes aTC with tcTypeName and applies the algorithms for it

Definition at line 57 of file RootParameterTracker.cc.

58{
59 auto* foundTCTypeData = m_algoDataInt.find(tcTypeName); // a KeyValBox with all algorithms and data collected to given tcTypeName
60
61 // skip if there is nothing stored for this tcType:
62 if (foundTCTypeData == nullptr) { return; }
63
64 // looping over algorithms:
65 for (auto& entry : *foundTCTypeData) {
66 // increase readability:
67 auto* anAlgorithm = entry.second.first;
68 auto* dataVector = entry.second.second;
69 // sanity check: key has to be compatible with stored algorithm:
70 std::string algoName = anAlgorithm->getIDName();
71 if (entry.first != algoName) {
72 B2ERROR("RootParameterTracker::collectData4DoubleAlgorithms() key (" << entry.first <<
73 ") of container does not match to its content (" << algoName <<
74 ") - skipping entry! ");
75 continue;
76 }
77 B2DEBUG(50, "RootParameterTracker::collectData4DoubleAlgorithms(), executing algorithm of type: " << algoName <<
78 " with collected data-entries of " << dataVector->size());
79
80 try {
81 int calcVal = anAlgorithm->calcData(aTC);
82 dataVector->push_back(calcVal);
83 B2DEBUG(20, "RootParameterTracker::collectData4DoubleAlgorithms(), tc with type " << tcTypeName <<
84 " and applied algorithm " << algoName <<
85 " and got " << calcVal << " as a result!");
86 } catch (AnalyzingAlgorithm<int>::No_refTC_Attached& anException) {
87 B2WARNING("RootParameterTracker::collectData4DoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
88 " and applied algorithm " << algoName <<
89 ". Failed with exception: " << anException.what() <<
90 " -> skipping tc!");
91 }
92 }// looping over algorithms
93}

◆ collectData4VecDoubleAlgorithms()

void collectData4VecDoubleAlgorithms ( std::string  tcTypeName,
const AnalizerTCInfo aTC 
)
protected

takes aTC with tcTypeName and applies the algorithms for it

Definition at line 100 of file RootParameterTracker.cc.

101{
102 auto* foundTCTypeData = m_algoDataVecDouble.find(
103 tcTypeName); // a KeyValBox with all algorithms and data collected to given tcTypeName
104
105 // skip if there is nothing stored for this tcType:
106 if (foundTCTypeData == nullptr) { return; }
107
108 // looping over algorithms:
109 for (auto& entry : *foundTCTypeData) {
110 // increase readability:
111 auto* anAlgorithm = entry.second.first;
112 auto* dataVector = entry.second.second; // std::vector< vector < double>>
113 // sanity check: key has to be compatible with stored algorithm:
114 std::string algoName = anAlgorithm->getIDName();
115 if (entry.first != algoName) {
116 B2ERROR("RootParameterTracker::collectData4VecDoubleAlgorithms() key (" << entry.first <<
117 ") of container does not match to its content (" << algoName <<
118 ") - skipping entry! ");
119 continue;
120 }
121 B2DEBUG(50, "RootParameterTracker::collectData4VecDoubleAlgorithms(), executing algorithm of type: " << algoName <<
122 " with collected data-entries of " << dataVector->size());
123
124 try {
125 std::vector<double> calcVal = anAlgorithm->calcData(aTC);
126 dataVector->push_back(calcVal);
127 auto printVec = [&]() -> std::string {
128 std::string out;
129 for (double val : calcVal)
130 {
131 out += (" " + std::to_string(val));
132 }
133 return (out += "\n");
134 };
135 B2DEBUG(20, "RootParameterTracker::collectData4VecDoubleAlgorithms(), tc with type " << tcTypeName <<
136 " and applied algorithm " << algoName <<
137 " and got: " << printVec() <<
138 " as a result!");
139 } catch (AnalyzingAlgorithm<std::vector<double>>::No_refTC_Attached& anException) {
140 B2WARNING("RootParameterTracker::collectData4VecDoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
141 " and applied algorithm " << algoName <<
142 ". Failed with exception: " << anException.what() <<
143 " -> skipping tc!");
144 }
145 }// looping over algorithms
146}
AnalyzingAlgorithmBase< DataType, AnalizerTCInfo, ROOT::Math::XYZVector > AnalyzingAlgorithm
short-cut for typical algorithm-types used

◆ fillRoot()

void fillRoot ( )
inline

fills tree/branches with their stuff, clear intermediate results afterwards

Definition at line 206 of file RootParameterTracker.h.

207 {
208 B2DEBUG(21, "RootParameterTracker::fillRoot(), Executing " << m_treeBox.size() << " ttrees.");
209
210 m_file->cd(); //important! without this the famework root I/O (SimpleOutput etc) could mix with the root I/O of this module
211// m_file->ls();
212
213 for (auto& boxEntry : m_treeBox) {
214 int nBytesWritten = boxEntry.second->Fill();
215 B2DEBUG(20, "RootParameterTracker::fillRoot() ttree " << boxEntry.first << " got " << nBytesWritten << " Bytes written");
216 // boxEntry.second->Print();
217 }
218
219 for (auto& algoData2tcType : m_algoDataDouble) {
220 for (auto& algoPack : algoData2tcType.second) {
221 algoPack.second.second->clear();
222 }
223 }
224
225 for (auto& algoData2tcType : m_algoDataInt) {
226 for (auto& algoPack : algoData2tcType.second) {
227 algoPack.second.second->clear();
228 }
229 }
230
231 for (auto& algoData2tcType : m_algoDataVecDouble) {
232 for (auto& algoPack : algoData2tcType.second) {
233 algoPack.second.second->clear();
234 }
235 }
236 }
StringKeyBox< TTree * > m_treeBox
contains all the trees for rootFile-filling later-on.

◆ initialize()

void initialize ( std::string  fileName,
std::string  fileTreatment 
)
inline

creates rootFile, first parameter is fileName, second one specifies how the file shall be treated.

Valid values for fileTreatment: 'RECREATE' or 'UPDATE'.

calling it more than once will result in a B2FATAL-message.

Definition at line 147 of file RootParameterTracker.h.

148 {
149 if (fileTreatment != std::string("RECREATE") and fileTreatment != std::string("UPDATE")) {
150 B2FATAL("RootParameterTracker::initialize(), specified fileTreatment is " << fileTreatment <<
151 ", which is invalid, please read the documentation!");
152 }
153
154 if (m_file != nullptr) {
155 B2FATAL("RootParameterTracker::initialize(), there was a file already linked to this ParameterTracker, which is invalid, please read the documentation!");
156 }
157 B2DEBUG(20, "RootParameterTracker::initialize(), given parameters are fileName/fileTreatment: " << fileName << "/" <<
158 fileTreatment);
159 m_file = new TFile(fileName.c_str(), fileTreatment.c_str()); // alternative: UPDATE
160 m_file->ls();
161 }

◆ prepareTTree()

TTree * prepareTTree ( std::string  tcTypeName)
inlineprotected

checks if ttree for given tcTypeName exists and creates it if not.

returns ttree for given tcType

make sure that tree exists:

Definition at line 97 of file RootParameterTracker.h.

98 {
99 if (m_file == nullptr) {
100 B2FATAL("RootParameterTracker::prepareTTree(), Root file not initialized yet! Please call RootParameterTracker::initialize(...) first!");
101 }
102 m_file->cd();
103 // m_file->ls();
104
106 TTree** tree4tcType = m_treeBox.find(tcTypeName);
107 if (tree4tcType == nullptr) {
108 m_treeBox.push_back({
109 tcTypeName,
110 new TTree(tcTypeName.c_str(), (std::string("collects data collected to tcType ") + tcTypeName).c_str())
111 }
112 );
113 tree4tcType = m_treeBox.find(tcTypeName);
114 B2WARNING("RootParameterTracker::prepareTTree: new tree for tcType " << tcTypeName << " created, m_treeBox has now " <<
115 m_treeBox.size() << " entries");
116 return *tree4tcType;
117 }
118
119 B2WARNING("RootParameterTracker::prepareTTree: ttree for tcType " << tcTypeName << " is reused, m_treeBox has " << m_treeBox.size()
120 << " entries");
121 return *tree4tcType;
122 }

◆ terminate()

void terminate ( )
inline

final cleanup and closing rootFile

Definition at line 240 of file RootParameterTracker.h.

241 {
242 B2DEBUG(20, "RootParameterTracker::terminate(), Writing results to root-file and clean up heap.");
243 if (m_file == nullptr) {
244 B2WARNING("RootParameterTracker::terminate(): no rootFile found! skipping writing data into root file!");
245 return;
246 }
247
248 m_file->cd(); //important! without this the famework root I/O (SimpleOutput etc) could mix with the root I/O of this module
249 m_file->ls();
250
251 for (auto& boxEntry : m_treeBox) {
252 boxEntry.second->Write();
253
254 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 5, PACKAGENAME()) == true) {
255 B2DEBUG(20, "RootParameterTracker::terminate(), TTree " << boxEntry.first << " was written:");
256 // boxEntry.second->Print();
257 }
258 }
259 m_file->Close();
260
261 for (auto& algoData2tcType : m_algoDataDouble) {
262 for (auto& algoPack : algoData2tcType.second) {
263 delete algoPack.second.first; // algorithm
264 delete algoPack.second.second; // vector(data) to algorithm
265 }
266 }
267
268 for (auto& algoData2tcType : m_algoDataInt) {
269 for (auto& algoPack : algoData2tcType.second) {
270 delete algoPack.second.first; // algorithm
271 delete algoPack.second.second; // vector(data) to algorithm
272 }
273 }
274
275 for (auto& algoData2tcType : m_algoDataVecDouble) {
276 for (auto& algoPack : algoData2tcType.second) {
277 delete algoPack.second.first; // algorithm
278 delete algoPack.second.second; // vector(data) to algorithm
279 }
280 }
281 }
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31

Member Data Documentation

◆ m_algoDataDouble

AlgoDataBox<double> m_algoDataDouble
protected

contains all algorithms and its data storing one double per TC

Definition at line 81 of file RootParameterTracker.h.

◆ m_algoDataInt

AlgoDataBox<int> m_algoDataInt
protected

contains all algorithms and its data storing one int per TC

Definition at line 85 of file RootParameterTracker.h.

◆ m_algoDataVecDouble

AlgoDataBox<std::vector<double> > m_algoDataVecDouble
protected

contains all algorithms and its data storing one vector of double per TC

Definition at line 89 of file RootParameterTracker.h.

◆ m_file

TFile* m_file
protected

stores pointer to file

Definition at line 93 of file RootParameterTracker.h.

◆ m_treeBox

StringKeyBox<TTree*> m_treeBox
protected

contains all the trees for rootFile-filling later-on.

Key is tcTypeName as a string Value are TTrees, one tree for each tcType

Definition at line 77 of file RootParameterTracker.h.


The documentation for this class was generated from the following files: