LoopSequence Class Reference

#include <LoopSequence.h>

List of all members.

Public Member Functions

void Run () const
Long64_t StartEntry () const
Long64_t StopEntry () const
const ARGUMENTSGetCommandLineArgs ()

Protected Member Functions

 LoopSequence (const ARGUMENTS &args)
 LoopSequence (const LoopSequence &src)
LoopSequenceoperator= (const LoopSequence &rhs)
void Init ()
void Preprocess () const
void Process () const
void Postprocess () const
void Checkpoint (Long64_t entry) const

Private Attributes

const ARGUMENTS fArgs
Long64_t fStart
Long64_t fStop

Friends

class EventNavigator

Detailed Description

Definition at line 14 of file LoopSequence.h.


Constructor & Destructor Documentation

LoopSequence::LoopSequence ( const ARGUMENTS args  )  [inline, protected]

Definition at line 26 of file LoopSequence.h.

References Init().

00027     : fArgs(args)
00028   {
00029     Init();
00030   }

LoopSequence::LoopSequence ( const LoopSequence src  )  [protected]

Member Function Documentation

void LoopSequence::Checkpoint ( Long64_t  entry  )  const [protected]

Definition at line 183 of file LoopSequence.cpp.

References fStart, and fStop.

Referenced by Process().

00184 {
00185   Long64_t n = entry-fStart;
00186   static Long64_t nTot = fStop-fStart;
00187   static int nDig = 1+std::floor(std::log10(nTot));
00188   if ( n  < 10 || n %(nTot/10)==0 ) {
00189     std::cout << "Processed  " << std::setw(nDig) << n 
00190               << "/" << std::setw(nDig) << nTot
00191               << "  (" <<std::setw(2)<< std::floor((100.*n) / nTot) 
00192               << "%)" << std::endl;  
00193   }
00194   return;
00195 }

const ARGUMENTS& LoopSequence::GetCommandLineArgs (  )  [inline]

Definition at line 22 of file LoopSequence.h.

References fArgs.

00022 {return fArgs;}

void LoopSequence::Init (  )  [protected]

Definition at line 63 of file LoopSequence.cpp.

References fArgs, fStart, fStop, EventNavigator::GetInputNEntries(), EventNavigator::Instance(), ARGUMENTS::start, and ARGUMENTS::stop.

Referenced by LoopSequence().

00064 {
00065   // How many entries should we loop over?
00066   Long64_t nEntries = EventNavigator::Instance().GetInputNEntries();
00067   bool has_start = (fArgs.start > 0) && (fArgs.start < nEntries);
00068   fStart = (has_start) ? fArgs.start : 0;
00069   bool has_stop = (fArgs.stop > 0) && (fArgs.stop < nEntries);
00070   fStop = (has_stop) ? fArgs.stop : nEntries;
00071 }

LoopSequence& LoopSequence::operator= ( const LoopSequence rhs  )  [protected]
void LoopSequence::Postprocess (  )  const [protected]

Definition at line 120 of file LoopSequence.cpp.

References modules::navigator::Begin(), modules::navigator::End(), fStop, EventNavigator::GetRawData(), EventNavigator::GetSetupData(), modules::navigator::Instance(), EventNavigator::Instance(), and BaseModule::Postprocess().

Referenced by Run().

00121 {
00122   EventNavigator& enav = EventNavigator::Instance();
00123   int err_code =0;
00124   modules::navigator& mn = *modules::navigator::Instance();
00125   BaseModule* mod =NULL;
00126   for (modules::iterator it = mn.Begin(); it != mn.End() && !err_code; ++it) {
00127     mod = it->second;
00128     err_code |= mod->Postprocess(enav.GetRawData(), enav.GetSetupData());
00129   }
00130   if ( err_code ) throw postprocess_error(fStop-1,mod);
00131 }

void LoopSequence::Preprocess (  )  const [protected]

Definition at line 75 of file LoopSequence.cpp.

References modules::navigator::Begin(), modules::navigator::End(), fStart, EventNavigator::GetEntry(), EventNavigator::GetRawData(), EventNavigator::GetSetupData(), modules::navigator::Instance(), EventNavigator::Instance(), and BaseModule::Preprocess().

Referenced by Run().

00076 {
00077   EventNavigator& enav = EventNavigator::Instance();
00078   enav.GetEntry(fStart);
00079   int err_code =0;
00080   modules::navigator& mn = *modules::navigator::Instance();
00081   BaseModule* mod =NULL;
00082   for (modules::iterator it = mn.Begin(); it != mn.End() && !err_code; ++it) {
00083     mod = it->second;
00084     err_code |= mod->Preprocess(enav.GetRawData(), enav.GetSetupData());
00085   }
00086   if (err_code) throw preprocess_error(fStart,mod);
00087 }

void LoopSequence::Process (  )  const [protected]

Definition at line 91 of file LoopSequence.cpp.

References modules::navigator::Begin(), Checkpoint(), TGlobalData::Clear(), ClearGlobalData(), modules::navigator::End(), fStart, fStop, EventNavigator::GetEntry(), EventNavigator::GetRawData(), EventNavigator::GetSetupData(), modules::navigator::Instance(), EventNavigator::Instance(), and BaseModule::ProcessGenericEntry().

Referenced by Run().

00092 {
00093   EventNavigator& enav = EventNavigator::Instance();
00094   BaseModule* mod =NULL;
00095   for (Long64_t jentry = fStart; jentry < fStop; ++jentry){
00096     //This to move unrder event navigator
00097     TGlobalData* raw_data = enav.GetRawData();
00098     if (raw_data){
00099       raw_data->Clear("C");
00100       ClearGlobalData(raw_data);
00101     }
00102     
00103     Checkpoint(jentry);
00104     
00105     enav.GetEntry(jentry);
00106     int err_code = 0;
00107     modules::navigator& mn = *modules::navigator::Instance();
00108     for (modules::iterator it = mn.Begin(); it != mn.End() && ! err_code; ++it) {
00109       mod = it->second;
00110       err_code |= mod->ProcessGenericEntry(raw_data,enav.GetSetupData());
00111     }
00112     if (err_code) throw process_error(jentry,mod);
00113   
00114   }
00115   return;
00116 }

void LoopSequence::Run (  )  const

Definition at line 135 of file LoopSequence.cpp.

References Except::Base::bt(), module_error::fEvent, module_error::fModule, BaseModule::GetName(), Postprocess(), Preprocess(), Process(), and Except::Base::what().

Referenced by Main_event_loop().

00136 {
00137   try {
00138     this->Preprocess();
00139     this->Process();
00140     this->Postprocess();
00141   }
00142   catch (preprocess_error& e){
00143     std::cout << "\nError while preprocessing first entry (" 
00144               << e.fEvent << ")";
00145     if(e.fModule) std::cout<<" for module "<<e.fModule->GetName();
00146   }
00147   catch (process_error& e){
00148     try{
00149         // try to let each module finish to save plots etc
00150         this->Postprocess();
00151     } catch(...) {
00152         // if postprocess throws an error assume it's related to the process
00153         // error
00154         if(e.fModule) std::cout<<"\nModule "<<e.fModule->GetName();
00155         else std::cout << "\nA module";
00156         std::cout<<" returned non-zero on entry " << e.fEvent;
00157         throw;
00158     }
00159     if(e.fModule) std::cout<<"\nModule "<<e.fModule->GetName();
00160     else std::cout << "\nA module";
00161     std::cout<<" returned non-zero on entry " << e.fEvent;
00162   }
00163   catch (postprocess_error& e){
00164     if(e.fModule) std::cout<<"\nModule "<<e.fModule->GetName();
00165     else std::cout << "\nA module";
00166     std::cout<<" returned non-zero on during post-processing last entry " << e.fEvent;
00167   }
00168   catch (module_error& e){
00169     if(e.fModule) std::cout<<"\nModule "<<e.fModule->GetName();
00170     else std::cout << "\nA module";
00171     std::cout<<" returned non-zero on during pre-processing first entry " << e.fEvent;
00172   }
00173   catch (Except::Base& e){
00174       std::cout<<"Alcap exception was thrown: "<<std::endl;
00175       std::cout<<e.what()<<std::endl;
00176       std::cout<<e.bt()<<std::endl;
00177   }
00178   std::cout << std::endl;
00179 }  

Long64_t LoopSequence::StartEntry (  )  const [inline]

Definition at line 19 of file LoopSequence.h.

References fStart.

Referenced by EventNavigator::GetStartEntry().

00019 {return fStart;}

Long64_t LoopSequence::StopEntry (  )  const [inline]

Definition at line 20 of file LoopSequence.h.

References fStop.

Referenced by EventNavigator::GetStopEntry().

00020 {return fStop;}


Friends And Related Function Documentation

friend class EventNavigator [friend]

Definition at line 15 of file LoopSequence.h.


Member Data Documentation

const ARGUMENTS LoopSequence::fArgs [private]

Definition at line 42 of file LoopSequence.h.

Referenced by GetCommandLineArgs(), and Init().

Long64_t LoopSequence::fStart [private]

Definition at line 43 of file LoopSequence.h.

Referenced by Checkpoint(), Init(), Preprocess(), Process(), and StartEntry().

Long64_t LoopSequence::fStop [private]

Definition at line 44 of file LoopSequence.h.

Referenced by Checkpoint(), Init(), Postprocess(), Process(), and StopEntry().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1