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

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

Author
Monica Vazquez Acosta (CERN)

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

Definition at line 31 of file EgammaHLTPixelMatchElectronAlgo.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file EgammaHLTPixelMatchElectronAlgo.cc.

49  :
52  useGsfTracks_(conf.getParameter<bool>("UseGsfTracks")),
54  mtsTransform_(nullptr),
55  cacheIDTDGeom_(0),
57 {
58 
59 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
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 61 of file EgammaHLTPixelMatchElectronAlgo.cc.

References mtsTransform_.

62 {
63  delete mtsTransform_;
64  }
MultiTrajectoryStateTransform * mtsTransform_
EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 41 of file EgammaHLTPixelMatchElectronAlgo.h.

41 {}

Member Function Documentation

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

Definition at line 231 of file EgammaHLTPixelMatchElectronAlgo.cc.

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

231  {
232 
233  // define closest using the lost hits on the expectedhitsineer
234  unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
235  unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
236 
237  if (nLostHits!=iLostHits) {
238  return (nLostHits > iLostHits);
239  } else {
240  sameLayer = true;
241  return false;
242  }
243 }
EgammaHLTPixelMatchElectronAlgo& EgammaHLTPixelMatchElectronAlgo::operator= ( const EgammaHLTPixelMatchElectronAlgo rhs)
inlineprivate

Definition at line 42 of file EgammaHLTPixelMatchElectronAlgo.h.

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

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

Definition at line 116 of file EgammaHLTPixelMatchElectronAlgo.cc.

References MultiTrajectoryStateTransform::extrapolatedState(), RemoveAddSevLevel::flag, mps_fire::i, trajectoryStateTransform::innerFreeState(), MultiTrajectoryStateTransform::innerStateOnSurface(), isInnerMostWithLostHits(), TrajectoryStateOnSurface::isValid(), 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().

116  {
117 
118  if (!useGsfTracks_) {
119 
120  for (unsigned int i=0; i<tracksH->size(); ++i) {
121 
122  const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH, i);
123  edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
124  ElectronSeedRef elseed=seed.castTo<ElectronSeedRef>();
125 
126  edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster() ;
127  SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>() ;
128 
129  // Get the momentum at vertex (not at the innermost layer)
130  TSCPBuilderNoMaterial tscpBuilder;
131 
133  TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs);
134 
135  float scale = scRef->energy()/tscp.momentum().mag();
136 
137  const math::XYZTLorentzVector momentum(tscp.momentum().x()*scale,
138  tscp.momentum().y()*scale,
139  tscp.momentum().z()*scale,
140  scRef->energy());
141 
142  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
143  ele.setSuperCluster(scRef);
144  edm::Ref<TrackCollection> myRef(tracksH, i);
145  ele.setTrack(myRef);
146  outEle.push_back(ele);
147  } // loop over tracks
148  } else {
149 
150  // clean gsf tracks
151  std::vector<unsigned int> flag(gsfTracksH->size(), 0);
152  if (gsfTracksH->empty())
153  return;
154 
155  for (unsigned int i=0; i<gsfTracksH->size()-1; ++i) {
156  const GsfTrackRef trackRef1 = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
157  ElectronSeedRef elseed1 = trackRef1->extra()->seedRef().castTo<ElectronSeedRef>();
158  SuperClusterRef scRef1 = elseed1->caloCluster().castTo<SuperClusterRef>();
159 
162  GlobalVector innMom;
163  float pin1 = trackRef1->pMode();
164  if (fts.isValid()) {
166  pin1 = innMom.mag();
167  }
168 
169  for (unsigned int j=i+1; j<gsfTracksH->size(); ++j) {
170  const GsfTrackRef trackRef2 = edm::Ref<GsfTrackCollection>(gsfTracksH, j);
171  ElectronSeedRef elseed2 = trackRef2->extra()->seedRef().castTo<ElectronSeedRef>();
172  SuperClusterRef scRef2 = elseed2->caloCluster().castTo<SuperClusterRef>();
173 
176  GlobalVector innMom;
177  float pin2 = trackRef2->pMode();
178  if (fts.isValid()) {
180  pin2 = innMom.mag();
181  }
182 
183  if (scRef1 == scRef2) {
184  bool isSameLayer = false;
185  bool iGsfInnermostWithLostHits = isInnerMostWithLostHits(trackRef2, trackRef1, isSameLayer);
186 
187  if (iGsfInnermostWithLostHits) {
188  flag[j] = 1;
189  } else if(isSameLayer) {
190  if(fabs((scRef1->energy()/pin1)-1) < fabs((scRef2->energy()/pin2)-1))
191  flag[j] = 1;
192  } else {
193  flag[i] = 1;
194  }
195  }
196  }
197  }
198 
199  for (unsigned int i=0; i<gsfTracksH->size(); ++i) {
200  if (flag[i] == 1)
201  continue;
202 
203  const GsfTrackRef trackRef = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
204  ElectronSeedRef elseed = trackRef->extra()->seedRef().castTo<ElectronSeedRef>();
205  SuperClusterRef scRef = elseed->caloCluster().castTo<SuperClusterRef>();
206 
207  // Get the momentum at vertex (not at the innermost layer)
210  GlobalVector innMom;
212  if (fts.isValid()) {
214  }
215 
216  float scale = scRef->energy()/innMom.mag();
217  const math::XYZTLorentzVector momentum(innMom.x()*scale,
218  innMom.y()*scale,
219  innMom.z()*scale,
220  scRef->energy());
221 
222  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
223  ele.setSuperCluster(scRef);
224  edm::Ref<GsfTrackCollection> myRef(gsfTracksH, i);
225  ele.setGsfTrack(myRef);
226  outEle.push_back(ele);
227  }
228  }
229 }
T y() const
Definition: PV3DBase.h:63
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::ESHandle< MagneticField > magField_
T mag() const
Definition: PV3DBase.h:67
TrajectoryStateOnSurface extrapolatedState(const TrajectoryStateOnSurface tsos, const GlobalPoint &point) const
T z() const
Definition: PV3DBase.h:64
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:62
T const * product() const
Definition: ESHandle.h:86
void EgammaHLTPixelMatchElectronAlgo::run ( edm::Event e,
reco::ElectronCollection outEle 
)

Definition at line 92 of file EgammaHLTPixelMatchElectronAlgo.cc.

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

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

92  {
93 
94  // get the input
96  if (!useGsfTracks_)
97  e.getByToken(trackProducer_,tracksH);
98 
99  // get the input
101  if (useGsfTracks_)
102  e.getByToken(gsfTrackProducer_, gsfTracksH);
103 
104  //Get the Beam Spot position
105  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
106  e.getByToken(bsProducer_,recoBeamSpotHandle);
107 
108  // gets its position
109  const BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
110  Global3DPoint bs(bsPosition.x(),bsPosition.y(),0);
111  process(tracksH, gsfTracksH, outEle, bs);
112 
113  return;
114 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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:29
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackProducer_
edm::EDGetTokenT< reco::BeamSpot > bsProducer_
edm::EDGetTokenT< reco::TrackCollection > trackProducer_
const Point & position() const
position
Definition: BeamSpot.h:62
void EgammaHLTPixelMatchElectronAlgo::setupES ( const edm::EventSetup setup)

Definition at line 66 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().

66  {
67  //services
68 
69  bool updateField(false);
71  updateField = true;
72  cacheIDMagField_=es.get<IdealMagneticFieldRecord>().cacheIdentifier();
73  es.get<IdealMagneticFieldRecord>().get(magField_);
74  }
75 
76  if(useGsfTracks_){ //only need the geom and mtsTransform if we are doing gsf tracks
77  bool updateGeometry(false);
79  updateGeometry = true;
80  cacheIDTDGeom_=es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
82  }
83  if ( updateField || updateGeometry || !mtsTransform_ ) {
84  delete mtsTransform_;
86  }
87  }
88 
89 
90 }
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 58 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
private

Definition at line 65 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

int unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
private

Definition at line 64 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 56 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

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

Definition at line 62 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

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

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 55 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 57 of file EgammaHLTPixelMatchElectronAlgo.h.

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