CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::NavigateEventsLooper Class Reference
Inheritance diagram for edm::NavigateEventsLooper:
edm::EDLooperBase edm::EDConsumerBase

Public Member Functions

Status duringLoop (Event const &ev, EventSetup const &es, ProcessingController &pc) override
 
Status endOfLoop (EventSetup const &es, unsigned int iCounter) override
 
 NavigateEventsLooper (ParameterSet const &pset)
 
 NavigateEventsLooper (NavigateEventsLooper const &)=delete
 
NavigateEventsLooper const & operator= (NavigateEventsLooper const &)=delete
 
void startingNewLoop (unsigned int iIteration) override
 
 ~NavigateEventsLooper () override
 
- Public Member Functions inherited from edm::EDLooperBase
virtual void attachTo (ActivityRegistry &)
 Override this method if you need to monitor the state of the processing. More...
 
void beginOfJob (EventSetupImpl const &)
 
virtual void beginOfJob (EventSetup const &)
 
virtual void beginOfJob ()
 
void copyInfo (ScheduleInfo const &)
 
void doBeginLuminosityBlock (LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
 
void doBeginRun (RunPrincipal &, EventSetupImpl const &, ProcessContext *)
 
Status doDuringLoop (EventPrincipal &eventPrincipal, EventSetupImpl const &es, ProcessingController &, StreamContext *)
 
void doEndLuminosityBlock (LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
 
Status doEndOfLoop (EventSetupImpl const &es)
 
void doEndRun (RunPrincipal &, EventSetupImpl const &, ProcessContext *)
 
void doStartingNewLoop ()
 
 EDLooperBase ()
 
 EDLooperBase (EDLooperBase const &)=delete
 
virtual void endOfJob ()
 
void esPrefetchAsync (WaitingTaskHolder iTask, EventSetupImpl const &iImpl, Transition iTrans, ServiceToken const &iToken) const noexcept
 
virtual std::set< eventsetup::EventSetupRecordKeymodifyingRecords () const
 
EDLooperBaseoperator= (EDLooperBase const &)=delete
 
void prefetchAsync (WaitingTaskHolder iTask, ServiceToken const &token, Transition iTrans, Principal const &iPrincipal, EventSetupImpl const &iImpl) const noexcept
 
void prepareForNextLoop (eventsetup::EventSetupProvider *esp)
 
void setActionTable (ExceptionToActionTable const *actionTable)
 
void setModuleChanger (ModuleChanger *)
 
 ~EDLooperBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

int countLoops_
 
int maxLoops_
 
bool shouldStopLoop_
 
bool shouldStopProcess_
 

Additional Inherited Members

- Public Types inherited from edm::EDLooperBase
enum  Status { kContinue, kStop }
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDLooperBase
ModuleChangermoduleChanger ()
 This only returns a non-zero value during the call to endOfLoop. More...
 
ScheduleInfo const * scheduleInfo () const
 This returns a non-zero value after the constructor has been called. More...
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Allows interactive navigation from event to event in cmsRun jobs. Just add the looper to the python configuration and then respond to the questions that show up on the display by typing a number followed by return.

This was originally written to test the looper interface used by the Fireworks event display. It might be useful by itself.

If you use this either do not use a PoolOutputModule or turn off fast cloning its configuration.

Author
W. David Dagenhart, created 27 August, 2010

Definition at line 29 of file NavigateEventsLooper.cc.

Constructor & Destructor Documentation

◆ NavigateEventsLooper() [1/2]

edm::NavigateEventsLooper::NavigateEventsLooper ( ParameterSet const &  pset)

Definition at line 47 of file NavigateEventsLooper.cc.

◆ NavigateEventsLooper() [2/2]

edm::NavigateEventsLooper::NavigateEventsLooper ( NavigateEventsLooper const &  )
delete

◆ ~NavigateEventsLooper()

edm::NavigateEventsLooper::~NavigateEventsLooper ( )
override

Definition at line 53 of file NavigateEventsLooper.cc.

53 {}

Member Function Documentation

◆ duringLoop()

EDLooperBase::Status edm::NavigateEventsLooper::duringLoop ( Event const &  ,
EventSetup const &  ,
ProcessingController  
)
overridevirtual

Called after all event modules have had a chance to process the Event.

Implements edm::EDLooperBase.

Definition at line 57 of file NavigateEventsLooper.cc.

References edm::ProcessingController::canRandomAccess(), gather_cfg::cout, makeMEIFBenchmarkPlots::ev, edm::ProcessingController::forwardState(), edm::ProcessingController::kAtFirstEvent, edm::ProcessingController::kAtLastEvent, edm::EDLooperBase::kContinue, edm::ProcessingController::kEventsAheadInFile, edm::ProcessingController::kEventsBackwardsInFile, edm::ProcessingController::kNextFileExists, edm::ProcessingController::kPreviousFileExists, edm::EDLooperBase::kStop, edm::ProcessingController::kUnknownForward, edm::ProcessingController::lastOperationSucceeded(), edm::ProcessingController::reverseState(), writedatasetfile::run, edm::ProcessingController::setTransitionToEvent(), edm::ProcessingController::setTransitionToNextEvent(), edm::ProcessingController::setTransitionToPreviousEvent(), shouldStopLoop_, shouldStopProcess_, and x.

57  {
58  if (!pc.lastOperationSucceeded()) {
59  std::cout << "Event could not be found. Nothing done. Try again.\n";
60  }
61 
62  std::cout << "\nWhat should we do next?\n";
63 
64  if (pc.forwardState() == ProcessingController::kEventsAheadInFile) {
65  std::cout << "(0) process the next event\n";
66  } else if (pc.forwardState() == ProcessingController::kNextFileExists) {
67  std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n";
68  } else if (pc.forwardState() == ProcessingController::kAtLastEvent) {
69  std::cout << "(0) will stop the loop because this is the last event\n";
70  } else if (pc.forwardState() == ProcessingController::kUnknownForward) {
71  std::cout << "(0) process the next event (if it exists)\n";
72  }
73 
74  if (pc.canRandomAccess()) {
75  if (pc.reverseState() == ProcessingController::kEventsBackwardsInFile) {
76  std::cout << "(1) process the previous event\n";
77  } else if (pc.reverseState() == ProcessingController::kPreviousFileExists) {
78  std::cout << "(1) process the previous event if there are any (at first event in the open file. there are "
79  "previous files)\n";
80  } else if (pc.reverseState() == ProcessingController::kAtFirstEvent) {
81  std::cout << "(1) will stop the loop because this is the first event\n";
82  }
83 
84  std::cout << "(2) process a specific event\n";
85  }
86 
87  std::cout << "(3) stop loop\n";
88  std::cout << "(4) stop process" << std::endl;
89  long long int x;
90 
91  bool inputFailed = false;
92  do {
93  inputFailed = false;
94  if (!(std::cin >> x) || x < 0 || x > 4) {
95  inputFailed = true;
96  std::cin.clear();
97  std::cin.ignore(10000, '\n');
98  std::cout << "Please enter numeric characters only. The value must be in the range 0 to 4 (inclusive). Please "
99  "try again."
100  << std::endl;
101  }
102  if (!pc.canRandomAccess() && (x == 1 || x == 2)) {
103  inputFailed = true;
104  std::cout << "The source cannot do random access. 1 and 2 are illegal values. Please try again." << std::endl;
105  }
106  } while (inputFailed);
107 
108  shouldStopLoop_ = false;
109  shouldStopProcess_ = false;
110  if (x == 0) {
111  pc.setTransitionToNextEvent();
112  } else if (x == 1) {
113  pc.setTransitionToPreviousEvent();
114  } else if (x == 2) {
115  std::cout << "Which run?" << std::endl;
116  do {
117  inputFailed = false;
118  if (!(std::cin >> x)) {
119  inputFailed = true;
120  std::cin.clear();
121  std::cin.ignore(10000, '\n');
122  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
123  }
124  } while (inputFailed);
125  RunNumber_t run = x;
126  std::cout << "Which luminosity block?" << std::endl;
127  do {
128  inputFailed = false;
129  if (!(std::cin >> x)) {
130  inputFailed = true;
131  std::cin.clear();
132  std::cin.ignore(10000, '\n');
133  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
134  }
135  } while (inputFailed);
137  std::cout << "Which event?" << std::endl;
138  do {
139  inputFailed = false;
140  if (!(std::cin >> x)) {
141  inputFailed = true;
142  std::cin.clear();
143  std::cin.ignore(10000, '\n');
144  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
145  }
146  } while (inputFailed);
147  EventNumber_t ev = x;
148  pc.setTransitionToEvent(EventID(run, lumi, ev));
149  } else if (x == 3) {
150  pc.setTransitionToNextEvent();
151  shouldStopLoop_ = true;
152  } else if (x == 4) {
153  pc.setTransitionToNextEvent();
154  shouldStopLoop_ = true;
155  shouldStopProcess_ = true;
156  }
157  return shouldStopLoop_ ? kStop : kContinue;
158  }
unsigned long long EventNumber_t
unsigned int LuminosityBlockNumber_t
float x
unsigned int RunNumber_t

◆ endOfLoop()

EDLooperBase::Status edm::NavigateEventsLooper::endOfLoop ( EventSetup const &  ,
unsigned int  iCounter 
)
overridevirtual

Called after the system has finished one loop over the events. Thar argument is a count of how many loops have been processed before this loo. For the first time through the events the argument will be 0.

Implements edm::EDLooperBase.

Definition at line 160 of file NavigateEventsLooper.cc.

References countLoops_, gather_cfg::cout, edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, maxLoops_, and shouldStopProcess_.

◆ operator=()

NavigateEventsLooper const& edm::NavigateEventsLooper::operator= ( NavigateEventsLooper const &  )
delete

◆ startingNewLoop()

void edm::NavigateEventsLooper::startingNewLoop ( unsigned int  int)
overridevirtual

Called before system starts to loop over the events. The argument is a count of how many loops have been processed. For the first time through the events the argument will be 0.

Implements edm::EDLooperBase.

Definition at line 55 of file NavigateEventsLooper.cc.

55 {}

Member Data Documentation

◆ countLoops_

int edm::NavigateEventsLooper::countLoops_
private

Definition at line 42 of file NavigateEventsLooper.cc.

Referenced by endOfLoop().

◆ maxLoops_

int edm::NavigateEventsLooper::maxLoops_
private

Definition at line 41 of file NavigateEventsLooper.cc.

Referenced by endOfLoop().

◆ shouldStopLoop_

bool edm::NavigateEventsLooper::shouldStopLoop_
private

Definition at line 43 of file NavigateEventsLooper.cc.

Referenced by duringLoop().

◆ shouldStopProcess_

bool edm::NavigateEventsLooper::shouldStopProcess_
private

Definition at line 44 of file NavigateEventsLooper.cc.

Referenced by duringLoop(), and endOfLoop().