Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-30 22:39:09

0001 /** \class EcalCompactTrigPrimProducer
0002  *
0003  *  $Id:
0004  *  $Date:
0005  *  $Revision:
0006  *  \author Ph. Gras CEA/IRFU Saclay
0007  *
0008  **/
0009 
0010 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 class EcalCompactTrigPrimProducer : public edm::stream::EDProducer<> {
0016 public:
0017   EcalCompactTrigPrimProducer(const edm::ParameterSet& ps);
0018   ~EcalCompactTrigPrimProducer() override {}
0019   void produce(edm::Event& evt, const edm::EventSetup& es) override;
0020 
0021 private:
0022   edm::EDGetTokenT<EcalTrigPrimDigiCollection> inCollectionToken_;
0023 
0024   /*
0025    * output collections
0026    */
0027   std::string outCollection_;
0028 };
0029 
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 DEFINE_FWK_MODULE(EcalCompactTrigPrimProducer);
0032 
0033 EcalCompactTrigPrimProducer::EcalCompactTrigPrimProducer(const edm::ParameterSet& ps)
0034     : outCollection_(ps.getParameter<std::string>("outColl")) {
0035   inCollectionToken_ = consumes<EcalTrigPrimDigiCollection>((ps.getParameter<edm::InputTag>("inColl")));
0036   produces<EcalTrigPrimCompactColl>(outCollection_);
0037 }
0038 
0039 void EcalCompactTrigPrimProducer::produce(edm::Event& event, const edm::EventSetup& es) {
0040   auto outColl = std::make_unique<EcalTrigPrimCompactColl>();
0041   edm::Handle<EcalTrigPrimDigiCollection> hTPDigis;
0042   event.getByToken(inCollectionToken_, hTPDigis);
0043 
0044   const EcalTrigPrimDigiCollection* trigPrims = hTPDigis.product();
0045 
0046   for (EcalTrigPrimDigiCollection::const_iterator trigPrim = trigPrims->begin(); trigPrim != trigPrims->end();
0047        ++trigPrim) {
0048     outColl->setValue(
0049         trigPrim->id().ieta(), trigPrim->id().iphi(), trigPrim->sample(trigPrim->sampleOfInterest()).raw());
0050   }
0051   event.put(std::move(outColl), outCollection_);
0052 }