Go to the documentation of this file.00001
00009 #include <iostream>
00010 #include <vector>
00011 #include <memory>
00012
00013
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "DataFormats/Common/interface/Handle.h"
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/Utilities/interface/Exception.h"
00020
00021 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00022 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00023 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00024 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
00025
00026 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRecoEcalCandidateProducers.h"
00027
00028
00029 EgammaHLTRecoEcalCandidateProducers::EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet& config) :
00030 conf_(config)
00031
00032 {
00033
00034 scHybridBarrelProducer_ = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer");
00035 scIslandEndcapProducer_ = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer");
00036 recoEcalCandidateCollection_ = conf_.getParameter<std::string>("recoEcalCandidateCollection");
00037
00038
00039 produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_);
00040 }
00041
00042 EgammaHLTRecoEcalCandidateProducers::~EgammaHLTRecoEcalCandidateProducers() {}
00043
00044 void EgammaHLTRecoEcalCandidateProducers::beginJob() {}
00045
00046 void EgammaHLTRecoEcalCandidateProducers::produce(edm::Event& theEvent, const edm::EventSetup& theEventSetup) {
00047
00048 using namespace edm;
00049
00050
00051
00052
00053
00054 reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
00055 std::auto_ptr< reco::RecoEcalCandidateCollection > outputRecoEcalCandidateCollection_p(new reco::RecoEcalCandidateCollection);
00056
00057
00058 Handle<reco::SuperClusterCollection> scBarrelHandle;
00059 theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
00060
00061 Handle<reco::SuperClusterCollection> scEndcapHandle;
00062 theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);
00063
00064
00065 int iSC=0;
00066 int lSC=0;
00067
00068
00069 for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) {
00070
00071 const reco::Particle::Point vtx( 0, 0, 0 );
00072
00073
00074 math::XYZVector direction =aClus->position() - vtx;
00075 math::XYZVector momentum = direction.unit() * aClus->energy();
00076 const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
00077
00078 reco::RecoEcalCandidate newCandidate(0, p4, vtx);
00079
00080 outputRecoEcalCandidateCollection.push_back(newCandidate);
00081 reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
00082 outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
00083
00084 lSC++;
00085 iSC++;
00086
00087 }
00088
00089
00090 lSC=0;
00091
00092 for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) {
00093
00094 const reco::Particle::Point vtx( 0, 0, 0 );
00095
00096 math::XYZVector direction =aClus->position() - vtx;
00097 math::XYZVector momentum = direction.unit() * aClus->energy();
00098 const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
00099
00100 reco::RecoEcalCandidate newCandidate(0, p4, vtx);
00101
00102 outputRecoEcalCandidateCollection.push_back(newCandidate);
00103 reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC));
00104 outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
00105
00106 iSC++;
00107 lSC++;
00108
00109 }
00110
00111
00112 outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
00113 theEvent.put( outputRecoEcalCandidateCollection_p, recoEcalCandidateCollection_);
00114
00115 }
00116