Service to create a root-based D3PD.
More...
#include <RootD3PDSvc.h>
|
static void | cleanup () |
| Make sure all files are closed before exiting, to prevent crashes. More...
|
|
Service to create a root-based D3PD.
Definition at line 37 of file RootD3PDSvc.h.
◆ RootD3PDSvc() [1/2]
D3PD::RootD3PDSvc::RootD3PDSvc |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svcloc |
|
) |
| |
Constructor.
- Parameters
-
name | Service name. |
svcloc | Service locator. |
Definition at line 32 of file RootD3PDSvc.cxx.
34 : base_class (
name, svcloc),
42 declareProperty (
"MasterTree",
m_masterTree =
"CollectionTree");
43 declareProperty (
"IndexMajor",
m_indexMajor =
"RunNumber");
44 declareProperty (
"IndexMinor",
m_indexMinor =
"EventNumber");
48 "Value to set for ROOT's AutoFlush parameter. "
49 "(Tells how often the tree baskets will be flushed.) "
50 "0 disables flushing. "
51 "-1 (default) makes no changes to what THistSvc did. "
52 "Any other negative number gives the number of bytes "
53 "after which to flush. "
54 "A positive number gives the number of entries after which "
57 "Variable names allowed in the output D3PDs. An empty list "
58 "means that all variable names are allowed. Regular expressions "
61 "Variable names that are not allowed to end up in the "
62 "created D3PDs. Regular expressions are allowed.");
◆ RootD3PDSvc() [2/2]
◆ cleanup()
void D3PD::RootD3PDSvc::cleanup |
( |
| ) |
|
|
staticprivate |
Make sure all files are closed before exiting, to prevent crashes.
Root files are normally closed by THistSvc::finalize().
However, if we get an error during initialization, then the program will exit without running the finalize() methods. In that case, the root files will get closed when global destructors are run. But by that time, some of the root objects needed to perform the close may have already been deleted, leading to a crash.
To avoid this, we register this method with atexit(); we just loop through all existing root files and try to close them all.
Definition at line 80 of file RootD3PDSvc.cxx.
84 TIter
it (gROOT->GetListOfFiles());
85 while (TObject* o =
it.Next()) {
86 if (TFile*
f =
dynamic_cast<TFile*
> (o))
◆ finalize()
StatusCode D3PD::RootD3PDSvc::finalize |
( |
| ) |
|
|
overridevirtual |
◆ initialize()
StatusCode D3PD::RootD3PDSvc::initialize |
( |
| ) |
|
|
overridevirtual |
Standard Gaudi initialize method.
Definition at line 95 of file RootD3PDSvc.cxx.
99 return StatusCode::SUCCESS;
◆ make()
StatusCode D3PD::RootD3PDSvc::make |
( |
const std::string & |
name, |
|
|
ID3PD *& |
d3pd |
|
) |
| |
|
overridevirtual |
Create a new D3PD tree.
- Parameters
-
name | The name of the new tree. If the name contains a slash, it is interpreted as STREAM/NAME. If the stream name contains a colon, then the part of the name before the colon is the ‘parent’ stream name; this is used to locate the master tree. |
d3pd[out] | The created tree. |
name | The name of the new tree. If the name contains a slash, it is interpreted as STREAM/NAME. If the stream name is of the form ‘pool:FILE’, then this is a request to put the new tree in the given pool file. If the the stream name otherwise contains a colon, then the part of the name before the colon is the ‘parent’ stream name; this is used to locate the master tree. |
d3pd[out] | The created tree. |
Definition at line 175 of file RootD3PDSvc.cxx.
177 std::string tname =
name;
178 std::string::size_type ipos =
name.rfind (
'/');
180 std::string poolfile;
181 if (ipos != std::string::npos) {
182 tname =
name.substr (ipos+1);
184 std::string sname =
name.substr (0, ipos+1);
185 std::string::size_type jpos = sname.find (
':');
186 if (sname.substr (0, jpos) ==
"pool" ||
187 sname.substr (0, jpos) ==
"/pool")
189 poolfile = sname.substr (jpos+1, std::string::npos);
190 if (!poolfile.empty() && poolfile[poolfile.size()-1] ==
'/')
191 poolfile.erase (poolfile.size()-1);
194 if (jpos != std::string::npos){
195 sname.erase(jpos,sname.size()-jpos-1);
201 TTree*
tree =
new TTree (tname.c_str(), tname.c_str());
207 auto rd3pd = std::make_unique<RootD3PD>
212 if (!poolfile.empty())
213 rd3pd->setPoolFile (poolfile);
218 m_d3pds.push_back (std::move (rd3pd));
219 return StatusCode::SUCCESS;
◆ operator=()
◆ stop()
StatusCode D3PD::RootD3PDSvc::stop |
( |
| ) |
|
|
overridevirtual |
Standard Gaudi stop method.
Definition at line 115 of file RootD3PDSvc.cxx.
126 if (!d3pd->master().empty()) {
128 TDirectory*
dir = d3pd->tree()->GetDirectory();
130 dynamic_cast<TTree*
> (
dir->Get (d3pd->master().c_str()));
131 if (!
master && d3pd->tree()->GetEntries() > 0)
135 if (!
master->GetTreeIndex()) {
138 master->ResetBranchAddresses();
144 master->AddFriend (d3pd->tree());
149 TDirectory::TContext ctx (
gDirectory, d3pd->tree()->GetDirectory());
150 d3pd->tree()->Write();
158 return StatusCode::SUCCESS;
◆ m_allowedNames
std::vector< std::string > D3PD::RootD3PDSvc::m_allowedNames |
|
private |
◆ m_autoFlush
long long D3PD::RootD3PDSvc::m_autoFlush |
|
private |
Property: Value to set for ROOT's AutoFlush parameter.
(Tells how often the tree baskets will be flushed.) 0 disables flushing. -1 (default) makes no changes to what THistSvc did. Any other negative number gives the number of bytes after which to flush. A positive number gives the number of entries after which to flush.
Definition at line 101 of file RootD3PDSvc.h.
◆ m_basketSize
int D3PD::RootD3PDSvc::m_basketSize |
|
private |
◆ m_d3pds
std::vector<std::unique_ptr<RootD3PD> > D3PD::RootD3PDSvc::m_d3pds |
|
private |
Remember all the tuples we've made.
Definition at line 113 of file RootD3PDSvc.h.
◆ m_doBranchRef
bool D3PD::RootD3PDSvc::m_doBranchRef |
|
private |
◆ m_entryOffsetLen
int D3PD::RootD3PDSvc::m_entryOffsetLen |
|
private |
◆ m_histSvc
◆ m_indexMajor
std::string D3PD::RootD3PDSvc::m_indexMajor |
|
private |
◆ m_indexMinor
std::string D3PD::RootD3PDSvc::m_indexMinor |
|
private |
◆ m_masterTree
std::string D3PD::RootD3PDSvc::m_masterTree |
|
private |
Property: Name of the master tree.
If set, then this tree will be made a friend of the master. The master tree will also get an index built.
Definition at line 82 of file RootD3PDSvc.h.
◆ m_vetoedNames
std::vector< std::string > D3PD::RootD3PDSvc::m_vetoedNames |
|
private |
The documentation for this class was generated from the following files: