CMS 3D CMS Logo

Public Member Functions | Private Attributes

EgammaHLTElectronDetaDphiProducer Class Reference

#include <RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronDetaDphiProducer.h>

Inheritance diagram for EgammaHLTElectronDetaDphiProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EgammaHLTElectronDetaDphiProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EgammaHLTElectronDetaDphiProducer ()

Private Attributes

edm::InputTag BSProducer_
edm::ParameterSet conf_
edm::InputTag electronProducer_
bool useTrackProjectionToEcal_

Detailed Description

Author:
Roberto Covarelli (CERN)
Id:
EgammaHLTElectronDetaDphiProducer.cc,v 1.2 2009/01/28 15:10:18 covarell Exp

Definition at line 32 of file EgammaHLTElectronDetaDphiProducer.h.


Constructor & Destructor Documentation

EgammaHLTElectronDetaDphiProducer::EgammaHLTElectronDetaDphiProducer ( const edm::ParameterSet config) [explicit]

Definition at line 45 of file EgammaHLTElectronDetaDphiProducer.cc.

References BSProducer_, conf_, electronProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and useTrackProjectionToEcal_.

                                                                                                  : conf_(config)
{

  electronProducer_             = conf_.getParameter<edm::InputTag>("electronProducer");
  BSProducer_                   = conf_.getParameter<edm::InputTag>("BSProducer");
  useTrackProjectionToEcal_     = conf_.getUntrackedParameter<bool>("useTrackProjectionToEcal",false);

  //register your products
  produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" );
  produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );

}
EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer ( )

Definition at line 58 of file EgammaHLTElectronDetaDphiProducer.cc.

{}

Member Function Documentation

void EgammaHLTElectronDetaDphiProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 67 of file EgammaHLTElectronDetaDphiProducer.cc.

References BSProducer_, ECALPositionCalculator::ecalPhi(), electronProducer_, edm::EventSetup::get(), edm::Event::getByLabel(), edm::AssociationMap< Tag >::insert(), edm::ESHandle< T >::product(), edm::Event::put(), and useTrackProjectionToEcal_.

{

  // 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;

  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
    
    reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
    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;

    if (useTrackProjectionToEcal_) { 

      ECALPositionCalculator posCalc;
      const math::XYZPoint vertex(BSPosition.x(),BSPosition.y(),eleref->track()->vz());

      float phi1= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,1);
      float phi2= posCalc.ecalPhi(theMagField.product(),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;

    }
      
    detaMap.insert(eleref, deltaeta);
    dphiMap.insert(eleref, deltaphi);
      
  }

  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" );

}

Member Data Documentation