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::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) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
MultiTrajectoryStateTransform * mtsTransform_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo ( )

Definition at line 59 of file EgammaHLTPixelMatchElectronAlgo.cc.

References mtsTransform_.

59 { delete mtsTransform_; }
MultiTrajectoryStateTransform * mtsTransform_
EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 38 of file EgammaHLTPixelMatchElectronAlgo.h.

38 {}

Member Function Documentation

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

Definition at line 218 of file EgammaHLTPixelMatchElectronAlgo.cc.

Referenced by operator=(), and process().

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 }
EgammaHLTPixelMatchElectronAlgo& EgammaHLTPixelMatchElectronAlgo::operator= ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 39 of file EgammaHLTPixelMatchElectronAlgo.h.

References isInnerMostWithLostHits(), process(), run(), singleTopDQM_cfi::setup, and setupES().

39 { return *this; }
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.

References 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 operator=(), and run().

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 }
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
TrajectoryStateOnSurface extrapolatedState(const TrajectoryStateOnSurface tsos, const GlobalPoint &point) const
T z() const
Definition: PV3DBase.h:61
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
MultiTrajectoryStateTransform * mtsTransform_
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
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
T const * product() const
Definition: ESHandle.h:86
void EgammaHLTPixelMatchElectronAlgo::run ( edm::Event e,
reco::ElectronCollection outEle 
)

Definition at line 85 of file EgammaHLTPixelMatchElectronAlgo.cc.

References bsProducer_, edm::Event::getByToken(), gsfTrackProducer_, reco::BeamSpot::position(), process(), trackProducer_, and useGsfTracks_.

Referenced by operator=(), and EgammaHLTPixelMatchElectronProducers::produce().

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 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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_
const Point & position() const
position
Definition: BeamSpot.h:59
void EgammaHLTPixelMatchElectronAlgo::setupES ( const edm::EventSetup setup)

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.cc.

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

Referenced by operator=(), and EgammaHLTPixelMatchElectronProducers::produce().

61  {
62  //services
63 
64  bool updateField(false);
66  updateField = true;
67  cacheIDMagField_ = es.get<IdealMagneticFieldRecord>().cacheIdentifier();
68  es.get<IdealMagneticFieldRecord>().get(magField_);
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 }
unsigned long long cacheIdentifier() const
edm::ESHandle< MagneticField > magField_
MultiTrajectoryStateTransform * mtsTransform_
edm::ESHandle< TrackerGeometry > trackerGeom_
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

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

Definition at line 57 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
private

Definition at line 64 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

int unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
private

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 55 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

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

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

MultiTrajectoryStateTransform* EgammaHLTPixelMatchElectronAlgo::mtsTransform_
private
edm::ESHandle<TrackerGeometry> EgammaHLTPixelMatchElectronAlgo::trackerGeom_
private

Definition at line 62 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 54 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 56 of file EgammaHLTPixelMatchElectronAlgo.h.

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