4 #pragma warning(disable:2259)
20 #include "boost/bind.hpp"
25 #include "TDirectory.h"
41 std::transform(s.begin(), s.end(), s.begin(),
49 :
base_class(name, svc), m_log(msgSvc(), name ), signaledStop(false),
50 m_delayConnect(false),m_okToConnect(false),
51 p_incSvc(0), p_fileMgr(0) {
57 "maximum file size in MB. if exceeded, will cause an abort. -1 to never check.");
84 for ( std::vector<const Property*>::const_iterator cur = props->begin();
85 cur != props->end(); cur++) {
86 if ( (*cur)->name() ==
"OutputLevel" ) {
104 vector<string>::const_iterator itr;
111 <<
"Caught: " << err <<
endmsg;
119 <<
"Caught: " << err <<
endmsg;
125 static TROOT
root(
"root",
"ROOT I/O");
153 <<
"unable to register ROOT file open action with FileMgr"
159 <<
"unable to register ROOT file open Error action with FileMgr"
179 if (
service(
"IoComponentMgr", iomgr,
true).isFailure()) {
186 <<
"could not register with the I/O component manager !"
190 bool all_good =
true;
191 typedef std::map<std::string, std::pair<TFile*,Mode> > Registry_t;
193 for ( Registry_t::const_iterator
198 const std::string fname = ireg->second.first->GetName();
205 << fname <<
"] with the I/O component manager..." <<
endmsg;
214 <<
"problem while registering input/output files with "
215 <<
"the I/O component manager !" <<
endmsg;
256 uidMap::const_iterator uitr;
257 for (uitr=
m_uids.begin(); uitr !=
m_uids.end(); ++uitr) {
259 TObject* to = uitr->second.obj;
262 if (to && to->IsA()->InheritsFrom(
"TTree")) {
263 TTree* tr =
dynamic_cast<TTree*
>(to);
264 if (tr->GetDirectory() != 0) {
265 dirname = tr->GetDirectory()->GetPath();
267 }
else if (to && to->IsA()->InheritsFrom(
"TGraph")) {
268 if (!uitr->second.temp) {
269 dirname = uitr->second.file->GetPath();
270 string id2(uitr->second.id);
271 id2.erase(0,id2.find(
"/",1));
272 id2.erase(id2.rfind(
"/"), id2.length());
273 if (id2.find(
"/") == 0) {
280 }
else if (to && to->IsA()->InheritsFrom(
"TH1")) {
281 TH1* th =
dynamic_cast<TH1*
>(to);
285 if (th->GetDirectory() != 0) {
286 dirname = th->GetDirectory()->GetPath();
295 << uitr->second.temp <<
" dir: " << dirname
309 vector<TFile*> deleted_files;
310 map<string, pair<TFile*,Mode> >::const_iterator itr;
313 if (find(deleted_files.begin(), deleted_files.end(), itr->second.first) ==
314 deleted_files.end()) {
315 deleted_files.push_back(itr->second.first);
320 << itr->second.first->GetName()
335 m_log <<
"==> File: " << itr->second.first->GetName()
336 <<
" stream: " << itr->first <<
endmsg;
338 itr->second.first->Print(
"base");
341 string tmpfn=itr->second.first->GetName();
346 if (
service(
"IncidentSvc",pi).isFailure()) {
351 if (itr->second.second==
SHARE) {
365 TFile *outputfile = (TFile*) vf;
381 TFile *inputfile = (TFile*) vf;
383 outputfile->SetCompressionLevel( inputfile->GetCompressionLevel() );
397 delete itr->second.first;
416 std::cerr <<
"TDirectory == 0" << std::endl;
425 cout <<
"-> " << dir->GetPath() <<
" "
426 << dir->GetListOfKeys()->GetSize() << endl;
429 TIter nextkey(dir->GetList());
430 while (TKey *key = (TKey*)nextkey()) {
432 TObject *obj = key->ReadObj();
433 if (obj == 0) { cout << key->GetName() <<
" obj==0"<< endl;
continue; }
435 cout <<
" Key: " << key->GetName() <<
" "
436 <<
" tit: " << obj->GetTitle() <<
" "
437 <<
" (" << key->GetClassName() <<
")" << endl;
441 nextkey = dir->GetListOfKeys();
442 while (TKey *key = (TKey*)nextkey()) {
444 TObject *obj = key->ReadObj();
445 if (obj == 0) { cout << key->GetName() <<
" obj==0"<< endl;
continue; }
446 if (obj->IsA()->InheritsFrom(
"TDirectory")) {
447 TDirectory *tt =
dynamic_cast<TDirectory*
>(obj);
462 gErrorIgnoreLevel = kBreak;
465 m_log <<
MSG::ERROR <<
"getTHists: No such TDirectory \"" << td->GetPath()
471 m_log <<
MSG::DEBUG <<
"getTHists: \"" << td->GetPath() <<
"\": found "
472 << td->GetListOfKeys()->GetSize() <<
" keys" <<
endmsg;
474 TIter nextkey(td->GetListOfKeys());
475 while (TKey *key = (TKey*)nextkey()) {
478 TObject *obj = key->ReadObj();
479 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
481 m_log <<
" (" << obj->IsA()->GetName() <<
")";
482 }
else if (obj != 0 && obj->IsA()->InheritsFrom(
"TH1")) {
484 m_log <<
" (" << obj->IsA()->GetName() <<
")";
486 }
else if (obj != 0) {
488 m_log <<
" [" << obj->IsA()->GetName() <<
"]";
496 nextkey = td->GetListOfKeys();
497 while (TKey *key = (TKey*)nextkey()) {
498 TObject *obj = key->ReadObj();
499 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
500 TDirectory *tt =
dynamic_cast<TDirectory*
>(obj);
518 gErrorIgnoreLevel = kBreak;
522 std::string stream,rem,r2;
525 map< string,pair<TFile*,Mode> >::const_iterator itr =
m_files.find(stream);
527 r2 = itr->second.first->GetName();
533 <<
"\" looks like a stream name." <<
" associated TFile: \""
534 << itr->second.first->GetName() <<
"\"" <<
endmsg;
536 if (gDirectory->cd(r2.c_str())) {
549 m_log <<
MSG::DEBUG <<
"getTHists: stream \"" << stream <<
"\" not found"
553 if (!gDirectory->cd(dir.c_str())) {
554 m_log <<
MSG::ERROR <<
"getTHists: No such TDirectory/stream \"" << dir
570 gErrorIgnoreLevel = kBreak;
574 << td->GetPath() <<
"\"" <<
endmsg;
579 m_log <<
MSG::DEBUG <<
"getTHists: \"" << td->GetPath() <<
"\": found "
580 << td->GetListOfKeys()->GetSize() <<
" keys" <<
endmsg;
582 TIter nextkey(td->GetListOfKeys());
583 while (TKey *key = (TKey*)nextkey()) {
586 TObject *obj = key->ReadObj();
587 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
589 m_log <<
" (" << obj->IsA()->GetName() <<
")";
590 }
else if (obj != 0 && obj->IsA()->InheritsFrom(
"TTree")) {
592 m_log <<
" (" << obj->IsA()->GetName() <<
")";
594 }
else if (obj != 0) {
596 m_log <<
" [" << obj->IsA()->GetName() <<
"]";
603 nextkey = td->GetListOfKeys();
604 while (TKey *key = (TKey*)nextkey()) {
605 TObject *obj = key->ReadObj();
606 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
607 TDirectory *tt =
dynamic_cast<TDirectory*
>(obj);
623 gErrorIgnoreLevel = kBreak;
627 std::string stream,rem,r2;
630 map< string,pair<TFile*,Mode> >::const_iterator itr =
m_files.find(stream);
632 r2 = itr->second.first->GetName();
638 <<
"\" looks like a stream name." <<
" associated TFile: \""
639 << itr->second.first->GetName() <<
"\"" <<
endmsg;
641 if (gDirectory->cd(r2.c_str())) {
651 m_log <<
MSG::DEBUG <<
"getTTrees: stream \"" << stream <<
"\" not found"
655 if (!gDirectory->cd(dir.c_str())) {
656 m_log <<
MSG::ERROR <<
"getTTrees: No such TDirectory/stream \"" << dir
676 gErrorIgnoreLevel = kBreak;
679 m_log <<
MSG::ERROR <<
"getTHists: No such TDirectory \"" << td->GetPath()
685 m_log <<
MSG::DEBUG <<
"getTHists: \"" << td->GetPath() <<
"\": found "
686 << td->GetListOfKeys()->GetSize() <<
" keys" <<
endmsg;
688 TIter nextkey(td->GetListOfKeys());
689 while (TKey *key = (TKey*)nextkey()) {
692 TObject *obj = key->ReadObj();
693 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
695 m_log <<
" (" << obj->IsA()->GetName() <<
")";
696 }
else if (obj != 0 && obj->IsA()->InheritsFrom(
"TH1")) {
698 m_log <<
" (" << obj->IsA()->GetName() <<
")";
701 string dir = td->GetPath();
702 string fil = td->GetFile()->GetName();
703 dir.erase(0,fil.length()+1);
706 id =
id +
"/" + key->GetName();
708 id =
id + dir +
"/" + key->GetName();
712 m_log <<
" reg as \"" <<
id <<
"\"";
716 m_log <<
" already registered";
719 }
else if (obj != 0) {
721 m_log <<
" [" << obj->IsA()->GetName() <<
"]";
729 nextkey = td->GetListOfKeys();
730 while (TKey *key = (TKey*)nextkey()) {
731 TObject *obj = key->ReadObj();
732 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
733 TDirectory *tt =
dynamic_cast<TDirectory*
>(obj);
750 gErrorIgnoreLevel = kBreak;
754 std::string stream,rem,r2;
757 map< string,pair<TFile*,Mode> >::const_iterator itr =
m_files.find(stream);
759 r2 = itr->second.first->GetName();
765 <<
"\" looks like a stream name." <<
" associated TFile: \""
766 << itr->second.first->GetName() <<
"\"" <<
endmsg;
768 if (gDirectory->cd(r2.c_str())) {
781 m_log <<
MSG::DEBUG <<
"getTHists: stream \"" << stream <<
"\" not found"
785 if (!gDirectory->cd(dir.c_str())) {
786 m_log <<
MSG::ERROR <<
"getTHists: No such TDirectory/stream \"" << dir
792 <<
"without a valid stream name" <<
endmsg;
808 gErrorIgnoreLevel = kBreak;
812 << td->GetPath() <<
"\"" <<
endmsg;
817 m_log <<
MSG::DEBUG <<
"getTHists: \"" << td->GetPath() <<
"\": found "
818 << td->GetListOfKeys()->GetSize() <<
" keys" <<
endmsg;
820 TIter nextkey(td->GetListOfKeys());
821 while (TKey *key = (TKey*)nextkey()) {
824 TObject *obj = key->ReadObj();
825 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
827 m_log <<
" (" << obj->IsA()->GetName() <<
")";
828 }
else if (obj != 0 && obj->IsA()->InheritsFrom(
"TTree")) {
830 m_log <<
" (" << obj->IsA()->GetName() <<
")";
833 string dir = td->GetPath();
834 string fil = td->GetFile()->GetName();
835 dir.erase(0,fil.length()+1);
838 id =
id +
"/" + key->GetName();
840 id =
id + dir +
"/" + key->GetName();
844 m_log <<
" reg as \"" <<
id <<
"\"";
848 m_log <<
" already registered";
851 }
else if (obj != 0) {
853 m_log <<
" [" << obj->IsA()->GetName() <<
"]";
861 nextkey = td->GetListOfKeys();
862 while (TKey *key = (TKey*)nextkey()) {
863 TObject *obj = key->ReadObj();
864 if (obj != 0 && obj->IsA()->InheritsFrom(
"TDirectory")) {
865 TDirectory *tt =
dynamic_cast<TDirectory*
>(obj);
882 gErrorIgnoreLevel = kBreak;
886 std::string stream,rem,r2;
889 map< string,pair<TFile*,Mode> >::const_iterator itr =
m_files.find(stream);
891 r2 = itr->second.first->GetName();
897 <<
"\" looks like a stream name." <<
" associated TFile: \""
898 << itr->second.first->GetName() <<
"\"" <<
endmsg;
900 if (gDirectory->cd(r2.c_str())) {
910 m_log <<
MSG::DEBUG <<
"getTTrees: stream \"" << stream <<
"\" not found"
914 if (!gDirectory->cd(dir.c_str())) {
915 m_log <<
MSG::ERROR <<
"getTTrees: No such TDirectory/stream \"" << dir
931 objMap::iterator itr =
m_tobjs.find(obj);
935 uidMap::iterator itr2 =
m_uids.find(hid.
id);
936 if (itr2 ==
m_uids.end()) {
939 <<
"\" with id \"" << hid.
id <<
"\"" <<
endmsg;
943 std::string id,
root,rem;
946 idMap::iterator itr3;
949 std::pair<idMap::iterator, idMap::iterator> mitr =
m_ids.equal_range(rem);
950 if (mitr.first == mitr.second) {
953 <<
"\" with id \"" << hid.
id <<
"\"" <<
endmsg;
956 for (itr3 = mitr.first; itr3 != mitr.second; ++itr3) {
957 if (itr3->second.obj == obj) {
965 <<
"\" with id \"" << hid.
id <<
"\"" <<
endmsg;
976 m_log <<
MSG::ERROR <<
"Cannot unregister TObject \"" << obj->GetName()
977 <<
"\": not known to THistSvc" <<
endmsg;
989 uidMap::iterator itr =
m_uids.find(
id);
990 if (itr ==
m_uids.end()) {
996 TObject* obj = itr->second.obj;
1065 if ( strcmp(hist->GetName(),
"Graph") == 0 ) {
1067 std::string id2(
id);
1068 string::size_type
i = id2.rfind(
"/");
1069 if (i != string::npos) {
1073 m_log <<
MSG::INFO <<
"setting name of TGraph id: \"" <<
id <<
"\" to \""
1074 << id2 <<
"\" since it is unset" <<
endmsg;
1075 hist->SetName(id2.c_str());
1104 std::vector<std::string>
1107 std::vector<std::string>
names;
1108 names.reserve(
m_uids.size());
1110 uidMap::const_iterator itr;
1111 for (itr =
m_uids.begin(); itr !=
m_uids.end(); ++itr) {
1114 if (tid.
obj->IsA()->InheritsFrom(
"TH1")) {
1115 names.push_back(itr->first);
1132 std::vector<std::string>
1135 std::vector<std::string>
names;
1136 names.reserve(
m_uids.size());
1138 uidMap::const_iterator itr;
1139 for (itr =
m_uids.begin(); itr !=
m_uids.end(); ++itr) {
1142 if (tid.
obj->IsA()->InheritsFrom(
"TTree")) {
1143 names.push_back(itr->first);
1160 std::vector<std::string>
1163 std::vector<std::string>
names;
1164 names.reserve(
m_uids.size());
1166 uidMap::const_iterator itr;
1167 for (itr =
m_uids.begin(); itr !=
m_uids.end(); ++itr) {
1170 if (tid.
obj->IsA()->InheritsFrom(
"TGraph")) {
1171 names.push_back(itr->first);
1211 TFile*&
file)
const {
1213 string::size_type pos =
id.find(
"/");
1215 if (pos == string::npos) {
1218 }
else if (pos != 0) {
1223 string::size_type pos2 =
id.find(
"/",pos+1);
1225 if (pos2 == string::npos) {
1235 if (stream ==
"temp") {
1240 map< string,pair<TFile*,Mode> >::const_iterator itr =
m_files.find(stream);
1242 file = itr->second.first;
1246 <<
"\" associated with id: \"" <<
id <<
"\""
1258 string::size_type pos =
id.find(
"/");
1260 if (pos == string::npos) {
1269 root =
id.substr(0,pos);
1270 rem =
id.substr(pos+1,
id.length());
1282 <<
"Set it via the \"CL=\" parameter in the \"Output\" Property"
1296 m_log <<
MSG::DEBUG <<
"Delaying connection of Input Files until Initialize"
1308 typedef std::vector<std::string>
Strings_t;
1309 for ( Strings_t::const_iterator
1340 m_log <<
MSG::DEBUG <<
"Delaying connection of Input Files until Initialize"
1348 typedef std::vector<std::string>
Strings_t;
1349 for ( Strings_t::const_iterator
1386 uidMap::iterator uitr, uitr2;
1387 for (uitr=
m_uids.begin(); uitr !=
m_uids.end(); ++uitr) {
1391 << uitr->second.id <<
" " << uitr->second.mode <<
endmsg;
1393 TObject* to = uitr->second.obj;
1394 TFile* oldFile = uitr->second.file;
1397 }
else if ( uitr->second.temp || uitr->second.mode ==
READ ) {
1405 }
else if (to->IsA()->InheritsFrom(
"TTree")) {
1406 TTree* tr =
dynamic_cast<TTree*
>(to);
1407 TFile* newFile = tr->GetCurrentFile();
1409 if (oldFile != newFile) {
1410 std::string newFileName = newFile->GetName();
1411 std::string oldFileName(
""), streamName, rem;
1413 findStream(uitr->second.id, streamName, rem, dummy);
1415 map<string, pair<TFile*,Mode> >::iterator itr;
1417 if (itr->second.first == oldFile) {
1418 itr->second.first = newFile;
1424 for (; uitr2 !=
m_uids.end(); ++uitr2) {
1425 if (uitr2->second.file == oldFile) {
1426 uitr2->second.file = newFile;
1430 streamMap::iterator sitr;
1432 if (sitr->second == streamName) {
1433 oldFileName = sitr->first;
1442 <<
" stream: " << streamName
1443 <<
" oldFile: " << oldFileName
1444 <<
" newFile: " << newFileName
1449 if (oldFileName !=
"") {
1455 <<
"\" to \"" << newFileName <<
"\" for stream \""
1456 << sitr->second <<
"\"" <<
endmsg;
1465 <<
"Problems updating fileStreams with new file name" <<
endmsg;
1482 map<string, pair<TFile*,Mode> >::const_iterator itr;
1484 if (itr->second.second ==
WRITE || itr->second.second ==
UPDATE
1485 ||itr->second.second==
SHARE) {
1486 itr->second.first->Write(
"",TObject::kOverwrite);
1487 }
else if (itr->second.second ==
APPEND) {
1488 itr->second.first->Write(
"");
1494 m_log <<
MSG::DEBUG <<
"THistSvc::write()::List of Files connected in ROOT "
1497 TSeqCollection *filelist=gROOT->GetListOfFiles();
1498 for (
int ii=0; ii<filelist->GetEntries(); ii++) {
1501 <<
"THistSvc::write()::List of Files connected in ROOT: \""
1502 << filelist->At(ii)->GetName()<<
"\""<<
endmsg;
1516 string::size_type loc = ident.find(
" ");
1517 string stream = ident.substr(0,loc);
1519 typedef std::pair<std::string,std::string> Prop;
1520 std::vector<Prop> props;
1521 string val,VAL,TAG,filename,db_typ(
"ROOT");
1524 tok.
analyse(ident.substr(loc+1,ident.length()),
" ",
"",
"",
"=",
"'",
"'");
1526 for ( Tokenizer::Items::iterator
i = tok.
items().begin();
i != tok.
items().end();
i++) {
1527 const std::string& tag = (*i).tag();
1535 if (TAG ==
"FILE" || TAG ==
"DATAFILE") {
1538 }
else if ( TAG ==
"OPT" ) {
1539 if ( VAL ==
"APPEND" || VAL ==
"UPDATE" ) {
1541 }
else if ( VAL ==
"CREATE" || VAL ==
"NEW" || VAL ==
"WRITE" ) {
1543 }
else if ( VAL ==
"RECREATE" ) {
1545 }
else if (VAL ==
"SHARE") {
1547 }
else if ( VAL ==
"OLD" || VAL ==
"READ" ) {
1554 }
else if (TAG ==
"TYP") {
1555 db_typ = (*i).value();
1556 }
else if (TAG ==
"CL") {
1557 cl = atoi(val.c_str());
1559 props.push_back( Prop((*i).tag(), (*i).value()));
1564 if (stream ==
"temp") {
1566 <<
"\": stream name \"temp\" reserved."
1571 if (db_typ !=
"ROOT") {
1573 <<
"\": technology type \"" << db_typ <<
"\" not supported."
1581 <<
"\":\n stream \"" << stream <<
"\" already connected to file: \""
1582 <<
m_files[stream].first->GetName() <<
"\""
1590 }
else if (typ ==
'N') {
1592 }
else if (typ ==
'A') {
1594 }
else if (typ ==
'R') {
1596 }
else if (typ ==
'S') {
1600 m_log <<
MSG::ERROR <<
"No OPT= specified or unknown access mode in: "
1607 std::pair<streamMap::iterator, streamMap::iterator> fitr =
1610 std::string oldstream = (fitr.first)->second;
1612 std::pair<TFile*,Mode> f_info =
m_files[oldstream];
1614 if (newMode != f_info.second) {
1616 <<
"\":\n file \"" << filename <<
"\" already opened by stream: \""
1617 << oldstream <<
"\" with different access mode."
1621 TFile *f2 = f_info.first;
1622 m_files[stream] = make_pair(f2,newMode);
1625 <<
"\" to previously opened TFile: \"" << filename <<
"\""
1633 if (
service(
"IncidentSvc",pi).isFailure()) {
1647 m_log <<
"Unable to open ROOT file " << filename <<
" for reading"
1667 m_log <<
"Unable to open ROOT file " << filename <<
" for writing"
1681 <<
"\" for appending" <<
endmsg;
1693 static int ishared = 0;
1695 string realfilename=filename;
1697 filename = string(
"tmp_THistSvc_")+out.str()+string(
".root");
1701 <<
"\" and realfilename="<<realfilename <<
endmsg;
1709 m_log <<
"Unable to open ROOT file " << filename <<
" for writing"
1723 m_log <<
"Unable to open ROOT file " << filename <<
" for appending"
1732 m_files[stream] = make_pair(f,newMode);
1736 m_log <<
MSG::DEBUG <<
"Opening TFile \"" << filename <<
"\" stream: \""
1737 << stream <<
"\" mode: \"" << typ <<
"\"" <<
" comp level: " << cl
1748 string uid = hid.
id;
1750 string stream, fdir, bdir, dir, id;
1761 while ( (dir =
dirname(fdir)) !=
"") {
1762 if (! gDirectory->GetKey(dir.c_str())) {
1763 gDirectory->mkdir(dir.c_str());
1765 gDirectory->cd(dir.c_str());
1778 string::size_type
i = dir.find(
"/");
1780 if (i == string::npos) {
1789 string root = dir.substr(0,i);
1801 m_ge = gErrorIgnoreLevel;
1807 gErrorIgnoreLevel = m_ge;
1815 while (
id.find(
"//") != std::string::npos) {
1816 id.replace(
id.find(
"//"),2,
"/");
1827 TString
path( (
char*)strstr(target->GetPath(),
":") );
1831 TDirectory *current_sourcedir = gDirectory;
1834 TList *lkeys=current_sourcedir->GetListOfKeys();
1835 int nkeys=lkeys->GetEntries();
1837 for (
int jj=0; jj<nkeys; jj++) {
1838 key=(TKey*) lkeys->At(jj);
1839 string pathnameinsource=current_sourcedir->GetPath()+string(
"/")+key->GetName();
1844 TObject *obj=source->Get(pathnameinsource.c_str());
1847 if (obj->IsA()->InheritsFrom(
"TDirectory") ) {
1856 TDirectory *newtargetdir =
1857 target->mkdir(obj->GetName(), obj->GetTitle() );
1861 }
else if (obj->IsA()->InheritsFrom(
"TTree")) {
1864 TTree *mytree=
dynamic_cast<TTree*
>(obj);
1865 int nentries=(int) mytree->GetEntries();
1866 mytree->SetBranchStatus(
"*",1);
1878 mytree->CloneTree();
1886 obj->Write(key->GetName() );
1921 Long64_t mfs_warn = mfs * 95 / 100;
1925 map<string, pair<TFile*,Mode> >::const_iterator itr;
1927 TFile* tf = itr->second.first;
1932 << tf->GetName() <<
" size: " << tf->GetSize()
1937 if (tf->GetSize() > mfs) {
1942 <<
"\" associated with stream \"" << itr->first
1943 <<
"\" has exceeded the max file size of "
1948 if (
service(
"ApplicationMgr", evt,
true).isSuccess()) {
1954 }
else if (tf->GetSize() > mfs_warn) {
1956 <<
"\" associated with stream \"" << itr->first
1957 <<
"\" is at 95% of its maximum allowable file size of "
1973 <<
"copyFileLayout() to dst path: " << dst->GetPath () <<
endmsg;
1976 TString
path ((
char*)strstr (dst->GetPath(),
":"));
1980 TDirectory *cur_src_dir = gDirectory;
1983 TList *key_list = cur_src_dir->GetListOfKeys ();
1984 int n = key_list->GetEntries ();
1985 for (
int j = 0; j <
n; ++j ) {
1986 TKey *k = (TKey*)key_list->At (j);
1987 const std::string src_pathname = cur_src_dir->GetPath()
1990 TObject *o=src->Get (src_pathname.c_str());
1992 if (o != NULL && o->IsA()->InheritsFrom (
"TDirectory")) {
1997 TDirectory * dst_dir = dst->mkdir (o->GetName(), o->GetTitle());
2011 bool all_good =
true;
2019 if (
service(
"IoComponentMgr", iomgr,
true).isFailure()) {
2028 gErrorIgnoreLevel = kFatal;
2030 typedef std::map<std::string, std::pair<TFile*,Mode> > FileReg_t;
2032 for (FileReg_t::iterator ifile =
m_files.begin(), iend=
m_files.end();
2033 ifile != iend; ++ifile) {
2034 TFile *f = ifile->second.first;
2035 std::string fname = f->GetName();
2038 << f->GetOption() <<
"] r:"
2039 << f->GetFileBytesRead()
2040 <<
" w:" << f->GetFileBytesWritten()
2041 <<
" cnt:" << f->GetFileCounter()
2044 if ( ifile->second.second ==
READ ) {
2047 <<
" TFile opened in READ mode: not reassigning names" <<
endmsg;
2064 Option_t *
opts = f->GetOption();
2068 <<
"\" for writing" <<
endmsg;
2071 TFile *newfile = (TFile*) vf;
2072 newfile->SetOption(opts);
2077 ifile->second.first = newfile;
2082 for ( uidMap::iterator uid =
m_uids.begin(), uid_end =
m_uids.end();
2086 if ( hid.
file != f ) {
2089 TDirectory *olddir = this->
changeDir (hid);
2092 TDirectory *newdir = this->
changeDir (hid);
2093 TClass *cl = hid.
obj->IsA();
2097 if (cl->InheritsFrom (
"TTree")) {
2098 dynamic_cast<TTree*
> (hid.
obj)->SetDirectory (newdir);
2099 dynamic_cast<TTree*
> (hid.
obj)->Reset();
2101 else if (cl->InheritsFrom (
"TH1")) {
2102 dynamic_cast<TH1*
> (hid.
obj)->SetDirectory (newdir);
2103 dynamic_cast<TH1*
> (hid.
obj)->Reset();
2105 else if (cl->InheritsFrom (
"TGraph")) {
2106 olddir->Remove (hid.
obj);
2107 newdir->Append (hid.
obj);
2110 <<
"id: \"" << hid.
id <<
"\" is not a inheriting from a class "
2111 <<
"we know how to handle (received [" << cl->GetName()
2112 <<
"], " <<
"expected [TTree, TH1 or TGraph]) !"
2114 <<
"attaching to current dir [" << newdir->GetPath() <<
"] "
2115 <<
"nonetheless..." <<
endmsg;
2116 olddir->Remove (hid.
obj);
2117 newdir->Append (hid.
obj);
2139 if (fa->
desc() !=
"HIST") {
2171 if (fa->
desc() !=
"HIST") {
virtual StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname)=0
: retrieve the new filename for a given IIoComponent and
IntegerProperty m_outputLevel
Service output level.
virtual const std::vector< const Property * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
virtual StatusCode stopRun()=0
Schedule a stop of the current event processing.
This class is the FileIncident.
Define general base for Gaudi exception.
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode deReg(TObject *obj)
void handle(const Incident &)
Inform that a new incident has occurred.
IntegerProperty m_autoFlush
Items & items()
Access token collection.
virtual StatusCode setProperty(const Property &p)
Set the property by property.
MSG::Level level()
Retrieve output level.
std::vector< std::string > Strings_t
This file contains the class definition for the FileIncident class.
IntegerProperty m_autoSave
virtual StatusCode getGraph(const std::string &name, TGraph *&) const
bool isSuccess() const
Test for a status code of SUCCESS.
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
bool browseTDir(TDirectory *dir) const
void analyse(const std::string &s, const char *delim, const char *tagBegin, const char *tagEnd, const char *eq, const char *valBegin, const char *valEnd)
Analyse tokens from string.
void setupCompressionLevel(Property &cmp)
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
const std::string FailInputFile
could not open or read from this file
void copyFileLayout(TDirectory *, TDirectory *)
helper function to recursively copy the layout of a TFile into a new TFile
TDirectory * changeDir(const THistSvc::THistID &hid) const
bool isFailure() const
Test for a status code of FAILURE.
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
virtual StatusCode regTree(const std::string &name)
#define DECLARE_COMPONENT(type)
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &d="")=0
StringArrayProperty m_inputfile
const std::string & name() const
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
StringArrayProperty m_outputfile
virtual StatusCode regHist(const std::string &name)
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
void setupOutputFile(Property &outputfile)
call-back method to handle output stream property
Main interface for the JobOptions service.
const std::string & desc() const
boost::function< StatusCode(FILEMGR_CALLBACK_ARGS) > bfcn_action_t
std::string dirname(std::string &dir) const
virtual StatusCode getTree(const std::string &name, TTree *&) const
StatusCode readTree(const std::string &name, TTree *&) const
virtual std::vector< std::string > getHists() const
This class is used for returning status codes from appropriate routines.
std::map< std::string, std::pair< TFile *, Mode > > m_files
IntegerProperty m_maxFileSize
virtual std::vector< std::string > getTrees() const
virtual StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const
virtual StatusCode regGraph(const std::string &name)
const std::string BeginOutputFile
a new output file has been created
~GlobalDirectoryRestore()
StatusCode rootOpenErrAction(FILEMGR_CALLBACK_ARGS)
void parseString(const std::string &id, std::string &root, std::string &rem) const
StatusCode getHist_i(const std::string &name, T *&hist, bool quiet=false) const
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
virtual Gaudi::StateMachine::State FSMState() const
Get the current state.
const TYPE & value() const
explicit conversion
IntegerProperty m_compressionLevel
virtual const std::string & name() const
Retrieve name of the service.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual StatusCode io_reinit()
callback method to reinitialize the internal state of the component for I/O purposes (e...
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
std::map< std::string, std::string > m_sharedFiles
Property base class allowing Property* collections to be "homogeneous".
virtual StatusCode getHist(const std::string &name, TH1 *&) const
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
StatusCode regHist_i(T *hist, const std::string &name)
StatusCode readHist_i(const std::string &name, T *&hist) const
Base class for all Incidents (computing events).
void toupper(std::string &s)
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
void setLevel(int level)
Update outputlevel.
Templated class to add the standard messaging functionalities.
StatusCode connect(const std::string &)
The IEventProcessor is the interface to process events.
StatusCode readHist(const std::string &name, TH1 *&) const
virtual StatusCode io_register(IIoComponent *iocomponent)=0
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
virtual bool exists(const std::string &name) const
std::set< std::string > m_alreadyConnectedOutFiles
list of already connected files.
virtual std::vector< std::string > getGraphs() const
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
const std::string WroteToOutputFile
the output file was written to in this event
const std::string FailOutputFile
could not create or write to this file
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
std::set< std::string > m_alreadyConnectedInFiles
list of already connected files.
THistSvc(const std::string &name, ISvcLocator *svc)
void setupInputFile(Property &inputfile)
call-back method to handle input stream property
virtual StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
The interface implemented by the IncidentSvc service.
void MergeRootFile(TDirectory *target, TDirectory *source)
void removeDoubleSlash(std::string &) const
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0