ROOTHelpers.h
Go to the documentation of this file.
1 /*
2  * ROOTHelpers.h
3  *
4  * Helper functions convenient in ROOT macros
5  *
6  * Created on: Jan 18, 2018
7  * Author: J. Wolcott <jwolcott@fnal.gov>
8  */
9 
10 #ifndef UTILITIES_FUNC_ROOTHELPERS_H_
11 #define UTILITIES_FUNC_ROOTHELPERS_H_
12 
13 #include <string>
14 #include <vector>
15 
16 #include "TObject.h"
17 
18 namespace util
19 {
20 
21  inline void SaveObj(const TObject * obj,
22  const std::string & filenameStub,
23  const std::string & dirName="",
24  const std::vector<std::string> exts = {".png", ".eps", ".root"},
25  bool silent=false)
26  {
27  std::string fullFname = (dirName.size() ? (dirName + "/") : "") + filenameStub;
28  auto prevOutputFlag = gErrorIgnoreLevel;
29  if (silent)
30  gErrorIgnoreLevel = kWarning;
31  for (const auto & ext : exts)
32  obj->SaveAs( (fullFname + ext).c_str() );
33  if (silent)
34  gErrorIgnoreLevel = prevOutputFlag;
35  }
36 
37 }
38 #endif /* UTILITIES_FUNC_ROOTHELPERS_H_ */
Filter events based on their run/event numbers.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void SaveObj(const TObject *obj, const std::string &filenameStub, const std::string &dirName="", const std::vector< std::string > exts={".png",".eps",".root"}, bool silent=false)
Definition: ROOTHelpers.h:21