8 #include <tracking/trackFindingCDC/mva/Recorder.h> 
   11 #include <framework/datastore/StoreObjPtr.h> 
   12 #include <framework/pcore/RootMergeable.h> 
   25   namespace TrackFindingCDC {
 
   35       Impl(
const std::function<
void(TTree&)>& setBranches,
 
   36            const std::string& rootFileName,
 
   37            const std::string& treeName = 
"recorded_tree");
 
   60 #include <framework/datastore/DataStore.h> 
   61 #include <framework/pcore/ProcHandler.h> 
   67 using namespace TrackFindingCDC;
 
   70                      const std::string& rootFileName,
 
   71                      const std::string& treeName)
 
   73   , m_tTree(treeName, 
DataStore::c_Persistent)
 
   75   TDirectory* ptrSavedCurrentTDirectory = gDirectory;
 
   77   m_tFile = 
new TFile(rootFileName.c_str(), 
"RECREATE");
 
   81   m_tTree.construct(treeName.c_str(), treeName.c_str());
 
   87   if (ptrSavedCurrentTDirectory) {
 
   88     ptrSavedCurrentTDirectory->cd();
 
   98       m_tTree->get().SetDirectory(
nullptr);
 
  112       TDirectory* ptrSavedCurrentTDirectory = gDirectory;
 
  114       TFile* tFile = m_tTree->get().GetCurrentFile();
 
  118         m_tTree->get().Write(
"", TObject::kOverwrite);
 
  119         m_tTree->get().SetDirectory(
nullptr);
 
  122       if (ptrSavedCurrentTDirectory) {
 
  123         ptrSavedCurrentTDirectory->cd();
 
  134   m_tTree->get().Fill();
 
  140                    const std::string& rootFileName,
 
  141                    const std::string& treeName)
 
  142   : 
m_impl(std::make_unique<
Impl>(setBranches, rootFileName, treeName))
 
  147                    const std::string& rootFileName,
 
  148                    const std::string& treeName) :
 
  149   Recorder([ & namedVariables](TTree & tree)
 
  152     std::string name = namedVariable.getName();
 
  153     Float_t* variable = namedVariable;
 
  154     tree.Branch(name.c_str(), variable);
 
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).
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.
Type-safe access to single objects in the data store.
Record the MVA variables.
~Impl()
Destructor finalising the tree.
TFile * m_tFile
Reference to the open TFile.
Impl(const std::function< void(TTree &)> &setBranches, const std::string &rootFileName, const std::string &treeName="recorded_tree")
Constructor creating the TFile and TTree as well as setting up the branches with the given function.
void capture()
Capture the registered variable values and write them out.
void write()
Write all captured variables to disk.
StoreObjPtr< RootMergeable< TTree > > m_tTree
Reference to the TTree.
Class to fill a tree from a set of variables.
Recorder(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...
std::unique_ptr< Impl > m_impl
Pointer to implementation hiding the details.
void capture()
Capture the registered variable values and write them out.
void write()
Write all captured variables to disk.
~Recorder()
Destructor writing the TTree and closing the ROOT File.
Abstract base class for different kinds of events.