CMS 3D CMS Logo

EgammaHLTPixelMatchElectronAlgo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EgammaHLTAlgos
00004 // Class:      EgammaHLTPixelMatchElectronAlgo.
00005 // 
00011 //
00012 // Original Author:  Monica Vazquez Acosta (CERN)
00013 // $Id: EgammaHLTPixelMatchElectronAlgo.cc,v 1.12 2008/03/17 13:47:36 ghezzi Exp $
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 //using namespace math; // conflicts with DataFormat/Math/interface/Point3D.h!!!!
00047 
00048 //EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo():  
00049 //  theCkfTrajectoryBuilder(0), theTrajectoryCleaner(0),
00050 //  theInitialStateEstimator(0), theNavigationSchool(0) {}
00051 
00052 EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo(){}
00053 EgammaHLTPixelMatchElectronAlgo::~EgammaHLTPixelMatchElectronAlgo() {
00054 
00055   // delete theInitialStateEstimator;
00056   //delete theNavigationSchool;
00057   //delete theTrajectoryCleaner; 
00058     
00059 }
00060 
00061 void EgammaHLTPixelMatchElectronAlgo::setupES(const edm::EventSetup& es, const edm::ParameterSet &conf) {
00062 
00063   //services
00064   es.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker );
00065   es.get<IdealMagneticFieldRecord>().get(theMagField);
00066 
00067   /*
00068   // get nested parameter set for the TransientInitialStateEstimator
00069   ParameterSet tise_params = conf.getParameter<ParameterSet>("TransientInitialStateEstimatorParameters") ;
00070   theInitialStateEstimator       = new TransientInitialStateEstimator( es,tise_params);
00071 
00072   edm::ESHandle<NavigationSchool> nav;
00073   es.get<NavigationSchoolRecord>().get("SimpleNavigationSchool", nav);
00074   theNavigationSchool = nav.product();
00075   // set the correct navigation
00076   NavigationSetter setter(*theNavigationSchool);
00077 
00078   //  theCkfTrajectoryBuilder = new CkfTrajectoryBuilder(conf,es,theMeasurementTracker);
00079   theTrajectoryCleaner = new TrajectoryCleanerBySharedHits();    
00080   std::string trajectoryBuilderName = conf.getParameter<std::string>("TrajectoryBuilder");
00081   edm::ESHandle<TrajectoryBuilder> theTrajectoryBuilderHandle;
00082   es.get<CkfComponentsRecord>().get(trajectoryBuilderName,theTrajectoryBuilderHandle);
00083   theCkfTrajectoryBuilder = theTrajectoryBuilderHandle.product();    
00084   */
00085 
00086   //trackLabel_ = conf.getParameter<string>("TrackLabel");
00087   //  trackInstanceName_ = conf.getParameter<string>("TrackProducer");
00088   trackProducer_= conf.getParameter<edm::InputTag>("TrackProducer");
00089   //"offlineBeamSpot"
00090   BSProducer_ = conf.getParameter<edm::InputTag>("BSProducer");
00091 }
00092 
00093 void  EgammaHLTPixelMatchElectronAlgo::run(Event& e, ElectronCollection & outEle) {
00094 
00095   // get the input 
00096   edm::Handle<TrackCollection> tracksH;
00097   //  e.getByLabel(trackLabel_,trackInstanceName_,tracksH);
00098  e.getByLabel(trackProducer_,tracksH);
00099 
00100   //Get the Beam Spot position
00101   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00102   // iEvent.getByType(recoBeamSpotHandle);
00103   e.getByLabel(BSProducer_,recoBeamSpotHandle);
00104   // gets its position
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         // Get the momentum at vertex (not at the innermost layer)
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   }  // loop over tracks
00143 }
00144 

Generated on Tue Jun 9 17:43:22 2009 for CMSSW by  doxygen 1.5.4