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")),
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_

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

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 }

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

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(), pfClustersFromCombinedCaloHF_cfi::scale, fileCollector::seed, 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 z() const
Definition: PV3DBase.h:61
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
edm::ESHandle< MagneticField > magField_
T const * product() const
Definition: ESHandle.h:86
T mag() const
Definition: PV3DBase.h:64
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
std::unique_ptr< MultiTrajectoryStateTransform > mtsTransform_
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
bool momentumFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)

◆ run()

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

Definition at line 73 of file EgammaHLTPixelMatchElectronAlgo.cc.

References cms::cuda::bs, bsProducer_, MillePedeFileConverter_cfg::e, gsfTrackProducer_, reco::BeamSpot::position(), 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 }
const Point & position() const
position
Definition: BeamSpot.h:59
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_

◆ setupES()

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

Definition at line 54 of file EgammaHLTPixelMatchElectronAlgo.cc.

References edm::ESWatcher< T >::check(), options_cfi::eventSetup, magField_, magneticFieldToken_, magneticFieldWatcher_, mtsTransform_, edm::ESHandle< T >::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) {
61  }
62 
63  if (useGsfTracks_) { //only need the geom and mtsTransform if we are doing gsf tracks
64  if (updateGeometry) {
66  }
67  if (updateField || updateGeometry || !mtsTransform_) {
68  mtsTransform_ = std::make_unique<MultiTrajectoryStateTransform>(trackerGeom_.product(), magField_.product());
69  }
70  }
71 }
edm::ESHandle< MagneticField > magField_
T const * product() const
Definition: ESHandle.h:86
edm::ESWatcher< TrackerDigiGeometryRecord > trackerGeometryWatcher_
edm::ESWatcher< IdealMagneticFieldRecord > magneticFieldWatcher_
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

◆ 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().