Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:12

0001 //
0002 // Original Author:  Marco ZANETTI
0003 //         Created:  Mon Jan 28 18:22:13 CET 2008
0004 
0005 #include <memory>
0006 #include <utility>
0007 
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/EDProducer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 
0014 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0015 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0016 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0017 
0018 #include "EventFilter/RawDataCollector/interface/RawDataFEDSelector.h"
0019 
0020 class RawDataSelector : public edm::EDProducer {
0021 public:
0022   explicit RawDataSelector(const edm::ParameterSet&);
0023 
0024   ~RawDataSelector() override;
0025 
0026 private:
0027   void produce(edm::Event&, const edm::EventSetup&) override;
0028 
0029   RawDataFEDSelector* selector;
0030 
0031   edm::InputTag dataLabel;
0032   std::pair<int, int> fedRange;
0033 };
0034 
0035 RawDataSelector::RawDataSelector(const edm::ParameterSet& pset)
0036     : dataLabel(pset.getUntrackedParameter<edm::InputTag>("InputLabel", edm::InputTag("source"))) {
0037   fedRange = std::pair<int, int>(pset.getParameter<int>("lowerBound"), pset.getParameter<int>("upperBound"));
0038 
0039   selector = new RawDataFEDSelector();
0040 
0041   produces<FEDRawDataCollection>();
0042 }
0043 
0044 RawDataSelector::~RawDataSelector() { delete selector; }
0045 
0046 void RawDataSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047   using namespace edm;
0048   using namespace std;
0049 
0050   Handle<FEDRawDataCollection> rawData;
0051   iEvent.getByLabel(dataLabel, rawData);
0052 
0053   /* here eventually perform some operation to get the list of FED's 
0054      to be written in the new collection.
0055      In this case we simply take the range from the ParameterSet */
0056 
0057   // the filtered raw data collections
0058   std::unique_ptr<FEDRawDataCollection> selectedRawData = selector->select(rawData, fedRange);
0059 
0060   iEvent.put(std::move(selectedRawData));
0061 }
0062 
0063 //define this as a plug-in
0064 DEFINE_FWK_MODULE(RawDataSelector);