CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRecoEcalCandidateProducers.cc

Go to the documentation of this file.
00001 
00009 #include <iostream>
00010 #include <vector>
00011 #include <memory>
00012 
00013 // Framework
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   // use onfiguration file to setup input/output collection names
00034   scHybridBarrelProducer_       = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer");
00035   scIslandEndcapProducer_       = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer");
00036   recoEcalCandidateCollection_  = conf_.getParameter<std::string>("recoEcalCandidateCollection");
00037 
00038   // Register the product
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   // create empty output collections
00052   //
00053 
00054   reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
00055   std::auto_ptr< reco::RecoEcalCandidateCollection > outputRecoEcalCandidateCollection_p(new reco::RecoEcalCandidateCollection);
00056 
00057   // Get the  Barrel Super Cluster collection
00058   Handle<reco::SuperClusterCollection> scBarrelHandle;
00059   theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
00060   // Get the  Endcap Super Cluster collection
00061   Handle<reco::SuperClusterCollection> scEndcapHandle;
00062   theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);
00063 
00064   //  Loop over barrel SC and fill the  recoecal collection
00065   int iSC=0; // index in recoecal collection
00066   int lSC=0; // local index on barrel
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     // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
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   //  Loop over Endcap SC and fill the  recoecal collection
00090   lSC=0; // reset local index for endcap
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   // put the product in the event
00112   outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
00113   theEvent.put( outputRecoEcalCandidateCollection_p, recoEcalCandidateCollection_);
00114 
00115 }
00116