CMS 3D CMS Logo

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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void beginJob() override
KVFTrackUpdate(const edm::ParameterSet &)
void endJob() override
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
bool isValid() const
Definition: HandleBase.h:74
double b
Definition: hdecay.h:120
BTFtuple constrain(const reco::TransientTrack &track, const GlobalPoint &priorPos, const GlobalError &priorError) const
edm::EventID id() const
Definition: EventBase.h:60
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
T get() const
Definition: EventSetup.h:63
boost::tuple< bool, reco::TransientTrack, float > BTFtuple
~KVFTrackUpdate() override