CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventConsumerSelector.cc
Go to the documentation of this file.
1 // $Id: EventConsumerSelector.cc,v 1.13 2011/03/07 15:31:32 mommsen Exp $
3 
4 #include <vector>
5 
6 #include <boost/lambda/lambda.hpp>
7 
10 
12 
13 using namespace stor;
14 
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 }
66 
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 }
84 
86 {
87  if ( queueId() != other.queueId() )
88  return ( queueId() < other.queueId() );
89  return ( *(registrationInfo_) < *(other.registrationInfo_) );
90 }
91 
92 
virtual char const * what() const
Definition: Exception.cc:141
QueueID const queueId() const
std::vector< std::string > Strings
Definition: MsgTools.h:18
const EventConsRegPtr registrationInfo_
void hltTriggerNames(Strings &save_here) const
Definition: InitMessage.cc:142
void hltTriggerBits(std::vector< unsigned char > &bitList) const
Definition: I2OChain.cc:565
bool operator<(const EventConsumerSelector &other) const
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
bool acceptEvent(const I2OChain &)
std::string outputModuleLabel() const
Definition: InitMessage.cc:132
void initialize(const InitMsgView &)
uint32 outputModuleId() const
Definition: InitMessage.h:76
uint32_t hltTriggerCount() const
Definition: I2OChain.cc:555
uint32_t outputModuleId() const
Definition: I2OChain.cc:505