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

jobc::Sequence Class Reference

A sequence is a set of nodes that are executed together as if they were a single node. More...

#include <Sequence.h>

Inheritance diagram for jobc::Sequence:

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

Public Member Functions

 Sequence ()
 Sequence (const char *name)
 Sequence (const Sequence &s)
 ~Sequence ()
NodeGetNode (const char *name)
bool Exec (edm::EventHandle &evt)
void NewFile (const char *filename)
void EndFile (const char *filename)
void NewRun (int run, int subrun)
void EndRun (int run, int subrun)
void NewSubrun (int run, int subrun)
void EndSubrun (int run, int subrun)
void Print (const char *indent=0)
void ResourceReport (bool printheader=false) const
NodePushFront (const Node &n)
NodePushBack (const Node &n)
SequencePushFront (const Sequence &s)
SequencePushBack (const Sequence &s)
Sequenceoperator= (const Sequence &rhs)
std::string AsXML () const

Static Public Member Functions

void PrintCurrentNode ()

Protected Types

typedef std::list< Node * > NodeList

Protected Attributes

NodeList fNodeList
 List of nodes in this sequence.

Static Protected Attributes

std::string fsCurrentNode = ""
 Node currently being processed.
int fsCurrentEvent = 0
 Event number being processed.

Private Member Functions

void Clear ()

Detailed Description

A sequence is a set of nodes that are executed together as if they were a single node.

For example, the list of modules that perform cluster finding, merging, and fitting might be group into a sequence called "TrackReco"

Definition at line 22 of file Sequence.h.


Member Typedef Documentation

typedef std::list<Node*> jobc::Sequence::NodeList [protected]
 

Definition at line 56 of file Sequence.h.


Constructor & Destructor Documentation

Sequence::Sequence  ) 
 

Definition at line 26 of file Sequence.cxx.

Referenced by PushBack(), and PushFront().

00026 : Node("*","*",true) { }

Sequence::Sequence const char *  name  ) 
 

Definition at line 38 of file Sequence.cxx.

00038                                    : 
00039   Node(name,"*",true) 
00040 { }

Sequence::Sequence const Sequence s  ) 
 

Definition at line 30 of file Sequence.cxx.

00030                                     :
00031   Node("*","*",true)
00032 { 
00033   *this = s; 
00034 }

Sequence::~Sequence  ) 
 

Definition at line 44 of file Sequence.cxx.

References Clear().

00045 {
00046   this->Clear();
00047 }


Member Function Documentation

std::string Sequence::AsXML  )  const
 

Write out the sequence as an XML string

Reimplemented from jobc::Node.

Reimplemented in jobc::Job.

Definition at line 398 of file Sequence.cxx.

References fNodeList.

Referenced by testJobCSequence().

00399 {
00400   std::ostringstream xml;
00401   xml << "<sequence name=\"" << fName << "\">\n";
00402   NodeList::const_iterator itr(fNodeList.begin());
00403   NodeList::const_iterator itrEnd(fNodeList.end());
00404   for (; itr!=itrEnd; ++itr) {
00405     xml << "  " << (*itr)->AsXML() << "\n";
00406   }  
00407   xml << "</sequence>";
00408   return xml.str();
00409 }

void Sequence::Clear  )  [private]
 

Definition at line 51 of file Sequence.cxx.

References fNodeList.

Referenced by operator=(), and ~Sequence().

00052 {
00053   NodeList::iterator itr   (fNodeList.begin());
00054   NodeList::iterator itrEnd(fNodeList.end());
00055   for (; itr!=itrEnd; ++itr) {
00056     if (*itr) { 
00057       delete *itr; 
00058       *itr=0;
00059     }
00060   }
00061   fNodeList.clear(); 
00062 }

void Sequence::EndFile const char *  filename  ) 
 

Definition at line 155 of file Sequence.cxx.

References jobc::Module::EndFile(), fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00156 {
00157   NodeList::iterator itr   ( fNodeList.begin() );
00158   NodeList::iterator itrEnd( fNodeList.end()   );
00159   for (; itr!=itrEnd; ++itr) {
00160     Node*     n = *itr;
00161     Sequence* s = static_cast<Sequence*>(n);
00162     if (n->IsSequence()) { 
00163       s->EndFile(filename); 
00164     }
00165     else { 
00166       this->StepInToFolder();
00167       n->GetModule()->EndFile(filename); 
00168       this->StepOutOfFolder();
00169     }
00170   }
00171 }

void Sequence::EndRun int  run,
int  subrun
 

Definition at line 195 of file Sequence.cxx.

References jobc::Module::EndRun(), fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00196 {
00197   NodeList::const_iterator itr   ( fNodeList.begin() );
00198   NodeList::const_iterator itrEnd( fNodeList.end()   );
00199   for (; itr!=itrEnd; ++itr) {
00200     Node*     n = *itr;
00201     Sequence* s = static_cast<Sequence*>(n);
00202     if (n->IsSequence()) {
00203       s->EndRun(run, subrun); 
00204     }
00205     else {
00206       n->StepInToFolder();
00207       n->GetModule()->EndRun(run, subrun); 
00208       n->StepOutOfFolder();
00209     }
00210   }
00211 }

void Sequence::EndSubrun int  run,
int  subrun
 

Definition at line 235 of file Sequence.cxx.

References jobc::Module::EndSubrun(), fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00236 {
00237   NodeList::const_iterator itr   ( fNodeList.begin() );
00238   NodeList::const_iterator itrEnd( fNodeList.end()   );
00239   for (; itr!=itrEnd; ++itr) {
00240     Node*     n = *itr;
00241     Sequence* s = static_cast<Sequence*>(n);
00242     if (n->IsSequence()) {
00243       s->EndSubrun(run, subrun); 
00244     }
00245     else { 
00246       n->StepInToFolder();
00247       n->GetModule()->EndSubrun(run, subrun); 
00248       n->StepOutOfFolder();
00249     }
00250   }
00251 }

bool Sequence::Exec edm::EventHandle evt  )  [virtual]
 

Todo:
Support filters based on any combination of Reco and Ana results

Reimplemented from jobc::Node.

Definition at line 101 of file Sequence.cxx.

References jobc::Resource::Difference(), fNodeList, fsCurrentEvent, fsCurrentNode, edm::EventHandle::Header(), jobc::Resource::Log(), and jobc::Resource::Sum().

Referenced by jobc::Job::Run().

00102 {
00103   Resource r1;
00104   Resource r2;
00105 
00106   fsCurrentEvent  = evt.Header().Event();
00107   
00108   bool       passed = true;
00109   NodeList::iterator itr   (fNodeList.begin());
00110   NodeList::iterator itrEnd(fNodeList.end());
00111   r1.Log();
00112   for (; itr!=itrEnd; ++itr) {
00113     fsCurrentNode = (*itr)->Name();
00114     passed = (*itr)->Exec(evt);
00115     if (passed == false) break;
00116   }
00117   r2.Log();
00118   r2.Difference(r1);
00119   Node::fResourceAna.Sum(r2);
00120 
00121   if (passed) ++Node::fNpassReco;
00122   else        ++Node::fNfailReco;
00123 
00124   // No filters set, pass all events
00125   if (Node::fFilterActive==false) return true;
00126 
00127   // Filter reversed: flip pass/fail
00128   if (Node::fFilterReversed) return !passed;
00129 
00130   return passed;
00131 }

Node * Sequence::GetNode const char *  name  )  [virtual]
 

Reimplemented from jobc::Node.

Definition at line 86 of file Sequence.cxx.

References fNodeList, and jobc::Node::Name().

00087 {
00088   NodeList::iterator itr   (fNodeList.begin());
00089   NodeList::iterator itrEnd(fNodeList.end());
00090   for (; itr!=itrEnd; ++itr) if ((*itr)->Name() == name) return *itr;
00091 
00092   std::cerr 
00093     << "JobCSequence:" << __LINE__ 
00094     << " Node '" << name << "' not found in sequence '" << this->Name() 
00095     << "'" << std::endl;
00096   abort();
00097 }

void Sequence::NewFile const char *  filename  ) 
 

Definition at line 135 of file Sequence.cxx.

References fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Module::NewFile(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00136 {
00137   NodeList::iterator itr   ( fNodeList.begin() );
00138   NodeList::iterator itrEnd( fNodeList.end()   );
00139   for (; itr!=itrEnd; ++itr) {
00140     Node*     n = *itr;
00141     Sequence* s = static_cast<Sequence*>(n);
00142     if (n->IsSequence()) { 
00143       s->NewFile(filename); 
00144     }
00145     else {
00146       this->StepInToFolder();
00147       n->GetModule()->NewFile(filename); 
00148       this->StepOutOfFolder();
00149     }
00150   }
00151 }

void Sequence::NewRun int  run,
int  subrun
 

Definition at line 175 of file Sequence.cxx.

References fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Module::NewRun(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00176 {
00177   NodeList::const_iterator itr   ( fNodeList.begin() );
00178   NodeList::const_iterator itrEnd( fNodeList.end()   );
00179   for (; itr!=itrEnd; ++itr) {
00180     Node*     n = *itr;
00181     Sequence* s = static_cast<Sequence*>(n);
00182     if (n->IsSequence()) {
00183       s->NewRun(run, subrun); 
00184     }
00185     else { 
00186       n->StepInToFolder();
00187       n->GetModule()->NewRun(run, subrun); 
00188       n->StepOutOfFolder();
00189     }
00190   }
00191 }

void Sequence::NewSubrun int  run,
int  subrun
 

Definition at line 215 of file Sequence.cxx.

References fNodeList, jobc::Node::GetModule(), jobc::Node::IsSequence(), jobc::Module::NewSubrun(), jobc::Node::StepInToFolder(), and jobc::Node::StepOutOfFolder().

Referenced by jobc::Job::CheckStatus().

00216 {
00217   NodeList::const_iterator itr   ( fNodeList.begin() );
00218   NodeList::const_iterator itrEnd( fNodeList.end()   );
00219   for (; itr!=itrEnd; ++itr) {
00220     Node*     n = *itr;
00221     Sequence* s = static_cast<Sequence*>(n);
00222     if (n->IsSequence()) { 
00223       s->NewSubrun(run, subrun); 
00224     }
00225     else {
00226       n->StepInToFolder();
00227       n->GetModule()->NewSubrun(run, subrun);
00228       n->StepOutOfFolder();
00229     }
00230   }
00231 }

Sequence & Sequence::operator= const Sequence rhs  ) 
 

Definition at line 66 of file Sequence.cxx.

References Clear(), fNodeList, jobc::Node::IsSequence(), jobc::Node::operator=(), and PushBack().

00067 {
00068   // Base class copy
00069   this->Node::operator=(rhs);
00070   
00071   // Create copy of rhs's list of nodes
00072   this->Clear();
00073   NodeList::const_iterator itr   ( rhs.fNodeList.begin() );
00074   NodeList::const_iterator itrEnd( rhs.fNodeList.end()   );
00075   for (; itr!=itrEnd; ++itr) {
00076     const Node*     n = *itr;
00077     const Sequence* s = static_cast<const Sequence*>(n);
00078     if (n->IsSequence()) { this->PushBack(*s); }
00079     else                 { this->PushBack(*n); }
00080   }
00081   return *this;
00082 }

void Sequence::Print const char *  indent = 0  ) 
 

Definition at line 271 of file Sequence.cxx.

References jobc::Node::AnaTime(), fNodeList, jobc::Node::IsSequence(), jobc::Node::Name(), jobc::Node::Print(), jobc::Node::RecoTime(), jobc::HistoFile::StepIn(), and jobc::HistoFile::StepOut().

Referenced by jobc::Job::Run().

00272 {
00273   TH1F* histoR = 0;
00274   TH1F* histoA = 0;
00275   TH1F* histoTot = 0;
00276 
00277   if (indent) std::cout << indent;
00278   else {
00279     HistoFile::StepIn(0);
00280     char name[64], title[64];
00281     int n = fNodeList.size();
00282     sprintf(name, "recoTime_%s", Name());
00283     sprintf(title, "Time spent by %s in Reco(); ;Clock ticks", Name());
00284     histoR = new TH1F(name, title, n, 0, n);
00285     sprintf(name, "anaTime_%s", Name());
00286     sprintf(title, "Time spent by %s in Ana(); ;Clock ticks", Name());
00287     histoA = new TH1F(name, title, n, 0, n);
00288     sprintf(name, "totTime_%s", Name());
00289     sprintf(title, "Total Time Taken by %s; ;Clock Ticks", Name());
00290     histoTot = new TH1F(name, title, n, 0, n);
00291   }
00292   if (Node::fFilterActive) {
00293     if   (Node::fFilterReversed) std::cout << "!-";
00294     else                               std::cout << "+-";
00295   }
00296   else                               std::cout << "|-";
00297   std::cout << this->Name() << " sequence ("
00298             << Node::fNpassReco << "/"
00299             << Node::fNfailReco << "/"
00300             << Node::fNpassReco+fNfailReco
00301             << " events "
00302             << Node::fResourceAna.utime << "u/"
00303             << Node::fResourceAna.stime << "s seconds)"
00304             << std::endl;
00305 
00306   std::string ind2;
00307   if (indent) { ind2 = indent; ind2 += " "; }
00308   else        { ind2 = " "; }
00309 
00310   NodeList::iterator itr   (fNodeList.begin());
00311   NodeList::iterator itrEnd(fNodeList.end());
00312   for (unsigned int i = 0; itr != itrEnd; ++i, ++itr) {
00313     Node* n = (*itr);
00314     if (histoR) {
00315       histoA->GetXaxis()->SetBinLabel(i + 1, n->Name());
00316       histoA->Fill(i, n->AnaTime());
00317       histoR->GetXaxis()->SetBinLabel(i + 1, n->Name());
00318       histoR->Fill(i, n->RecoTime());
00319       histoTot->GetXaxis()->SetBinLabel(i + 1, n->Name());
00320       histoTot->Fill(i, n->AnaTime() + n->RecoTime());
00321     }
00322     Sequence* s = static_cast<Sequence*>(n);
00323     if (n->IsSequence()) s->Print(ind2.c_str());
00324     else                 n->Print(ind2.c_str());
00325   }
00326   if (histoR) {
00327     HistoFile::StepIn(0);
00328     histoR->Write();
00329     histoA->Write();
00330     histoTot->Write();
00331     delete histoR;
00332     delete histoA;
00333     delete histoTot;
00334     HistoFile::StepOut();
00335   }
00336 }

void Sequence::PrintCurrentNode  )  [static]
 

Definition at line 388 of file Sequence.cxx.

References fsCurrentEvent, and fsCurrentNode.

Referenced by gsSIGHUPhandler().

00389 {
00390   std::cout << "Processing " << fsCurrentNode << ", event "
00391             << fsCurrentEvent << std::endl;
00392 }

Sequence * Sequence::PushBack const Sequence s  ) 
 

Definition at line 376 of file Sequence.cxx.

References fNodeList, and Sequence().

00377 {
00378   // Add a copy of the node n to the sequence
00379   Sequence* ss = new Sequence(s);
00380   fNodeList.push_back( ss );
00381   
00382   // Return the node just added
00383   return ss;
00384 }

Node * Sequence::PushBack const Node n  ) 
 

Definition at line 352 of file Sequence.cxx.

References fNodeList, and jobc::Node::Node().

Referenced by operator=(), testJobCJob(), and testJobCSequence().

00353 {
00354   // Add a copy of the node n to the sequence
00355   Node* nn = new Node( n );
00356   fNodeList.push_back( nn );
00357 
00358   // Return the node just added
00359   return nn;
00360 }

Sequence * Sequence::PushFront const Sequence s  ) 
 

Definition at line 364 of file Sequence.cxx.

References fNodeList, and Sequence().

00365 {
00366   // Add a copy of the node n to the sequence
00367   Sequence* ss = new Sequence(s);
00368   fNodeList.push_front(ss);
00369 
00370   // Return the node just added
00371   return ss;
00372 }

Node * Sequence::PushFront const Node n  ) 
 

Definition at line 340 of file Sequence.cxx.

References fNodeList, and jobc::Node::Node().

Referenced by jobc::sequenceBuilder::Build(), and jobc::jobBuilder::Build().

00341 {
00342   // Add a copy of the node n to the sequence
00343   Node* nn = new Node( n );
00344   fNodeList.push_front(nn);
00345   
00346   // Return the node just added
00347   return nn;
00348 }

void Sequence::ResourceReport bool  printheader = false  )  const [virtual]
 

Reimplemented from jobc::Node.

Definition at line 255 of file Sequence.cxx.

References fNodeList, jobc::Node::IsSequence(), and jobc::Node::ResourceReport().

Referenced by jobc::Job::Run().

00256 {
00257   bool doheader = printheader;
00258   NodeList::const_iterator itr   (fNodeList.begin());
00259   NodeList::const_iterator itrEnd(fNodeList.end());
00260   for (; itr!=itrEnd; ++itr) {
00261     const Node*     n = (*itr);
00262     const Sequence* s = static_cast<const Sequence*>(n);
00263     if (n->IsSequence()) s->ResourceReport(doheader);
00264     else                 n->ResourceReport(doheader);
00265     doheader = false;
00266   }
00267 }


Member Data Documentation

NodeList jobc::Sequence::fNodeList [protected]
 

List of nodes in this sequence.

Definition at line 58 of file Sequence.h.

Referenced by AsXML(), Clear(), EndFile(), EndRun(), EndSubrun(), Exec(), GetNode(), NewFile(), NewRun(), NewSubrun(), operator=(), Print(), PushBack(), PushFront(), and ResourceReport().

int Sequence::fsCurrentEvent = 0 [static, protected]
 

Event number being processed.

Definition at line 22 of file Sequence.cxx.

Referenced by Exec(), and PrintCurrentNode().

std::string Sequence::fsCurrentNode = "" [static, protected]
 

Node currently being processed.

Definition at line 21 of file Sequence.cxx.

Referenced by Exec(), and PrintCurrentNode().


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 04:45:33 2009 for NOvA Offline by  doxygen 1.3.9.1