Belle II Software  release-08-01-10
RootParameterTracker Class Reference

Production notes for RootParameterTracker: More...

#include <RootParameterTracker.h>

Collaboration diagram for RootParameterTracker:

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. More...
 
void addParameters4DoubleAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one double per TC: More...
 
void addParameters4IntAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one int per TC: More...
 
void addParameters4VecDoubleAlgorithms (std::string tcTypeName, std::string algorithmName)
 relevant for all algorithms storing one vector of double per TC: More...
 
void collectData (const std::vector< AnalizerTCInfo > &tcVector)
 take vector and fill for each tcType stored in rootParameterTracker More...
 
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. More...
 

Protected Member Functions

TTree * prepareTTree (std::string tcTypeName)
 checks if ttree for given tcTypeName exists and creates it if not. More...
 
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. More...
 
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.

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.

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.

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.

◆ 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.

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.

◆ 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

◆ 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.

◆ 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.

Member Data Documentation

◆ 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: