14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/pcore/RootMergeable.h>
16#include <framework/pcore/ProcHandler.h>
17#include <tracking/trackFindingVXD/utilities/Named.h>
46 const std::string& rootFileName,
47 const std::string& treeName =
"recorded_tree") :
51 TDirectory* ptrSavedCurrentTDirectory = gDirectory;
53 m_tFile =
new TFile(rootFileName.c_str(),
"RECREATE");
57 m_tTree.construct(treeName.c_str(), treeName.c_str());
62 if (ptrSavedCurrentTDirectory) {
63 ptrSavedCurrentTDirectory->cd();
80 const std::string& treeName) :
83 for (
auto& variable : namedVariables) {
84 tree.Branch(variable.getName().c_str(), variable.getValue());
86 }, fileName, treeName)
94 m_tTree->get().SetDirectory(
nullptr);
120 TDirectory* tmpDirectory = gDirectory;
122 TFile* tFile =
m_tTree->get().GetCurrentFile();
126 m_tTree->get().Write(
"", TObject::kOverwrite);
127 m_tTree->get().SetDirectory(
nullptr);
In the store you can park objects that have to be accessed by various modules.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
A mixin class to attach a name to an object. Based on class with same name in CDC package.
static bool isOutputProcess()
Return true if the process is an output process.
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
Class to write collected variables into a root file, Used by VXDQETrainingDataCollectorModule.
TFile * m_tFile
ROOT file to which should be written.
SimpleVariableRecorder & operator=(SimpleVariableRecorder &)=delete
assignment operator ("=") needs to be implemented if needed as class has dynamic memory/resource allo...
SimpleVariableRecorder(const std::function< void(TTree &)> &setBranches, const std::string &rootFileName, const std::string &treeName="recorded_tree")
Construct the Recorder opening the given ROOT file and create the underlying TTree and add let the gi...
SimpleVariableRecorder(std::vector< Named< float * > > &namedVariables, const std::string &fileName, const std::string &treeName)
Construct the Recorder opening the given ROOT file and create the underlying TTree and add let the gi...
void write()
Write out TFile to root file.
SimpleVariableRecorder(SimpleVariableRecorder &)=delete
copy constructor needs to be implemented if needed as class has dynamic memory/resource allocation (a...
~SimpleVariableRecorder()
Destructor that closes used TTrees and TFiles.
void record()
Record variables by filling the TTree.
StoreObjPtr< RootMergeable< TTree > > m_tTree
TTree that contains recorded variables.
Type-safe access to single objects in the data store.
Abstract base class for different kinds of events.