CMS 3D CMS Logo

List of all members | Public Member Functions | Private 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)
 
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...
 
virtual void beginOfJob ()
 
virtual void beginOfJob (EventSetup const &)
 
void beginOfJob (EventSetupImpl const &)
 
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 ()
 
virtual std::set< eventsetup::EventSetupRecordKeymodifyingRecords () const
 
EDLooperBaseoperator= (EDLooperBase const &)=delete
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 48 of file NavigateEventsLooper.cc.

49  : maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)),
50  countLoops_(0),
51  shouldStopLoop_(false),
52  shouldStopProcess_(false) {}

◆ ~NavigateEventsLooper()

edm::NavigateEventsLooper::~NavigateEventsLooper ( )
override

Definition at line 54 of file NavigateEventsLooper.cc.

54 {}

◆ NavigateEventsLooper() [2/2]

edm::NavigateEventsLooper::NavigateEventsLooper ( NavigateEventsLooper const &  )
privatedelete

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 58 of file NavigateEventsLooper.cc.

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

References edm::ProcessingController::canRandomAccess(), gather_cfg::cout, 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_, and shouldStopProcess_.

◆ 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 161 of file NavigateEventsLooper.cc.

161  {
162  std::cout << "Ending loop" << std::endl;
163  if (shouldStopProcess_)
164  return kStop;
165  ++countLoops_;
166  return (maxLoops_ < 0 || countLoops_ < maxLoops_) ? kContinue : kStop;
167  }

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

◆ operator=()

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

◆ startingNewLoop()

void edm::NavigateEventsLooper::startingNewLoop ( unsigned 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 56 of file NavigateEventsLooper.cc.

56 {}

Member Data Documentation

◆ countLoops_

int edm::NavigateEventsLooper::countLoops_
private

Definition at line 43 of file NavigateEventsLooper.cc.

Referenced by endOfLoop().

◆ maxLoops_

int edm::NavigateEventsLooper::maxLoops_
private

Definition at line 42 of file NavigateEventsLooper.cc.

Referenced by endOfLoop().

◆ shouldStopLoop_

bool edm::NavigateEventsLooper::shouldStopLoop_
private

Definition at line 44 of file NavigateEventsLooper.cc.

Referenced by duringLoop().

◆ shouldStopProcess_

bool edm::NavigateEventsLooper::shouldStopProcess_
private

Definition at line 45 of file NavigateEventsLooper.cc.

Referenced by duringLoop(), and endOfLoop().

edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::ProcessingController::kAtLastEvent
Definition: ProcessingController.h:34
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::EDLooperBase::kStop
Definition: EDLooperBase.h:80
edm::ProcessingController::kNextFileExists
Definition: ProcessingController.h:33
edm::ProcessingController::kAtFirstEvent
Definition: ProcessingController.h:41
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::NavigateEventsLooper::shouldStopLoop_
bool shouldStopLoop_
Definition: NavigateEventsLooper.cc:44
edm::ProcessingController::kEventsAheadInFile
Definition: ProcessingController.h:32
edm::NavigateEventsLooper::maxLoops_
int maxLoops_
Definition: NavigateEventsLooper.cc:42
edm::EDLooperBase::kContinue
Definition: EDLooperBase.h:80
edm::NavigateEventsLooper::shouldStopProcess_
bool shouldStopProcess_
Definition: NavigateEventsLooper.cc:45
edm::ProcessingController::kEventsBackwardsInFile
Definition: ProcessingController.h:39
writedatasetfile.run
run
Definition: writedatasetfile.py:27
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
genVertex_cff.x
x
Definition: genVertex_cff.py:12
edm::ProcessingController::kUnknownForward
Definition: ProcessingController.h:35
edm::ProcessingController::kPreviousFileExists
Definition: ProcessingController.h:40
lumi
Definition: LumiSectionData.h:20
edm::NavigateEventsLooper::countLoops_
int countLoops_
Definition: NavigateEventsLooper.cc:43
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27