Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:06

0001 //Package:    EgammaHFProdcers
0002 // Class  :    HFEMClusterProducer
0003 // Original Author:  Kevin Klapoetke (minnesota)
0004 //
0005 // $Id: HFEMClusterProducer.cc,v 1.2 2007/09/19 Kevin Klapoetke
0006 //
0007 
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0015 
0016 #include "HFClusterAlgo.h"
0017 
0018 class HFEMClusterProducer : public edm::stream::EDProducer<> {
0019 public:
0020   explicit HFEMClusterProducer(edm::ParameterSet const& conf);
0021   void produce(edm::Event& e, edm::EventSetup const& iSetup) override;
0022   void beginRun(edm::Run const&, edm::EventSetup const&) final { algo_.resetForRun(); }
0023 
0024 private:
0025   const edm::EDGetTokenT<HFRecHitCollection> hfreco_;
0026   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometryToken_;
0027   HFClusterAlgo algo_;
0028 };
0029 
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 DEFINE_FWK_MODULE(HFEMClusterProducer);
0032 
0033 using namespace reco;
0034 HFEMClusterProducer::HFEMClusterProducer(edm::ParameterSet const& conf)
0035     : hfreco_(consumes(conf.getParameter<edm::InputTag>("hits"))), geometryToken_{esConsumes()} {
0036   produces<reco::HFEMClusterShapeCollection>();
0037   produces<reco::BasicClusterCollection>();
0038   produces<reco::SuperClusterCollection>();
0039   produces<reco::HFEMClusterShapeAssociationCollection>();
0040   algo_.setup(conf.getParameter<double>("minTowerEnergy"),
0041               conf.getParameter<double>("seedThresholdET"),
0042               conf.getParameter<double>("maximumSL"),
0043               conf.getParameter<double>("maximumRenergy"),
0044               conf.getParameter<bool>("usePMTFlag"),
0045               conf.getParameter<bool>("usePulseFlag"),
0046               conf.getParameter<bool>("forcePulseFlagMC"),
0047               conf.getParameter<int>("correctionType"));
0048 }
0049 
0050 void HFEMClusterProducer::produce(edm::Event& e, edm::EventSetup const& iSetup) {
0051   auto const& hf_hits = e.get(hfreco_);
0052   auto const& geometry = iSetup.getData(geometryToken_);
0053 
0054   // create return data
0055   auto retdata1 = std::make_unique<HFEMClusterShapeCollection>();
0056   auto retdata2 = std::make_unique<SuperClusterCollection>();
0057 
0058   algo_.isMC(!e.isRealData());
0059 
0060   algo_.clusterize(hf_hits, geometry, *retdata1, *retdata2);
0061   edm::OrphanHandle<reco::SuperClusterCollection> SupHandle;
0062   edm::OrphanHandle<reco::HFEMClusterShapeCollection> ShapeHandle;
0063 
0064   // put the results
0065   ShapeHandle = e.put(std::move(retdata1));
0066   SupHandle = e.put(std::move(retdata2));
0067 
0068   auto retdata3 = std::make_unique<HFEMClusterShapeAssociationCollection>(SupHandle, ShapeHandle);
0069 
0070   for (unsigned int i = 0; i < ShapeHandle->size(); i++) {
0071     retdata3->insert(edm::Ref<reco::SuperClusterCollection>(SupHandle, i),
0072                      edm::Ref<reco::HFEMClusterShapeCollection>(ShapeHandle, i));
0073   }
0074 
0075   e.put(std::move(retdata3));
0076 }