CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/EventFilter/StorageManager/src/EventConsumerRegistrationInfo.cc

Go to the documentation of this file.
00001 // $Id: EventConsumerRegistrationInfo.cc,v 1.15 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/EventConsumerRegistrationInfo.h"
00005 #include "EventFilter/StorageManager/interface/EventDistributor.h"
00006 #include "EventFilter/StorageManager/interface/Exception.h"
00007 #include "FWCore/Utilities/interface/EDMException.h"
00008 
00009 #include <algorithm>
00010 #include <iterator>
00011 #include <ostream>
00012 
00013 
00014 namespace stor
00015 {
00016   EventConsumerRegistrationInfo::EventConsumerRegistrationInfo
00017   (
00018     const edm::ParameterSet& pset,
00019     const EventServingParams& eventServingParams,
00020     const std::string& remoteHost
00021   ) :
00022   RegistrationInfoBase(pset, remoteHost, eventServingParams, true)
00023   {
00024     parsePSet(pset);
00025   }
00026 
00027   EventConsumerRegistrationInfo::EventConsumerRegistrationInfo
00028   (
00029     const edm::ParameterSet& pset,
00030     const std::string& remoteHost
00031   ) :
00032   RegistrationInfoBase(pset, remoteHost, EventServingParams(), false)
00033   {
00034     parsePSet(pset);
00035   }
00036 
00037   void 
00038   EventConsumerRegistrationInfo::parsePSet(const edm::ParameterSet& pset)
00039   {
00040     try
00041     {
00042       outputModuleLabel_ = pset.getUntrackedParameter<std::string>("SelectHLTOutput");
00043     }
00044     catch( edm::Exception& e )
00045     {
00046       XCEPT_RAISE( stor::exception::ConsumerRegistration,
00047         "No HLT output module specified" );
00048     }
00049 
00050     triggerSelection_ = pset.getUntrackedParameter<std::string>("TriggerSelector", "");
00051 
00052     try
00053     {
00054       eventSelection_ = pset.getParameter<Strings>("TrackedEventSelection");
00055     }
00056     catch( edm::Exception& e )
00057     {
00058       edm::ParameterSet tmpPSet1 =
00059         pset.getUntrackedParameter<edm::ParameterSet>("SelectEvents", edm::ParameterSet());
00060       if ( ! tmpPSet1.empty() )
00061       {
00062         eventSelection_ = tmpPSet1.getParameter<Strings>("SelectEvents");
00063       }
00064     }
00065 
00066     prescale_ = pset.getUntrackedParameter<int>("prescale", 1);
00067     uniqueEvents_ = pset.getUntrackedParameter<bool>("uniqueEvents", false);
00068     headerRetryInterval_ = pset.getUntrackedParameter<int>("headerRetryInterval", 5);
00069   }
00070   
00071   
00072   void
00073   EventConsumerRegistrationInfo::do_appendToPSet(edm::ParameterSet& pset) const
00074   {
00075     pset.addUntrackedParameter<std::string>("SelectHLTOutput", outputModuleLabel_);
00076     pset.addUntrackedParameter<std::string>("TriggerSelector", triggerSelection_);
00077     pset.addParameter<Strings>("TrackedEventSelection", eventSelection_);
00078     pset.addUntrackedParameter<bool>("uniqueEvents", uniqueEvents_);
00079     pset.addUntrackedParameter<int>("prescale", prescale_);
00080 
00081     if ( headerRetryInterval_ != 5 )
00082       pset.addUntrackedParameter<int>("headerRetryInterval", headerRetryInterval_);
00083   }
00084 
00085   void 
00086   EventConsumerRegistrationInfo::do_registerMe(EventDistributor* evtDist)
00087   {
00088     evtDist->registerEventConsumer(shared_from_this());
00089   }
00090   
00091   void
00092   EventConsumerRegistrationInfo::do_eventType(std::ostream& os) const
00093   {
00094     os << "Output module: " << outputModuleLabel_ << "\n";
00095 
00096     if ( triggerSelection_.empty() )
00097     {
00098       if ( ! eventSelection_.empty() )
00099       {
00100         os  << "Event Selection: ";
00101         std::copy(eventSelection_.begin(), eventSelection_.end()-1,
00102           std::ostream_iterator<Strings::value_type>(os, ","));
00103         os << *(eventSelection_.end()-1);
00104       }
00105     }
00106     else
00107       os << "Trigger Selection: " << triggerSelection_;
00108 
00109     if ( prescale_ != 1 )
00110       os << "; prescale: " << prescale_;
00111 
00112     if ( uniqueEvents_ != false )
00113       os << "; uniqueEvents";
00114 
00115     os << "\n";
00116     queueInfo(os);
00117   }
00118   
00119   bool
00120   EventConsumerRegistrationInfo::operator<(const EventConsumerRegistrationInfo& other) const
00121   {
00122     if ( outputModuleLabel() != other.outputModuleLabel() )
00123       return ( outputModuleLabel() < other.outputModuleLabel() );
00124     if ( triggerSelection() != other.triggerSelection() )
00125       return ( triggerSelection() < other.triggerSelection() );
00126     if ( eventSelection() != other.eventSelection() )
00127       return ( eventSelection() < other.eventSelection() );
00128     if ( prescale() != other.prescale() )
00129       return ( prescale() < other.prescale() );
00130     if ( uniqueEvents() != other.uniqueEvents() )
00131       return ( uniqueEvents() < other.uniqueEvents() );
00132     return RegistrationInfoBase::operator<(other);
00133   }
00134 
00135   bool
00136   EventConsumerRegistrationInfo::operator==(const EventConsumerRegistrationInfo& other) const
00137   {
00138     return (
00139       outputModuleLabel() == other.outputModuleLabel() &&
00140       triggerSelection() == other.triggerSelection() &&
00141       eventSelection() == other.eventSelection() &&
00142       prescale() == other.prescale() &&
00143       uniqueEvents() == other.uniqueEvents() &&
00144       RegistrationInfoBase::operator==(other)
00145     );
00146   }
00147 
00148   bool
00149   EventConsumerRegistrationInfo::operator!=(const EventConsumerRegistrationInfo& other) const
00150   {
00151     return ! ( *this == other );
00152   }
00153 
00154 }
00155