#include <RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h>
Public Member Functions | |
virtual void | beginRun (edm::Run const &, edm::EventSetup const &) override |
EgammaHLTElectronDetaDphiProducer (const edm::ParameterSet &) | |
virtual void | produce (edm::Event &, const edm::EventSetup &) override |
~EgammaHLTElectronDetaDphiProducer () | |
Private Member Functions | |
std::pair< float, float > | calDEtaDPhiSCTrk (reco::ElectronRef &eleref, const reco::BeamSpot::Point &BSPosition, const MagneticField *magField) |
Static Private Member Functions | |
static reco::ElectronRef | getEleRef (const reco::RecoEcalCandidateRef &recoEcalCandRef, const edm::Handle< reco::ElectronCollection > &electronHandle) |
Private Attributes | |
edm::InputTag | bsProducer_ |
edm::InputTag | electronProducer_ |
const MagneticField * | magField_ |
edm::InputTag | recoEcalCandidateProducer_ |
bool | useSCRefs_ |
bool | useTrackProjectionToEcal_ |
bool | variablesAtVtx_ |
Definition at line 43 of file EgammaHLTElectronDetaDphiProducer.h.
EgammaHLTElectronDetaDphiProducer::EgammaHLTElectronDetaDphiProducer | ( | const edm::ParameterSet & | config | ) | [explicit] |
Definition at line 49 of file EgammaHLTElectronDetaDphiProducer.cc.
References bsProducer_, electronProducer_, edm::ParameterSet::getParameter(), recoEcalCandidateProducer_, useSCRefs_, useTrackProjectionToEcal_, and variablesAtVtx_.
{ electronProducer_ = config.getParameter<edm::InputTag>("electronProducer"); bsProducer_ = config.getParameter<edm::InputTag>("BSProducer"); useTrackProjectionToEcal_ = config.getParameter<bool>("useTrackProjectionToEcal"); variablesAtVtx_ = config.getParameter<bool>("variablesAtVtx"); recoEcalCandidateProducer_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer"); useSCRefs_ = config.getParameter<bool>("useSCRefs"); //register your products if(!useSCRefs_){ produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" ); produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); }else{ produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" ); produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); } }
EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer | ( | ) |
Definition at line 69 of file EgammaHLTElectronDetaDphiProducer.cc.
{}
void EgammaHLTElectronDetaDphiProducer::beginRun | ( | edm::Run const & | , |
edm::EventSetup const & | iSetup | ||
) | [override, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 194 of file EgammaHLTElectronDetaDphiProducer.cc.
References edm::EventSetup::get(), and magField_.
{ using namespace edm; ESHandle<MagneticField> magneticField; iSetup.get<IdealMagneticFieldRecord>().get(magneticField); magField_ = magneticField.product(); }
std::pair< float, float > EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk | ( | reco::ElectronRef & | eleref, |
const reco::BeamSpot::Point & | BSPosition, | ||
const MagneticField * | magField | ||
) | [private] |
Definition at line 133 of file EgammaHLTElectronDetaDphiProducer.cc.
References ECALPositionCalculator::ecalPhi(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), magField_, reco::TransientTrack::stateOnSurface(), groupFilesInBlocks::tt, useTrackProjectionToEcal_, and variablesAtVtx_.
Referenced by produce().
{ const reco::SuperClusterRef theClus = eleref->superCluster(); const math::XYZVector trackMom = eleref->track()->momentum(); math::XYZPoint SCcorrPosition(theClus->x()-bsPosition.x(), theClus->y()-bsPosition.y() , theClus->z()-eleref->track()->vz() ); float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta()); float deltaphi = 999.; bool recoveryForFailingPropagation = false; if (variablesAtVtx_) { reco::TrackRef track = eleref->track(); reco::TransientTrack tt(track, magField_); TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(),theClus->y(),theClus->z())); if (sclTSOS.isValid()) { EleRelPointPair scAtVtx(theClus->position(), sclTSOS.globalPosition(), bsPosition); deltaeta = fabs(scAtVtx.dEta()); deltaphi = fabs(scAtVtx.dPhi()); } else { recoveryForFailingPropagation = true; } } else if (useTrackProjectionToEcal_ or recoveryForFailingPropagation) { ECALPositionCalculator posCalc; const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz()); float phi1= posCalc.ecalPhi(magField,trackMom,vertex,1); float phi2= posCalc.ecalPhi(magField,trackMom,vertex,-1); float deltaphi1=fabs( phi1 - theClus->position().phi() ); if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308; if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1; float deltaphi2=fabs( phi2 - theClus->position().phi() ); if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308; if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2; deltaphi = deltaphi1; if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;} } else { deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi()); if(deltaphi>6.283185308) deltaphi -= 6.283185308; if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi; } return std::make_pair(deltaeta,deltaphi); }
reco::ElectronRef EgammaHLTElectronDetaDphiProducer::getEleRef | ( | const reco::RecoEcalCandidateRef & | recoEcalCandRef, |
const edm::Handle< reco::ElectronCollection > & | electronHandle | ||
) | [static, private] |
Definition at line 181 of file EgammaHLTElectronDetaDphiProducer.cc.
Referenced by produce().
{ reco::ElectronRef eleRef; for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){ if(eleIt->superCluster()==recoEcalCandRef->superCluster()){ eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin()); break; } } return eleRef; }
void EgammaHLTElectronDetaDphiProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [override, virtual] |
Implements edm::EDProducer.
Definition at line 77 of file EgammaHLTElectronDetaDphiProducer.cc.
References bsProducer_, calDEtaDPhiSCTrk(), electronProducer_, edm::EventSetup::get(), edm::Event::getByLabel(), getEleRef(), edm::AssociationMap< Tag >::insert(), edm::ESHandle< T >::product(), edm::Event::put(), recoEcalCandidateProducer_, and useSCRefs_.
{ // Get the HLT filtered objects edm::Handle<reco::ElectronCollection> electronHandle; iEvent.getByLabel(electronProducer_,electronHandle); edm::Handle<reco::BeamSpot> recoBeamSpotHandle; iEvent.getByLabel(bsProducer_,recoBeamSpotHandle); // gets its position const reco::BeamSpot::Point& bsPosition = recoBeamSpotHandle->position(); edm::ESHandle<MagneticField> theMagField; iSetup.get<IdealMagneticFieldRecord>().get(theMagField); reco::ElectronIsolationMap detaMap; reco::ElectronIsolationMap dphiMap; reco::RecoEcalCandidateIsolationMap detaCandMap; reco::RecoEcalCandidateIsolationMap dphiCandMap; if(!useSCRefs_){ for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){ reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin())); std::pair<float,float> dEtaDPhi = calDEtaDPhiSCTrk(eleref,bsPosition,theMagField.product()); detaMap.insert(eleref, dEtaDPhi.first); dphiMap.insert(eleref, dEtaDPhi.second); } }else { //we loop over reco ecal candidates edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle; iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle); for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){ reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin()); reco::ElectronRef eleRef = getEleRef(recoEcalCandRef,electronHandle); std::pair<float,float> dEtaDPhi(999999,999999); if(eleRef.isNonnull()) dEtaDPhi = calDEtaDPhiSCTrk(eleRef,bsPosition,theMagField.product()); detaCandMap.insert(recoEcalCandRef, dEtaDPhi.first); dphiCandMap.insert(recoEcalCandRef, dEtaDPhi.second); }//end loop over reco ecal candidates }//end if between electrons or reco ecal candidates if(!useSCRefs_){ std::auto_ptr<reco::ElectronIsolationMap> detMap(new reco::ElectronIsolationMap(detaMap)); std::auto_ptr<reco::ElectronIsolationMap> dphMap(new reco::ElectronIsolationMap(dphiMap)); iEvent.put(detMap, "Deta" ); iEvent.put(dphMap, "Dphi" ); }else{ std::auto_ptr<reco::RecoEcalCandidateIsolationMap> detaCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(detaCandMap)); std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dphiCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(dphiCandMap)); iEvent.put(detaCandMapForEvent, "Deta" ); iEvent.put(dphiCandMapForEvent, "Dphi" ); } }
Definition at line 62 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by EgammaHLTElectronDetaDphiProducer(), and produce().
Definition at line 55 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by EgammaHLTElectronDetaDphiProducer(), and produce().
const MagneticField* EgammaHLTElectronDetaDphiProducer::magField_ [private] |
Definition at line 61 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by beginRun(), and calDEtaDPhiSCTrk().
Definition at line 56 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by EgammaHLTElectronDetaDphiProducer(), and produce().
bool EgammaHLTElectronDetaDphiProducer::useSCRefs_ [private] |
Definition at line 58 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by EgammaHLTElectronDetaDphiProducer(), and produce().
bool EgammaHLTElectronDetaDphiProducer::useTrackProjectionToEcal_ [private] |
Definition at line 59 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by calDEtaDPhiSCTrk(), and EgammaHLTElectronDetaDphiProducer().
bool EgammaHLTElectronDetaDphiProducer::variablesAtVtx_ [private] |
Definition at line 60 of file EgammaHLTElectronDetaDphiProducer.h.
Referenced by calDEtaDPhiSCTrk(), and EgammaHLTElectronDetaDphiProducer().