CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

edm::Path Class Reference

#include <Path.h>

List of all members.

Public Types

typedef WorkersInPath::size_type size_type
typedef hlt::HLTState State
typedef boost::shared_ptr
< HLTGlobalStatus
TrigResPtr
typedef std::vector< WorkerInPathWorkersInPath

Public Member Functions

int bitPosition () const
void clearCounters ()
Worker const * getWorker (size_type i) const
std::string const & name () const
 Path (int bitpos, std::string const &path_name, WorkersInPath const &workers, TrigResPtr trptr, ActionTable const &actions, boost::shared_ptr< ActivityRegistry > reg, bool isEndPath)
template<typename T >
void processOneOccurrence (typename T::MyPrincipal &, EventSetup const &)
size_type size () const
State state () const
std::pair< double, double > timeCpuReal () const
std::pair< double, double > timeCpuReal (unsigned int const i) const
int timesExcept (size_type i) const
int timesExcept () const
int timesFailed (size_type i) const
int timesFailed () const
int timesPassed () const
int timesPassed (size_type i) const
int timesRun () const
int timesVisited (size_type i) const
void useStopwatch ()

Private Member Functions

bool handleWorkerFailure (cms::Exception &e, int nwrwue, bool isEvent, bool begin, BranchType branchType, CurrentProcessingContext const &cpc, std::string const &id)
void recordStatus (int nwrwue, bool isEvent)
void updateCounters (bool succeed, bool isEvent)

Static Private Member Functions

static void exceptionContext (cms::Exception &ex, bool isEvent, bool begin, BranchType branchType, CurrentProcessingContext const &cpc, std::string const &id)

Private Attributes

ActionTable const * act_table_
boost::shared_ptr
< ActivityRegistry
actReg_
int bitpos_
bool isEndPath_
std::string name_
State state_
RunStopwatch::StopwatchPointer stopwatch_
int timesExcept_
int timesFailed_
int timesPassed_
int timesRun_
TrigResPtr trptr_
WorkersInPath workers_

Detailed Description

Definition at line 34 of file Path.h.


Member Typedef Documentation

typedef WorkersInPath::size_type edm::Path::size_type

Definition at line 39 of file Path.h.

Definition at line 36 of file Path.h.

typedef boost::shared_ptr<HLTGlobalStatus> edm::Path::TrigResPtr

Definition at line 40 of file Path.h.

typedef std::vector<WorkerInPath> edm::Path::WorkersInPath

Definition at line 38 of file Path.h.


Constructor & Destructor Documentation

edm::Path::Path ( int  bitpos,
std::string const &  path_name,
WorkersInPath const &  workers,
TrigResPtr  trptr,
ActionTable const &  actions,
boost::shared_ptr< ActivityRegistry reg,
bool  isEndPath 
)

Definition at line 12 of file Path.cc.

                            :
    stopwatch_(),
    timesRun_(),
    timesPassed_(),
    timesFailed_(),
    timesExcept_(),
    state_(hlt::Ready),
    bitpos_(bitpos),
    name_(path_name),
    trptr_(trptr),
    actReg_(areg),
    act_table_(&actions),
    workers_(workers),
    isEndPath_(isEndPath) {
  }

Member Function Documentation

int edm::Path::bitPosition ( ) const [inline]

Definition at line 52 of file Path.h.

References bitpos_.

Referenced by edm::fillPathSummary(), and processOneOccurrence().

{ return bitpos_; }
void edm::Path::clearCounters ( )
void edm::Path::exceptionContext ( cms::Exception ex,
bool  isEvent,
bool  begin,
BranchType  branchType,
CurrentProcessingContext const &  cpc,
std::string const &  id 
) [static, private]

Definition at line 78 of file Path.cc.

References cms::Exception::addContext(), edm::InLumi, edm::InRun, edm::CurrentProcessingContext::moduleDescription(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and edm::CurrentProcessingContext::pathName().

Referenced by handleWorkerFailure().

                                              {
    std::ostringstream ost;
    if (isEvent) {
      ost << "Calling event method";
    }
    else if (begin && branchType == InRun) {
      ost << "Calling beginRun";
    }
    else if (begin && branchType == InLumi) {
      ost << "Calling beginLuminosityBlock";
    }
    else if (!begin && branchType == InLumi) {
      ost << "Calling endLuminosityBlock";
    }
    else if (!begin && branchType == InRun) {
      ost << "Calling endRun";
    }
    else {
      // It should be impossible to get here ...
      ost << "Calling unknown function";
    }
    if (cpc.moduleDescription()) {
      ost << " for module " << cpc.moduleDescription()->moduleName() << "/'" << cpc.moduleDescription()->moduleLabel() << "'";
    }
    ex.addContext(ost.str());
    ost.str("");
    ost << "Running path '";
    if (cpc.pathName()) {
      ost << *cpc.pathName() << "'";
    }
    else {
      ost << "unknown'";
    }
    ex.addContext(ost.str());
    ost.str("");
    ost << "Processing ";
    ost << id;
    ex.addContext(ost.str());
  }
Worker const* edm::Path::getWorker ( size_type  i) const [inline]

Definition at line 80 of file Path.h.

References workers_.

Referenced by edm::fillModuleInPathSummary().

{ return workers_.at(i).getWorker(); }
bool edm::Path::handleWorkerFailure ( cms::Exception e,
int  nwrwue,
bool  isEvent,
bool  begin,
BranchType  branchType,
CurrentProcessingContext const &  cpc,
std::string const &  id 
) [private]

Definition at line 34 of file Path.cc.

References act_table_, alignmentValidation::action, cms::Exception::addAdditionalInfo(), cms::Exception::category(), edm::Exception::codeToString(), Exception, exceptionContext(), edm::actions::FailPath, edm::ActionTable::find(), edm::printCmsExceptionWarning(), edm::errors::ProductNotFound, recordStatus(), edm::actions::Rethrow, state_, and timesExcept_.

Referenced by processOneOccurrence().

                                                 {

    exceptionContext(e, isEvent, begin, branchType, cpc, id);

    bool should_continue = true;

    // there is no support as of yet for specific paths having
    // different exception behavior
    
    // If not processing an event, always rethrow.
    actions::ActionCodes action = (isEvent ? act_table_->find(e.category()) : actions::Rethrow);
    switch(action) {
      case actions::FailPath: {
          should_continue = false;
          edm::printCmsExceptionWarning("FailPath", e);
          break;
      }
      default: {
          if (isEvent) ++timesExcept_;
          state_ = hlt::Exception;
          recordStatus(nwrwue, isEvent);
          if (action == actions::Rethrow) {
            std::string pNF = Exception::codeToString(errors::ProductNotFound);
            if (e.category() == pNF) {
              std::ostringstream ost;
              ost <<  "If you wish to continue processing events after a " << pNF << " exception,\n" <<
              "add \"SkipEvent = cms.untracked.vstring('ProductNotFound')\" to the \"options\" PSet in the configuration.\n";
              e.addAdditionalInfo(ost.str());
            }
          }
          throw;
      }
    }

    return should_continue;
  }
std::string const& edm::Path::name ( void  ) const [inline]

Definition at line 53 of file Path.h.

References name_.

Referenced by edm::Schedule::availablePaths(), edm::fillPathSummary(), and edm::Schedule::modulesInPath().

{ return name_; }
template<typename T >
void edm::Path::processOneOccurrence ( typename T::MyPrincipal &  ep,
EventSetup const &  es 
)

Definition at line 145 of file Path.h.

References edm::CurrentProcessingContext::activate(), actReg_, edm::convertException::badAllocToEDM(), bitPosition(), trackerHits::c, edm::convertException::charPtrToEDM(), end, exception, handleWorkerFailure(), i, isEndPath_, name_, Ready, recordStatus(), asciidump::s, state_, edm::convertException::stdToEDM(), stopwatch_, edm::convertException::stringToEDM(), timesRun_, edm::convertException::unknownToEDM(), updateCounters(), and workers_.

Referenced by edm::ProcessOneOccurrence< T >::operator()().

                                                                                 {

    //Create the PathSignalSentry before the RunStopwatch so that
    // we only record the time spent in the path not from the signal
    int nwrwue = -1;
    PathSignalSentry<T> signaler(actReg_.get(), name_, nwrwue, state_);

    // A RunStopwatch, but only if we are processing an event.
    RunStopwatch stopwatch(T::isEvent_ ? stopwatch_ : RunStopwatch::StopwatchPointer());

    if (T::isEvent_) {
      ++timesRun_;
    }
    state_ = hlt::Ready;

    // nwrue =  numWorkersRunWithoutUnhandledException
    bool should_continue = true;
    CurrentProcessingContext cpc(&name_, bitPosition(), isEndPath_);

    WorkersInPath::size_type idx = 0;
    // It seems likely that 'nwrwue' and 'idx' can never differ ---
    // if so, we should remove one of them!.
    for (WorkersInPath::iterator i = workers_.begin(), end = workers_.end();
          i != end && should_continue;
          ++i, ++idx) {
      ++nwrwue;
      assert (static_cast<int>(idx) == nwrwue);
      try {
        try {
          cpc.activate(idx, i->getWorker()->descPtr());
          should_continue = i->runWorker<T>(ep, es, &cpc);
        }
        catch (cms::Exception& e) { throw; }
        catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
        catch (std::exception& e) { convertException::stdToEDM(e); }
        catch(std::string& s) { convertException::stringToEDM(s); }
        catch(char const* c) { convertException::charPtrToEDM(c); }
        catch (...) { convertException::unknownToEDM(); }
      }
      catch(cms::Exception& ex) {
        // handleWorkerFailure may throw a new exception.
        std::ostringstream ost;
        ost << ep.id();
        should_continue = handleWorkerFailure(ex, nwrwue, T::isEvent_, T::begin_, T::branchType_, cpc, ost.str());
      }
    }
    updateCounters(should_continue, T::isEvent_);
    recordStatus(nwrwue, T::isEvent_);
  }
void edm::Path::recordStatus ( int  nwrwue,
bool  isEvent 
) [private]

Definition at line 124 of file Path.cc.

References bitpos_, and state_.

Referenced by handleWorkerFailure(), and processOneOccurrence().

                                             {
    if(isEvent) {
      (*trptr_)[bitpos_]=HLTPathStatus(state_, nwrwue);    
    }
  }
size_type edm::Path::size ( void  ) const [inline]

Definition at line 75 of file Path.h.

References workers_.

Referenced by edm::fillPathSummary().

{ return workers_.size(); }
State edm::Path::state ( ) const [inline]

Definition at line 73 of file Path.h.

References state_.

{ return state_; }
std::pair<double, double> edm::Path::timeCpuReal ( ) const [inline]

Definition at line 55 of file Path.h.

References stopwatch_.

                                                {
      if(stopwatch_) {
        return std::pair<double, double>(stopwatch_->cpuTime(), stopwatch_->realTime());
      }
      return std::pair<double, double>(0., 0.);
    }
std::pair<double, double> edm::Path::timeCpuReal ( unsigned int const  i) const [inline]

Definition at line 62 of file Path.h.

References workers_.

                                                                    {
      return workers_.at(i).timeCpuReal();
    }
int edm::Path::timesExcept ( size_type  i) const [inline]

Definition at line 79 of file Path.h.

References workers_.

{ return workers_.at(i).timesExcept() ; }
int edm::Path::timesExcept ( ) const [inline]

Definition at line 71 of file Path.h.

References timesExcept_.

Referenced by edm::fillModuleInPathSummary(), and edm::fillPathSummary().

{ return timesExcept_; }
int edm::Path::timesFailed ( ) const [inline]

Definition at line 70 of file Path.h.

References timesFailed_.

Referenced by edm::fillModuleInPathSummary(), and edm::fillPathSummary().

{ return timesFailed_; }
int edm::Path::timesFailed ( size_type  i) const [inline]

Definition at line 78 of file Path.h.

References workers_.

{ return workers_.at(i).timesFailed() ; }
int edm::Path::timesPassed ( ) const [inline]

Definition at line 69 of file Path.h.

References timesPassed_.

Referenced by edm::fillModuleInPathSummary(), and edm::fillPathSummary().

{ return timesPassed_; }
int edm::Path::timesPassed ( size_type  i) const [inline]

Definition at line 77 of file Path.h.

References workers_.

{ return workers_.at(i).timesPassed() ; }
int edm::Path::timesRun ( ) const [inline]

Definition at line 68 of file Path.h.

References timesRun_.

Referenced by edm::fillPathSummary().

{ return timesRun_; }
int edm::Path::timesVisited ( size_type  i) const [inline]

Definition at line 76 of file Path.h.

References workers_.

Referenced by edm::fillModuleInPathSummary().

{ return workers_.at(i).timesVisited(); }
void edm::Path::updateCounters ( bool  succeed,
bool  isEvent 
) [private]

Definition at line 131 of file Path.cc.

References Fail, Pass, state_, timesFailed_, and timesPassed_.

Referenced by processOneOccurrence().

                                                 {
    if (success) {
      if (isEvent) ++timesPassed_;
      state_ = hlt::Pass;
    } else {
      if(isEvent) ++timesFailed_;
      state_ = hlt::Fail;
    }
  }
void edm::Path::useStopwatch ( )

Definition at line 148 of file Path.cc.

References stopwatch_, and workers_.

Referenced by edm::Schedule::fillEndPath(), and edm::Schedule::fillTrigPath().

                     {
    stopwatch_.reset(new RunStopwatch::StopwatchPointer::element_type);
    for(WorkersInPath::iterator it=workers_.begin(), itEnd = workers_.end();
        it != itEnd;
        ++it) {
      it->useStopwatch();
    }
  }

Member Data Documentation

Definition at line 96 of file Path.h.

Referenced by handleWorkerFailure().

boost::shared_ptr<ActivityRegistry> edm::Path::actReg_ [private]

Definition at line 95 of file Path.h.

Referenced by processOneOccurrence().

int edm::Path::bitpos_ [private]

Definition at line 92 of file Path.h.

Referenced by bitPosition(), and recordStatus().

bool edm::Path::isEndPath_ [private]

Definition at line 100 of file Path.h.

Referenced by processOneOccurrence().

std::string edm::Path::name_ [private]

Definition at line 93 of file Path.h.

Referenced by name(), and processOneOccurrence().

Definition at line 90 of file Path.h.

Referenced by handleWorkerFailure(), processOneOccurrence(), recordStatus(), state(), and updateCounters().

Definition at line 84 of file Path.h.

Referenced by processOneOccurrence(), timeCpuReal(), and useStopwatch().

int edm::Path::timesExcept_ [private]

Definition at line 88 of file Path.h.

Referenced by clearCounters(), handleWorkerFailure(), and timesExcept().

int edm::Path::timesFailed_ [private]

Definition at line 87 of file Path.h.

Referenced by clearCounters(), timesFailed(), and updateCounters().

int edm::Path::timesPassed_ [private]

Definition at line 86 of file Path.h.

Referenced by clearCounters(), timesPassed(), and updateCounters().

int edm::Path::timesRun_ [private]

Definition at line 85 of file Path.h.

Referenced by clearCounters(), processOneOccurrence(), and timesRun().

Definition at line 94 of file Path.h.