CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
stor::EventConsumerSelector Class Reference

#include <EventConsumerSelector.h>

Public Member Functions

bool acceptEvent (const I2OChain &)
 
 EventConsumerSelector (const EventConsRegPtr registrationInfo)
 
void initialize (const InitMsgView &)
 
bool isInitialized () const
 
bool operator< (const EventConsumerSelector &other) const
 
QueueID const queueId () const
 
 ~EventConsumerSelector ()
 

Private Attributes

unsigned long acceptedEvents_
 
TriggerSelectorPtr eventSelector_
 
bool initialized_
 
unsigned int outputModuleId_
 
const EventConsRegPtr registrationInfo_
 

Detailed Description

Defines the common interface for event and DQM consumer registration info objects.

Author:
mommsen
Revision:
1.9
Date:
2011/03/07 15:31:31

Definition at line 25 of file EventConsumerSelector.h.

Constructor & Destructor Documentation

stor::EventConsumerSelector::EventConsumerSelector ( const EventConsRegPtr  registrationInfo)
inline

Constructs an EventConsumerSelector instance based on the specified registration information.

Definition at line 34 of file EventConsumerSelector.h.

34  :
35  initialized_( false ),
36  outputModuleId_( 0 ),
37  registrationInfo_( registrationInfo ),
38  acceptedEvents_( 0 )
39  {}
const EventConsRegPtr registrationInfo_
stor::EventConsumerSelector::~EventConsumerSelector ( )
inline

Destructs the EventConsumerSelector instance.

Definition at line 44 of file EventConsumerSelector.h.

44 {}

Member Function Documentation

bool EventConsumerSelector::acceptEvent ( const I2OChain ioc)

Tests whether the specified event is accepted by this selector - returns true if the event is accepted, false otherwise.

Definition at line 67 of file EventConsumerSelector.cc.

References acceptedEvents_, eventSelector_, stor::I2OChain::hltTriggerBits(), stor::I2OChain::hltTriggerCount(), initialized_, stor::I2OChain::outputModuleId(), outputModuleId_, and registrationInfo_.

68 {
69 
70  if( !initialized_ ) return false;
71 
72  if( ioc.outputModuleId() != outputModuleId_ ) return false;
73 
74  std::vector<unsigned char> hlt_out;
75  ioc.hltTriggerBits( hlt_out );
76 
77  if ( eventSelector_->wantAll()
78  || eventSelector_->acceptEvent( &hlt_out[0], ioc.hltTriggerCount() ) )
79  {
80  if ( (++acceptedEvents_ % registrationInfo_->prescale()) == 0 ) return true;
81  }
82  return false;
83 }
const EventConsRegPtr registrationInfo_
void hltTriggerBits(std::vector< unsigned char > &bitList) const
Definition: I2OChain.cc:565
uint32_t hltTriggerCount() const
Definition: I2OChain.cc:555
uint32_t outputModuleId() const
Definition: I2OChain.cc:505
void EventConsumerSelector::initialize ( const InitMsgView imv)

Initializes the selector instance from the specified INIT message. EventConsumerSelector instances need to be initialized before they will accept any events.

Definition at line 15 of file EventConsumerSelector.cc.

References acceptedEvents_, edm::ParameterSet::addParameter(), alignCSCRings::e, eventSelector_, cppFunctionSkipper::exception, InitMsgView::hltTriggerNames(), initialized_, InitMsgView::outputModuleId(), outputModuleId_, InitMsgView::outputModuleLabel(), registrationInfo_, and cms::Exception::what().

Referenced by stor::EventDistributor::tagCompleteEventForQueues().

16 {
17 
18  if( initialized_ ) return;
19 
20  if( registrationInfo_->outputModuleLabel() != imv.outputModuleLabel() ) return;
21 
23 
24  edm::ParameterSet pset;
25  pset.addParameter<std::string>( "TriggerSelector", registrationInfo_->triggerSelection() );
26  pset.addParameter<Strings>( "SelectEvents", registrationInfo_->eventSelection() );
27 
28  Strings tnames;
29  imv.hltTriggerNames( tnames );
30 
31  std::ostringstream errorMsg;
32  errorMsg << "Cannot initialize edm::EventSelector for consumer" <<
33  registrationInfo_->consumerName() << " running on " << registrationInfo_->remoteHost() <<
34  " requesting output module ID" << outputModuleId_ <<
35  " with label " << registrationInfo_->outputModuleLabel() <<
36  " and HLT trigger names";
37  boost::lambda::placeholder1_type arg1;
38  std::for_each(tnames.begin(), tnames.end(), errorMsg << boost::lambda::constant(" ") << arg1);
39  try
40  {
41  eventSelector_.reset( new TriggerSelector( pset, tnames ) );
42  }
43  catch ( edm::Exception& e )
44  {
45  errorMsg << e.what();
46 
47  XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
48  }
49  catch( std::exception &e )
50  {
51  errorMsg << e.what();
52 
53  XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
54  }
55  catch(...)
56  {
57  errorMsg << "Unknown exception";
58 
59  XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
60  }
61 
62  acceptedEvents_ = 0;
63  initialized_ = true;
64 
65 }
virtual char const * what() const
Definition: Exception.cc:141
std::vector< std::string > Strings
Definition: MsgTools.h:18
const EventConsRegPtr registrationInfo_
void hltTriggerNames(Strings &save_here) const
Definition: InitMessage.cc:142
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
std::string outputModuleLabel() const
Definition: InitMessage.cc:132
uint32 outputModuleId() const
Definition: InitMessage.h:76
bool stor::EventConsumerSelector::isInitialized ( ) const
inline

Tests whether this selector has been initialized.

Definition at line 67 of file EventConsumerSelector.h.

References initialized_.

bool EventConsumerSelector::operator< ( const EventConsumerSelector other) const

Comparison:

Definition at line 85 of file EventConsumerSelector.cc.

References queueId(), and registrationInfo_.

86 {
87  if ( queueId() != other.queueId() )
88  return ( queueId() < other.queueId() );
89  return ( *(registrationInfo_) < *(other.registrationInfo_) );
90 }
QueueID const queueId() const
const EventConsRegPtr registrationInfo_
QueueID const stor::EventConsumerSelector::queueId ( ) const
inline

Returns the ID of the queue corresponding to this selector.

Definition at line 62 of file EventConsumerSelector.h.

References registrationInfo_.

Referenced by operator<().

62 { return registrationInfo_->queueId(); }
const EventConsRegPtr registrationInfo_

Member Data Documentation

unsigned long stor::EventConsumerSelector::acceptedEvents_
private

Definition at line 80 of file EventConsumerSelector.h.

Referenced by acceptEvent(), and initialize().

TriggerSelectorPtr stor::EventConsumerSelector::eventSelector_
private

Definition at line 79 of file EventConsumerSelector.h.

Referenced by acceptEvent(), and initialize().

bool stor::EventConsumerSelector::initialized_
private

Definition at line 76 of file EventConsumerSelector.h.

Referenced by acceptEvent(), initialize(), and isInitialized().

unsigned int stor::EventConsumerSelector::outputModuleId_
private

Definition at line 77 of file EventConsumerSelector.h.

Referenced by acceptEvent(), and initialize().

const EventConsRegPtr stor::EventConsumerSelector::registrationInfo_
private

Definition at line 78 of file EventConsumerSelector.h.

Referenced by acceptEvent(), initialize(), operator<(), and queueId().