10 #include <tracking/trackFindingVXD/analyzingTools/RootParameterTracker.h>
17 void RootParameterTracker::collectData4DoubleAlgorithms(std::string tcTypeName,
const AnalizerTCInfo& aTC)
19 auto* foundTCTypeData = m_algoDataDouble.find(tcTypeName);
22 if (foundTCTypeData == NULL) {
return; }
25 for (
auto& entry : *foundTCTypeData) {
27 auto* anAlgorithm = entry.second.first;
28 auto* dataVector = entry.second.second;
30 string algoName = anAlgorithm->getIDName();
31 if (entry.first != algoName) {
32 B2ERROR(
"RootParameterTracker::collectData4DoubleAlgorithms() key (" << entry.first <<
33 ") of container does not match to its content (" << algoName <<
34 ") - skipping entry! ");
37 B2DEBUG(50,
"RootParameterTracker::collectData4DoubleAlgorithms(), executing algorithm of type: " << algoName <<
38 " with collected data-entries of " << dataVector->size());
41 double calcVal = anAlgorithm->calcData(aTC);
42 dataVector->push_back(calcVal);
43 B2DEBUG(20,
"RootParameterTracker::collectData4DoubleAlgorithms(), tc with type " << tcTypeName <<
44 " and applied algorithm " << algoName <<
45 " and got " << calcVal <<
" as a result!");
47 B2WARNING(
"RootParameterTracker::collectData4DoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
48 " and applied algorithm " << algoName <<
49 ". Failed with exception: " << anException.what() <<
60 void RootParameterTracker::collectData4IntAlgorithms(std::string tcTypeName,
const AnalizerTCInfo& aTC)
62 auto* foundTCTypeData = m_algoDataInt.find(tcTypeName);
65 if (foundTCTypeData == NULL) {
return; }
68 for (
auto& entry : *foundTCTypeData) {
70 auto* anAlgorithm = entry.second.first;
71 auto* dataVector = entry.second.second;
73 string algoName = anAlgorithm->getIDName();
74 if (entry.first != algoName) {
75 B2ERROR(
"RootParameterTracker::collectData4DoubleAlgorithms() key (" << entry.first <<
76 ") of container does not match to its content (" << algoName <<
77 ") - skipping entry! ");
80 B2DEBUG(50,
"RootParameterTracker::collectData4DoubleAlgorithms(), executing algorithm of type: " << algoName <<
81 " with collected data-entries of " << dataVector->size());
84 int calcVal = anAlgorithm->calcData(aTC);
85 dataVector->push_back(calcVal);
86 B2DEBUG(20,
"RootParameterTracker::collectData4DoubleAlgorithms(), tc with type " << tcTypeName <<
87 " and applied algorithm " << algoName <<
88 " and got " << calcVal <<
" as a result!");
90 B2WARNING(
"RootParameterTracker::collectData4DoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
91 " and applied algorithm " << algoName <<
92 ". Failed with exception: " << anException.what() <<
103 void RootParameterTracker::collectData4VecDoubleAlgorithms(std::string tcTypeName,
const AnalizerTCInfo& aTC)
105 auto* foundTCTypeData = m_algoDataVecDouble.find(
109 if (foundTCTypeData == NULL) {
return; }
112 for (
auto& entry : *foundTCTypeData) {
114 auto* anAlgorithm = entry.second.first;
115 auto* dataVector = entry.second.second;
117 string algoName = anAlgorithm->getIDName();
118 if (entry.first != algoName) {
119 B2ERROR(
"RootParameterTracker::collectData4VecDoubleAlgorithms() key (" << entry.first <<
120 ") of container does not match to its content (" << algoName <<
121 ") - skipping entry! ");
124 B2DEBUG(50,
"RootParameterTracker::collectData4VecDoubleAlgorithms(), executing algorithm of type: " << algoName <<
125 " with collected data-entries of " << dataVector->size());
128 vector<double> calcVal = anAlgorithm->calcData(aTC);
129 dataVector->push_back(calcVal);
130 auto printVec = [&]() ->
string {
132 for (
double val : calcVal)
134 out += (
" " + to_string(val));
136 return (out +=
"\n");
138 B2DEBUG(20,
"RootParameterTracker::collectData4VecDoubleAlgorithms(), tc with type " << tcTypeName <<
139 " and applied algorithm " << algoName <<
140 " and got: " << printVec() <<
143 B2WARNING(
"RootParameterTracker::collectData4VecDoubleAlgorithms(), Exception caught for tc with type " << tcTypeName <<
144 " and applied algorithm " << algoName <<
145 ". Failed with exception: " << anException.what() <<
158 void RootParameterTracker::addParameters4DoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
181 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), given parameters are tcTypeName/algorithmName: " << tcTypeName
185 TTree* tree4tcType = prepareTTree(tcTypeName);
188 auto* algorithms4tcType = m_algoDataDouble.find(tcTypeName);
189 if (algorithms4tcType == NULL) {
190 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), tcType " << tcTypeName <<
191 " not yet added to m_algoDataDouble, doing it now...");
192 m_algoDataDouble.push_back({
196 algorithms4tcType = m_algoDataDouble.find(tcTypeName);
198 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataDouble has " << m_algoDataDouble.size() <<
202 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
203 if (data4AlgorithmOftcType == NULL) {
204 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), algorithm " << algorithmName <<
205 " not yet added to m_algoDataDouble[tcType], doing it now...");
207 (AlgoritmType::getTypeEnum(algorithmName));
208 algorithms4tcType->push_back({
215 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
218 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
219 if (newBranch == NULL) B2ERROR(
"Could not create Branch " << algorithmName);
222 B2WARNING(
"RootParameterTracker::addParameters4DoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
223 "/" << algorithmName <<
224 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
226 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataDouble[tcType] has " << algorithms4tcType->size() <<
227 " algorithms stored");
237 void RootParameterTracker::addParameters4IntAlgorithms(std::string tcTypeName, std::string algorithmName)
239 B2DEBUG(5,
"RootParameterTracker::addParameters4IntAlgorithms(), given parameters are tcTypeName/algorithmName: " << tcTypeName <<
243 TTree* tree4tcType = prepareTTree(tcTypeName);
246 auto* algorithms4tcType = m_algoDataInt.find(tcTypeName);
247 if (algorithms4tcType == NULL) {
248 B2DEBUG(5,
"RootParameterTracker::addParameters4IntAlgorithms(), tcType " << tcTypeName <<
249 " not yet added to m_algoDataInt, doing it now...");
250 m_algoDataInt.push_back({
254 algorithms4tcType = m_algoDataInt.find(tcTypeName);
256 B2DEBUG(5,
"RootParameterTracker::addParameters4IntAlgorithms(), m_algoDataInt has " << m_algoDataInt.size() <<
" tcTypes stored");
259 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
260 if (data4AlgorithmOftcType == NULL) {
261 B2DEBUG(5,
"RootParameterTracker::addParameters4IntAlgorithms(), algorithm " << algorithmName <<
262 " not yet added to m_algoDataInt[tcType], doing it now...");
263 AnalyzingAlgorithm<int>* newAlgorithm = AnalyzingAlgorithmFactoryInt<int, AnalizerTCInfo, TVector3>(AlgoritmType::getTypeEnum(
265 algorithms4tcType->push_back({
272 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
275 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
276 if (newBranch == NULL) B2ERROR(
"Could not create Branch " << algorithmName);
279 B2WARNING(
"RootParameterTracker::addParameters4DoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
280 "/" << algorithmName <<
281 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
283 B2DEBUG(5,
"RootParameterTracker::addParameters4DoubleAlgorithms(), m_algoDataInt[tcType] has " << algorithms4tcType->size() <<
284 " algorithms stored");
294 void RootParameterTracker::addParameters4VecDoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
296 B2DEBUG(5,
"RootParameterTracker::addParameters4VecDoubleAlgorithms(), given parameters are tcTypeName/algorithmName: " <<
300 TTree* tree4tcType = prepareTTree(tcTypeName);
303 auto* algorithms4tcType = m_algoDataVecDouble.find(tcTypeName);
304 if (algorithms4tcType == NULL) {
305 B2DEBUG(5,
"RootParameterTracker::addParameters4VecDoubleAlgorithms(), tcType " << tcTypeName <<
306 " not yet added to m_algoDataVecDouble, doing it now...");
307 m_algoDataVecDouble.push_back({
311 algorithms4tcType = m_algoDataVecDouble.find(tcTypeName);
313 B2DEBUG(5,
"RootParameterTracker::addParameters4VecDoubleAlgorithms(), m_algoDataVecDouble has " << m_algoDataVecDouble.size() <<
317 auto* data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
318 if (data4AlgorithmOftcType == NULL) {
319 B2DEBUG(5,
"RootParameterTracker::addParameters4VecDoubleAlgorithms(), algorithm " << algorithmName <<
320 " not yet added to m_algoDataVecDouble[tcType], doing it now...");
322 (AlgoritmType::getTypeEnum(algorithmName));
323 algorithms4tcType->push_back({
327 new vector<vector<double>>()
330 data4AlgorithmOftcType = algorithms4tcType->find(algorithmName);
333 auto* newBranch = tree4tcType->Branch(algorithmName.c_str(), data4AlgorithmOftcType->second);
334 if (newBranch == NULL) B2ERROR(
"Could not create Branch " << algorithmName);
337 B2WARNING(
"RootParameterTracker::addParameters4VecDoubleAlgorithms() given tcTypeName/algorithmName: " << tcTypeName <<
338 "/" << algorithmName <<
339 " was already added and will not be added again. This is a sign for unintended behavior - nothing will be added!");
341 B2DEBUG(5,
"RootParameterTracker::addParameters4VecDoubleAlgorithms(), m_algoDataVecDouble[tcType] has " <<
342 algorithms4tcType->size() <<
" algorithms stored");