25 #include <TDirectory.h>
28 #include <TSysEvtHandler.h>
125 for (
int i = 0;
i < kMAXSIGNALS;
i++)
127 gSystem->IgnoreSignal((ESignals)
i);
131 histomanagername =
Name() +
"HISTOS";
148 std::cout <<
"Fun4AllServer::dumpHistos() dumping histograms" << std::endl;
149 if (!filename.empty())
153 std::vector<Fun4AllHistoManager *>::const_iterator hiter;
156 iret += (*hiter)->dumpHistos(
"", openmode);
185 TDirectory *tmpdir = gDirectory;
186 if (!tmpdir->FindObject(topnodename.c_str()))
188 tmpdir = tmpdir->mkdir(topnodename.c_str());
191 std::cout <<
PHWHERE <<
" Error creating TDirectory topdir " << topnodename << std::endl;
200 gROOT->cd(topnodename.c_str());
202 if (!tmpdir->FindObject(subsystem->
Name().c_str()))
204 tmpdir = tmpdir->mkdir(subsystem->
Name().c_str());
207 std::cout <<
PHWHERE <<
"Error creating TDirectory subdir " << subsystem->
Name() << std::endl;
216 std::pair<SubsysReco *, PHCompositeNode *> newsubsyspair(subsystem, subsystopNode);
220 std::string memory_tracker_name = subsystem->
Name() +
"_" + topnodename;
224 iret = subsystem->
Init(subsystopNode);
229 catch (
const std::exception &
e)
231 std::cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::Init() from "
232 << subsystem->
Name() << std::endl;
233 std::cout <<
"error: " << e.what() << std::endl;
238 std::cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::Init() from "
239 << subsystem->
Name() << std::endl;
242 gROOT->cd(currdir.c_str());
249 std::cout <<
"Not Registering Subsystem " << subsystem->
Name() << std::endl;
253 std::cout <<
PHWHERE <<
" Error from Init() method by "
254 << subsystem->
Name() <<
", return code: " << iret << std::endl;
259 std::cout <<
"Registering Subsystem " << subsystem->
Name() << std::endl;
263 timer_name = subsystem->
Name() +
"_" + topnodename;
267 timer_map.insert(make_pair(timer_name, timer));
275 std::pair<SubsysReco *, PHCompositeNode *> subsyspair(subsystem, 0);
283 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator sysiter, removeiter;
292 if ((*sysiter).first == (*removeiter).first)
301 std::cout <<
"unregisterSubsystem: Could not find SubsysReco "
302 << (*removeiter).first->Name()
303 <<
" in Fun4All Reco Module list" << std::endl;
304 delete (*removeiter).first;
309 std::cout <<
"Removing Subsystem: " << (*removeiter).first->Name()
310 <<
" at index " << index << std::endl;
313 delete (*removeiter).first;
316 std::vector<Fun4AllOutputManager *>::iterator outiter;
330 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator sysiter;
333 if ((*sysiter).first->Name() ==
name)
337 std::cout <<
"Found Subsystem " << name << std::endl;
339 return (*sysiter).first;
342 std::cout <<
"Could not find SubsysReco " << name << std::endl;
349 std::string separatorstring =
"------------------------------";
350 std::ostringstream complaintno;
365 std::vector<Fun4AllOutputManager *>::iterator iter;
368 if ((*iter)->Name() == manager->
Name())
370 std::cout <<
"OutputManager " << manager->
Name() <<
" allready in list" << std::endl;
376 std::cout <<
"Registering OutputManager " << manager->
Name() << std::endl;
385 std::vector<std::string>::iterator striter;
386 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::const_iterator subsysiter;
394 std::cout <<
PHWHERE <<
"striter: " << *striter << std::endl;
400 if (*striter == (*subsysiter).first->Name())
405 std::cout <<
PHWHERE <<
"setting RecoModuleIndex to " << index << std::endl;
414 std::cout <<
"Could not find module " << *striter
415 <<
", removing it from list of event selector modules" << std::endl;
427 std::vector<Fun4AllOutputManager *>::iterator iter;
430 if (name == (*iter)->Name())
434 std::cout <<
"Found OutputManager " << name << std::endl;
439 std::cout <<
"Could not find OutputManager" << name << std::endl;
446 std::vector<Fun4AllHistoManager *>::iterator iter;
449 if ((*iter)->Name() ==
name)
453 std::cout <<
"Found HistoManager " << name << std::endl;
460 std::cout <<
"Could not find HistoManager " << name << std::endl;
467 std::vector<Fun4AllHistoManager *>::iterator iter;
470 if ((*iter)->Name() == manager->
Name())
472 std::cout <<
"HistoManager " << manager->
Name() <<
" allready in list" << std::endl;
478 std::cout <<
"Registering HistoManager " << manager->
Name() << std::endl;
508 std::cout <<
"*******************************************************************************" << std::endl;
509 std::cout <<
"*******************************************************************************" << std::endl;
510 std::cout <<
"*******************************************************************************" << std::endl;
511 std::cout <<
"Now that I have your attention, please fix the following "
513 std::vector<std::string>::const_iterator viter;
516 std::cout << *viter << std::endl;
518 std::cout <<
" " << std::endl;
519 std::cout <<
"*******************************************************************************" << std::endl;
520 std::cout <<
"*******************************************************************************" << std::endl;
521 std::cout <<
"*******************************************************************************" << std::endl;
533 std::cout <<
"Fun4AllServer::process_event processing " << Subsystem.first->Name() << std::endl;
535 std::string newdirname = Subsystem.second->getName() +
"/" + Subsystem.first->Name();
536 if (!gROOT->cd(newdirname.c_str()))
538 std::cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
539 << Subsystem.second->getName()
540 <<
" - send e-mail to off-l with your macro" << std::endl;
547 std::cout <<
"process_event: cded to " << newdirname << std::endl;
554 timer_name = Subsystem.first->Name() +
"_" + Subsystem.second->getName();
555 std::map<const std::string, PHTimer>::iterator titer =
timer_map.find(timer_name);
556 bool timer_found =
false;
560 titer->second.restart();
564 std::cout <<
"could not find timer for " << timer_name << std::endl;
570 int retcode = Subsystem.first->process_event(Subsystem.second);
582 catch (
const std::exception &
e)
584 std::cout <<
PHWHERE <<
" caught exception thrown during RetCodes.at(icnt)" << std::endl;
585 std::cout <<
"RetCodes.size(): " <<
RetCodes.size() <<
", icnt: " << icnt << std::endl;
586 std::cout <<
"error: " << e.what() << std::endl;
591 titer->second.stop();
597 catch (
const std::exception &
e)
599 std::cout <<
PHWHERE <<
" caught exception thrown during process_event from "
600 << Subsystem.first->Name() << std::endl;
601 std::cout <<
"error: " << e.what() << std::endl;
606 std::cout <<
PHWHERE <<
" caught unknown type exception thrown during process_event from "
607 << Subsystem.first->Name() << std::endl;
616 std::cout <<
"Fun4AllServer::Discard Event by " << Subsystem.first->Name() << std::endl;
625 std::cout <<
"Fun4AllServer::Abort Event by " << Subsystem.first->Name() << std::endl;
632 std::cout <<
"Fun4AllServer::Abort Run by " << Subsystem.first->Name() << std::endl;
637 std::cout <<
"Fun4AllServer::Unknown return code: "
638 <<
RetCodes[icnt] <<
" from process_event method of "
639 << Subsystem.first->Name() << std::endl;
640 std::cout <<
"This smells like an uninitialized return code and" << std::endl;
641 std::cout <<
"it is too dangerous to continue, this Run will be aborted" << std::endl;
642 std::cout <<
"If you do not know how to fix this please send mail to" << std::endl;
643 std::cout <<
"phenix-off-l with this message" << std::endl;
654 gROOT->cd(currdir.c_str());
668 static int first = 1;
680 std::cout <<
PHWHERE <<
" FATAL: Someone changed the number of Output Nodes on the fly, from " <<
OutNodeCount <<
" to " << newcount << std::endl;
683 std::vector<Fun4AllOutputManager *>::iterator iterOutMan;
686 if (!(*iterOutMan)->DoNotWriteEvent(&
RetCodes))
690 std::cout <<
"Writing Event for " << (*iterOutMan)->Name() << std::endl;
696 (*iterOutMan)->WriteGeneric(dstNode);
701 if ((*iterOutMan)->EventsWritten() >= (*iterOutMan)->GetNEvents())
705 std::cout <<
PHWHERE << (*iterOutMan)->Name() <<
" wrote " << (*iterOutMan)->EventsWritten()
706 <<
" events, closing " << (*iterOutMan)->OutFileName() << std::endl;
711 (*iterOutMan)->WriteNode(runNode);
718 std::cout <<
"Not Writing Event for " << (*iterOutMan)->Name() << std::endl;
724 for (
auto &Subsystem : Subsystems)
728 std::cout <<
"Fun4AllServer::process_event Resetting Event " << Subsystem.first->Name() << std::endl;
730 Subsystem.first->ResetEvent(Subsystem.second);
736 std::cout <<
"Fun4AllServer::process_event Resetting Event for Sync Manager " << syncman->Name() << std::endl;
738 syncman->ResetEvent();
747 std::vector<std::string> ResetNodeList;
748 ResetNodeList.emplace_back(
"DST");
751 std::map<std::string, PHCompositeNode *>::const_iterator iter;
755 for (
const auto &nodename : ResetNodeList)
757 if (mainIter.
cd(nodename))
770 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
775 std::cout <<
"Fun4AllServer::Reset Resetting " << (*iter).first->Name() << std::endl;
777 i += (*iter).first->Reset((*iter).second);
779 std::vector<Fun4AllHistoManager *>::iterator hiter;
790 std::cout <<
"Setting BOR timestamp to ";
792 std::cout << std::endl;
813 std::cout <<
"overriding BOR timestamp by ";
815 std::cout << std::endl;
820 std::cout <<
"Fun4AllServer::BeginRun: Run number " << runno <<
" uses RECO TIMESTAMP: ";
822 std::cout << std::endl;
824 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
850 gROOT->cd(currdir.c_str());
862 std::string newdirname = subsys.second->getName() +
"/" + subsys.first->Name();
863 if (!gROOT->cd(newdirname.c_str()))
865 std::cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
866 << subsys.second->getName()
867 <<
" - send e-mail to off-l with your macro" << std::endl;
874 std::cout <<
"BeginRun: cded to " << newdirname << std::endl;
880 std::cout <<
"Fun4AllServer::BeginRun: InitRun for " << subsys.first->Name() << std::endl;
887 iret = subsys.first->InitRun(subsys.second);
892 catch (
const std::exception &
e)
894 std::cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::InitRun() from "
895 << subsys.first->Name() << std::endl;
896 std::cout <<
"error: " << e.what() << std::endl;
901 std::cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::InitRun() from "
902 << subsys.first->Name() << std::endl;
908 std::cout <<
PHWHERE <<
"Module " << subsys.first->Name() <<
" issued Abort Run, exiting" << std::endl;
913 std::cout <<
PHWHERE <<
"Module " << subsys.first->Name() <<
" issued non Fun4AllReturnCodes::EVENT_OK return code " << iret <<
" in InitRun()" << std::endl;
933 while ((thisNode = iterat()))
935 if ((thisNode->getType() ==
"PHCompositeNode"))
944 std::cout << thisNode->getName() <<
", Node Count: " << icnt << std::endl;
957 while ((thisNode = iterat()))
959 if ((thisNode->getType() ==
"PHCompositeNode"))
965 thisNode->makeTransient();
977 while ((thisNode = iterat()))
979 if ((thisNode->getType() ==
"PHCompositeNode"))
985 thisNode->makePersistent();
993 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
1000 std::cout <<
"Fun4AllServer::EndRun: EndRun("
1001 << runno <<
") for " << (*iter).first->Name() << std::endl;
1003 std::string newdirname = (*iter).second->getName() +
"/" + (*iter).first->Name();
1004 if (!gROOT->cd(newdirname.c_str()))
1006 std::cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
1007 << (*iter).second->getName()
1008 <<
" - send e-mail to off-l with your macro" << std::endl;
1015 std::cout <<
"EndRun: cded to " << newdirname << std::endl;
1020 (*iter).first->EndRun(runno);
1022 catch (
const std::exception &
e)
1024 std::cout <<
PHWHERE <<
" caught exception thrown during SubsysReco::EndRun() from "
1025 << (*iter).first->Name() << std::endl;
1026 std::cout <<
"error: " << e.what() << std::endl;
1031 std::cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::EndRun() from "
1032 << (*iter).first->Name() << std::endl;
1036 gROOT->cd(currdir.c_str());
1046 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::iterator iter;
1053 std::cout <<
"Fun4AllServer::End: End for " << (*iter).first->Name() << std::endl;
1055 std::string newdirname = (*iter).second->getName() +
"/" + (*iter).first->Name();
1056 if (!gROOT->cd(newdirname.c_str()))
1058 std::cout <<
PHWHERE <<
"Unexpected TDirectory Problem cd'ing to "
1059 << (*iter).second->getName()
1060 <<
" - send e-mail to off-l with your macro" << std::endl;
1067 std::cout <<
"End: cded to " << newdirname << std::endl;
1072 i += (*iter).first->End((*iter).second);
1074 catch (
const std::exception &
e)
1076 std::cout <<
PHWHERE <<
" caught exception thrown during SusbsysReco::End() from "
1077 << (*iter).first->Name() << std::endl;
1078 std::cout <<
"error: " << e.what() << std::endl;
1083 std::cout <<
PHWHERE <<
" caught unknown type exception thrown during SubsysReco::End() from "
1084 << (*iter).first->Name() << std::endl;
1088 gROOT->cd(currdir.c_str());
1093 std::cout <<
"No Run Node, not writing Runwise info" << std::endl;
1100 std::vector<Fun4AllOutputManager *>::iterator IOiter;
1103 (*IOiter)->WriteNode(runNode);
1113 std::cout <<
"*******************************************************************************" << std::endl;
1114 std::cout <<
"*******************************************************************************" << std::endl;
1115 std::cout <<
"*******************************************************************************" << std::endl;
1116 std::cout <<
"Now that we are at the End(), please fix the following "
1118 std::vector<std::string>::const_iterator viter;
1121 std::cout << *viter << std::endl;
1123 std::cout <<
" " << std::endl;
1124 std::cout <<
"*******************************************************************************" << std::endl;
1125 std::cout <<
"*******************************************************************************" << std::endl;
1126 std::cout <<
"*******************************************************************************" << std::endl;
1134 if (what ==
"ALL" || what ==
"HISTOS")
1139 histoman->Print(what);
1142 if (what ==
"ALL" || what ==
"SUBSYSTEMS")
1145 std::cout <<
"--------------------------------------" << std::endl
1147 std::cout <<
"List of Subsystems in Fun4AllServer:" << std::endl;
1149 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::const_iterator miter;
1152 std::cout << (*miter).first->Name()
1153 <<
" running under topNode " << (*miter).second->getName() << std::endl;
1155 std::cout << std::endl;
1158 if (what ==
"ALL" || what ==
"INPUTMANAGER")
1163 std::cout <<
"SyncManager: " << syncman->Name() << std::endl;
1164 syncman->Print(what);
1168 if (what ==
"ALL" || what.find(
"OUTPUTMANAGER") != std::string::npos)
1172 if (pass_on ==
"ALL" || pass_on ==
"OUTPUTMANAGER")
1174 std::cout <<
"--------------------------------------" << std::endl
1176 std::cout <<
"List of OutputManagers in Fun4AllServer:" << std::endl;
1181 std::string::size_type
pos = pass_on.find(
'%');
1182 pass_on = pass_on.substr(pos + 1, pass_on.size());
1186 outman->Print(pass_on);
1188 std::cout << std::endl;
1190 if (what ==
"ALL" || what ==
"TOPNODES")
1193 std::cout <<
"--------------------------------------" << std::endl
1195 std::cout <<
"List of TopNodes in Fun4AllServer:" << std::endl;
1197 std::map<std::string, PHCompositeNode *>::const_iterator iter;
1200 std::cout << iter->first <<
" is at " << std::hex
1201 << iter->second << std::dec << std::endl;
1203 std::cout << std::endl;
1205 if (what ==
"ALL" || what ==
"NODETREE")
1208 std::cout <<
"--------------------------------------" << std::endl
1210 std::cout <<
"List of Nodes in Fun4AllServer:" << std::endl;
1212 std::map<std::string, PHCompositeNode *>::const_iterator iter;
1215 std::cout <<
"Node Tree under TopNode " << iter->first << std::endl;
1218 std::cout << std::endl;
1220 std::cout << std::endl;
1227 out <<
"Fun4AllServer Name: " <<
Name() << std::endl;
1237 std::cout <<
"Erasing OutputManager "
1239 <<
" at memory location " << *(
OutputManager.begin()) << std::endl;
1262 std::map<std::string, PHCompositeNode *>::const_iterator iter;
1266 return iter->second;
1273 return iter->second;
1275 std::cout <<
PHWHERE <<
" Could not create new topNode " << name
1276 <<
" send email to off-l with the following printout: " << std::endl;
1279 std::cout << iter->first <<
" is at " << std::hex << iter->second << std::dec << std::endl;
1286 std::map<std::string, PHCompositeNode *>::const_iterator iter;
1318 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1321 if ((*iter)->getInputManager(name))
1323 return (*iter)->getInputManager(name);
1326 std::cout <<
"Could not locate input manager " << name << std::endl;
1344 static bool run_number_forced = rc->
FlagExist(
"RUNNUMBER");
1345 static int ifirst = 1;
1346 if (ifirst && run_number_forced)
1349 std::cout <<
"Fun4AllServer: Runnumber forced to " <<
runnumber <<
" by RUNNUMBER IntFlag" << std::endl;
1354 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1357 int resetnodetree = 0;
1362 std::cout <<
"executing run for input master " << (*iter)->Name() << std::endl;
1364 int retval = (*iter)->run(1);
1389 (*iter)->PushBackInputMgrsEvents(1);
1401 int runno = (*iter)->CurrentRun();
1405 if (currentrun == 0)
1411 if (currentrun != runno)
1413 if (!(*iter)->MixRunsOk())
1415 std::cout <<
"Mixing of Runs within same event is not supported" << std::endl;
1416 std::cout <<
"Here is the list of Sync Managers and their runnumbers:" << std::endl;
1417 std::vector<Fun4AllSyncManager *>::const_iterator syiter;
1420 std::cout << (*syiter)->Name() <<
" run number: " << (*syiter)->CurrentRun() << std::endl;
1422 std::cout <<
"Exiting now" << std::endl;
1431 if (currentrun !=
runnumber && !run_number_forced)
1439 else if (!run_number_forced)
1451 std::cout <<
"Fun4AllServer::run - processing event "
1452 << (icnt + 1) <<
" from run " <<
runnumber << std::endl;
1473 if (require_nevents)
1481 if (iret || (nevnts > 0 && icnt_good >= nevnts))
1486 else if (iret || (nevnts > 0 && icnt >= nevnts))
1500 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1503 iret += (*iter)->skip(nevnts);
1514 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1517 iret += (*iter)->fileopen(managername, filename);
1525 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1528 iret += (*iter)->BranchSelect(managername, branch, iflag);
1536 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1539 iret += (*iter)->BranchSelect(branch, iflag);
1547 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1550 iret += (*iter)->setBranches(managername);
1558 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1561 iret += (*iter)->setBranches();
1569 std::vector<Fun4AllSyncManager *>::const_iterator iter;
1572 iret += (*iter)->fileclose(managername);
1592 std::map<std::string, PHCompositeNode *>::const_iterator iter;
1595 names.push_back(iter->first);
1597 return names.size();
1603 std::vector<Fun4AllOutputManager *>::const_iterator iter;
1606 names.push_back((*iter)->Name());
1614 std::vector<std::pair<SubsysReco *, PHCompositeNode *>>::const_iterator iter;
1617 names.push_back((*iter).first->Name());
1626 if (syncman->Name() == newmaster->
Name())
1628 std::cout <<
"Input Master " << newmaster->
Name()
1629 <<
" already registered" << std::endl;
1635 std::cout <<
"Registering Input Master " << newmaster->
Name() << std::endl;
1637 SyncManagers.push_back(newmaster);
1644 if (name ==
"DefaultSyncManager")
1648 std::vector<Fun4AllSyncManager *>::iterator iter;
1652 if ((*iter)->Name() ==
name)
1657 std::cout <<
"Could not find Input Master " << name << std::endl;
1669 std::cout <<
"Fun4AllServer::setRun(): run " << runno
1685 std::cout <<
"Could not locate node " << name
1686 <<
" or no PHObject Node" << std::endl;
1693 std::map<const std::string, PHTimer>::const_iterator iter;
1699 iter->second.print_stat();
1707 iter->second.print_stat();
1711 std::cout <<
"No timer with name " << name <<
" found" << std::endl;
1712 std::cout <<
"Existing timers:" << std::endl;
1715 std::cout << iter->first << std::endl;
1724 #ifdef FFAMEMTRACKER
1727 std::cout <<
"PrintMemoryTracker called with " << name <<
" is disabled" << std::endl;