CMS 3D CMS Logo

KVFTrackUpdate.cc
Go to the documentation of this file.
2 
14 
15 #include <iostream>
16 
17 using namespace reco;
18 using namespace edm;
19 using namespace std;
20 
22  : estoken_TTB(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))) {
23  token_tracks = consumes<TrackCollection>(iConfig.getParameter<InputTag>("TrackLabel"));
24  token_beamSpot = consumes<BeamSpot>(iConfig.getParameter<InputTag>("beamSpotLabel"));
25 }
26 
28 
30 
32 
33 //
34 // member functions
35 //
36 
38  try {
39  edm::LogInfo("RecoVertex/KVFTrackUpdate") << "Reconstructing event number: " << iEvent.id() << "\n";
40 
41  // get RECO tracks from the event
42  // `tks` can be used as a ptr to a reco::TrackCollection
44  iEvent.getByToken(token_tracks, tks);
45 
46  edm::LogInfo("RecoVertex/KVFTrackUpdate") << "Found: " << (*tks).size() << " reconstructed tracks"
47  << "\n";
48  edm::LogPrint("RecoVertex/KVFTrackUpdate") << "got " << (*tks).size() << " tracks " << std::endl;
49 
50  // Transform Track to TransientTrack
51 
52  //get the builder:
53  const auto& theB = &iSetup.getData(estoken_TTB);
54  //do the conversion:
55  std::vector<TransientTrack> t_tks = theB->build(tks);
56 
57  edm::LogInfo("RecoVertex/KVFTrackUpdate") << "Found: " << t_tks.size() << " reconstructed tracks"
58  << "\n";
59 
60  GlobalPoint glbPos(0., 0., 0.);
61 
63  mat[0][0] = (20.e-04) * (20.e-04);
64  mat[1][1] = (20.e-04) * (20.e-04);
65  mat[2][2] = (5.3) * (5.3);
66  GlobalError glbErrPos(mat);
67 
68  reco::BeamSpot vertexBeamSpot;
69  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
70  iEvent.getByToken(token_beamSpot, recoBeamSpotHandle);
71 
73  for (unsigned int i = 0; i < t_tks.size(); i++) {
74  SingleTrackVertexConstraint::BTFtuple a = stvc.constrain(t_tks[i], glbPos, glbErrPos);
75  edm::LogPrint("RecoVertex/KVFTrackUpdate") << "Chi2: " << std::get<2>(a) << std::endl;
76  if (recoBeamSpotHandle.isValid()) {
77  SingleTrackVertexConstraint::BTFtuple b = stvc.constrain(t_tks[i], *recoBeamSpotHandle);
78  edm::LogPrint("RecoVertex/KVFTrackUpdate") << "Chi2: " << std::get<2>(b) << std::endl;
79  }
80  }
81  }
82 
83  catch (std::exception& err) {
84  edm::LogInfo("RecoVertex/KVFTrackUpdate") << "Exception during event number: " << iEvent.id() << "\n"
85  << err.what() << "\n";
86  }
87 }
88 
edm::EDGetTokenT< reco::TrackCollection > token_tracks
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::tuple< bool, reco::TransientTrack, float > BTFtuple
void beginJob() override
KVFTrackUpdate(const edm::ParameterSet &)
void endJob() override
void analyze(const edm::Event &, const edm::EventSetup &) override
BTFtuple constrain(const reco::TransientTrack &track, const GlobalPoint &priorPos, const GlobalError &priorError) const
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Warning, true > LogPrint
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > estoken_TTB
Log< level::Info, false > LogInfo
double b
Definition: hdecay.h:118
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:119
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
~KVFTrackUpdate() override
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot