CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static 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::EDConsumerBase edm::ProductRegistryHelper

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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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::EDGetTokenT< reco::BeamSpotbsProducer_
 
edm::EDGetTokenT
< reco::ElectronCollection
electronProducer_
 
const MagneticFieldmagField_
 
edm::EDGetTokenT
< reco::RecoEcalCandidateCollection
recoEcalCandidateProducer_
 
bool useSCRefs_
 
bool useTrackProjectionToEcal_
 
bool variablesAtVtx_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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.1 2012/01/23 12:56:38 sharper Exp

Definition at line 37 of file EgammaHLTElectronDetaDphiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 35 of file EgammaHLTElectronDetaDphiProducer.cc.

References bsProducer_, electronProducer_, edm::ParameterSet::getParameter(), recoEcalCandidateProducer_, useSCRefs_, useTrackProjectionToEcal_, and variablesAtVtx_.

35  {
36 
37  electronProducer_ = consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("electronProducer"));
38  bsProducer_ = consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("BSProducer"));
39  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
40 
41  useSCRefs_ = config.getParameter<bool>("useSCRefs");
42  useTrackProjectionToEcal_ = config.getParameter<bool>("useTrackProjectionToEcal");
43  variablesAtVtx_ = config.getParameter<bool>("variablesAtVtx");
44 
45  //register your products
46  if(!useSCRefs_){
47  produces < reco::ElectronIsolationMap >( "Deta" ).setBranchAlias( "deta" );
48  produces < reco::ElectronIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
49  }else{
50  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
51  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
52  }
53 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
EgammaHLTElectronDetaDphiProducer::~EgammaHLTElectronDetaDphiProducer ( )

Definition at line 55 of file EgammaHLTElectronDetaDphiProducer.cc.

56 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 186 of file EgammaHLTElectronDetaDphiProducer.cc.

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

186  {
187  using namespace edm;
188 
189  ESHandle<MagneticField> magneticField;
190  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
191  magField_ = magneticField.product();
192 
193 }
std::pair< float, float > EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk ( reco::ElectronRef eleref,
const reco::BeamSpot::Point BSPosition,
const MagneticField magField 
)
private

Definition at line 125 of file EgammaHLTElectronDetaDphiProducer.cc.

References ECALPositionCalculator::ecalPhi(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), magField_, or, reco::TransientTrack::stateOnSurface(), groupFilesInBlocks::tt, useTrackProjectionToEcal_, and variablesAtVtx_.

Referenced by produce().

125  {
126 
127  const reco::SuperClusterRef theClus = eleref->superCluster();
128  const math::XYZVector trackMom = eleref->track()->momentum();
129 
130  math::XYZPoint SCcorrPosition(theClus->x()-bsPosition.x(), theClus->y()-bsPosition.y() , theClus->z()-eleref->track()->vz() );
131  float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta());
132  float deltaphi = 999.;
133 
134  bool recoveryForFailingPropagation = false;
135  if (variablesAtVtx_) {
136  reco::TrackRef track = eleref->track();
138  TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(),theClus->y(),theClus->z()));
139 
140  if (sclTSOS.isValid()) {
141  EleRelPointPair scAtVtx(theClus->position(), sclTSOS.globalPosition(), bsPosition);
142  deltaeta = fabs(scAtVtx.dEta());
143  deltaphi = fabs(scAtVtx.dPhi());
144  } else {
145  recoveryForFailingPropagation = true;
146  }
147  } else if (useTrackProjectionToEcal_ or recoveryForFailingPropagation) {
148  ECALPositionCalculator posCalc;
149  const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz());
150 
151  float phi1= posCalc.ecalPhi(magField,trackMom,vertex,1);
152  float phi2= posCalc.ecalPhi(magField,trackMom,vertex,-1);
153 
154  float deltaphi1=fabs( phi1 - theClus->position().phi() );
155  if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
156  if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
157 
158  float deltaphi2=fabs( phi2 - theClus->position().phi() );
159  if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
160  if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
161 
162  deltaphi = deltaphi1;
163  if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
164  } else {
165  deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
166  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
167  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
168  }
169 
170  return std::make_pair(deltaeta,deltaphi);
171 }
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:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void EgammaHLTElectronDetaDphiProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 58 of file EgammaHLTElectronDetaDphiProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

58  {
60  desc.add<edm::InputTag>(("electronProducer"), edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded"));
61  desc.add<edm::InputTag>(("BSProducer"), edm::InputTag("hltOnlineBeamSpot"));
62  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag());
63  desc.add<bool>(("useSCRefs"), false);
64  desc.add<bool>(("useTrackProjectionToEcal"), false);
65  desc.add<bool>(("variablesAtVtx"), true);
66  descriptions.add(("hltEgammaHLTElectronDetaDphiProducer"), desc);
67 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
reco::ElectronRef EgammaHLTElectronDetaDphiProducer::getEleRef ( const reco::RecoEcalCandidateRef recoEcalCandRef,
const edm::Handle< reco::ElectronCollection > &  electronHandle 
)
staticprivate

Definition at line 173 of file EgammaHLTElectronDetaDphiProducer.cc.

Referenced by produce().

174 {
175  reco::ElectronRef eleRef;
176  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
177  if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
178  eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
179  break;
180  }
181  }
182  return eleRef;
183 }
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 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 69 of file EgammaHLTElectronDetaDphiProducer.cc.

References bsProducer_, calDEtaDPhiSCTrk(), electronProducer_, edm::EventSetup::get(), edm::Event::getByToken(), getEleRef(), edm::AssociationMap< Tag >::insert(), edm::ESHandle< class >::product(), edm::Event::put(), recoEcalCandidateProducer_, and useSCRefs_.

69  {
70  // Get the HLT filtered objects
72  iEvent.getByToken(electronProducer_,electronHandle);
73 
74  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
75  iEvent.getByToken(bsProducer_,recoBeamSpotHandle);
76  // gets its position
77  const reco::BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
78 
79  edm::ESHandle<MagneticField> theMagField;
80  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
81 
86 
87  if(!useSCRefs_){
88 
89  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
90 
91  reco::ElectronRef eleref(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
92  std::pair<float,float> dEtaDPhi = calDEtaDPhiSCTrk(eleref,bsPosition,theMagField.product());
93 
94  detaMap.insert(eleref, dEtaDPhi.first);
95  dphiMap.insert(eleref, dEtaDPhi.second);
96  }
97  }else { //we loop over reco ecal candidates
99  iEvent.getByToken(recoEcalCandidateProducer_,recoEcalCandHandle);
100  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
101 
102  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
103 
104  reco::ElectronRef eleRef = getEleRef(recoEcalCandRef,electronHandle);
105  std::pair<float,float> dEtaDPhi(999999,999999);
106  if(eleRef.isNonnull()) dEtaDPhi = calDEtaDPhiSCTrk(eleRef,bsPosition,theMagField.product());
107  detaCandMap.insert(recoEcalCandRef, dEtaDPhi.first);
108  dphiCandMap.insert(recoEcalCandRef, dEtaDPhi.second);
109  }//end loop over reco ecal candidates
110  }//end if between electrons or reco ecal candidates
111 
112  if(!useSCRefs_){
113  std::auto_ptr<reco::ElectronIsolationMap> detMap(new reco::ElectronIsolationMap(detaMap));
114  std::auto_ptr<reco::ElectronIsolationMap> dphMap(new reco::ElectronIsolationMap(dphiMap));
115  iEvent.put(detMap, "Deta" );
116  iEvent.put(dphMap, "Dphi" );
117  }else{
118  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> detaCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(detaCandMap));
119  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dphiCandMapForEvent(new reco::RecoEcalCandidateIsolationMap(dphiCandMap));
120  iEvent.put(detaCandMapForEvent, "Deta" );
121  iEvent.put(dphiCandMapForEvent, "Dphi" );
122  }
123 }
std::pair< float, float > calDEtaDPhiSCTrk(reco::ElectronRef &eleref, const reco::BeamSpot::Point &BSPosition, const MagneticField *magField)
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
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::EDGetTokenT<reco::BeamSpot> EgammaHLTElectronDetaDphiProducer::bsProducer_
private
edm::EDGetTokenT<reco::ElectronCollection> EgammaHLTElectronDetaDphiProducer::electronProducer_
private
const MagneticField* EgammaHLTElectronDetaDphiProducer::magField_
private

Definition at line 56 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by beginRun(), and calDEtaDPhiSCTrk().

edm::EDGetTokenT<reco::RecoEcalCandidateCollection> EgammaHLTElectronDetaDphiProducer::recoEcalCandidateProducer_
private
bool EgammaHLTElectronDetaDphiProducer::useSCRefs_
private
bool EgammaHLTElectronDetaDphiProducer::useTrackProjectionToEcal_
private
bool EgammaHLTElectronDetaDphiProducer::variablesAtVtx_
private