CMS 3D CMS Logo

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

#include <EgammaHLTPixelMatchElectronAlgo.h>

Public Member Functions

 EgammaHLTPixelMatchElectronAlgo (const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
 
void run (edm::Event &, reco::ElectronCollection &)
 
void setupES (const edm::EventSetup &setup)
 

Private Member Functions

 EgammaHLTPixelMatchElectronAlgo (const EgammaHLTPixelMatchElectronAlgo &rhs)
 
bool isInnerMostWithLostHits (const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
 
EgammaHLTPixelMatchElectronAlgooperator= (const EgammaHLTPixelMatchElectronAlgo &rhs)
 
void process (edm::Handle< reco::TrackCollection > tracksH, edm::Handle< reco::GsfTrackCollection > gsfTracksH, reco::ElectronCollection &outEle, Global3DPoint &bs)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbsProducer_
 
edm::EDGetTokenT
< reco::GsfTrackCollection
gsfTrackProducer_
 
edm::ESHandle< MagneticFieldmagField_
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
magneticFieldToken_
 
edm::ESWatcher
< IdealMagneticFieldRecord
magneticFieldWatcher_
 
std::unique_ptr
< MultiTrajectoryStateTransform
mtsTransform_ = nullptr
 
edm::ESHandle< TrackerGeometrytrackerGeom_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
trackerGeometryToken_
 
edm::ESWatcher
< TrackerDigiGeometryRecord
trackerGeometryWatcher_
 
edm::EDGetTokenT
< reco::TrackCollection
trackProducer_
 
bool useGsfTracks_
 

Detailed Description

Description: top algorithm producing TrackCandidate and Electron objects from supercluster driven pixel seeded Ckf tracking for HLT

Class to reconstruct electron tracks from electron pixel seeds keep track of information about the initiating supercluster

Author
Monica Vazquez Acosta (CERN)

Definition at line 36 of file EgammaHLTPixelMatchElectronAlgo.h.

Constructor & Destructor Documentation

EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)

Definition at line 45 of file EgammaHLTPixelMatchElectronAlgo.cc.

47  : trackProducer_(iC.consumes(conf.getParameter<edm::InputTag>("TrackProducer"))),
48  gsfTrackProducer_(iC.consumes(conf.getParameter<edm::InputTag>("GsfTrackProducer"))),
49  useGsfTracks_(conf.getParameter<bool>("UseGsfTracks")),
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 42 of file EgammaHLTPixelMatchElectronAlgo.h.

42 {}

Member Function Documentation

bool EgammaHLTPixelMatchElectronAlgo::isInnerMostWithLostHits ( const reco::GsfTrackRef nGsfTrack,
const reco::GsfTrackRef iGsfTrack,
bool &  sameLayer 
)
private

Definition at line 206 of file EgammaHLTPixelMatchElectronAlgo.cc.

Referenced by process().

208  {
209  // define closest using the lost hits on the expectedhitsineer
210  auto nLostHits = nGsfTrack->missingInnerHits();
211  auto iLostHits = iGsfTrack->missingInnerHits();
212 
213  if (nLostHits != iLostHits) {
214  return (nLostHits > iLostHits);
215  } else {
216  sameLayer = true;
217  return false;
218  }
219 }
EgammaHLTPixelMatchElectronAlgo& EgammaHLTPixelMatchElectronAlgo::operator= ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 43 of file EgammaHLTPixelMatchElectronAlgo.h.

43 { return *this; }
void EgammaHLTPixelMatchElectronAlgo::process ( edm::Handle< reco::TrackCollection tracksH,
edm::Handle< reco::GsfTrackCollection gsfTracksH,
reco::ElectronCollection outEle,
Global3DPoint bs 
)
private

Definition at line 96 of file EgammaHLTPixelMatchElectronAlgo.cc.

References mps_fire::i, trajectoryStateTransform::innerFreeState(), isInnerMostWithLostHits(), TrajectoryStateOnSurface::isValid(), dqmiolumiharvest::j, PV3DBase< T, PVType, FrameType >::mag(), magField_, multiTrajectoryStateMode::momentumFromModeCartesian(), mtsTransform_, edm::ESHandle< class >::product(), pileupReCalc_HLTpaths::scale, fileCollector::seed, reco::Electron::setSuperCluster(), useGsfTracks_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by run().

99  {
100  if (!useGsfTracks_) {
101  for (unsigned int i = 0; i < tracksH->size(); ++i) {
102  const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH, i);
103  edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
104  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
105 
106  edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster();
107  SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>();
108 
109  // Get the momentum at vertex (not at the innermost layer)
110  TSCPBuilderNoMaterial tscpBuilder;
111 
113  TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs);
114 
115  float scale = scRef->energy() / tscp.momentum().mag();
116 
117  const math::XYZTLorentzVector momentum(
118  tscp.momentum().x() * scale, tscp.momentum().y() * scale, tscp.momentum().z() * scale, scRef->energy());
119 
120  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
121  ele.setSuperCluster(scRef);
122  edm::Ref<TrackCollection> myRef(tracksH, i);
123  ele.setTrack(myRef);
124  outEle.push_back(ele);
125  } // loop over tracks
126  } else {
127  // clean gsf tracks
128  std::vector<unsigned int> flag(gsfTracksH->size(), 0);
129  if (gsfTracksH->empty())
130  return;
131 
132  for (unsigned int i = 0; i < gsfTracksH->size() - 1; ++i) {
133  const GsfTrackRef trackRef1 = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
134  ElectronSeedRef elseed1 = trackRef1->extra()->seedRef().castTo<ElectronSeedRef>();
135  SuperClusterRef scRef1 = elseed1->caloCluster().castTo<SuperClusterRef>();
136 
137  TrajectoryStateOnSurface inTSOS = mtsTransform_->innerStateOnSurface((*trackRef1));
138  TrajectoryStateOnSurface fts = mtsTransform_->extrapolatedState(inTSOS, bs);
139  GlobalVector innMom;
140  float pin1 = trackRef1->pMode();
141  if (fts.isValid()) {
143  pin1 = innMom.mag();
144  }
145 
146  for (unsigned int j = i + 1; j < gsfTracksH->size(); ++j) {
147  const GsfTrackRef trackRef2 = edm::Ref<GsfTrackCollection>(gsfTracksH, j);
148  ElectronSeedRef elseed2 = trackRef2->extra()->seedRef().castTo<ElectronSeedRef>();
149  SuperClusterRef scRef2 = elseed2->caloCluster().castTo<SuperClusterRef>();
150 
151  TrajectoryStateOnSurface inTSOS = mtsTransform_->innerStateOnSurface((*trackRef2));
152  TrajectoryStateOnSurface fts = mtsTransform_->extrapolatedState(inTSOS, bs);
153  GlobalVector innMom;
154  float pin2 = trackRef2->pMode();
155  if (fts.isValid()) {
157  pin2 = innMom.mag();
158  }
159 
160  if (scRef1 == scRef2) {
161  bool isSameLayer = false;
162  bool iGsfInnermostWithLostHits = isInnerMostWithLostHits(trackRef2, trackRef1, isSameLayer);
163 
164  if (iGsfInnermostWithLostHits) {
165  flag[j] = 1;
166  } else if (isSameLayer) {
167  if (fabs((scRef1->energy() / pin1) - 1) < fabs((scRef2->energy() / pin2) - 1))
168  flag[j] = 1;
169  } else {
170  flag[i] = 1;
171  }
172  }
173  }
174  }
175 
176  for (unsigned int i = 0; i < gsfTracksH->size(); ++i) {
177  if (flag[i] == 1)
178  continue;
179 
180  const GsfTrackRef trackRef = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
181  ElectronSeedRef elseed = trackRef->extra()->seedRef().castTo<ElectronSeedRef>();
182  SuperClusterRef scRef = elseed->caloCluster().castTo<SuperClusterRef>();
183 
184  // Get the momentum at vertex (not at the innermost layer)
185  TrajectoryStateOnSurface inTSOS = mtsTransform_->innerStateOnSurface((*trackRef));
186  TrajectoryStateOnSurface fts = mtsTransform_->extrapolatedState(inTSOS, bs);
187  GlobalVector innMom;
189  if (fts.isValid()) {
191  }
192 
193  float scale = scRef->energy() / innMom.mag();
194  const math::XYZTLorentzVector momentum(
195  innMom.x() * scale, innMom.y() * scale, innMom.z() * scale, scRef->energy());
196 
197  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
198  ele.setSuperCluster(scRef);
199  edm::Ref<GsfTrackCollection> myRef(gsfTracksH, i);
200  ele.setGsfTrack(myRef);
201  outEle.push_back(ele);
202  }
203  }
204 }
T y() const
Definition: PV3DBase.h:60
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::ESHandle< MagneticField > magField_
T mag() const
Definition: PV3DBase.h:64
T z() const
Definition: PV3DBase.h:61
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
T const * product() const
Definition: ESHandle.h:86
std::unique_ptr< MultiTrajectoryStateTransform > mtsTransform_
void setSuperCluster(const reco::SuperClusterRef &r)
set refrence to Photon component
Definition: Electron.h:35
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
bool momentumFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)
T x() const
Definition: PV3DBase.h:59
void EgammaHLTPixelMatchElectronAlgo::run ( edm::Event e,
reco::ElectronCollection outEle 
)

Definition at line 73 of file EgammaHLTPixelMatchElectronAlgo.cc.

References cms::cuda::bs, bsProducer_, edm::Event::getByToken(), gsfTrackProducer_, process(), trackProducer_, and useGsfTracks_.

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

73  {
74  // get the input
76  if (!useGsfTracks_)
77  e.getByToken(trackProducer_, tracksH);
78 
79  // get the input
81  if (useGsfTracks_)
82  e.getByToken(gsfTrackProducer_, gsfTracksH);
83 
84  //Get the Beam Spot position
85  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
86  e.getByToken(bsProducer_, recoBeamSpotHandle);
87 
88  // gets its position
89  const BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
90  Global3DPoint bs(bsPosition.x(), bsPosition.y(), 0);
91  process(tracksH, gsfTracksH, outEle, bs);
92 
93  return;
94 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void process(edm::Handle< reco::TrackCollection > tracksH, edm::Handle< reco::GsfTrackCollection > gsfTracksH, reco::ElectronCollection &outEle, Global3DPoint &bs)
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
void EgammaHLTPixelMatchElectronAlgo::setupES ( const edm::EventSetup setup)

Definition at line 54 of file EgammaHLTPixelMatchElectronAlgo.cc.

References edm::ESWatcher< T >::check(), edm::EventSetup::getHandle(), magField_, magneticFieldToken_, magneticFieldWatcher_, mtsTransform_, edm::ESHandle< class >::product(), trackerGeom_, trackerGeometryToken_, trackerGeometryWatcher_, and useGsfTracks_.

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

54  {
55  //services
56  bool updateField = magneticFieldWatcher_.check(eventSetup);
57  bool updateGeometry = trackerGeometryWatcher_.check(eventSetup);
58 
59  if (updateField) {
60  magField_ = eventSetup.getHandle(magneticFieldToken_);
61  }
62 
63  if (useGsfTracks_) { //only need the geom and mtsTransform if we are doing gsf tracks
64  if (updateGeometry) {
65  trackerGeom_ = eventSetup.getHandle(trackerGeometryToken_);
66  }
67  if (updateField || updateGeometry || !mtsTransform_) {
68  mtsTransform_ = std::make_unique<MultiTrajectoryStateTransform>(trackerGeom_.product(), magField_.product());
69  }
70  }
71 }
edm::ESHandle< MagneticField > magField_
edm::ESWatcher< TrackerDigiGeometryRecord > trackerGeometryWatcher_
edm::ESWatcher< IdealMagneticFieldRecord > magneticFieldWatcher_
T const * product() const
Definition: ESHandle.h:86
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::unique_ptr< MultiTrajectoryStateTransform > mtsTransform_
edm::ESHandle< TrackerGeometry > trackerGeom_

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> EgammaHLTPixelMatchElectronAlgo::bsProducer_
private

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

edm::EDGetTokenT<reco::GsfTrackCollection> EgammaHLTPixelMatchElectronAlgo::gsfTrackProducer_
private

Definition at line 59 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

edm::ESHandle<MagneticField> EgammaHLTPixelMatchElectronAlgo::magField_
private

Definition at line 65 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> EgammaHLTPixelMatchElectronAlgo::magneticFieldToken_
private

Definition at line 71 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

edm::ESWatcher<IdealMagneticFieldRecord> EgammaHLTPixelMatchElectronAlgo::magneticFieldWatcher_
private

Definition at line 68 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

std::unique_ptr<MultiTrajectoryStateTransform> EgammaHLTPixelMatchElectronAlgo::mtsTransform_ = nullptr
private

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

edm::ESHandle<TrackerGeometry> EgammaHLTPixelMatchElectronAlgo::trackerGeom_
private

Definition at line 66 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> EgammaHLTPixelMatchElectronAlgo::trackerGeometryToken_
private

Definition at line 72 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

edm::ESWatcher<TrackerDigiGeometryRecord> EgammaHLTPixelMatchElectronAlgo::trackerGeometryWatcher_
private

Definition at line 69 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

edm::EDGetTokenT<reco::TrackCollection> EgammaHLTPixelMatchElectronAlgo::trackProducer_
private

Definition at line 58 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 60 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), run(), and setupES().