CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/EventFilter/StorageManager/src/EventConsumerSelector.cc

Go to the documentation of this file.
00001 // $Id: EventConsumerSelector.cc,v 1.13 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include <vector>
00005 
00006 #include <boost/lambda/lambda.hpp>
00007 
00008 #include "EventFilter/StorageManager/interface/EventConsumerSelector.h"
00009 #include "EventFilter/StorageManager/interface/Exception.h"
00010 
00011 #include "FWCore/Utilities/interface/EDMException.h"
00012 
00013 using namespace stor;
00014 
00015 void EventConsumerSelector::initialize( const InitMsgView& imv )
00016 {
00017 
00018   if( initialized_ ) return;
00019 
00020   if( registrationInfo_->outputModuleLabel() != imv.outputModuleLabel() ) return; 
00021 
00022   outputModuleId_ = imv.outputModuleId();
00023 
00024   edm::ParameterSet pset;
00025   pset.addParameter<std::string>( "TriggerSelector", registrationInfo_->triggerSelection() );
00026   pset.addParameter<Strings>( "SelectEvents", registrationInfo_->eventSelection() );
00027 
00028   Strings tnames;
00029   imv.hltTriggerNames( tnames );
00030 
00031   std::ostringstream errorMsg;
00032   errorMsg << "Cannot initialize edm::EventSelector for consumer" <<
00033     registrationInfo_->consumerName() << " running on " << registrationInfo_->remoteHost() <<
00034     " requesting output module ID" << outputModuleId_ <<
00035     " with label " << registrationInfo_->outputModuleLabel() <<
00036     " and HLT trigger names";
00037   boost::lambda::placeholder1_type arg1;
00038   std::for_each(tnames.begin(), tnames.end(), errorMsg << boost::lambda::constant(" ") << arg1);
00039   try
00040   {
00041     eventSelector_.reset( new TriggerSelector( pset, tnames ) );
00042   }
00043   catch ( edm::Exception& e )
00044   {
00045     errorMsg << e.what();
00046     
00047     XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
00048   }
00049   catch( std::exception &e )
00050   {
00051     errorMsg << e.what();
00052 
00053     XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
00054   }
00055   catch(...)
00056   {
00057     errorMsg << "Unknown exception";
00058 
00059     XCEPT_RAISE(stor::exception::InvalidEventSelection, errorMsg.str());
00060   }
00061 
00062   acceptedEvents_ = 0;
00063   initialized_ = true;
00064 
00065 }
00066 
00067 bool EventConsumerSelector::acceptEvent( const I2OChain& ioc )
00068 {
00069 
00070   if( !initialized_ ) return false;
00071 
00072   if( ioc.outputModuleId() != outputModuleId_ ) return false;
00073 
00074   std::vector<unsigned char> hlt_out;
00075   ioc.hltTriggerBits( hlt_out );
00076 
00077   if ( eventSelector_->wantAll()
00078     || eventSelector_->acceptEvent( &hlt_out[0], ioc.hltTriggerCount() ) )
00079   {
00080     if ( (++acceptedEvents_ % registrationInfo_->prescale()) == 0 ) return true;
00081   }
00082   return false;
00083 }
00084 
00085 bool EventConsumerSelector::operator<(const EventConsumerSelector& other) const
00086 {
00087   if ( queueId() != other.queueId() )
00088     return ( queueId() < other.queueId() );
00089   return ( *(registrationInfo_) < *(other.registrationInfo_) );
00090 }
00091 
00092