CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/EventFilter/RawDataCollector/src/RawDataSelector.cc

Go to the documentation of this file.
00001 //
00002 // Original Author:  Marco ZANETTI
00003 //         Created:  Mon Jan 28 18:22:13 CET 2008
00004 
00005 
00006 
00007 #include <memory>
00008 #include <utility>
00009 
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/EDProducer.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/MakerMacros.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h> 
00017 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00018 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00019 
00020 #include <EventFilter/RawDataCollector/interface/RawDataFEDSelector.h>
00021 
00022 class RawDataSelector : public edm::EDProducer {
00023 
00024 public:
00025 
00026   explicit RawDataSelector(const edm::ParameterSet&);
00027 
00028   ~RawDataSelector();
00029 
00030 private:
00031 
00032   virtual void produce(edm::Event&, const edm::EventSetup&);
00033   void beginRun(const edm::Run&, const edm::EventSetup&);
00034 
00035   RawDataFEDSelector * selector; 
00036 
00037   edm::InputTag dataLabel;
00038   std::pair<int,int> fedRange;
00039   
00040 };
00041 
00042 RawDataSelector::RawDataSelector(const edm::ParameterSet& pset) :
00043   dataLabel(pset.getUntrackedParameter<edm::InputTag>("InputLabel",edm::InputTag("source"))) {
00044 
00045   fedRange = std::pair<int,int>(pset.getParameter<int>("lowerBound"), pset.getParameter<int>("upperBound"));
00046 
00047   selector = new RawDataFEDSelector();
00048 
00049   produces<FEDRawDataCollection>();
00050 
00051 }
00052 
00053 
00054 RawDataSelector::~RawDataSelector() {
00055   delete selector;
00056 }
00057 
00058 
00059 void RawDataSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00060 
00061   using namespace edm;
00062   using namespace std;
00063 
00064   Handle<FEDRawDataCollection> rawData;
00065   iEvent.getByLabel( dataLabel, rawData);
00066 
00067   /* here eventually perform some operation to get the list of FED's 
00068      to be written in the new collection.
00069      In this case we simply take the range from the ParameterSet */
00070 
00071 
00072   // the filtered raw data collections
00073   auto_ptr<FEDRawDataCollection> selectedRawData = selector->select(rawData, fedRange);
00074 
00075 
00076   iEvent.put(selectedRawData);
00077   
00078 }
00079 
00080 
00081 //define this as a plug-in
00082 DEFINE_FWK_MODULE(RawDataSelector);