24 #include <TDirectory.h>
27 #include <TSysEvtHandler.h>
122 for (
int i = 0; i < kMAXSIGNALS; i++)
124 gSystem->IgnoreSignal((ESignals) i);
126 string histomanagername;
127 histomanagername =
Name() +
"HISTOS";
145 cout <<
"Fun4AllServer::dumpHistos() dumping histograms" << endl;
146 if (!filename.empty())
150 vector<Fun4AllHistoManager *>::const_iterator hiter;
153 iret += (*hiter)->dumpHistos(
"", openmode);
181 string currdir = gDirectory->GetPath();
182 TDirectory *tmpdir = gDirectory;
183 if (!tmpdir->FindObject(topnodename.c_str()))
185 tmpdir = tmpdir->mkdir(topnodename.c_str());
188 cout <<
"Error creating TDirectory topdir " << topnodename.c_str() << endl;
197 gROOT->cd(topnodename.c_str());
199 if (!tmpdir->FindObject(subsystem->
Name().c_str()))
201 tmpdir = tmpdir->mkdir(subsystem->
Name().c_str());
204 cout <<
"Error creating TDirectory subdir " << subsystem->
Name() << endl;
213 pair<SubsysReco *, PHCompositeNode *> newsubsyspair(subsystem, subsystopNode);
217 string memory_tracker_name = subsystem->
Name() +
"_" + topnodename;
219 iret = subsystem->
Init(subsystopNode);
222 catch (
const exception &
e)
224 cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::Init() from "
225 << subsystem->
Name() << endl;
226 cout <<
"error: " << e.what() << endl;
231 cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::Init() from "
232 << subsystem->
Name() << endl;
235 gROOT->cd(currdir.c_str());
242 cout <<
"Not Registering Subsystem " << subsystem->
Name() << endl;
246 cout <<
PHWHERE <<
" Error initializing subsystem "
247 << subsystem->
Name() <<
", return code: " << iret << endl;
252 cout <<
"Registering Subsystem " << subsystem->
Name() << endl;
256 timer_name = subsystem->
Name() +
"_" + topnodename;
260 timer_map.insert(make_pair(timer_name, timer));
268 pair<SubsysReco *, PHCompositeNode *> subsyspair(subsystem, 0);
276 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator sysiter, removeiter;
285 if ((*sysiter).first == (*removeiter).first)
294 cout <<
"unregisterSubsystem: Could not find SubsysReco "
295 << (*removeiter).first->Name()
296 <<
" in Fun4All Reco Module list" << endl;
297 delete (*removeiter).first;
302 cout <<
"Removing Subsystem: " << (*removeiter).first->Name()
303 <<
" at index " << index << endl;
306 delete (*removeiter).first;
309 vector<Fun4AllOutputManager *>::iterator outiter;
323 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator sysiter;
326 if ((*sysiter).first->Name() ==
name)
330 cout <<
"Found Subsystem " << name << endl;
332 return (*sysiter).first;
335 cout <<
"Could not find SubsysReco " << name << endl;
342 string separatorstring =
"------------------------------";
343 ostringstream complaintno;
358 vector<Fun4AllOutputManager *>::iterator iter;
361 if ((*iter)->Name() == manager->
Name())
363 cout <<
"OutputManager " << manager->
Name() <<
" allready in list" << endl;
369 cout <<
"Registering OutputManager " << manager->
Name() << endl;
378 vector<string>::iterator striter;
379 vector<pair<SubsysReco *, PHCompositeNode *>>::const_iterator subsysiter;
387 cout <<
PHWHERE <<
"striter: " << *striter << endl;
393 if (*striter == (*subsysiter).first->Name())
398 cout <<
PHWHERE <<
"setting RecoModuleIndex to " << index << endl;
407 cout <<
"Could not find module " << *striter
408 <<
", removing it from list of event selector modules" << endl;
419 vector<Fun4AllOutputManager *>::iterator iter;
422 if (name == (*iter)->Name())
426 cout <<
"Found OutputManager " << name << endl;
431 cout <<
"Could not find OutputManager" << name << endl;
438 vector<Fun4AllHistoManager *>::iterator iter;
441 if ((*iter)->Name() ==
name)
445 cout <<
"Found HistoManager " << name << endl;
452 cout <<
"Could not find HistoManager " << name << endl;
459 vector<Fun4AllHistoManager *>::iterator iter;
462 if ((*iter)->Name() == manager->
Name())
464 cout <<
"HistoManager " << manager->
Name() <<
" allready in list" << endl;
470 cout <<
"Registering HistoManager " << manager->
Name() << endl;
500 cout <<
"*******************************************************************************" << endl;
501 cout <<
"*******************************************************************************" << endl;
502 cout <<
"*******************************************************************************" << endl;
503 cout <<
"Now that I have your attention, please fix the following "
505 vector<string>::const_iterator viter;
508 cout << *viter << endl;
511 cout <<
"*******************************************************************************" << endl;
512 cout <<
"*******************************************************************************" << endl;
513 cout <<
"*******************************************************************************" << endl;
520 string currdir = gDirectory->GetPath();
521 for (vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter =
Subsystems.begin(); iter !=
Subsystems.end(); ++iter)
525 cout <<
"Fun4AllServer::process_event processing " << (*iter).first->Name() << endl;
527 ostringstream newdirname;
528 newdirname << (*iter).second->getName() <<
"/" << (*iter).first->Name();
529 if (!gROOT->cd(newdirname.str().c_str()))
531 cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
532 << (*iter).second->getName()
533 <<
" - send e-mail to off-l with your macro" << endl;
540 cout <<
"process_event: cded to " << newdirname.str().c_str() << endl;
547 timer_name = (*iter).first->Name() +
"_" + (*iter).second->getName();
548 std::map<const std::string, PHTimer>::iterator titer =
timer_map.find(timer_name);
549 bool timer_found =
false;
553 titer->second.restart();
557 cout <<
"could not find timer for " << timer_name << endl;
561 int retcode = (*iter).first->process_event((*iter).second);
571 catch (
const exception &
e)
573 cout <<
PHWHERE <<
" caught exception thrown during RetCodes.at(icnt)" << endl;
574 cout <<
"RetCodes.size(): " <<
RetCodes.size() <<
", icnt: " << icnt << endl;
575 cout <<
"error: " << e.what() << endl;
580 titer->second.stop();
584 catch (
const exception &
e)
586 cout <<
PHWHERE <<
" caught exception thrown during process_event from "
587 << (*iter).first->Name() << endl;
588 cout <<
"error: " << e.what() << endl;
593 cout <<
PHWHERE <<
" caught unknown type exception thrown during process_event from "
594 << (*iter).first->Name() << endl;
603 cout <<
"Fun4AllServer::Discard Event by " << (*iter).first->Name() << endl;
612 cout <<
"Fun4AllServer::Abort Event by " << (*iter).first->Name() << endl;
619 cout <<
"Fun4AllServer::Abort Run by " << (*iter).first->Name() << endl;
624 cout <<
"Fun4AllServer::Unknown return code: "
625 <<
RetCodes[icnt] <<
" from process_event method of "
626 << (*iter).first->Name() << endl;
627 cout <<
"This smells like an uninitialized return code and" << endl;
628 cout <<
"it is too dangerous to continue, this Run will be aborted" << endl;
629 cout <<
"If you do not know how to fix this please send mail to" << endl;
630 cout <<
"phenix-off-l with this message" << endl;
641 gROOT->cd(currdir.c_str());
655 static int first = 1;
667 cout <<
PHWHERE <<
" FATAL: Someone changed the number of Output Nodes on the fly, from " <<
OutNodeCount <<
" to " << newcount << endl;
670 vector<Fun4AllOutputManager *>::iterator iterOutMan;
673 if (!(*iterOutMan)->DoNotWriteEvent(&
RetCodes))
677 cout <<
"Writing Event for " << (*iterOutMan)->Name() << endl;
681 (*iterOutMan)->WriteGeneric(dstNode);
689 cout <<
"Not Writing Event for " << (*iterOutMan)->Name() << endl;
695 for (vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter =
Subsystems.begin(); iter !=
Subsystems.end(); ++iter)
699 cout <<
"Fun4AllServer::process_event Resetting Event " << (*iter).first->Name() << endl;
701 (*iter).first->ResetEvent((*iter).second);
707 cout <<
"Fun4AllServer::process_event Resetting Event for Sync Manager " << syncman->Name() << endl;
709 syncman->ResetEvent();
717 vector<string> ResetNodeList;
718 ResetNodeList.push_back(
"DST");
721 map<string, PHCompositeNode *>::const_iterator iter;
725 for (vector<string>::const_iterator nodename = ResetNodeList.begin();
726 nodename != ResetNodeList.end(); ++nodename)
728 if (mainIter.
cd(*nodename))
741 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
746 cout <<
"Fun4AllServer::Reset Resetting " << (*iter).first->Name() << endl;
748 i += (*iter).first->Reset((*iter).second);
750 vector<Fun4AllHistoManager *>::iterator hiter;
761 cout <<
"Setting BOR timestamp to ";
782 cout <<
"overriding BOR timestamp by ";
789 cout <<
"Fun4AllServer::BeginRun: Run number " << runno <<
" uses RECO TIMESTAMP: ";
793 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
808 string currdir = gDirectory->GetPath();
811 ostringstream newdirname;
812 newdirname << (*iter).second->getName() <<
"/" << (*iter).first->Name();
813 if (!gROOT->cd(newdirname.str().c_str()))
815 cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
816 << (*iter).second->getName()
817 <<
" - send e-mail to off-l with your macro" << endl;
824 cout <<
"BeginRun: cded to " << newdirname.str().c_str() << endl;
830 cout <<
"Fun4AllServer::BeginRun: InitRun for " << (*iter).first->Name() << endl;
835 iret = (*iter).first->InitRun((*iter).second);
838 catch (
const exception &
e)
840 cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::InitRun() from "
841 << (*iter).first->Name() << endl;
842 cout <<
"error: " << e.what() << endl;
847 cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::InitRun() from "
848 << (*iter).first->Name() << endl;
854 cout <<
PHWHERE <<
"Module " << (*iter).first->Name() <<
" issued Abort Run, exiting" << endl;
859 cout <<
PHWHERE <<
"Module " << (*iter).first->Name() <<
" issued non Fun4AllReturnCodes::EVENT_OK return code " << iret <<
" in InitRun()" << endl;
863 gROOT->cd(currdir.c_str());
874 cout <<
"WARNING WARNING, DBs will not be disconnected" << endl;
875 cout <<
"This is for DB server testing purposes only" << endl;
876 cout <<
"If you do not test our DB servers, remove" << endl;
877 cout <<
"Fun4AllServer->KeepDBConnection()" << endl;
878 cout <<
"from your macro" << endl;
899 while ((thisNode = iterat()))
901 if ((thisNode->getType() ==
"PHCompositeNode"))
910 cout << thisNode->getName() <<
", Node Count: " << icnt << endl;
922 while ((thisNode = iterat()))
924 if ((thisNode->getType() ==
"PHCompositeNode"))
930 thisNode->makeTransient();
941 while ((thisNode = iterat()))
943 if ((thisNode->getType() ==
"PHCompositeNode"))
949 thisNode->makePersistent();
957 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
959 string currdir = gDirectory->GetPath();
964 cout <<
"Fun4AllServer::EndRun: EndRun("
965 << runno <<
") for " << (*iter).first->Name() << endl;
967 ostringstream newdirname;
968 newdirname << (*iter).second->getName() <<
"/" << (*iter).first->Name();
969 if (!gROOT->cd(newdirname.str().c_str()))
971 cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
972 << (*iter).second->getName()
973 <<
" - send e-mail to off-l with your macro" << endl;
980 cout <<
"EndRun: cded to " << newdirname.str().c_str() << endl;
985 (*iter).first->EndRun(runno);
987 catch (
const exception &
e)
989 cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::EndRun() from "
990 << (*iter).first->Name() << endl;
991 cout <<
"error: " << e.what() << endl;
996 cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::EndRun() from "
997 << (*iter).first->Name() << endl;
1001 gROOT->cd(currdir.c_str());
1011 vector<pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
1013 string currdir = gDirectory->GetPath();
1018 cout <<
"Fun4AllServer::End: End for " << (*iter).first->Name() << endl;
1020 ostringstream newdirname;
1021 newdirname << (*iter).second->getName() <<
"/" << (*iter).first->Name();
1022 if (!gROOT->cd(newdirname.str().c_str()))
1024 cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
1025 << (*iter).second->getName()
1026 <<
" - send e-mail to off-l with your macro" << endl;
1033 cout <<
"End: cded to " << newdirname.str().c_str() << endl;
1038 i += (*iter).first->End((*iter).second);
1040 catch (
const exception &
e)
1042 cout <<
PHWHERE <<
" caught exception thrown during SusbsysReco::End() from "
1043 << (*iter).first->Name() << endl;
1044 cout <<
"error: " << e.what() << endl;
1049 cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::End() from "
1050 << (*iter).first->Name() << endl;
1054 gROOT->cd(currdir.c_str());
1059 cout <<
"No Run Node, not writing Runwise info" << endl;
1066 vector<Fun4AllOutputManager *>::iterator IOiter;
1069 (*IOiter)->WriteNode(runNode);
1079 cout <<
"*******************************************************************************" << endl;
1080 cout <<
"*******************************************************************************" << endl;
1081 cout <<
"*******************************************************************************" << endl;
1082 cout <<
"Now that we are at the End(), please fix the following "
1084 vector<string>::const_iterator viter;
1087 cout << *viter << endl;
1089 cout <<
" " << endl;
1090 cout <<
"*******************************************************************************" << endl;
1091 cout <<
"*******************************************************************************" << endl;
1092 cout <<
"*******************************************************************************" << endl;
1100 if (what ==
"ALL" || what ==
"HISTOS")
1105 histoman->Print(what);
1108 if (what ==
"ALL" || what ==
"SUBSYSTEMS")
1111 cout <<
"--------------------------------------" << endl
1113 cout <<
"List of Subsystems in Fun4AllServer:" << endl;
1115 vector<pair<SubsysReco *, PHCompositeNode *>>::const_iterator miter;
1118 cout << (*miter).first->Name()
1119 <<
" running under topNode " << (*miter).second->getName() << endl;
1124 if (what ==
"ALL" || what ==
"INPUTMANAGER")
1129 cout <<
"SyncManager: " << syncman->Name() << endl;
1130 syncman->Print(what);
1134 if (what ==
"ALL" || what.find(
"OUTPUTMANAGER") != string::npos)
1137 string pass_on = what;
1138 if (pass_on ==
"ALL" || pass_on ==
"OUTPUTMANAGER")
1140 cout <<
"--------------------------------------" << endl
1142 cout <<
"List of OutputManagers in Fun4AllServer:" << endl;
1147 string::size_type
pos = pass_on.find(
"%");
1148 pass_on = pass_on.substr(pos + 1, pass_on.size());
1152 outman->Print(pass_on);
1156 if (what ==
"ALL" || what ==
"TOPNODES")
1159 cout <<
"--------------------------------------" << endl
1161 cout <<
"List of TopNodes in Fun4AllServer:" << endl;
1163 map<std::string, PHCompositeNode *>::const_iterator iter;
1166 cout << iter->first <<
" is at " << hex
1167 << iter->second << dec << endl;
1171 if (what ==
"ALL" || what ==
"NODETREE")
1174 cout <<
"--------------------------------------" << endl
1176 cout <<
"List of Nodes in Fun4AllServer:" << endl;
1178 map<std::string, PHCompositeNode *>::const_iterator iter;
1181 cout <<
"Node Tree under TopNode " << iter->first << endl;
1193 out <<
"Fun4AllServer Name: " <<
Name() << endl;
1203 cout <<
"Erasing OutputManager "
1205 <<
" at memory location " << *(
OutputManager.begin()) << endl;
1228 map<string, PHCompositeNode *>::const_iterator iter;
1232 return iter->second;
1239 return iter->second;
1241 cout <<
PHWHERE <<
" Could not create new topNode " << name
1242 <<
" send email to off-l with the following printout: " << endl;
1245 cout << iter->first <<
" is at " << hex << iter->second << dec << endl;
1252 map<string, PHCompositeNode *>::const_iterator iter;
1284 vector<Fun4AllSyncManager *>::const_iterator iter;
1287 if ((*iter)->getInputManager(name))
1289 return (*iter)->getInputManager(name);
1292 cout <<
"Could not locate input manager " << name << endl;
1310 static bool run_number_forced = rc->
FlagExist(
"RUNNUMBER");
1311 static int ifirst = 1;
1312 if (ifirst && run_number_forced)
1315 cout <<
"Fun4AllServer: Runnumber forced to " <<
runnumber <<
" by RUNNUMBER IntFlag" << endl;
1320 vector<Fun4AllSyncManager *>::const_iterator iter;
1323 int resetnodetree = 0;
1328 cout <<
"executing run for input master " << (*iter)->Name() << endl;
1330 int retval = (*iter)->run(1);
1355 (*iter)->PushBackInputMgrsEvents(1);
1367 int runno = (*iter)->CurrentRun();
1371 if (currentrun == 0)
1377 if (currentrun != runno)
1379 cout <<
"Mixing of Runs within same event is not supported" << endl;
1380 cout <<
"Here is the list of Sync Managers and their runnumbers:" << endl;
1381 vector<Fun4AllSyncManager *>::const_iterator syiter;
1384 cout << (*syiter)->Name() <<
" run number: " << (*syiter)->CurrentRun() << endl;
1386 cout <<
"Exiting now" << endl;
1394 if (currentrun !=
runnumber && !run_number_forced)
1402 else if (!run_number_forced)
1414 cout <<
"Fun4AllServer::run - processing event "
1415 << (icnt+1) <<
" from run " <<
runnumber << endl;
1436 if (require_nevents)
1442 if (iret || (nevnts > 0 && icnt_good >= nevnts))
1445 else if (iret || (nevnts > 0 && icnt >= nevnts))
1459 vector<Fun4AllSyncManager *>::const_iterator iter;
1462 iret += (*iter)->skip(nevnts);
1473 vector<Fun4AllSyncManager *>::const_iterator iter;
1476 iret += (*iter)->fileopen(managername, filename);
1484 vector<Fun4AllSyncManager *>::const_iterator iter;
1487 iret += (*iter)->BranchSelect(managername, branch, iflag);
1495 vector<Fun4AllSyncManager *>::const_iterator iter;
1498 iret += (*iter)->BranchSelect(branch, iflag);
1506 vector<Fun4AllSyncManager *>::const_iterator iter;
1509 iret += (*iter)->setBranches(managername);
1517 vector<Fun4AllSyncManager *>::const_iterator iter;
1520 iret += (*iter)->setBranches();
1528 vector<Fun4AllSyncManager *>::const_iterator iter;
1531 iret += (*iter)->fileclose(managername);
1556 map<string, PHCompositeNode *>::const_iterator iter;
1559 names.push_back(iter->first);
1561 return names.size();
1567 vector<Fun4AllOutputManager *>::const_iterator iter;
1570 names.push_back((*iter)->Name());
1578 vector<pair<SubsysReco *, PHCompositeNode *>>::const_iterator iter;
1581 names.push_back((*iter).first->Name());
1590 if (syncman->Name() == newmaster->
Name())
1592 cout <<
"Input Master " << newmaster->
Name()
1593 <<
" already registered" << endl;
1599 cout <<
"Registering Input Master " << newmaster->
Name() << endl;
1601 SyncManagers.push_back(newmaster);
1608 if (name ==
"DefaultSyncManager")
1612 vector<Fun4AllSyncManager *>::iterator iter;
1616 if ((*iter)->Name() ==
name)
1621 cout <<
"Could not find Input Master " << name << endl;
1633 cout <<
"Fun4AllServer::setRun(): could not get timestamp for run " << runno
1634 <<
", using tics(0) timestamp: ";
1652 cout <<
"Could not locate node " << name
1653 <<
" or no PHObject Node" << endl;
1660 map<const string, PHTimer>::const_iterator iter;
1666 iter->second.print_stat();
1674 iter->second.print_stat();
1678 cout <<
"No timer with name " << name <<
" found" << endl;
1679 cout <<
"Existing timers:" << endl;
1682 cout << iter->first << endl;