CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OniaVtxReProducer.cc
Go to the documentation of this file.
9 
11 {
12  const edm::Provenance *prov = handle.provenance();
13  if (prov == 0) throw cms::Exception("CorruptData") << "Vertex handle doesn't have provenance.";
14 // edm::ParameterSetID psid = prov->psetID();
15 
16 // edm::pset::Registry *psregistry = edm::pset::Registry::instance();
17  edm::ParameterSet psetFromProvenance = edm::parameterSet(*prov);
18 // if (!psregistry->getMapped(psid, psetFromProvenance))
19 // throw cms::Exception("CorruptData") << "Vertex handle parameter set ID id = " << psid;
20 
21  if (edm::moduleName(*prov) != "RecoChargedRefCandidatePrimaryVertexSorter" )
22  //if (edm::moduleName(*prov) != "PrimaryVertexProducer")
23  throw cms::Exception("Configuration") << "Vertices to re-produce don't come from a PrimaryVertexProducer, but from a "
24  << edm::moduleName(*prov) <<".\n";
25 
26  configure(psetFromProvenance);
27 
28  // Now we also dig out the ProcessName used for the reco::Tracks and reco::Vertices
29  std::vector<edm::BranchID> parents = prov->parents();
30  bool foundTracks = false;
31  bool foundBeamSpot = false;
32  for (std::vector<edm::BranchID>::const_iterator it = parents.begin(), ed = parents.end(); it != ed; ++it) {
33  edm::Provenance parprov = iEvent.getProvenance(*it);
34  if (parprov.friendlyClassName() == "recoTracks") {
35  tracksTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
36  foundTracks = true;
37  } else if (parprov.friendlyClassName() == "recoBeamSpot") {
38  beamSpotTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
39  foundBeamSpot = true;
40  }
41  }
42  if (!foundTracks || !foundBeamSpot) {
43  edm::LogWarning("OniaVtxReProducer_MissingParentage") <<
44  "Can't find parentage info for vertex collection inputs: " <<
45  (foundTracks ? "" : "tracks ") << (foundBeamSpot ? "" : "beamSpot") << "\n";
46  }
47 }
48 
49 void
51 {
52  config_ = iConfig;
53  tracksTag_ = iConfig.getParameter<edm::InputTag>("TrackLabel");
54  beamSpotTag_ = iConfig.getParameter<edm::InputTag>("beamSpotLabel");
55  algo_.reset(new PrimaryVertexProducerAlgorithm(iConfig));
56 }
57 
58 std::vector<TransientVertex>
60  const reco::BeamSpot &bs,
61  const edm::EventSetup &iSetup) const
62 {
64  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
65 
66  std::vector<reco::TransientTrack> t_tks; t_tks.reserve(tracks.size());
67  for (reco::TrackCollection::const_iterator it = tracks.begin(), ed = tracks.end(); it != ed; ++it) {
68  t_tks.push_back((*theB).build(*it));
69  t_tks.back().setBeamSpot(bs);
70  }
71 
72  return algo_->vertices(t_tks, bs,"KalmanVertexFitter");
73 }
T getParameter(std::string const &) const
TPRegexp parents
Definition: eve_filter.cc:21
std::auto_ptr< PrimaryVertexProducerAlgorithm > algo_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::string const & processName() const
Definition: Provenance.h:61
OniaVtxReProducer(const edm::Handle< reco::VertexCollection > &configFromOriginalVertexCollection, const edm::Event &iEvent)
This is the real constructor to be used.
int iEvent
Definition: GenABIO.cc:230
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
tuple handle
Definition: patZpeak.py:22
std::vector< TransientVertex > makeVertices(const reco::TrackCollection &tracks, const reco::BeamSpot &bs, const edm::EventSetup &iSetup) const
Make the vertices.
void configure(const edm::ParameterSet &iConfig)
std::string const & friendlyClassName() const
Definition: Provenance.h:63
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:56
std::vector< BranchID > const & parents() const
Definition: Provenance.h:70
std::string const & moduleLabel() const
Definition: Provenance.h:60
edm::ParameterSet config_
edm::InputTag tracksTag_
edm::InputTag beamSpotTag_
std::string const & productInstanceName() const
Definition: Provenance.h:62
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:85
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
Provenance const * provenance() const
Definition: HandleBase.h:84