CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoEgamma/EgammaHFProducers/plugins/HFEMClusterProducer.cc

Go to the documentation of this file.
00001 //Package:    EgammaHFProdcers
00002 // Class  :    HFEMClusterProducer
00003 // Original Author:  Kevin Klapoetke (minnesota)
00004 //        
00005 // $Id: HFEMClusterProducer.cc,v 1.2 2007/09/19 Kevin Klapoetke
00006 //
00007 
00008 #include <iostream>
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00012 #include "RecoEgamma/EgammaHFProducers/plugins/HFEMClusterProducer.h"
00013 using namespace reco;
00014 HFEMClusterProducer::HFEMClusterProducer(edm::ParameterSet const& conf): hfreco_(conf.getParameter<edm::InputTag>("hits")) {
00015   produces<reco::HFEMClusterShapeCollection>();
00016   produces<reco::BasicClusterCollection>();
00017   produces<reco::SuperClusterCollection>();
00018   produces<reco::HFEMClusterShapeAssociationCollection>(); 
00019   algo_.setup(conf.getParameter<double>("minTowerEnergy"),
00020               conf.getParameter<double>("seedThresholdET"),
00021               conf.getParameter<double>("maximumSL"),
00022               conf.getParameter<double>("maximumRenergy"),
00023               conf.getParameter<bool>("usePMTFlag"),
00024               conf.getParameter<bool>("usePulseFlag"),
00025               conf.getParameter<bool>("forcePulseFlagMC"),
00026               conf.getParameter<int>("correctionType"));
00027 }
00028 
00029 void HFEMClusterProducer::produce(edm::Event & e, edm::EventSetup const& iSetup) {  
00030   
00031   edm::Handle<HFRecHitCollection> hf_hits;
00032   
00033   e.getByLabel(hfreco_,hf_hits);
00034   
00035   edm::ESHandle<CaloGeometry> geometry;
00036   iSetup.get<CaloGeometryRecord>().get(geometry);
00037   
00038   // create return data
00039   std::auto_ptr<reco::HFEMClusterShapeCollection> retdata1(new HFEMClusterShapeCollection());
00040   std::auto_ptr<reco::SuperClusterCollection> retdata2(new SuperClusterCollection());
00041   std::auto_ptr<reco::HFEMClusterShapeAssociationCollection> retdata3(new HFEMClusterShapeAssociationCollection());
00042 
00043   algo_.isMC(!e.isRealData());
00044  
00045  
00046   algo_.clusterize(*hf_hits, *geometry, *retdata1, *retdata2);
00047   edm::OrphanHandle<reco::SuperClusterCollection> SupHandle;
00048   edm::OrphanHandle<reco::HFEMClusterShapeCollection> ShapeHandle;
00049 
00050   // put the results
00051   ShapeHandle=e.put(retdata1);
00052   SupHandle=e.put(retdata2);
00053   for (unsigned int i=0; i < ShapeHandle->size();i++){
00054     retdata3->insert(edm::Ref<reco::SuperClusterCollection>(SupHandle,i),edm::Ref<reco::HFEMClusterShapeCollection>(ShapeHandle,i));
00055   }
00056 
00057 
00058   e.put(retdata3);
00059 
00060 }