All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
icarus::trigger::PlotSandbox::TFileDirectoryHelper Struct Reference

Contains both a art::TFileDirectory and the TDirectory it manages. More...

Public Member Functions

 TFileDirectoryHelper (art::TFileDirectory dir, TDirectory *ROOTdir)
 
template<typename RootDir >
auto create (art::TFileDirectory parentDir, std::string const &subdir, std::string const &dirTitle) -> TFileDirectoryHelper
 

Static Public Member Functions

template<typename RootDir = TDirectoryFile>
static TFileDirectoryHelper create (art::TFileDirectory parentDir, std::string const &subdir, std::string const &dirTitle="")
 Creates a helper managing a subdirectory of parentDir. More...
 
static TFileDirectoryHelper create (art::TFileDirectory dir)
 

Public Attributes

art::TFileDirectory fDir
 
TDirectory * fROOTdir
 

Detailed Description

Contains both a art::TFileDirectory and the TDirectory it manages.

Definition at line 103 of file PlotSandbox.h.

Constructor & Destructor Documentation

icarus::trigger::PlotSandbox::TFileDirectoryHelper::TFileDirectoryHelper ( art::TFileDirectory  dir,
TDirectory *  ROOTdir 
)
inline

Definition at line 107 of file PlotSandbox.h.

Member Function Documentation

template<typename RootDir = TDirectoryFile>
static TFileDirectoryHelper icarus::trigger::PlotSandbox::TFileDirectoryHelper::create ( art::TFileDirectory  parentDir,
std::string const &  subdir,
std::string const &  dirTitle = "" 
)
static

Creates a helper managing a subdirectory of parentDir.

auto icarus::trigger::PlotSandbox::TFileDirectoryHelper::create ( art::TFileDirectory  dir)
static

Definition at line 32 of file PlotSandbox.cxx.

33 {
34 
35  /*
36  * Finding the ROOT directory is going to be tricky, since the interface
37  * includes: `mkdir()`, `make()` and `makeAndRegister()`. Woah.
38  *
39  * So the plan is:
40  * 1. have `art::TFileDirectory` `make()` a new ROOT object in its directory;
41  * let that ROOT object be a `TDirectory`
42  * 2. `TDirectory` is placed by default in the current directory (as usual),
43  * and it knows which its parent directory is
44  * 3. after learning which that parent directory is, we delete the directory
45  * we just created; this also updates the mother directory
46  */
47 
48  static constexpr const char* TestDirName = " PlotSandbox invalid name! ";
49 
50  // even if another directory with this name existed, it would not be replaced,
51  // but rather another one would be created with this name:
52  TDirectory* testDir = dir.make<TDirectory>(TestDirName, TestDirName);
53  if (!testDir) {
54  throw cet::exception("PlotSandbox") << "TFileDirectoryHelper::create() "
55  "failed to figure out the ROOT directory!\n";
56  }
57  TDirectory* pROOTdir = testDir->GetMotherDir();
58  MF_LOG_DEBUG("TFileDirectoryHelper")
59  << "icarus::trigger::PlotSandbox::TFileDirectoryHelper::create(): "
60  << "found parent directory: '" << pROOTdir->GetName() << "'";
61  // ... and even if there are multiple directories with the same name, using
62  // the pointer to the object makes this deletion affect only the object itself
63  delete testDir;
64 
65  return { dir, pROOTdir };
66 } // icarus::trigger::PlotSandbox::TFileDirectoryHelper::create()
tuple dir
Definition: dropbox.py:28
template<typename RootDir >
auto icarus::trigger::PlotSandbox::TFileDirectoryHelper::create ( art::TFileDirectory  parentDir,
std::string const &  subdir,
std::string const &  dirTitle 
) -> TFileDirectoryHelper

Definition at line 620 of file PlotSandbox.h.

625 {
626  // NOTE: we only support a direct subdirectory of parentDir.
627  // NOTE: if the directory already exists the results are undefined;
628  // we can't figure out if the direct
629 
630  // first we create the directory directly via ROOT,
631  // but starting from the directory stored in `parentDir`
632  TDirectory* pROOTdir
633  = parentDir.make<RootDir>(subdir.c_str(), dirTitle.c_str());
634 
635  // then we create a `art::TFileDirectory` for the same directory;
636  // this is the only way we can create a new `art::TFileDirectory`,
637  // and it actually does not create the ROOT directory because it's lazy,
638  // and it will create it only when it is needed, if not present yet.
639  return { parentDir.mkdir(subdir, dirTitle), pROOTdir };
640 
641 } // icarus::trigger::PlotSandbox::TFileDirectoryHelper::create()

Member Data Documentation

art::TFileDirectory icarus::trigger::PlotSandbox::TFileDirectoryHelper::fDir

Definition at line 104 of file PlotSandbox.h.

TDirectory* icarus::trigger::PlotSandbox::TFileDirectoryHelper::fROOTdir

Definition at line 105 of file PlotSandbox.h.


The documentation for this struct was generated from the following files: