CMS 3D CMS Logo

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::GsfTrackCollectiongsfTrackProducer_
 
edm::ESHandle< MagneticFieldmagField_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::ESWatcher< IdealMagneticFieldRecordmagneticFieldWatcher_
 
std::unique_ptr< MultiTrajectoryStateTransformmtsTransform_ = nullptr
 
edm::ESHandle< TrackerGeometrytrackerGeom_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryToken_
 
edm::ESWatcher< TrackerDigiGeometryRecordtrackerGeometryWatcher_
 
edm::EDGetTokenT< reco::TrackCollectiontrackProducer_
 
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() [1/2]

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

◆ EgammaHLTPixelMatchElectronAlgo() [2/2]

EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 42 of file EgammaHLTPixelMatchElectronAlgo.h.

42 {}

Member Function Documentation

◆ isInnerMostWithLostHits()

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

Definition at line 206 of file EgammaHLTPixelMatchElectronAlgo.cc.

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 }

Referenced by process().

◆ operator=()

EgammaHLTPixelMatchElectronAlgo& EgammaHLTPixelMatchElectronAlgo::operator= ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 43 of file EgammaHLTPixelMatchElectronAlgo.h.

43 { return *this; }

◆ process()

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.

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 }

References cms::cuda::bs, RemoveAddSevLevel::flag, mps_fire::i, trajectoryStateTransform::innerFreeState(), isInnerMostWithLostHits(), TrajectoryStateOnSurface::isValid(), dqmiolumiharvest::j, PV3DBase< T, PVType, FrameType >::mag(), magField_, multiTrajectoryStateMode::momentumFromModeCartesian(), mtsTransform_, edm::ESHandle< T >::product(), L1EGammaCrystalsEmulatorProducer_cfi::scale, fileCollector::seed, useGsfTracks_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by run().

◆ run()

void EgammaHLTPixelMatchElectronAlgo::run ( edm::Event e,
reco::ElectronCollection outEle 
)

Definition at line 73 of file EgammaHLTPixelMatchElectronAlgo.cc.

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 }

References cms::cuda::bs, bsProducer_, MillePedeFileConverter_cfg::e, gsfTrackProducer_, reco::BeamSpot::position(), process(), trackProducer_, and useGsfTracks_.

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

◆ setupES()

void EgammaHLTPixelMatchElectronAlgo::setupES ( const edm::EventSetup setup)

Definition at line 54 of file EgammaHLTPixelMatchElectronAlgo.cc.

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 }

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

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

Member Data Documentation

◆ bsProducer_

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

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ gsfTrackProducer_

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

Definition at line 59 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ magField_

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

Definition at line 65 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

◆ magneticFieldToken_

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

Definition at line 71 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ magneticFieldWatcher_

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

Definition at line 68 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ mtsTransform_

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

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

◆ trackerGeom_

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

Definition at line 66 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ trackerGeometryToken_

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

Definition at line 72 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ trackerGeometryWatcher_

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

Definition at line 69 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ trackProducer_

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

Definition at line 58 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ useGsfTracks_

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 60 of file EgammaHLTPixelMatchElectronAlgo.h.

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

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EgammaHLTPixelMatchElectronAlgo::trackProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:58
mps_fire.i
i
Definition: mps_fire.py:428
EgammaHLTPixelMatchElectronAlgo::isInnerMostWithLostHits
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
Definition: EgammaHLTPixelMatchElectronAlgo.cc:206
EgammaHLTPixelMatchElectronAlgo::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: EgammaHLTPixelMatchElectronAlgo.h:71
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
bool useGsfTracks_
Definition: EgammaHLTPixelMatchElectronAlgo.h:60
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
Electron
Definition: Electron.py:1
EgammaHLTPixelMatchElectronAlgo::gsfTrackProducer_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:59
EgammaHLTPixelMatchElectronAlgo::magneticFieldWatcher_
edm::ESWatcher< IdealMagneticFieldRecord > magneticFieldWatcher_
Definition: EgammaHLTPixelMatchElectronAlgo.h:68
multiTrajectoryStateMode::momentumFromModeCartesian
bool momentumFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)
Definition: MultiTrajectoryStateMode.cc:16
EgammaHLTPixelMatchElectronAlgo::trackerGeometryWatcher_
edm::ESWatcher< TrackerDigiGeometryRecord > trackerGeometryWatcher_
Definition: EgammaHLTPixelMatchElectronAlgo.h:69
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< TrackCollection >
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
fileCollector.seed
seed
Definition: fileCollector.py:127
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
cms::cuda::bs
bs
Definition: HistoContainer.h:76
EgammaHLTPixelMatchElectronAlgo::bsProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:61
EgammaHLTPixelMatchElectronAlgo::magField_
edm::ESHandle< MagneticField > magField_
Definition: EgammaHLTPixelMatchElectronAlgo.h:65
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
Point3DBase< float, GlobalTag >
EgammaHLTPixelMatchElectronAlgo::trackerGeom_
edm::ESHandle< TrackerGeometry > trackerGeom_
Definition: EgammaHLTPixelMatchElectronAlgo.h:66
EgammaHLTPixelMatchElectronAlgo::process
void process(edm::Handle< reco::TrackCollection > tracksH, edm::Handle< reco::GsfTrackCollection > gsfTracksH, reco::ElectronCollection &outEle, Global3DPoint &bs)
Definition: EgammaHLTPixelMatchElectronAlgo.cc:96
EgammaHLTPixelMatchElectronAlgo::mtsTransform_
std::unique_ptr< MultiTrajectoryStateTransform > mtsTransform_
Definition: EgammaHLTPixelMatchElectronAlgo.h:63
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrajectoryStateClosestToPoint
Definition: TrajectoryStateClosestToPoint.h:18
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
trajectoryStateTransform::innerFreeState
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
Definition: TrajectoryStateTransform.cc:86
TSCPBuilderNoMaterial
Definition: TSCPBuilderNoMaterial.h:17
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< TrajectorySeed >
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15
EgammaHLTPixelMatchElectronAlgo::trackerGeometryToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
Definition: EgammaHLTPixelMatchElectronAlgo.h:72
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37