CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoVertex/KalmanVertexFit/plugins/KVFTrackUpdate.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KalmanVertexFit/plugins/KVFTrackUpdate.h"
00002 
00003 #include "DataFormats/VertexReco/interface/Vertex.h"
00004 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00005 #include "DataFormats/TrackReco/interface/Track.h"
00006 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00007 #include "DataFormats/Common/interface/EDProduct.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012 
00013 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00014 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00015 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00016 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00017 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
00018 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00019 #include "RecoVertex/KalmanVertexFit/interface/SingleTrackVertexConstraint.h"
00020 
00021 #include <iostream>
00022 
00023 using namespace reco;
00024 using namespace edm;
00025 using namespace std;
00026 
00027 KVFTrackUpdate::KVFTrackUpdate(const edm::ParameterSet& iConfig)
00028 {
00029   trackLabel_ = iConfig.getParameter<edm::InputTag>("TrackLabel");
00030   beamSpotLabel = iConfig.getParameter<edm::InputTag>("beamSpotLabel");
00031 }
00032 
00033 
00034 KVFTrackUpdate::~KVFTrackUpdate() {
00035 }
00036 
00037 void KVFTrackUpdate::beginJob(){
00038 }
00039 
00040 
00041 void KVFTrackUpdate::endJob() {
00042 }
00043 
00044 //
00045 // member functions
00046 //
00047 
00048 void
00049 KVFTrackUpdate::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00050 {
00051 
00052 
00053 
00054   try {
00055     edm::LogInfo("RecoVertex/KVFTrackUpdate") 
00056       << "Reconstructing event number: " << iEvent.id() << "\n";
00057     
00058     // get RECO tracks from the event
00059     // `tks` can be used as a ptr to a reco::TrackCollection
00060     edm::Handle<reco::TrackCollection> tks;
00061     iEvent.getByLabel(trackLabel_, tks);
00062 
00063     edm::LogInfo("RecoVertex/KVFTrackUpdate") 
00064       << "Found: " << (*tks).size() << " reconstructed tracks" << "\n";
00065     std::cout << "got " << (*tks).size() << " tracks " << std::endl;
00066 
00067     // Transform Track to TransientTrack
00068 
00069     //get the builder:
00070     edm::ESHandle<TransientTrackBuilder> theB;
00071     iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
00072     //do the conversion:
00073     std::vector<TransientTrack> t_tks = (*theB).build(tks);
00074 
00075     edm::LogInfo("RecoVertex/KVFTrackUpdate") 
00076       << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
00077     
00078     GlobalPoint glbPos(0.,0.,0.);
00079 
00080     AlgebraicSymMatrix mat(3,0);
00081     mat[0][0] = (20.e-04)*(20.e-04);
00082     mat[1][1] = (20.e-04)*(20.e-04);
00083     mat[2][2] = (5.3)*(5.3);
00084     GlobalError glbErrPos(mat);
00085 
00086     reco::BeamSpot vertexBeamSpot;
00087     edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00088     iEvent.getByLabel(beamSpotLabel,recoBeamSpotHandle);
00089 
00090 
00091     SingleTrackVertexConstraint stvc;
00092     for (unsigned int i = 0; i<t_tks.size();i++) {
00093       SingleTrackVertexConstraint::BTFtuple a = 
00094         stvc.constrain(t_tks[i], glbPos, glbErrPos);
00095       std::cout << "Chi2: "<< a.get<2>()<<std::endl;
00096       if (recoBeamSpotHandle.isValid()){
00097         SingleTrackVertexConstraint::BTFtuple b =
00098           stvc.constrain(t_tks[i], *recoBeamSpotHandle);
00099         std::cout << "Chi2: "<< b.get<2>()<<std::endl;
00100       }
00101     }
00102   }
00103 
00104 
00105   catch (std::exception & err) {
00106     edm::LogInfo("RecoVertex/KVFTrackUpdate") 
00107       << "Exception during event number: " << iEvent.id() 
00108       << "\n" << err.what() << "\n";
00109   }
00110 
00111 }
00112 
00113 DEFINE_FWK_MODULE(KVFTrackUpdate);