anamipp.cc

Go to the documentation of this file.
00001 #include <list>
00002 #include <string>
00003 #include <csignal>
00004 #include "TROOT.h"
00005 #include "JobControl/JobCmdLine.h"
00006 #include "JobControl/JobCStack.h"
00007 #include "JobControl/JobCHistoFile.h"
00008 #include "JobControl/JobCSequence.h"
00009 #include "MippXML/MXML.h"
00010 #include "Config/CfgTable.h"
00011 
00012 static TROOT troot("anamipp","anamipp");
00013 
00014 TFile* gsHistoFile = 0;
00015 
00016 static void gsSIGHUPhandler(int s) 
00017 {
00018   switch (s) {
00019   case SIGINT: case SIGQUIT: case SIGTERM: case SIGHUP:
00020     JobCmdLine::Instance().SetSIGHUP();
00021     break;
00022 
00023   case SIGUSR1:
00024     JobCSequence::PrintCurrentNode();
00025     break;
00026 
00027   default:
00028     break;
00029   }
00030 }
00031 
00032 //......................................................................
00033 
00034 int main(int argc, char** argv) 
00035 {
00036   JobCmdLine::Instance().Parse(argc, argv);
00037   JobCHistoFile::SetFileName(JobCmdLine::Instance().HistoFileName());
00038 
00039   // Start the XML parser and load files and directories specified on
00040   // the command line
00041   MXML::Initialize();
00042 
00043   std::list<std::string>::const_iterator itr;
00044   std::list<std::string>::const_iterator itrEnd;
00045 
00046   itr    = JobCmdLine::Instance().XMLFileList().begin();
00047   itrEnd = JobCmdLine::Instance().XMLFileList().end();
00048   for (; itr!=itrEnd; ++itr) MXML::ReadFile((*itr).c_str());
00049 
00050   itr    = JobCmdLine::Instance().XMLDirList().begin();
00051   itrEnd = JobCmdLine::Instance().XMLDirList().end();
00052   for (; itr!=itrEnd; ++itr) MXML::ReadDirectory((*itr).c_str());
00053   
00054   // Set the handler for the SIGHUP signal. Signal ends the job
00055   // gracefully at end of event currently being processed
00056   signal(SIGINT,gsSIGHUPhandler);
00057   signal(SIGQUIT,gsSIGHUPhandler);
00058   signal(SIGTERM,gsSIGHUPhandler);
00059   signal(SIGHUP,gsSIGHUPhandler);
00060   signal(SIGUSR1,gsSIGHUPhandler);
00061 
00062   // Run all the jobs in the stack
00063   JobCStack::Instance().Run();
00064   JobCStack::Instance().CleanUp();
00065 
00066   // Clean up the histogram file
00067   if (JobCHistoFile::File()) {
00068     JobCHistoFile::File()->Write();
00069     JobCHistoFile::File()->Close();
00070   }
00071 
00072   return 0;
00073 }
00074 ////////////////////////////////////////////////////////////////////////

Generated on Mon Nov 23 08:01:43 2009 for MIPP(E907) by  doxygen 1.4.7