1 #ifndef GAUDISVC_THISTSVC_ICC
2 #define GAUDISVC_THISTSVC_ICC
4 #ifndef GAUDIKERNEL_MSGSTREAM_H
24 if (idr.find(
"/") == idr.length()) {
26 <<
"Must not end with a /" <<
endmsg;
32 std::string stream,rem;
39 std::string uid =
"/" + stream +
"/" + rem;
40 uidMap::const_iterator itr =
m_uids.find(uid);
42 m_log <<
MSG::ERROR <<
"already registered an object with identifier \""
52 m_log <<
MSG::DEBUG <<
"Historgram with id \"" << idr <<
"\" is temporary"
61 if (!temp &&
m_files.find(stream)->second.second ==
READ) {
65 <<
"\" with non zero pointer!" <<
endmsg;
72 to =
dynamic_cast<TObject*
>(hist);
75 }
else if (hist == 0) {
82 to =
dynamic_cast<TObject*
>(hist);
89 objMap::const_iterator oitr =
m_tobjs.find(to);
92 <<
"\" with identifier \"" << oitr->second.id <<
"\"" <<
endmsg;
99 if ( dynamic_cast<TTree*>(hist) != 0 ) {
100 dynamic_cast<TTree*
>(hist)->SetDirectory(dir);
101 }
else if ( dynamic_cast<TH1*>(hist) != 0 ) {
102 dynamic_cast<TH1*
>(hist)->SetDirectory(dir);
103 }
else if ( dynamic_cast<TGraph*>(hist) != 0 ) {
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
130 m_ids.insert(std::pair<std::string,THistID>(rem, hid));
140 template <
typename T>
150 if (idr.find(
"/") == 0) {
151 std::map<std::string, THistID>::const_iterator itr =
m_uids.find(
id);
152 if (itr ==
m_uids.end()) {
154 m_log <<
MSG::ERROR <<
"Could not locate Hist with id \"" << idr <<
"\""
163 hist =
dynamic_cast<T*
>(hid.
obj);
172 <<
"\" id: \"" << idr <<
"\"" <<
endmsg;
177 <<
"\" type: \"" << hid.
obj->IsA()->GetName() <<
"\""
188 std::pair< std::multimap<std::string,THistID>::const_iterator,
189 std::multimap<std::string,THistID>::const_iterator > mitr =
m_ids.equal_range(idr);
192 if (mitr.first == mitr.second) {
193 m_log <<
MSG::ERROR <<
"Could not locate Hist with id \"" << idr <<
"\""
199 if (distance(mitr.first,mitr.second) == 1) {
200 THistID hid = mitr.first->second;
202 hist =
dynamic_cast<T*
>(hid.
obj);
209 <<
"\" id: \"" << idr <<
"\"" <<
endmsg;
214 << hid.
obj->IsA()->GetName() <<
"\""
223 <<
" Further specifications required."
241 template <
typename T>
250 std::string stream, rem, dir, fdir, bdir, fdir2;
267 while ( (dir=
dirname(fdir)) !=
"" ) {
268 if (! gDirectory->GetKey(dir.c_str())) {
269 m_log <<
MSG::ERROR <<
"Directory \"" << fdir2 <<
"\" doesnt exist in "
270 << file->GetName() <<
endmsg;
273 gDirectory->cd(dir.c_str());
277 gDirectory->GetObject(fdir.c_str(), to);
281 << gDirectory->GetPath() <<
endmsg;
287 hist =
dynamic_cast<T*
>(to);
291 << to->IsA()->GetName()
299 << hist->GetName() <<
"\" from file "
300 << file->GetName() <<
endmsg;
MSG::Level level()
Retrieve output level.
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
TDirectory * changeDir(const THistSvc::THistID &hid) const
bool isFailure() const
Test for a status code of FAILURE.
std::string dirname(std::string &dir) const
This class is used for returning status codes from appropriate routines.
std::map< std::string, std::pair< TFile *, Mode > > m_files
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
StatusCode regHist_i(T *hist, const std::string &name)
StatusCode readHist_i(const std::string &name, T *&hist) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void removeDoubleSlash(std::string &) const