Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:43

0001 // -*- C++ -*-
0002 
0003 // system include files
0004 #include <memory>
0005 #include <string>
0006 // user include files
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/global/EDProducer.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/EventSetup.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014 
0015 #include "DataFormats/Common/interface/Ref.h"
0016 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0017 #include "DataFormats/DetId/interface/DetId.h"
0018 
0019 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0020 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0021 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0022 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0023 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0024 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0025 
0026 //
0027 // class decleration
0028 //
0029 
0030 class AlCaEcalHcalReadoutsProducer : public edm::global::EDProducer<> {
0031 public:
0032   explicit AlCaEcalHcalReadoutsProducer(const edm::ParameterSet&);
0033   ~AlCaEcalHcalReadoutsProducer() override = default;
0034 
0035   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0036   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0037 
0038 private:
0039   // ----------member data ---------------------------
0040 
0041   edm::EDGetTokenT<HBHERecHitCollection> tok_hbhe_;
0042   edm::EDGetTokenT<HORecHitCollection> tok_ho_;
0043   edm::EDGetTokenT<HFRecHitCollection> tok_hf_;
0044 
0045   edm::EDPutTokenT<HBHERecHitCollection> put_hbhe_;
0046   edm::EDPutTokenT<HORecHitCollection> put_ho_;
0047   edm::EDPutTokenT<HFRecHitCollection> put_hf_;
0048 };
0049 
0050 AlCaEcalHcalReadoutsProducer::AlCaEcalHcalReadoutsProducer(const edm::ParameterSet& iConfig) {
0051   tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
0052   tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
0053   tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
0054 
0055   //register your products
0056   put_hbhe_ = produces<HBHERecHitCollection>("HBHERecHitCollection");
0057   put_ho_ = produces<HORecHitCollection>("HORecHitCollection");
0058   put_hf_ = produces<HFRecHitCollection>("HFRecHitCollection");
0059 }
0060 
0061 // ------------ method called to produce the data  ------------
0062 void AlCaEcalHcalReadoutsProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0063   edm::Handle<HBHERecHitCollection> hbhe = iEvent.getHandle(tok_hbhe_);
0064   if (!hbhe.isValid()) {
0065     edm::LogVerbatim("AlCaEcalHcal") << "AlCaEcalHcalReadoutProducer: Error! can't get hbhe product!";
0066     return;
0067   }
0068 
0069   edm::Handle<HORecHitCollection> ho = iEvent.getHandle(tok_ho_);
0070   if (!ho.isValid()) {
0071     edm::LogVerbatim("AlCaEcalHcal") << "AlCaEcalHcalReadoutProducer: Error! can't get ho product!";
0072   }
0073 
0074   edm::Handle<HFRecHitCollection> hf = iEvent.getHandle(tok_hf_);
0075   if (!hf.isValid()) {
0076     edm::LogVerbatim("AlCaEcalHcal") << "AlCaEcalHcalReadoutProducer: Error! can't get hf product!";
0077   }
0078 
0079   //Put selected information in the event
0080   iEvent.emplace(put_hbhe_, *hbhe);
0081   iEvent.emplace(put_ho_, *ho);
0082   iEvent.emplace(put_hf_, *hf);
0083 }
0084 
0085 void AlCaEcalHcalReadoutsProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0086   edm::ParameterSetDescription desc;
0087   desc.add<edm::InputTag>("hbheInput", edm::InputTag("hbhereco"));
0088   desc.add<edm::InputTag>("hfInput", edm::InputTag("hfreco"));
0089   desc.add<edm::InputTag>("hoInput", edm::InputTag("horeco"));
0090   descriptions.add("alcaEcalHcalReadoutsProducer", desc);
0091 }
0092 
0093 #include "FWCore/PluginManager/interface/ModuleDef.h"
0094 #include "FWCore/Framework/interface/MakerMacros.h"
0095 
0096 DEFINE_FWK_MODULE(AlCaEcalHcalReadoutsProducer);