CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTPixelMatchElectronAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaHLTAlgos
4 // Class: EgammaHLTPixelMatchElectronAlgo.
5 //
11 //
12 // Original Author: Monica Vazquez Acosta (CERN)
13 // $Id: EgammaHLTPixelMatchElectronAlgo.cc,v 1.13 2009/01/28 17:08:22 ghezzi Exp $
14 //
15 //
17 
20 
25 
28 
33 
36 
39 
42 
43 using namespace edm;
44 using namespace std;
45 using namespace reco;
46 //using namespace math; // conflicts with DataFormat/Math/interface/Point3D.h!!!!
47 
48 //EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo():
49 // theCkfTrajectoryBuilder(0), theTrajectoryCleaner(0),
50 // theInitialStateEstimator(0), theNavigationSchool(0) {}
51 
53  trackProducer_( conf.getParameter<edm::InputTag>("TrackProducer") ),
54  BSProducer_( conf.getParameter<edm::InputTag>("BSProducer") )
55 {}
56 
58 
59  // delete theInitialStateEstimator;
60  //delete theNavigationSchool;
61  //delete theTrajectoryCleaner;
62 
63 }
64 
66  //services
69 }
70 
72 
73  // get the input
75  // e.getByLabel(trackLabel_,trackInstanceName_,tracksH);
76  e.getByLabel(trackProducer_,tracksH);
77 
78  //Get the Beam Spot position
79  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
80  // iEvent.getByType(recoBeamSpotHandle);
81  e.getByLabel(BSProducer_,recoBeamSpotHandle);
82  // gets its position
83  const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
84  Global3DPoint bs(BSPosition.x(),BSPosition.y(),0);
85  process(tracksH,outEle,bs);
86 
87  return;
88 }
89 
91  const TrackCollection *tracks=tracksH.product();
92  for (unsigned int i=0;i<tracks->size();++i) {
93  const Track & t=(*tracks)[i];
94 
95  const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH,i);
96  edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
97  ElectronSeedRef elseed=seed.castTo<ElectronSeedRef>();
98 
99  edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster() ;
100  SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>() ;
101 
102  //const SuperClusterRef & scRef=elseed->superCluster();
103 
104  // Get the momentum at vertex (not at the innermost layer)
105  TSCPBuilderNoMaterial tscpBuilder;
106  TrajectoryStateTransform tsTransform;
107  FreeTrajectoryState fts = tsTransform.innerFreeState(t,theMagField.product());
108  TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs );
109 
110  float scale = scRef->energy()/tscp.momentum().mag();
111 
112  const math::XYZTLorentzVector momentum(tscp.momentum().x()*scale,
113  tscp.momentum().y()*scale,
114  tscp.momentum().z()*scale,
115  scRef->energy());
116 
117 
118  Electron ele(t.charge(),momentum, t.vertex() );
119  ele.setSuperCluster(scRef);
120  edm::Ref<TrackCollection> myRef(tracksH,i);
121  ele.setTrack(myRef);
122  outEle.push_back(ele);
123 
124  } // loop over tracks
125 }
126 
int i
Definition: DBlmapReader.cc:9
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:57
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
T mag() const
Definition: PV3DBase.h:61
void run(edm::Event &, reco::ElectronCollection &)
T z() const
Definition: PV3DBase.h:58
void setupES(const edm::EventSetup &setup)
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
tuple conf
Definition: dbtoconf.py:185
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:155
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
EgammaHLTPixelMatchElectronAlgo(const edm::ParameterSet &conf)
T const * product() const
Definition: Handle.h:74
void process(edm::Handle< reco::TrackCollection > tracksH, reco::ElectronCollection &outEle, Global3DPoint &bs)
edm::ESHandle< MagneticField > theMagField
int charge() const
track electric charge
Definition: TrackBase.h:112
void setSuperCluster(const reco::SuperClusterRef &r)
set refrence to Photon component
Definition: Electron.h:33
T x() const
Definition: PV3DBase.h:56
edm::ESHandle< GeometricSearchTracker > theGeomSearchTracker