Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:15

0001 #ifndef CommonTools_UtilAlgos_DummySelector_h
0002 #define CommonTools_UtilAlgos_DummySelector_h
0003 /* \class DummySelector
0004  *
0005  * Dummy generic selector following the
0006  * interface proposed in the document:
0007  *
0008  * https://twiki.cern.ch/twiki/bin/view/CMS/SelectorInterface
0009  *
0010  * \author Luca Lista, INFN
0011  */
0012 #include "CommonTools/UtilAlgos/interface/EventSetupInitTrait.h"
0013 
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015 #include "FWCore/Utilities/interface/EDMException.h"
0016 
0017 namespace edm {
0018   class ParameterSet;
0019   class Event;
0020   class EventSetup;
0021 }  // namespace edm
0022 
0023 class DummySelector {
0024 public:
0025   explicit DummySelector(const edm::ParameterSet&, edm::ConsumesCollector& iC) : updated_(false) {}
0026   void newEvent(const edm::Event&, const edm::EventSetup&) { updated_ = true; }
0027   template <typename T>
0028   bool operator()(const T&) {
0029     if (!updated_)
0030       throw edm::Exception(edm::errors::Configuration) << "DummySelector: forgot to call newEvent\n";
0031     return true;
0032   }
0033 
0034 private:
0035   bool updated_;
0036 };
0037 
0038 namespace dummy {
0039   template <typename T>
0040   inline bool select(const T&) {
0041     return true;
0042   }
0043 }  // namespace dummy
0044 
0045 EVENTSETUP_STD_INIT(DummySelector);
0046 
0047 #endif