CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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::InputTag bsProducer_
 
unsigned long long cacheIDMagField_
 
int unsigned long long cacheIDTDGeom_
 
edm::InputTag gsfTrackProducer_
 
edm::ESHandle< MagneticFieldmagField_
 
MultiTrajectoryStateModemtsMode_
 
MultiTrajectoryStateTransformmtsTransform_
 
edm::ESHandle< TrackerGeometrytrackerGeom_
 
edm::InputTag trackProducer_
 
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)

Definition at line 50 of file EgammaHLTPixelMatchElectronAlgo.cc.

50  :
51  trackProducer_(conf.getParameter<edm::InputTag>("TrackProducer")),
52  gsfTrackProducer_(conf.getParameter<edm::InputTag>("GsfTrackProducer")),
53  useGsfTracks_(conf.getParameter<bool>("UseGsfTracks")),
54  bsProducer_(conf.getParameter<edm::InputTag>("BSProducer")),
56  mtsTransform_(0),
57  cacheIDTDGeom_(0),
59 {
60 
61 }
T getParameter(std::string const &) const
MultiTrajectoryStateTransform * mtsTransform_
EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo ( )

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.cc.

References mtsMode_, and mtsTransform_.

64 {
65  delete mtsTransform_;
66  delete mtsMode_;
67  }
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 234 of file EgammaHLTPixelMatchElectronAlgo.cc.

Referenced by process().

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

Definition at line 42 of file EgammaHLTPixelMatchElectronAlgo.h.

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

References MultiTrajectoryStateTransform::extrapolatedState(), i, trajectoryStateTransform::innerFreeState(), MultiTrajectoryStateTransform::innerStateOnSurface(), isInnerMostWithLostHits(), TrajectoryStateOnSurface::isValid(), j, PV3DBase< T, PVType, FrameType >::mag(), magField_, MultiTrajectoryStateMode::momentumFromModeCartesian(), mtsMode_, mtsTransform_, edm::ESHandle< class >::product(), pileupReCalc_HLTpaths::scale, reco::Electron::setSuperCluster(), useGsfTracks_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), and run().

119  {
120 
121  if (!useGsfTracks_) {
122 
123  for (unsigned int i=0; i<tracksH->size(); ++i) {
124 
125  const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH, i);
126  edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
127  ElectronSeedRef elseed=seed.castTo<ElectronSeedRef>();
128 
129  edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster() ;
130  SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>() ;
131 
132  // Get the momentum at vertex (not at the innermost layer)
133  TSCPBuilderNoMaterial tscpBuilder;
134 
136  TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs);
137 
138  float scale = scRef->energy()/tscp.momentum().mag();
139 
140  const math::XYZTLorentzVector momentum(tscp.momentum().x()*scale,
141  tscp.momentum().y()*scale,
142  tscp.momentum().z()*scale,
143  scRef->energy());
144 
145  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
146  ele.setSuperCluster(scRef);
147  edm::Ref<TrackCollection> myRef(tracksH, i);
148  ele.setTrack(myRef);
149  outEle.push_back(ele);
150  } // loop over tracks
151  } else {
152 
153  // clean gsf tracks
154  std::vector<unsigned int> flag(gsfTracksH->size(), 0);
155  if (gsfTracksH->size() == 0)
156  return;
157 
158  for (unsigned int i=0; i<gsfTracksH->size()-1; ++i) {
159  const GsfTrackRef trackRef1 = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
160  ElectronSeedRef elseed1 = trackRef1->extra()->seedRef().castTo<ElectronSeedRef>();
161  SuperClusterRef scRef1 = elseed1->caloCluster().castTo<SuperClusterRef>();
162 
165  GlobalVector innMom;
166  float pin1 = trackRef1->pMode();
167  if (fts.isValid()) {
168  mtsMode_->momentumFromModeCartesian(fts, innMom);
169  pin1 = innMom.mag();
170  }
171 
172  for (unsigned int j=i+1; j<gsfTracksH->size(); ++j) {
173  const GsfTrackRef trackRef2 = edm::Ref<GsfTrackCollection>(gsfTracksH, j);
174  ElectronSeedRef elseed2 = trackRef2->extra()->seedRef().castTo<ElectronSeedRef>();
175  SuperClusterRef scRef2 = elseed2->caloCluster().castTo<SuperClusterRef>();
176 
179  GlobalVector innMom;
180  float pin2 = trackRef2->pMode();
181  if (fts.isValid()) {
182  mtsMode_->momentumFromModeCartesian(fts, innMom);
183  pin2 = innMom.mag();
184  }
185 
186  if (scRef1 == scRef2) {
187  bool isSameLayer = false;
188  bool iGsfInnermostWithLostHits = isInnerMostWithLostHits(trackRef2, trackRef1, isSameLayer);
189 
190  if (iGsfInnermostWithLostHits) {
191  flag[j] = 1;
192  } else if(isSameLayer) {
193  if(fabs((scRef1->energy()/pin1)-1) < fabs((scRef2->energy()/pin2)-1))
194  flag[j] = 1;
195  } else {
196  flag[i] = 1;
197  }
198  }
199  }
200  }
201 
202  for (unsigned int i=0; i<gsfTracksH->size(); ++i) {
203  if (flag[i] == 1)
204  continue;
205 
206  const GsfTrackRef trackRef = edm::Ref<GsfTrackCollection>(gsfTracksH, i);
207  ElectronSeedRef elseed = trackRef->extra()->seedRef().castTo<ElectronSeedRef>();
208  SuperClusterRef scRef = elseed->caloCluster().castTo<SuperClusterRef>();
209 
210  // Get the momentum at vertex (not at the innermost layer)
213  GlobalVector innMom;
214  mtsMode_->momentumFromModeCartesian(inTSOS, innMom);
215  if (fts.isValid()) {
216  mtsMode_->momentumFromModeCartesian(fts, innMom);
217  }
218 
219  float scale = scRef->energy()/innMom.mag();
220  const math::XYZTLorentzVector momentum(innMom.x()*scale,
221  innMom.y()*scale,
222  innMom.z()*scale,
223  scRef->energy());
224 
225  Electron ele(trackRef->charge(), momentum, trackRef->vertex());
226  ele.setSuperCluster(scRef);
227  edm::Ref<GsfTrackCollection> myRef(gsfTracksH, i);
228  ele.setGsfTrack(myRef);
229  outEle.push_back(ele);
230  }
231  }
232 }
int i
Definition: DBlmapReader.cc:9
long int flag
Definition: mlp_lapack.h:47
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field)
T y() const
Definition: PV3DBase.h:62
bool momentumFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
edm::ESHandle< MagneticField > magField_
T mag() const
Definition: PV3DBase.h:66
TrajectoryStateOnSurface extrapolatedState(const TrajectoryStateOnSurface tsos, const GlobalPoint &point) const
T z() const
Definition: PV3DBase.h:63
int j
Definition: DBlmapReader.cc:9
bool isInnerMostWithLostHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &, bool &)
MultiTrajectoryStateTransform * mtsTransform_
T const * product() const
Definition: ESHandle.h:62
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
void setSuperCluster(const reco::SuperClusterRef &r)
set refrence to Photon component
Definition: Electron.h:36
T x() const
Definition: PV3DBase.h:61
void EgammaHLTPixelMatchElectronAlgo::run ( edm::Event e,
reco::ElectronCollection outEle 
)

Definition at line 95 of file EgammaHLTPixelMatchElectronAlgo.cc.

References bsProducer_, edm::Event::getByLabel(), gsfTrackProducer_, process(), trackProducer_, and useGsfTracks_.

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

95  {
96 
97  // get the input
99  if (!useGsfTracks_)
100  e.getByLabel(trackProducer_,tracksH);
101 
102  // get the input
104  if (useGsfTracks_)
105  e.getByLabel(gsfTrackProducer_, gsfTracksH);
106 
107  //Get the Beam Spot position
108  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
109  e.getByLabel(bsProducer_,recoBeamSpotHandle);
110 
111  // gets its position
112  const BeamSpot::Point& bsPosition = recoBeamSpotHandle->position();
113  Global3DPoint bs(bsPosition.x(),bsPosition.y(),0);
114  process(tracksH, gsfTracksH, outEle, bs);
115 
116  return;
117 }
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:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void EgammaHLTPixelMatchElectronAlgo::setupES ( const edm::EventSetup setup)

Definition at line 69 of file EgammaHLTPixelMatchElectronAlgo.cc.

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

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

69  {
70  //services
71 
72  bool updateField(false);
74  updateField = true;
75  cacheIDMagField_=es.get<IdealMagneticFieldRecord>().cacheIdentifier();
76  es.get<IdealMagneticFieldRecord>().get(magField_);
77  }
78 
79  if(useGsfTracks_){ //only need the geom and mtsTransform if we are doing gsf tracks
80  bool updateGeometry(false);
82  updateGeometry = true;
83  cacheIDTDGeom_=es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
85  }
86  if ( updateField || updateGeometry || !mtsTransform_ ) {
87  delete mtsTransform_;
89  }
90  }
91 
92 
93 }
unsigned long long cacheIdentifier() const
edm::ESHandle< MagneticField > magField_
MultiTrajectoryStateTransform * mtsTransform_
T const * product() const
Definition: ESHandle.h:62
edm::ESHandle< TrackerGeometry > trackerGeom_

Member Data Documentation

edm::InputTag EgammaHLTPixelMatchElectronAlgo::bsProducer_
private

Definition at line 58 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
private

Definition at line 66 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

int unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
private

Definition at line 65 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

edm::InputTag EgammaHLTPixelMatchElectronAlgo::gsfTrackProducer_
private

Definition at line 56 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

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

Definition at line 63 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

MultiTrajectoryStateMode* EgammaHLTPixelMatchElectronAlgo::mtsMode_
private

Definition at line 60 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and ~EgammaHLTPixelMatchElectronAlgo().

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

Definition at line 64 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

edm::InputTag 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().