00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019 #include "FastSimulation/EgammaElectronAlgos/plugins/ElectronGSPixelSeedProducer.h"
00020 #include "FastSimulation/EgammaElectronAlgos/interface/ElectronGSPixelSeedGenerator.h"
00021
00022 #include "FWCore/Framework/interface/Event.h"
00023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00025
00026 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00027 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00028 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00029 #include "RecoEgamma/EgammaTools/interface/HoECalculator.h"
00030
00031 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2DCollection.h"
00032 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00033 #include "DataFormats/EgammaReco/interface/ElectronPixelSeed.h"
00034 #include "DataFormats/EgammaReco/interface/ElectronPixelSeedFwd.h"
00035 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00036 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00037
00038 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00039
00040 #include <iostream>
00041
00042 ElectronGSPixelSeedProducer::ElectronGSPixelSeedProducer(const edm::ParameterSet& iConfig)
00043 {
00044
00045 edm::ParameterSet pset = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration");
00046 SCEtCut_=pset.getParameter<double>("SCEtCut");
00047 maxHOverE_=pset.getParameter<double>("maxHOverE");
00048 fromTrackerSeeds_=pset.getParameter<bool>("fromTrackerSeeds");
00049 initialSeeds_=pset.getParameter<edm::InputTag>("initialSeeds");
00050
00051 matcher_ = new ElectronGSPixelSeedGenerator(pset,
00052 iConfig.getParameter<double>("pTMin"),
00053 iConfig.getParameter<edm::InputTag>("beamSpot"));
00054
00055
00056 clusters_[0]=iConfig.getParameter<edm::InputTag>("barrelSuperClusters");
00057 clusters_[1]=iConfig.getParameter<edm::InputTag>("endcapSuperClusters");
00058 simTracks_=iConfig.getParameter<edm::InputTag>("simTracks");
00059 trackerHits_=iConfig.getParameter<edm::InputTag>("trackerHits");
00060 hcalRecHits_= pset.getParameter<edm::InputTag>("hcalRecHits");
00061
00062
00063 produces<reco::ElectronPixelSeedCollection>();
00064
00065 }
00066
00067
00068 ElectronGSPixelSeedProducer::~ElectronGSPixelSeedProducer()
00069 {
00070
00071
00072 delete matcher_;
00073 }
00074
00075 void
00076 ElectronGSPixelSeedProducer::beginRun(edm::Run & run, const edm::EventSetup & es) {
00077
00078 edm::ESHandle<CaloGeometry> theCaloGeom;
00079 es.get<CaloGeometryRecord>().get(theCaloGeom);
00080
00081
00082 calc_=HoECalculator(theCaloGeom);
00083
00084 matcher_->setupES(es);
00085
00086 }
00087
00088 void ElectronGSPixelSeedProducer::produce(edm::Event& e, const edm::EventSetup& iSetup)
00089 {
00090 LogDebug("entering");
00091 LogDebug("") <<"[ElectronGSPixelSeedProducer::produce] entering " ;
00092
00093
00094 if (fromTrackerSeeds_) {
00095
00096 edm::Handle<TrajectorySeedCollection> hSeeds;
00097 e.getByLabel(initialSeeds_, hSeeds);
00098 theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
00099
00100 } else {
00101
00102 theInitialSeedColl=0;
00103
00104 }
00105
00106 std::auto_ptr<reco::ElectronPixelSeedCollection> pSeeds;
00107 reco::ElectronPixelSeedCollection *seeds= new reco::ElectronPixelSeedCollection;
00108
00109
00110 edm::Handle<edm::SimTrackContainer> theSTC;
00111 e.getByLabel(simTracks_,theSTC);
00112 const edm::SimTrackContainer* theSimTracks = &(*theSTC);
00113
00114
00115 edm::Handle<SiTrackerGSMatchedRecHit2DCollection> theRHC;
00116 e.getByLabel(trackerHits_, theRHC);
00117 const SiTrackerGSMatchedRecHit2DCollection* theGSRecHits = &(*theRHC);
00118
00119
00120 edm::Handle<HBHERecHitCollection> hbhe;
00121 HBHERecHitMetaCollection *mhbhe=0;
00122 bool got = e.getByLabel(hcalRecHits_,hbhe);
00123 if (got) mhbhe = new HBHERecHitMetaCollection(*hbhe);
00124
00125
00126 for (unsigned int i=0; i<2; i++) {
00127
00128
00129 edm::Handle<reco::SuperClusterCollection> clusters;
00130 e.getByLabel(clusters_[i],clusters);
00131 reco::SuperClusterRefVector clusterRefs;
00132 filterClusters(clusters,mhbhe,clusterRefs);
00133 matcher_->run(e,clusterRefs,theGSRecHits,theSimTracks,theInitialSeedColl,*seeds);
00134
00135 }
00136
00137
00138 pSeeds= std::auto_ptr<reco::ElectronPixelSeedCollection>(seeds);
00139 e.put(pSeeds);
00140
00141
00142 delete mhbhe;
00143 }
00144
00145
00146 void
00147 ElectronGSPixelSeedProducer::filterClusters(const edm::Handle<reco::SuperClusterCollection>& superClusters,
00148 HBHERecHitMetaCollection*mhbhe,
00149 reco::SuperClusterRefVector &sclRefs)
00150 {
00151
00152
00153
00154
00155 for (unsigned int i=0;i<superClusters->size();++i) {
00156
00157 const reco::SuperCluster &scl=(*superClusters)[i];
00158
00159 if (scl.energy()/cosh(scl.eta())>SCEtCut_) {
00160
00161 double HoE=calc_(&scl,mhbhe);
00162 if (HoE <= maxHOverE_) {
00163 sclRefs.push_back(edm::Ref<reco::SuperClusterCollection> (superClusters,i));
00164 }
00165
00166 }
00167
00168 }
00169
00170 LogDebug("ElectronPixelSeedProducer") <<"Filtered out "<<sclRefs.size() <<" superclusters from "<<superClusters->size() ;
00171
00172 }