6 #include <boost/shared_ptr.hpp>
9 #include <TDirectory.h>
18 class ROOTContextSentinel {
20 ROOTContextSentinel() :
dir(gDirectory),
file(gFile) {}
21 ~ROOTContextSentinel() { gDirectory =
dir; gFile =
file; }
30 namespace PhysicsTools {
34 ROOTContextSentinel ctx;
36 rootFile.reset(TFile::Open(fileName.c_str(),
"RECREATE"));
45 ROOTContextSentinel ctx;
47 typedef std::map<std::string, boost::shared_ptr<Module> > Map;
48 for(Map::const_iterator iter =
modules.begin();
49 iter !=
modules.end(); ++iter) {
51 TDirectory *
dir =
rootFile->mkdir(iter->first.c_str());
53 iter->second->write(dir);
67 typedef std::map<std::string, boost::shared_ptr<Object> > Map;
68 for(Map::const_iterator iter =
data.begin();
69 iter !=
data.end(); ++iter)
70 iter->second->write(dir);
75 boost::shared_ptr<Object> ptr(
object);
76 if (!
data.insert(std::make_pair(object->
getName(), ptr)).second)
78 <<
"Node \"" <<
object->getName() <<
"\" already"
79 " exists." << std::endl;
85 if (!
modules.insert(std::make_pair(name, module)).second)
87 <<
"Module \"" << name <<
"\" already"
88 " exists." << std::endl;