11#include <tracking/trackFindingVXD/analyzingTools/AnalizerTCInfo.h>
12#include <tracking/trackFindingVXD/analyzingTools/AnalyzingAlgorithmFactory.h>
13#include <tracking/trackFindingVXD/analyzingTools/KeyValBox.h>
15#include <framework/logging/Logger.h>
20#include <Math/Vector3D.h>
100 B2FATAL(
"RootParameterTracker::prepareTTree(), Root file not initialized yet! Please call RootParameterTracker::initialize(...) first!");
106 TTree** tree4tcType =
m_treeBox.find(tcTypeName);
107 if (tree4tcType ==
nullptr) {
110 new TTree(tcTypeName.c_str(), (std::string(
"collects data collected to tcType ") + tcTypeName).c_str())
113 tree4tcType =
m_treeBox.find(tcTypeName);
114 B2WARNING(
"RootParameterTracker::prepareTTree: new tree for tcType " << tcTypeName <<
" created, m_treeBox has now " <<
119 B2WARNING(
"RootParameterTracker::prepareTTree: ttree for tcType " << tcTypeName <<
" is reused, m_treeBox has " <<
m_treeBox.size()
147 void initialize(std::string fileName, std::string fileTreatment)
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!");
155 B2FATAL(
"RootParameterTracker::initialize(), there was a file already linked to this ParameterTracker, which is invalid, please read the documentation!");
157 B2DEBUG(20,
"RootParameterTracker::initialize(), given parameters are fileName/fileTreatment: " << fileName <<
"/" <<
159 m_file =
new TFile(fileName.c_str(), fileTreatment.c_str());
192 B2DEBUG(21,
"RootParameterTracker::collectData(), size of given tcVector is: " << tcVector.size());
196 B2DEBUG(22,
"RootParameterTracker::collectData(), executing TC of type: " << tcTypeName);
208 B2DEBUG(21,
"RootParameterTracker::fillRoot(), Executing " <<
m_treeBox.size() <<
" ttrees.");
214 int nBytesWritten = boxEntry.second->Fill();
215 B2DEBUG(20,
"RootParameterTracker::fillRoot() ttree " << boxEntry.first <<
" got " << nBytesWritten <<
" Bytes written");
220 for (
auto& algoPack : algoData2tcType.second) {
221 algoPack.second.second->clear();
226 for (
auto& algoPack : algoData2tcType.second) {
227 algoPack.second.second->clear();
232 for (
auto& algoPack : algoData2tcType.second) {
233 algoPack.second.second->clear();
242 B2DEBUG(20,
"RootParameterTracker::terminate(), Writing results to root-file and clean up heap.");
244 B2WARNING(
"RootParameterTracker::terminate(): no rootFile found! skipping writing data into root file!");
252 boxEntry.second->Write();
255 B2DEBUG(20,
"RootParameterTracker::terminate(), TTree " << boxEntry.first <<
" was written:");
262 for (
auto& algoPack : algoData2tcType.second) {
263 delete algoPack.second.first;
264 delete algoPack.second.second;
269 for (
auto& algoPack : algoData2tcType.second) {
270 delete algoPack.second.first;
271 delete algoPack.second.second;
276 for (
auto& algoPack : algoData2tcType.second) {
277 delete algoPack.second.first;
278 delete algoPack.second.second;
simple class storing infos relevant for a TC for analyzing it.
Base class for storing an algorithm determining the data one wants to have.
Minimal container storing a pair of < KeyType, ValueType>
@ c_Debug
Debug: for code development.
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Production notes for RootParameterTracker:
AlgoDataBox< int > m_algoDataInt
contains all algorithms and its data storing one int per TC
void addParameters4DoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one double per TC:
StringKeyBox< TTree * > m_treeBox
contains all the trees for rootFile-filling later-on.
void addParameters4VecDoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one vector of double per TC:
void terminate()
final cleanup and closing rootFile
RootParameterTracker()
constructor setting standard values
void fillRoot()
fills tree/branches with their stuff, clear intermediate results afterwards
void initialize(std::string fileName, std::string fileTreatment)
creates rootFile, first parameter is fileName, second one specifies how the file shall be treated.
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 addParameters4IntAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one int per TC:
TFile * m_file
stores pointer to file
TTree * prepareTTree(std::string tcTypeName)
checks if ttree for given tcTypeName exists and creates it if not.
void collectData4VecDoubleAlgorithms(std::string tcTypeName, const AnalizerTCInfo &aTC)
takes aTC with tcTypeName and applies the algorithms for it
void collectData(const std::vector< AnalizerTCInfo > &tcVector)
take vector and fill for each tcType stored in rootParameterTracker
AlgoDataBox< std::vector< double > > m_algoDataVecDouble
contains all algorithms and its data storing one vector of double per TC
AlgoDataBox< double > m_algoDataDouble
contains all algorithms and its data storing one double per TC
static std::string getTypeName(TCType::Type type)
for given TCType the corresponding string-name will be returned.
Abstract base class for different kinds of events.