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, 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::GsfTrackCollection
gsfTrackProducer_
 
edm::ESHandle< MagneticFieldmagField_
 
MultiTrajectoryStateModemtsMode_
 
MultiTrajectoryStateTransformmtsTransform_
 
edm::ESHandle< TrackerGeometrytrackerGeom_
 
edm::EDGetTokenT
< reco::TrackCollection
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 32 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")),
55  mtsTransform_(0),
56  cacheIDTDGeom_(0),
58 {
59 
60 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
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 62 of file EgammaHLTPixelMatchElectronAlgo.cc.

References mtsMode_, and mtsTransform_.

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

Definition at line 42 of file EgammaHLTPixelMatchElectronAlgo.h.

42 {}

Member Function Documentation

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

Definition at line 233 of file EgammaHLTPixelMatchElectronAlgo.cc.

Referenced by process().

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

Definition at line 43 of file EgammaHLTPixelMatchElectronAlgo.h.

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

Definition at line 118 of file EgammaHLTPixelMatchElectronAlgo.cc.

References MultiTrajectoryStateTransform::extrapolatedState(), archive::flag, 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, fileCollector::seed, reco::Electron::setSuperCluster(), useGsfTracks_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), ConfigBuilder.ConfigBuilder::prepare_FASTSIM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), run(), and ConfigBuilder.ConfigBuilder::scheduleSequence().

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

Definition at line 94 of file EgammaHLTPixelMatchElectronAlgo.cc.

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

Referenced by EgammaHLTPixelMatchElectronProducers::produce().

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

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

68  {
69  //services
70 
71  bool updateField(false);
73  updateField = true;
74  cacheIDMagField_=es.get<IdealMagneticFieldRecord>().cacheIdentifier();
75  es.get<IdealMagneticFieldRecord>().get(magField_);
76  }
77 
78  if(useGsfTracks_){ //only need the geom and mtsTransform if we are doing gsf tracks
79  bool updateGeometry(false);
81  updateGeometry = true;
82  cacheIDTDGeom_=es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
84  }
85  if ( updateField || updateGeometry || !mtsTransform_ ) {
86  delete mtsTransform_;
88  }
89  }
90 
91 
92 }
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::EDGetTokenT<reco::BeamSpot> EgammaHLTPixelMatchElectronAlgo::bsProducer_
private

Definition at line 59 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDMagField_
private

Definition at line 67 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

int unsigned long long EgammaHLTPixelMatchElectronAlgo::cacheIDTDGeom_
private

Definition at line 66 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 57 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

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

Definition at line 64 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by process(), and setupES().

MultiTrajectoryStateMode* EgammaHLTPixelMatchElectronAlgo::mtsMode_
private

Definition at line 61 of file EgammaHLTPixelMatchElectronAlgo.h.

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

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

Definition at line 65 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by setupES().

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

Definition at line 56 of file EgammaHLTPixelMatchElectronAlgo.h.

Referenced by run().

bool EgammaHLTPixelMatchElectronAlgo::useGsfTracks_
private

Definition at line 58 of file EgammaHLTPixelMatchElectronAlgo.h.

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