 |
Belle II Software
release-05-02-19
|
13 #include <tracking/trackFindingVXD/analyzingTools/AnalizerTCInfo.h>
14 #include <tracking/trackFindingVXD/analyzingTools/AnalyzingAlgorithmFactory.h>
15 #include <tracking/trackFindingVXD/analyzingTools/KeyValBox.h>
17 #include <framework/logging/Logger.h>
51 class RootParameterTracker {
55 template<
class ValueType>
using StringKeyBox = KeyValBox<std::string, ValueType>;
102 B2FATAL(
"RootParameterTracker::prepareTTree(), Root file not initialized yet! Please call RootParameterTracker::initialize(...) first!");
108 TTree** tree4tcType =
m_treeBox.find(tcTypeName);
109 if (tree4tcType == NULL) {
112 new TTree(tcTypeName.c_str(), (std::string(
"collects data collected to tcType ") + tcTypeName).c_str())
115 tree4tcType =
m_treeBox.find(tcTypeName);
116 B2WARNING(
"RootParameterTracker::prepareTTree: new tree for tcType " << tcTypeName <<
" created, m_treeBox has now " <<
121 B2WARNING(
"RootParameterTracker::prepareTTree: ttree for tcType " << tcTypeName <<
" is reused, m_treeBox has " <<
m_treeBox.size()
149 void initialize(std::string fileName, std::string fileTreatment)
151 if (fileTreatment != std::string(
"RECREATE") and fileTreatment != std::string(
"UPDATE")) {
152 B2FATAL(
"RootParameterTracker::initialize(), specified fileTreatment is " << fileTreatment <<
153 ", which is invalid, please read the documentation!");
157 B2FATAL(
"RootParameterTracker::initialize(), there was a file already linked to this ParameterTracker, which is invalid, please read the documentation!");
159 B2DEBUG(5,
"RootParameterTracker::initialize(), given parameters are fileName/fileTreatment: " << fileName <<
"/" <<
161 m_file =
new TFile(fileName.c_str(), fileTreatment.c_str());
185 void collectData(
const std::vector<AnalizerTCInfo>& tcVector)
194 B2DEBUG(15,
"RootParameterTracker::collectData(), size of given tcVector is: " << tcVector.size());
196 for (
const AnalizerTCInfo& tc : tcVector) {
198 B2DEBUG(50,
"RootParameterTracker::collectData(), executing TC of type: " << tcTypeName);
210 B2DEBUG(15,
"RootParameterTracker::fillRoot(), Executing " <<
m_treeBox.size() <<
" ttrees.");
216 int nBytesWritten = boxEntry.second->Fill();
217 B2DEBUG(20,
"RootParameterTracker::fillRoot() ttree " << boxEntry.first <<
" got " << nBytesWritten <<
" Bytes written");
222 for (
auto& algoPack : algoData2tcType.second) {
223 algoPack.second.second->clear();
228 for (
auto& algoPack : algoData2tcType.second) {
229 algoPack.second.second->clear();
234 for (
auto& algoPack : algoData2tcType.second) {
235 algoPack.second.second->clear();
244 B2DEBUG(2,
"RootParameterTracker::terminate(), Writing results to root-file and clean up heap.");
246 B2WARNING(
"RootParameterTracker::terminate(): no rootFile found! skipping writing data into root file!");
254 boxEntry.second->Write();
257 B2DEBUG(5,
"RootParameterTracker::terminate(), TTree " << boxEntry.first <<
" was written:");
264 for (
auto& algoPack : algoData2tcType.second) {
265 delete algoPack.second.first;
266 delete algoPack.second.second;
271 for (
auto& algoPack : algoData2tcType.second) {
272 delete algoPack.second.first;
273 delete algoPack.second.second;
278 for (
auto& algoPack : algoData2tcType.second) {
279 delete algoPack.second.first;
280 delete algoPack.second.second;
void collectData4DoubleAlgorithms(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.
void fillRoot()
fills tree/branches with their stuff, clear intermediate results afterwards
Minimal container storing a pair of < KeyType, ValueType>
KeyValBox< std::string, ValueType > StringKeyBox
short-cut since strings are always used as keys here:
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
TTree * prepareTTree(std::string tcTypeName)
checks if ttree for given tcTypeName exists and creates it if not.
TFile * m_file
stores pointer to file
Abstract base class for different kinds of events.
void collectData(const std::vector< AnalizerTCInfo > &tcVector)
take vector and fill for each tcType stored in rootParameterTracker
void addParameters4IntAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one int per TC:
AlgoDataBox< double > m_algoDataDouble
contains all algorithms and its data storing one double per TC
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
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
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:
@ c_Debug
Debug: for code development.
StringKeyBox< TTree * > m_treeBox
contains all the trees for rootFile-filling later-on.
RootParameterTracker()
constructor setting standard values
Base class for storing an algorithm determining the data one wants to have.
void initialize(std::string fileName, std::string fileTreatment)
creates rootFile, first parameter is fileName, second one specifies how the file shall be treated.
AlgoDataBox< std::vector< double > > m_algoDataVecDouble
contains all algorithms and its data storing one vector of double per TC