CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KVFTrackUpdate.cc
Go to the documentation of this file.
2 
10 
19 
20 #include <iostream>
21 
22 using namespace reco;
23 using namespace edm;
24 using namespace std;
25 
27 {
28  token_tracks = consumes<TrackCollection>(iConfig.getParameter<InputTag>("TrackLabel"));
29  token_beamSpot = consumes<BeamSpot>(iConfig.getParameter<InputTag>("beamSpotLabel"));
30 }
31 
32 
34 }
35 
37 }
38 
39 
41 }
42 
43 //
44 // member functions
45 //
46 
47 void
49 {
50 
51 
52 
53  try {
54  edm::LogInfo("RecoVertex/KVFTrackUpdate")
55  << "Reconstructing event number: " << iEvent.id() << "\n";
56 
57  // get RECO tracks from the event
58  // `tks` can be used as a ptr to a reco::TrackCollection
60  iEvent.getByToken(token_tracks, tks);
61 
62  edm::LogInfo("RecoVertex/KVFTrackUpdate")
63  << "Found: " << (*tks).size() << " reconstructed tracks" << "\n";
64  std::cout << "got " << (*tks).size() << " tracks " << std::endl;
65 
66  // Transform Track to TransientTrack
67 
68  //get the builder:
70  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
71  //do the conversion:
72  std::vector<TransientTrack> t_tks = (*theB).build(tks);
73 
74  edm::LogInfo("RecoVertex/KVFTrackUpdate")
75  << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
76 
77  GlobalPoint glbPos(0.,0.,0.);
78 
80  mat[0][0] = (20.e-04)*(20.e-04);
81  mat[1][1] = (20.e-04)*(20.e-04);
82  mat[2][2] = (5.3)*(5.3);
83  GlobalError glbErrPos(mat);
84 
85  reco::BeamSpot vertexBeamSpot;
86  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
87  iEvent.getByToken(token_beamSpot,recoBeamSpotHandle);
88 
89 
91  for (unsigned int i = 0; i<t_tks.size();i++) {
93  stvc.constrain(t_tks[i], glbPos, glbErrPos);
94  std::cout << "Chi2: "<< a.get<2>()<<std::endl;
95  if (recoBeamSpotHandle.isValid()){
97  stvc.constrain(t_tks[i], *recoBeamSpotHandle);
98  std::cout << "Chi2: "<< b.get<2>()<<std::endl;
99  }
100  }
101  }
102 
103 
104  catch (std::exception & err) {
105  edm::LogInfo("RecoVertex/KVFTrackUpdate")
106  << "Exception during event number: " << iEvent.id()
107  << "\n" << err.what() << "\n";
108  }
109 
110 }
111 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
KVFTrackUpdate(const edm::ParameterSet &)
virtual void beginJob()
int iEvent
Definition: GenABIO.cc:230
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
bool isValid() const
Definition: HandleBase.h:75
const T & get() const
Definition: EventSetup.h:55
double b
Definition: hdecay.h:120
virtual void endJob()
BTFtuple constrain(const reco::TransientTrack &track, const GlobalPoint &priorPos, const GlobalError &priorError) const
edm::EventID id() const
Definition: EventBase.h:60
double a
Definition: hdecay.h:121
boost::tuple< bool, reco::TransientTrack, float > BTFtuple
tuple cout
Definition: gather_cfg.py:121
virtual void analyze(const edm::Event &, const edm::EventSetup &)