CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
EgammaHLTElectronDetaDphiProducer Class Reference

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

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

Public Member Functions

virtual void beginRun (edm::Run &, edm::EventSetup const &)
 
 EgammaHLTElectronDetaDphiProducer (const edm::ParameterSet &)
 
virtual void endRun (edm::Run &, edm::EventSetup const &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~EgammaHLTElectronDetaDphiProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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 MagneticFieldmagField_
 
edm::InputTag recoEcalCandidateProducer_
 
bool useSCRefs_
 
bool useTrackProjectionToEcal_
 
bool variablesAtVtx_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Author
Roberto Covarelli (CERN)
Id:
EgammaHLTElectronDetaDphiProducer.cc,v 1.8 2012/03/29 14:15:04 sani Exp
Author
Roberto Covarelli (CERN)
Id:
EgammaHLTGsfTrackVarProducer.cc,v 1.2 2012/02/03 18:48:34 sharper Exp

Definition at line 43 of file EgammaHLTElectronDetaDphiProducer.h.

Constructor & Destructor Documentation

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_.

50 {
51 
52  electronProducer_ = config.getParameter<edm::InputTag>("electronProducer");
53  bsProducer_ = config.getParameter<edm::InputTag>("BSProducer");
54  useTrackProjectionToEcal_ = config.getParameter<bool>("useTrackProjectionToEcal");
55  variablesAtVtx_ = config.getParameter<bool>("variablesAtVtx");
56  recoEcalCandidateProducer_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
57  useSCRefs_ = config.getParameter<bool>("useSCRefs");
58 
59  //register your products
60  if(!useSCRefs_){
61  produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" );
62  produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
63  }else{
64  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
65  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
66  }
67 }
T getParameter(std::string const &) const
EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer ( )

Definition at line 69 of file EgammaHLTElectronDetaDphiProducer.cc.

69 {}

Member Function Documentation

void EgammaHLTElectronDetaDphiProducer::beginRun ( edm::Run ,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 194 of file EgammaHLTElectronDetaDphiProducer.cc.

References edm::EventSetup::get(), and magField_.

194  {
195  using namespace edm;
196 
197  ESHandle<MagneticField> magneticField;
198  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
199  magField_ = magneticField.product();
200 
201 }
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_, or, reco::TransientTrack::stateOnSurface(), groupFilesInBlocks::tt, useTrackProjectionToEcal_, and variablesAtVtx_.

Referenced by produce().

133  {
134 
135  const reco::SuperClusterRef theClus = eleref->superCluster();
136  const math::XYZVector trackMom = eleref->track()->momentum();
137 
138  math::XYZPoint SCcorrPosition(theClus->x()-bsPosition.x(), theClus->y()-bsPosition.y() , theClus->z()-eleref->track()->vz() );
139  float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta());
140  float deltaphi = 999.;
141 
142  bool recoveryForFailingPropagation = false;
143  if (variablesAtVtx_) {
144  reco::TrackRef track = eleref->track();
146  TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(),theClus->y(),theClus->z()));
147 
148  if (sclTSOS.isValid()) {
149  EleRelPointPair scAtVtx(theClus->position(), sclTSOS.globalPosition(), bsPosition);
150  deltaeta = fabs(scAtVtx.dEta());
151  deltaphi = fabs(scAtVtx.dPhi());
152  } else {
153  recoveryForFailingPropagation = true;
154  }
155  } else if (useTrackProjectionToEcal_ or recoveryForFailingPropagation) {
156  ECALPositionCalculator posCalc;
157  const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz());
158 
159  float phi1= posCalc.ecalPhi(magField,trackMom,vertex,1);
160  float phi2= posCalc.ecalPhi(magField,trackMom,vertex,-1);
161 
162  float deltaphi1=fabs( phi1 - theClus->position().phi() );
163  if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
164  if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
165 
166  float deltaphi2=fabs( phi2 - theClus->position().phi() );
167  if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
168  if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
169 
170  deltaphi = deltaphi1;
171  if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
172  } else {
173  deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
174  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
175  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
176  }
177 
178  return std::make_pair(deltaeta,deltaphi);
179 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
double ecalPhi(const MagneticField *magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void EgammaHLTElectronDetaDphiProducer::endRun ( edm::Run ,
edm::EventSetup const &   
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 203 of file EgammaHLTElectronDetaDphiProducer.cc.

203 {}
reco::ElectronRef EgammaHLTElectronDetaDphiProducer::getEleRef ( const reco::RecoEcalCandidateRef recoEcalCandRef,
const edm::Handle< reco::ElectronCollection > &  electronHandle 
)
staticprivate

Definition at line 181 of file EgammaHLTElectronDetaDphiProducer.cc.

Referenced by produce().

182 {
183  reco::ElectronRef eleRef;
184  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
185  if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
186  eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
187  break;
188  }
189  }
190  return eleRef;
191 }
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
void EgammaHLTElectronDetaDphiProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
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< class >::product(), edm::Event::put(), recoEcalCandidateProducer_, and useSCRefs_.

77  {
78 
79  // Get the HLT filtered objects
81  iEvent.getByLabel(electronProducer_,electronHandle);
82 
83  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
84  iEvent.getByLabel(bsProducer_,recoBeamSpotHandle);
85  // gets its position
86  const reco::BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
87 
88  edm::ESHandle<MagneticField> theMagField;
89  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
90 
95 
96  if(!useSCRefs_){
97  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
98 
99  reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
100  std::pair<float,float> dEtaDPhi = calDEtaDPhiSCTrk(eleref,bsPosition,theMagField.product());
101 
102  detaMap.insert(eleref, dEtaDPhi.first);
103  dphiMap.insert(eleref, dEtaDPhi.second);
104  }
105  }else { //we loop over reco ecal candidates
107  iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle);
108  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
109 
110  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
111 
112  reco::ElectronRef eleRef = getEleRef(recoEcalCandRef,electronHandle);
113  std::pair<float,float> dEtaDPhi(999999,999999);
114  if(eleRef.isNonnull()) dEtaDPhi = calDEtaDPhiSCTrk(eleRef,bsPosition,theMagField.product());
115  detaCandMap.insert(recoEcalCandRef, dEtaDPhi.first);
116  dphiCandMap.insert(recoEcalCandRef, dEtaDPhi.second);
117  }//end loop over reco ecal candidates
118  }//end if between electrons or reco ecal candidates
119 
120  if(!useSCRefs_){
121  std::auto_ptr<reco::ElectronIsolationMap> detMap(new reco::ElectronIsolationMap(detaMap));
122  std::auto_ptr<reco::ElectronIsolationMap> dphMap(new reco::ElectronIsolationMap(dphiMap));
123  iEvent.put(detMap, "Deta" );
124  iEvent.put(dphMap, "Dphi" );
125  }else{
126  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> detaCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(detaCandMap));
127  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dphiCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(dphiCandMap));
128  iEvent.put(detaCandMapForEvent, "Deta" );
129  iEvent.put(dphiCandMapForEvent, "Dphi" );
130  }
131 }
std::pair< float, float > calDEtaDPhiSCTrk(reco::ElectronRef &eleref, const reco::BeamSpot::Point &BSPosition, const MagneticField *magField)
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
static reco::ElectronRef getEleRef(const reco::RecoEcalCandidateRef &recoEcalCandRef, const edm::Handle< reco::ElectronCollection > &electronHandle)

Member Data Documentation

edm::InputTag EgammaHLTElectronDetaDphiProducer::bsProducer_
private
edm::InputTag EgammaHLTElectronDetaDphiProducer::electronProducer_
private
const MagneticField* EgammaHLTElectronDetaDphiProducer::magField_
private

Definition at line 62 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by beginRun(), and calDEtaDPhiSCTrk().

edm::InputTag EgammaHLTElectronDetaDphiProducer::recoEcalCandidateProducer_
private
bool EgammaHLTElectronDetaDphiProducer::useSCRefs_
private
bool EgammaHLTElectronDetaDphiProducer::useTrackProjectionToEcal_
private
bool EgammaHLTElectronDetaDphiProducer::variablesAtVtx_
private