Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EventSelector.cc
Go to the documentation of this file.
1 #include "marlin/EventSelector.h"
2 
3 #include <iostream>
4 
5 // ----- include for verbosity dependend logging ---------
7 
8 
9 using namespace lcio ;
10 using namespace marlin ;
11 
12 
14 
15 
16 EventSelector::EventSelector() : Processor("EventSelector") {
17 
18  // modify processor description
19  _description = "EventSelector returns true if given event was specified in EventList" ;
20 
21  IntVec evtsExample ;
22  // evtsExample.push_back( 42 );
23  // evtsExample.push_back( 1024 );
24 
25 
26  registerProcessorParameter( "EventList" ,
27  "event list - pairs of Eventnumber RunNumber" ,
28  _evtList ,
29  evtsExample ) ;
30  _nEvt = -1;
31  _nRun = -1;
32 }
33 
34 
36 
37  // usually a good idea to
38  printParameters() ;
39 
40  _nRun = 0 ;
41  _nEvt = 0 ;
42 
43 
44  unsigned nEvts = _evtList.size() ;
45 
46  for( unsigned i=0 ; i < nEvts ; i+=2 ) {
47 
48  _evtSet.insert( std::make_pair( _evtList[i] , _evtList[ i+1 ] ) ) ;
49  }
50 }
51 
52 void EventSelector::processRunHeader( LCRunHeader* ) {
53 
54  _nRun++ ;
55 }
56 
57 
58 void EventSelector::modifyEvent( LCEvent *evt ) {
59  processEvent( evt );
60 }
61 
62 void EventSelector::processEvent( LCEvent * evt ) {
63 
64  // if no events specifiec - always return true
65  if( _evtList.size() == 0 ) {
66  setReturnValue( true ) ;
67  return ;
68  }
69 
70  SET::iterator it = _evtSet.find( std::make_pair( evt->getEventNumber() , evt->getRunNumber() ) ) ;
71 
72  bool isInList = it != _evtSet.end() ;
73 
74 
75  //-- note: this will not be printed if compiled w/o MARLINDEBUG=1 !
76 
77  streamlog_out(DEBUG) << " processing event: " << evt->getEventNumber()
78  << " in run: " << evt->getRunNumber()
79  << " - in event list : " << isInList
80  << std::endl ;
81 
82  setReturnValue( isInList ) ;
83 
84 
85  _nEvt ++ ;
86 }
87 
88 
89 
90 void EventSelector::check( LCEvent * ) {
91  // nothing to check here - could be used to fill checkplots in reconstruction processor
92 }
93 
94 
96 
97 // std::cout << "EventSelector::end() " << name()
98 // << " processed " << _nEvt << " events in " << _nRun << " runs "
99 // << std::endl ;
100 
101 }
102 
virtual void processEvent(LCEvent *evt)
Called for every event - the working horse.
void registerProcessorParameter(const std::string &parameterName, const std::string &parameterDescription, T &parameter, const T &defaultVal, int setSize=0)
Register a steering variable for this processor - call in constructor of processor.
Definition: Processor.h:254
IntVec _evtList
Input collection name.
Definition: EventSelector.h:66
virtual void end()
Called after data processing for clean up.
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
T endl(T...args)
virtual void check(LCEvent *evt)
Called for every event - right after processEvent() has been called for this processor.
T end(T...args)
void printParameters()
Print the parameters and their values depending on the given verbosity level.
Definition: Processor.h:156
virtual void modifyEvent(LCEvent *evt)
void setReturnValue(bool val)
Set the return value for this processor - typically at end of processEvent().
Definition: Processor.cc:232
T make_pair(T...args)
T insert(T...args)
T find(T...args)
T size(T...args)
virtual void init()
Called at the begin of the job before anything is read.
Base class for Marlin processors.
Definition: Processor.h:64
EventSelector aEventSelector
std::string _description
Describes what the processor does.
Definition: Processor.h:452