00001
00002
00003
00004
00005
00011
00012
00013
00014
00015
00016 #include "RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTPixelMatchElectronAlgo.h"
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020
00021 #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h"
00022 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00023 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00024 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateClosestToPoint.h"
00025
00026 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00027 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00028
00029 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00030 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00031 #include "DataFormats/EgammaReco/interface/ElectronPixelSeed.h"
00032 #include "DataFormats/EgammaReco/interface/ElectronPixelSeedFwd.h"
00033
00034 #include "DataFormats/TrackCandidate/interface/TrackCandidate.h"
00035 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00036
00037 #include "DataFormats/TrackReco/interface/Track.h"
00038 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00039
00040 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00041 #include "DataFormats/Math/interface/Point3D.h"
00042
00043 using namespace edm;
00044 using namespace std;
00045 using namespace reco;
00046
00047
00048
00049
00050
00051
00052 EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo(){}
00053 EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo() {
00054
00055
00056
00057
00058
00059 }
00060
00061 void EgammaHLTPixelMatchElectronAlgo::setupES(const edm::EventSetup& es, const edm::ParameterSet &conf) {
00062
00063
00064 es.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker );
00065 es.get<IdealMagneticFieldRecord>().get(theMagField);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 trackProducer_= conf.getParameter<edm::InputTag>("TrackProducer");
00089
00090 BSProducer_ = conf.getParameter<edm::InputTag>("BSProducer");
00091 }
00092
00093 void EgammaHLTPixelMatchElectronAlgo::run(Event& e, ElectronCollection & outEle) {
00094
00095
00096 edm::Handle<TrackCollection> tracksH;
00097
00098 e.getByLabel(trackProducer_,tracksH);
00099
00100
00101 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00102
00103 e.getByLabel(BSProducer_,recoBeamSpotHandle);
00104
00105 const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
00106 Global3DPoint bs(BSPosition.x(),BSPosition.y(),0);
00107 process(tracksH,outEle,bs);
00108
00109 return;
00110 }
00111
00112 void EgammaHLTPixelMatchElectronAlgo::process(edm::Handle<TrackCollection> tracksH, ElectronCollection & outEle, Global3DPoint & bs) {
00113 const TrackCollection *tracks=tracksH.product();
00114 for (unsigned int i=0;i<tracks->size();++i) {
00115 const Track & t=(*tracks)[i];
00116
00117 const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH,i);
00118 edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
00119 ElectronPixelSeedRef elseed=seed.castTo<ElectronPixelSeedRef>();
00120 const SuperClusterRef & scRef=elseed->superCluster();
00121
00122
00123 TSCPBuilderNoMaterial tscpBuilder;
00124 TrajectoryStateTransform tsTransform;
00125 FreeTrajectoryState fts = tsTransform.innerFreeState(t,theMagField.product());
00126 TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs );
00127
00128 float scale = scRef->energy()/tscp.momentum().mag();
00129
00130 const math::XYZTLorentzVector momentum(tscp.momentum().x()*scale,
00131 tscp.momentum().y()*scale,
00132 tscp.momentum().z()*scale,
00133 scRef->energy());
00134
00135
00136 Electron ele(t.charge(),momentum, t.vertex() );
00137 ele.setSuperCluster(scRef);
00138 edm::Ref<TrackCollection> myRef(tracksH,i);
00139 ele.setTrack(myRef);
00140 outEle.push_back(ele);
00141
00142 }
00143 }
00144