1 #ifndef GAUDISVC_THISTSVC_ICC 2 #define GAUDISVC_THISTSVC_ICC 4 #ifndef GAUDIKERNEL_MSGSTREAM_H 25 error() <<
"Badly formed identifier \"" << idr <<
"\": " 26 <<
"Must not end with a /" <<
endmsg;
34 error() <<
"Could not register id: \"" << idr <<
"\"" 42 error() <<
"already registered an object with identifier \"" 52 debug() <<
"Historgram with id \"" << idr <<
"\" is temporary" 57 TObject *to =
nullptr;
64 warning() <<
"Registering id: \"" << idr
65 <<
"\" with non zero pointer!" <<
endmsg;
72 to =
dynamic_cast<TObject*
>(hist);
75 }
else if (hist == 0) {
76 error() <<
"Unable to read in hist with id: \"" 82 to =
dynamic_cast<TObject*
>(hist);
84 error() <<
"Could not dcast to TObject. id: \"" << idr
91 error() <<
"already registered id: \"" << idr
92 <<
"\" with identifier \"" << oitr->second.id <<
"\"" <<
endmsg;
99 if ( dynamic_cast<TTree*>(hist) ) {
100 dynamic_cast<TTree*
>(hist)->SetDirectory(dir);
101 }
else if ( dynamic_cast<TH1*>(hist) ) {
102 dynamic_cast<TH1*
>(hist)->SetDirectory(dir);
103 }
else if ( dynamic_cast<TGraph*>(hist) ) {
106 error() <<
"id: \"" << idr
107 <<
"\" is not a TH, TTree, or TGraph. Attaching it to current dir." 118 fname = f->GetName();
123 <<
" title: \"" << hist->GetTitle()
124 <<
"\" id: \"" << uid <<
"\" dir: " 127 <<
" file: " << fname
140 template <
typename T>
150 if (idr.
find(
"/") == 0) {
154 error() <<
"Could not locate Hist with id \"" << idr <<
"\"" 163 hist =
dynamic_cast<T*
>(hid.
obj);
165 error() <<
"dcast failed, Hist id: \"" << idr <<
"\"" 170 verbose() <<
"found unique Hist title: \"" 172 <<
"\" id: \"" << idr <<
"\"" <<
endmsg;
176 verbose() <<
"found unique Hist id: \"" << idr
177 <<
"\" type: \"" << hid.
obj->IsA()->GetName() <<
"\"" 191 if (mitr.first == mitr.second) {
192 error() <<
"Could not locate Hist with id \"" << idr <<
"\"" 198 if (distance(mitr.first,mitr.second) == 1) {
199 THistID hid = mitr.first->second;
201 hist =
dynamic_cast<T*
>(hid.
obj);
207 verbose() <<
"found Hist title: \"" << hist->GetTitle()
208 <<
"\" id: \"" << idr <<
"\"" <<
endmsg;
212 verbose() <<
"found Hist id: \"" << idr <<
"\" type: \"" 213 << hid.
obj->IsA()->GetName() <<
"\"" 221 error() <<
"Multiple matches with id \"" << idr <<
"\"." 222 <<
" Further specifications required." 228 info() <<
"Found multiple matches with id \"" << idr
240 template <
typename T>
266 while ( (dir=
dirname(fdir)) !=
"" ) {
267 if (! gDirectory->GetKey(dir.
c_str())) {
268 error() <<
"Directory \"" << fdir2 <<
"\" doesnt exist in " 269 << file->GetName() <<
endmsg;
272 gDirectory->cd(dir.
c_str());
276 gDirectory->GetObject(fdir.
c_str(), to);
279 error() <<
"Could not get obj \"" << fdir <<
"\" in " 280 << gDirectory->GetPath() <<
endmsg;
286 hist =
dynamic_cast<T*
>(to);
288 error() <<
"Could not convert \"" << idr <<
"\" to a " 290 << to->IsA()->GetName()
297 debug() <<
"Read in " << hist->IsA()->GetName() <<
" \"" 298 << hist->GetName() <<
"\" from file " 299 << file->GetName() <<
endmsg;
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
TDirectory * changeDir(const THistSvc::THistID &hid) const
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
std::string dirname(std::string &dir) const
This class is used for returning status codes from appropriate routines.
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
StatusCode regHist_i(T *hist, const std::string &name)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
StatusCode readHist_i(const std::string &name, T *&hist) const
std::map< std::string, std::pair< TFile *, Mode > > m_files
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void removeDoubleSlash(std::string &) const