Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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)

Static Public Member Functions

void PrintCurrentNode ()

Private Types

typedef std::list< Node * > NodeList

Private Member Functions

void Clear ()

Private Attributes

NodeList fNodeList
 List of nodes in this sequence.


Static Private Attributes

std::string fsCurrentNode = ""
 Node currently being processed.

int fsCurrentEvent = 0
 Event number being processed.


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 [private]
 

Definition at line 54 of file Sequence.h.


Constructor & Destructor Documentation

Sequence::Sequence  ) 
 

Definition at line 24 of file Sequence.cxx.

Referenced by PushBack(), and PushFront().

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

Sequence::Sequence const char *  name  ) 
 

Definition at line 36 of file Sequence.cxx.

00036                                    : 
00037   Node(name,"*",true) 
00038 { }

Sequence::Sequence const Sequence s  ) 
 

Definition at line 28 of file Sequence.cxx.

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

Sequence::~Sequence  ) 
 

Definition at line 42 of file Sequence.cxx.

References Clear().

00043 {
00044   this->Clear();
00045 }


Member Function Documentation

void Sequence::Clear  )  [private]
 

Definition at line 49 of file Sequence.cxx.

References fNodeList.

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

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

void Sequence::EndFile const char *  filename  ) 
 

Definition at line 153 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().

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

void Sequence::EndRun int  run,
int  subrun
 

Definition at line 193 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().

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

void Sequence::EndSubrun int  run,
int  subrun
 

Definition at line 233 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().

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

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

Reimplemented from jobc::Node.

Definition at line 99 of file Sequence.cxx.

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

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

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

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

Reimplemented from jobc::Node.

Definition at line 84 of file Sequence.cxx.

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

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

void Sequence::NewFile const char *  filename  ) 
 

Definition at line 133 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().

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

void Sequence::NewRun int  run,
int  subrun
 

Definition at line 173 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().

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

void Sequence::NewSubrun int  run,
int  subrun
 

Definition at line 213 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().

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

Sequence & Sequence::operator= const Sequence rhs  ) 
 

Definition at line 64 of file Sequence.cxx.

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

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

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

Definition at line 269 of file Sequence.cxx.

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

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

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

void Sequence::PrintCurrentNode  )  [static]
 

Definition at line 386 of file Sequence.cxx.

References fsCurrentEvent, and fsCurrentNode.

Referenced by gsSIGHUPhandler().

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

Sequence * Sequence::PushBack const Sequence s  ) 
 

Definition at line 374 of file Sequence.cxx.

References fNodeList, and Sequence().

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

Node * Sequence::PushBack const Node n  ) 
 

Definition at line 350 of file Sequence.cxx.

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

Referenced by operator=().

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

Sequence * Sequence::PushFront const Sequence s  ) 
 

Definition at line 362 of file Sequence.cxx.

References fNodeList, and Sequence().

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

Node * Sequence::PushFront const Node n  ) 
 

Definition at line 338 of file Sequence.cxx.

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

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

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

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

Reimplemented from jobc::Node.

Definition at line 253 of file Sequence.cxx.

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

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

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


Member Data Documentation

NodeList jobc::Sequence::fNodeList [private]
 

List of nodes in this sequence.

Definition at line 56 of file Sequence.h.

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

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

Event number being processed.

Definition at line 20 of file Sequence.cxx.

Referenced by Exec(), and PrintCurrentNode().

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

Node currently being processed.

Definition at line 19 of file Sequence.cxx.

Referenced by Exec(), and PrintCurrentNode().


The documentation for this class was generated from the following files:
Generated on Fri Jul 25 02:05:54 2008 for NOvA Offline by doxygen 1.3.5