Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

jobc::Job Class Reference

Encapsulate a reconstruction job. More...

#include <Job.h>

Inheritance diagram for jobc::Job:

jobc::Sequence jobc::Node List of all members.

Public Member Functions

 Job (const char *name)
int Run (int nevent=0)
std::string AsXML () const
void CheckStatus (const std::string &s, const edm::EventHandle *evt)

Private Attributes

bool fInit
 Have first-time initializations been done?
int fCurrentRun
 Run number in progress.
int fCurrentSubrun
 Subrun number in progress.
std::string fCurrentFile
 File name in progress.

Detailed Description

Encapsulate a reconstruction job.

Definition at line 18 of file Job.h.


Constructor & Destructor Documentation

Job::Job const char *  name  ) 
 

Definition at line 40 of file Job.cxx.

00040                          : 
00041   Sequence      (name ),
00042   fInit         (false),
00043   fCurrentRun   (-1   ),
00044   fCurrentSubrun(-1   ),
00045   fCurrentFile  (""   )
00046 { }


Member Function Documentation

std::string Job::AsXML  )  const
 

Print the job configuration as an XML string

Reimplemented from jobc::Sequence.

Definition at line 194 of file Job.cxx.

Referenced by testJobCJob().

00195 {
00196   std::ostringstream xml;
00197   xml << "<job name=\"" << fName << "\">\n";
00198   // fNodeList is inherited from Sequence
00199   NodeList::const_iterator itr(fNodeList.begin());
00200   NodeList::const_iterator itrEnd(fNodeList.end());
00201   for (; itr!=itrEnd; ++itr) {
00202     xml << "  " << (*itr)->AsXML() << "\n";
00203   }  
00204   xml << "</job>";
00205   return xml.str();
00206 }

void Job::CheckStatus const std::string &  s,
const edm::EventHandle evt
 

Definition at line 137 of file Job.cxx.

References jobc::Sequence::EndFile(), jobc::Sequence::EndRun(), jobc::Sequence::EndSubrun(), fCurrentFile, fCurrentRun, fCurrentSubrun, fInit, edm::EventHandle::Header(), jobc::Sequence::NewFile(), jobc::Sequence::NewRun(), jobc::Sequence::NewSubrun(), edm::EventHeader::Run(), and edm::EventHeader::Subrun().

Referenced by Run().

00139 {
00140 //======================================================================
00141 // Check the run status looking for things like new files, new run
00142 // numbers, etc.
00143 //======================================================================
00144   int run    = -1;
00145   int subrun = -1;
00146 
00147   if (evt) {
00148     const edm::EventHeader& head = evt->Header();
00149     run    = head.Run();
00150     subrun = head.Subrun();
00151   }
00152   
00153   // Very first time we should issue a begin file, run, and subrun in
00154   // that order. All other times we need to check the status.
00155   switch (fInit) {
00156 
00157   case false:
00158     //------------------------------------------------------------------
00159     if (run>=0 && subrun>=0) {
00160       this->NewRun(run, subrun);
00161       this->NewSubrun(run, subrun);
00162       this->NewFile(file.c_str());
00163     }
00164     break;
00165 
00166   case true:
00167     //------------------------------------------------------------------
00168     // Check status changes in order of most frequent to least frequent
00169     if (fCurrentSubrun != subrun) {
00170       if (fCurrentSubrun!=-1) this->EndSubrun(fCurrentRun, fCurrentSubrun);
00171       if (subrun!=-1)         this->NewSubrun(run, subrun);
00172     }
00173     if (fCurrentRun != run) {
00174       if (fCurrentRun!=-1) this->EndRun(fCurrentRun, fCurrentSubrun);
00175       if (run!=-1) this->NewRun(run, subrun);
00176     }
00177     if (fCurrentFile != file) {
00178       if (fCurrentFile!="") this->EndFile(fCurrentFile.c_str());
00179       if (file!="")         this->NewFile(file.c_str());
00180     }
00181     break;
00182   }
00183   fCurrentRun    = run;
00184   fCurrentSubrun = subrun;
00185   fCurrentFile   = file;
00186   fInit          = true;
00187 }

int Job::Run int  nevent = 0  ) 
 

Todo:
The following code should probably be done only once per instance of the job. Consider moving it to the constructor.

Definition at line 50 of file Job.cxx.

References io::ReadWriteModule::Advance(), CheckStatus(), io::ReadWriteModule::CurrentFile(), jobc::CmdLine::DumpOnException(), io::ReadWriteModule::EventNumber(), jobc::Sequence::Exec(), io::ReadWriteModule::GetEvent(), jobc::CmdLine::HaveSIGHUP(), jobc::CmdLine::Instance(), jobc::Node::Name(), jobc::CmdLine::NmemReport(), jobc::CmdLine::OutFileName(), jobc::Sequence::Print(), io::ReadWriteModule::ReadOK(), io::ReadWriteModule::Report(), jobc::Sequence::ResourceReport(), io::ReadWriteModule::RunNumber(), jobc::CmdLine::SetupIoModule(), tstamp(), and io::ReadWriteModule::WriteEvent().

00051 {
00052 //======================================================================
00053 // Process the next nevents in the queue through this job Use
00054 // nevent=-1 to process all events
00055 //======================================================================
00056   int  nMemReport = 0;
00057   bool printFlag = (nevent!=0);
00058 
00059   // Print begin run status
00060   if (printFlag) {
00061     std::cout << "** Start job '" << this->Name() << "' "
00062               << tstamp() << " **" << std::endl;
00063   }
00064   
00067   //
00068   // Setup the I/O module
00069   //
00070   int            nevt = nevent;
00071   CmdLine& opt  = CmdLine::Instance();
00072   
00073   io::ReadWriteModule iomod;
00074   opt.SetupIoModule(iomod, &nevt);
00075   bool outfile = !(opt.OutFileName()==std::string(""));
00076   if (printFlag) iomod.Report();
00077 
00078   // Event loop
00079   if (nevt==0) {
00080     edm::EventHandle& evt = iomod.GetEvent();
00081     this->CheckStatus(iomod.CurrentFile(), &evt);
00082     this->Exec(evt);
00083   }
00084   else {
00085     int n = 0;
00086     nMemReport = opt.NmemReport();
00087     for (; (iomod.ReadOK() && n<nevt); iomod.Advance()) {
00088       edm::EventHandle& evt = iomod.GetEvent();
00089       try {
00090         this->CheckStatus(iomod.CurrentFile(), &evt);
00091         bool passed = this->Exec(evt);
00092         if (passed && outfile) iomod.WriteEvent();
00093       }
00094       catch(Exception jce) {
00095         std::cout << "Job assertion '" << jce.fExpression
00096                   << "' failed:\n";
00097         if (!jce.fMessage.empty()) std::cout<<"  | "<<jce.fMessage<<"\n";
00098         std::cout << "  | in " << jce.fFile << ":" << jce.fLine
00099                   << "\n  |- Run "<<iomod.RunNumber() << " event " 
00100                   << iomod.EventNumber() << ": " << iomod.CurrentFile()
00101                   << std::endl;
00102         if (opt.DumpOnException()) break;
00103       }
00104       ++n;
00105       if (n>0 && nMemReport>0 && n%nMemReport==0) {
00106         this->ResourceReport(true);
00107       }
00108       if (n%1000==0) {
00109         std::cout << "[" << n << "] " 
00110                   << tstamp() << " /"
00111                   << iomod.RunNumber() << ":" << iomod.EventNumber()
00112                   << "/ " << iomod.CurrentFile()
00113                   << std::endl;
00114       }
00115       // Check for sighup signal
00116       if (CmdLine::Instance().HaveSIGHUP()==true) {
00117         std::cout << "** Job ending on SIGHUP " << std::endl;
00118         break;
00119       }
00120     }
00121   }
00122   this->CheckStatus(std::string(""),0);
00123 
00124   // Print end run status
00125   if (printFlag) {
00126     std::cout << "** " << tstamp() << " End job " << this->Name() 
00127               << " **" << std::endl;
00128     this->Print();
00129   }
00130   if (nMemReport>0) this->ResourceReport(true);
00131 
00132   return 1;
00133 }


Member Data Documentation

std::string jobc::Job::fCurrentFile [private]
 

File name in progress.

Definition at line 32 of file Job.h.

Referenced by CheckStatus().

int jobc::Job::fCurrentRun [private]
 

Run number in progress.

Definition at line 30 of file Job.h.

Referenced by CheckStatus().

int jobc::Job::fCurrentSubrun [private]
 

Subrun number in progress.

Definition at line 31 of file Job.h.

Referenced by CheckStatus().

bool jobc::Job::fInit [private]
 

Have first-time initializations been done?

Definition at line 29 of file Job.h.

Referenced by CheckStatus().


The documentation for this class was generated from the following files:
Generated on Sun Nov 22 04:45:31 2009 for NOvA Offline by  doxygen 1.3.9.1