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)
 
 ~EgammaHLTPixelMatchElectronAlgo ()
 

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_
 
unsigned long long cacheIDMagField_
 
int unsigned long long cacheIDTDGeom_
 
edm::EDGetTokenT< reco::GsfTrackCollectiongsfTrackProducer_
 
edm::ESHandle< MagneticFieldmagField_
 
MultiTrajectoryStateTransformmtsTransform_
 
edm::ESHandle< TrackerGeometrytrackerGeom_
 
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 30 of file EgammaHLTPixelMatchElectronAlgo.h.

Constructor & Destructor Documentation

◆ EgammaHLTPixelMatchElectronAlgo() [1/2]

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

Definition at line 49 of file EgammaHLTPixelMatchElectronAlgo.cc.

53  useGsfTracks_(conf.getParameter<bool>("UseGsfTracks")),
55  mtsTransform_(nullptr),
56  cacheIDTDGeom_(0),
57  cacheIDMagField_(0) {}

◆ ~EgammaHLTPixelMatchElectronAlgo()

EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo ( )

Definition at line 59 of file EgammaHLTPixelMatchElectronAlgo.cc.

59 { delete mtsTransform_; }

References mtsTransform_.

◆ EgammaHLTPixelMatchElectronAlgo() [2/2]

EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 38 of file EgammaHLTPixelMatchElectronAlgo.h.

38 {}

Member Function Documentation

◆ isInnerMostWithLostHits()

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

Definition at line 218 of file EgammaHLTPixelMatchElectronAlgo.cc.

220  {
221  // define closest using the lost hits on the expectedhitsineer
222  unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
223  unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
224 
225  if (nLostHits != iLostHits) {
226  return (nLostHits > iLostHits);
227  } else {
228  sameLayer = true;
229  return false;
230  }
231 }

Referenced by process().

◆ operator=()

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

Definition at line 39 of file EgammaHLTPixelMatchElectronAlgo.h.

39 { 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 108 of file EgammaHLTPixelMatchElectronAlgo.cc.

111  {
112  if (!useGsfTracks_) {
113  for (unsigned int i = 0; i < tracksH->size(); ++i) {
114  const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH, i);
115  edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
116  ElectronSeedRef elseed = seed.castTo<ElectronSeedRef>();
117 
118  edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster();
119  SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>();
120 
121  // Get the momentum at vertex (not at the innermost layer)
122  TSCPBuilderNoMaterial tscpBuilder;
123 
125  TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs);
126 
127  float scale = scRef->energy() / tscp.momentum().mag();
128 
129  const math::XYZTLorentzVector momentum(
130  tscp.momentum().x() * scale, tscp.momentum().y() * scale, tscp.momentum().z() * scale, scRef->energy());
131 
132  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
133  ele.setSuperCluster(scRef);
134  edm::Ref<TrackCollection> myRef(tracksH, i);
135  ele.setTrack(myRef);
136  outEle.push_back(ele);
137  } // loop over tracks
138  } else {
139  // clean gsf tracks
140  std::vector<unsigned int> flag(gsfTracksH->size(), 0);
141  if (gsfTracksH->empty())
142  return;
143 
144  for (unsigned int i = 0; i < gsfTracksH->size() - 1; ++i) {
145  const GsfTrackRef trackRef1 = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
146  ElectronSeedRef elseed1 = trackRef1->extra()->seedRef().castTo<ElectronSeedRef>();
147  SuperClusterRef scRef1 = elseed1->caloCluster().castTo<SuperClusterRef>();
148 
151  GlobalVector innMom;
152  float pin1 = trackRef1->pMode();
153  if (fts.isValid()) {
155  pin1 = innMom.mag();
156  }
157 
158  for (unsigned int j = i + 1; j < gsfTracksH->size(); ++j) {
159  const GsfTrackRef trackRef2 = edm::Ref<GsfTrackCollection>(gsfTracksH, j);
160  ElectronSeedRef elseed2 = trackRef2->extra()->seedRef().castTo<ElectronSeedRef>();
161  SuperClusterRef scRef2 = elseed2->caloCluster().castTo<SuperClusterRef>();
162 
165  GlobalVector innMom;
166  float pin2 = trackRef2->pMode();
167  if (fts.isValid()) {
169  pin2 = innMom.mag();
170  }
171 
172  if (scRef1 == scRef2) {
173  bool isSameLayer = false;
174  bool iGsfInnermostWithLostHits = isInnerMostWithLostHits(trackRef2, trackRef1, isSameLayer);
175 
176  if (iGsfInnermostWithLostHits) {
177  flag[j] = 1;
178  } else if (isSameLayer) {
179  if (fabs((scRef1->energy() / pin1) - 1) < fabs((scRef2->energy() / pin2) - 1))
180  flag[j] = 1;
181  } else {
182  flag[i] = 1;
183  }
184  }
185  }
186  }
187 
188  for (unsigned int i = 0; i < gsfTracksH->size(); ++i) {
189  if (flag[i] == 1)
190  continue;
191 
192  const GsfTrackRef trackRef = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
193  ElectronSeedRef elseed = trackRef->extra()->seedRef().castTo<ElectronSeedRef>();
194  SuperClusterRef scRef = elseed->caloCluster().castTo<SuperClusterRef>();
195 
196  // Get the momentum at vertex (not at the innermost layer)
199  GlobalVector innMom;
201  if (fts.isValid()) {
203  }
204 
205  float scale = scRef->energy() / innMom.mag();
206  const math::XYZTLorentzVector momentum(
207  innMom.x() * scale, innMom.y() * scale, innMom.z() * scale, scRef->energy());
208 
209  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
210  ele.setSuperCluster(scRef);
211  edm::Ref<GsfTrackCollection> myRef(gsfTracksH, i);
212  ele.setGsfTrack(myRef);
213  outEle.push_back(ele);
214  }
215  }
216 }

References cms::cuda::bs, MultiTrajectoryStateTransform::extrapolatedState(), RemoveAddSevLevel::flag, mps_fire::i, trajectoryStateTransform::innerFreeState(), MultiTrajectoryStateTransform::innerStateOnSurface(), isInnerMostWithLostHits(), TrajectoryStateOnSurface::isValid(), dqmiolumiharvest::j, PV3DBase< T, PVType, FrameType >::mag(), magField_, multiTrajectoryStateMode::momentumFromModeCartesian(), mtsTransform_, edm::ESHandle< T >::product(), Scenarios_cff::scale, SurveyInfoScenario_cff::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 85 of file EgammaHLTPixelMatchElectronAlgo.cc.

85  {
86  // get the input
88  if (!useGsfTracks_)
89  e.getByToken(trackProducer_, tracksH);
90 
91  // get the input
93  if (useGsfTracks_)
94  e.getByToken(gsfTrackProducer_, gsfTracksH);
95 
96  //Get the Beam Spot position
97  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
98  e.getByToken(bsProducer_, recoBeamSpotHandle);
99 
100  // gets its position
101  const BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
102  Global3DPoint bs(bsPosition.x(), bsPosition.y(), 0);
103  process(tracksH, gsfTracksH, outEle, bs);
104 
105  return;
106 }

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 61 of file EgammaHLTPixelMatchElectronAlgo.cc.

61  {
62  //services
63 
64  bool updateField(false);
66  updateField = true;
67  cacheIDMagField_ = es.get<IdealMagneticFieldRecord>().cacheIdentifier();
69  }
70 
71  if (useGsfTracks_) { //only need the geom and mtsTransform if we are doing gsf tracks
72  bool updateGeometry(false);
74  updateGeometry = true;
75  cacheIDTDGeom_ = es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
77  }
78  if (updateField || updateGeometry || !mtsTransform_) {
79  delete mtsTransform_;
81  }
82  }
83 }

References edm::eventsetup::EventSetupRecord::cacheIdentifier(), cacheIDMagField_, cacheIDTDGeom_, edm::EventSetup::get(), get, magField_, mtsTransform_, edm::ESHandle< T >::product(), trackerGeom_, and useGsfTracks_.

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

Member Data Documentation

◆ bsProducer_

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

Definition at line 57 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ cacheIDMagField_

unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
private

Definition at line 64 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ cacheIDTDGeom_

int unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
private

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ gsfTrackProducer_

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

Definition at line 55 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ magField_

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

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

◆ mtsTransform_

MultiTrajectoryStateTransform* EgammaHLTPixelMatchElectronAlgo::mtsTransform_
private

◆ trackerGeom_

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

Definition at line 62 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

◆ trackProducer_

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

Definition at line 54 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

◆ useGsfTracks_

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 56 of file EgammaHLTPixelMatchElectronAlgo.h.

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

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EgammaHLTPixelMatchElectronAlgo::trackProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:54
mps_fire.i
i
Definition: mps_fire.py:355
EgammaHLTPixelMatchElectronAlgo::isInnerMostWithLostHits
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
Definition: EgammaHLTPixelMatchElectronAlgo.cc:218
MultiTrajectoryStateTransform::extrapolatedState
TrajectoryStateOnSurface extrapolatedState(const TrajectoryStateOnSurface tsos, const GlobalPoint &point) const
Definition: MultiTrajectoryStateTransform.cc:104
EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
bool useGsfTracks_
Definition: EgammaHLTPixelMatchElectronAlgo.h:56
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
Electron
Definition: Electron.py:1
EgammaHLTPixelMatchElectronAlgo::gsfTrackProducer_
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:55
multiTrajectoryStateMode::momentumFromModeCartesian
bool momentumFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)
Definition: MultiTrajectoryStateMode.cc:16
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< TrackCollection >
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
cms::cuda::bs
bs
Definition: HistoContainer.h:127
EgammaHLTPixelMatchElectronAlgo::bsProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
Definition: EgammaHLTPixelMatchElectronAlgo.h:57
EgammaHLTPixelMatchElectronAlgo::magField_
edm::ESHandle< MagneticField > magField_
Definition: EgammaHLTPixelMatchElectronAlgo.h:61
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
Point3DBase< float, GlobalTag >
EgammaHLTPixelMatchElectronAlgo::trackerGeom_
edm::ESHandle< TrackerGeometry > trackerGeom_
Definition: EgammaHLTPixelMatchElectronAlgo.h:62
EgammaHLTPixelMatchElectronAlgo::process
void process(edm::Handle< reco::TrackCollection > tracksH, edm::Handle< reco::GsfTrackCollection > gsfTracksH, reco::ElectronCollection &outEle, Global3DPoint &bs)
Definition: EgammaHLTPixelMatchElectronAlgo.cc:108
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrajectoryStateClosestToPoint
Definition: TrajectoryStateClosestToPoint.h:18
get
#define get
MultiTrajectoryStateTransform
Definition: MultiTrajectoryStateTransform.h:18
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
trajectoryStateTransform::innerFreeState
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
Definition: TrajectoryStateTransform.cc:86
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
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
EgammaHLTPixelMatchElectronAlgo::mtsTransform_
MultiTrajectoryStateTransform * mtsTransform_
Definition: EgammaHLTPixelMatchElectronAlgo.h:59
EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
unsigned long long cacheIDMagField_
Definition: EgammaHLTPixelMatchElectronAlgo.h:64
edm::RefToBase< TrajectorySeed >
MultiTrajectoryStateTransform::innerStateOnSurface
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
Definition: MultiTrajectoryStateTransform.cc:23
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:185
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
int unsigned long long cacheIDTDGeom_
Definition: EgammaHLTPixelMatchElectronAlgo.h:63
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37