test
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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 EgammaHLTElectronDetaDphiProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTElectronDetaDphiProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducerBase
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

const edm::EDGetTokenT
< reco::BeamSpot
bsProducer_
 
const edm::EDGetTokenT
< reco::ElectronCollection
electronProducer_
 
const MagneticFieldmagField_
 
const edm::EDGetTokenT
< reco::RecoEcalCandidateCollection
recoEcalCandidateProducer_
 
const bool useSCRefs_
 
const bool useTrackProjectionToEcal_
 
const bool variablesAtVtx_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 31 of file EgammaHLTElectronDetaDphiProducer.cc.

References useSCRefs_.

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

Definition at line 49 of file EgammaHLTElectronDetaDphiProducer.cc.

50 {}

Member Function Documentation

void EgammaHLTElectronDetaDphiProducer::beginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
)
overridevirtual
std::pair< float, float > EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk ( reco::ElectronRef eleref,
const reco::BeamSpot::Point BSPosition,
const MagneticField magField 
)
private

Definition at line 121 of file EgammaHLTElectronDetaDphiProducer.cc.

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

Referenced by produce().

121  {
122 
123  const reco::SuperClusterRef theClus = eleref->superCluster();
124  const math::XYZVector trackMom = eleref->track()->momentum();
125 
126  math::XYZPoint SCcorrPosition(theClus->x()-bsPosition.x(), theClus->y()-bsPosition.y() , theClus->z()-eleref->track()->vz() );
127  float deltaeta = fabs(SCcorrPosition.eta()-eleref->track()->eta());
128  float deltaphi = 999.;
129 
130  bool recoveryForFailingPropagation = false;
131  if (variablesAtVtx_) {
132  reco::TrackRef track = eleref->track();
134  TrajectoryStateOnSurface sclTSOS = tt.stateOnSurface(GlobalPoint(theClus->x(),theClus->y(),theClus->z()));
135 
136  if (sclTSOS.isValid()) {
137  EleRelPointPair scAtVtx(theClus->position(), sclTSOS.globalPosition(), bsPosition);
138  deltaeta = fabs(scAtVtx.dEta());
139  deltaphi = fabs(scAtVtx.dPhi());
140  } else {
141  recoveryForFailingPropagation = true;
142  }
143  } else if (useTrackProjectionToEcal_ or recoveryForFailingPropagation) {
144  ECALPositionCalculator posCalc;
145  const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz());
146 
147  float phi1= posCalc.ecalPhi(magField,trackMom,vertex,1);
148  float phi2= posCalc.ecalPhi(magField,trackMom,vertex,-1);
149 
150  float deltaphi1=fabs( phi1 - theClus->position().phi() );
151  if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
152  if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
153 
154  float deltaphi2=fabs( phi2 - theClus->position().phi() );
155  if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
156  if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
157 
158  deltaphi = deltaphi1;
159  if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
160  } else {
161  deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
162  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
163  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
164  }
165 
166  return std::make_pair(deltaeta,deltaphi);
167 }
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 52 of file EgammaHLTElectronDetaDphiProducer.cc.

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

52  {
54  desc.add<edm::InputTag>(("electronProducer"), edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded"));
55  desc.add<edm::InputTag>(("BSProducer"), edm::InputTag("hltOnlineBeamSpot"));
56  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag());
57  desc.add<bool>(("useSCRefs"), false);
58  desc.add<bool>(("useTrackProjectionToEcal"), false);
59  desc.add<bool>(("variablesAtVtx"), true);
60  descriptions.add(("hltEgammaHLTElectronDetaDphiProducer"), desc);
61 }
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 169 of file EgammaHLTElectronDetaDphiProducer.cc.

Referenced by produce().

170 {
171  reco::ElectronRef eleRef;
172  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
173  if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
174  eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
175  break;
176  }
177  }
178  return eleRef;
179 }
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::stream::EDProducerBase.

Definition at line 63 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_.

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

Member Data Documentation

const edm::EDGetTokenT<reco::BeamSpot> EgammaHLTElectronDetaDphiProducer::bsProducer_
private

Definition at line 50 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::ElectronCollection> EgammaHLTElectronDetaDphiProducer::electronProducer_
private

Definition at line 49 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by produce().

const MagneticField* EgammaHLTElectronDetaDphiProducer::magField_
private

Definition at line 57 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by beginRun(), and calDEtaDPhiSCTrk().

const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> EgammaHLTElectronDetaDphiProducer::recoEcalCandidateProducer_
private

Definition at line 51 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by produce().

const bool EgammaHLTElectronDetaDphiProducer::useSCRefs_
private
const bool EgammaHLTElectronDetaDphiProducer::useTrackProjectionToEcal_
private

Definition at line 54 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by calDEtaDPhiSCTrk().

const bool EgammaHLTElectronDetaDphiProducer::variablesAtVtx_
private

Definition at line 55 of file EgammaHLTElectronDetaDphiProducer.h.

Referenced by calDEtaDPhiSCTrk().