00001 // -*- C++ -*- 00002 // 00003 // Package: PickEvents 00004 // Class: PickEvents 00005 // 00013 // 00014 // Original Author: Michael Henry Schmitt 00015 // Created: Mon Sep 15 19:36:37 CEST 2008 00016 // $Id: PickEvents.cc,v 1.1 2008/09/18 08:59:28 schmittm Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 00024 // user include files 00025 #include "FWCore/Framework/interface/Frameworkfwd.h" 00026 #include "FWCore/Framework/interface/EDFilter.h" 00027 00028 #include "FWCore/Framework/interface/Event.h" 00029 #include "FWCore/Framework/interface/MakerMacros.h" 00030 00031 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00032 00033 // 00034 // class declaration 00035 // 00036 00037 class PickEvents : public edm::EDFilter { 00038 public: 00039 explicit PickEvents(const edm::ParameterSet&); 00040 ~PickEvents(); 00041 00042 private: 00043 virtual void beginJob(const edm::EventSetup&) ; 00044 virtual bool filter(edm::Event&, const edm::EventSetup&); 00045 virtual void endJob() ; 00046 00047 int nEventsAnalyzed; 00048 int nEventsSelected; 00049 int whichRun; 00050 int whichEventFirst; 00051 int whichEventLast ; 00052 00053 }; 00054 00055 using namespace std; 00056 using namespace edm; 00057 00058 00059 00060 PickEvents::PickEvents(const edm::ParameterSet& iConfig) 00061 { 00062 whichRun = iConfig.getUntrackedParameter<int>("whichRun",1); 00063 whichEventFirst = iConfig.getUntrackedParameter<int>("whichEventFirst",11); 00064 whichEventLast = iConfig.getUntrackedParameter<int>("whichEventLast",19); 00065 00066 } 00067 00068 00069 PickEvents::~PickEvents() 00070 { 00071 } 00072 00073 bool 00074 PickEvents::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) 00075 { 00076 using namespace edm; 00077 00078 int kRun = iEvent.id().run(); 00079 int kEvent = iEvent.id().event(); 00080 00081 bool selectThisEvent = false; 00082 if (kRun == whichRun) { 00083 if ( (kEvent >= whichEventFirst) && (kEvent <= whichEventLast) ) { 00084 selectThisEvent = true; 00085 } 00086 } 00087 00088 nEventsAnalyzed++; 00089 if (selectThisEvent) nEventsSelected++; 00090 00091 return selectThisEvent; 00092 } 00093 00094 void 00095 PickEvents::beginJob(const edm::EventSetup&) 00096 { 00097 nEventsAnalyzed = 0; 00098 nEventsSelected = 0; 00099 } 00100 void 00101 PickEvents::endJob() { 00102 cout << "================================================\n" 00103 << " n Events Analyzed ............... " << nEventsAnalyzed << endl 00104 << " n Events Selected ............... " << nEventsSelected<< endl 00105 << "================================================\n\n" ; 00106 } 00107 00108 00109 DEFINE_FWK_MODULE(PickEvents);