Go to the documentation of this file.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/ElectronSeed.h"
00032 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.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(const edm::ParameterSet &conf) :
00053 trackProducer_( conf.getParameter<edm::InputTag>("TrackProducer") ),
00054 BSProducer_( conf.getParameter<edm::InputTag>("BSProducer") )
00055 {}
00056
00057 EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo() {
00058
00059
00060
00061
00062
00063 }
00064
00065 void EgammaHLTPixelMatchElectronAlgo::setupES(const edm::EventSetup& es) {
00066
00067 es.get<TrackerRecoGeometryRecord>().get(theGeomSearchTracker);
00068 es.get<IdealMagneticFieldRecord>().get(theMagField);
00069 }
00070
00071 void EgammaHLTPixelMatchElectronAlgo::run(Event& e, ElectronCollection & outEle) {
00072
00073
00074 edm::Handle<TrackCollection> tracksH;
00075
00076 e.getByLabel(trackProducer_,tracksH);
00077
00078
00079 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00080
00081 e.getByLabel(BSProducer_,recoBeamSpotHandle);
00082
00083 const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position();
00084 Global3DPoint bs(BSPosition.x(),BSPosition.y(),0);
00085 process(tracksH,outEle,bs);
00086
00087 return;
00088 }
00089
00090 void EgammaHLTPixelMatchElectronAlgo::process(edm::Handle<TrackCollection> tracksH, ElectronCollection & outEle, Global3DPoint & bs) {
00091 const TrackCollection *tracks=tracksH.product();
00092 for (unsigned int i=0;i<tracks->size();++i) {
00093 const Track & t=(*tracks)[i];
00094
00095 const TrackRef trackRef = edm::Ref<TrackCollection>(tracksH,i);
00096 edm::RefToBase<TrajectorySeed> seed = trackRef->extra()->seedRef();
00097 ElectronSeedRef elseed=seed.castTo<ElectronSeedRef>();
00098
00099 edm::RefToBase<CaloCluster> caloCluster = elseed->caloCluster() ;
00100 SuperClusterRef scRef = caloCluster.castTo<SuperClusterRef>() ;
00101
00102
00103
00104
00105 TSCPBuilderNoMaterial tscpBuilder;
00106 TrajectoryStateTransform tsTransform;
00107 FreeTrajectoryState fts = tsTransform.innerFreeState(t,theMagField.product());
00108 TrajectoryStateClosestToPoint tscp = tscpBuilder(fts, bs );
00109
00110 float scale = scRef->energy()/tscp.momentum().mag();
00111
00112 const math::XYZTLorentzVector momentum(tscp.momentum().x()*scale,
00113 tscp.momentum().y()*scale,
00114 tscp.momentum().z()*scale,
00115 scRef->energy());
00116
00117
00118 Electron ele(t.charge(),momentum, t.vertex() );
00119 ele.setSuperCluster(scRef);
00120 edm::Ref<TrackCollection> myRef(tracksH,i);
00121 ele.setTrack(myRef);
00122 outEle.push_back(ele);
00123
00124 }
00125 }
00126