CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
OniaVtxReProducer Class Reference

#include <OniaVtxReProducer.h>

Public Member Functions

const edm::InputTaginputBeamSpot () const
 Get the InputTag of the BeamSpot used in the VertexProducer. More...
 
const edm::ParameterSetinputConfig () const
 Get the configuration used in the VertexProducer. More...
 
const edm::InputTaginputTracks () const
 Get the InputTag of the TrackCollection used in the VertexProducer. More...
 
std::vector< TransientVertexmakeVertices (const reco::TrackCollection &tracks, const reco::BeamSpot &bs, const edm::EventSetup &iSetup) const
 Make the vertices. More...
 
 OniaVtxReProducer (const edm::Handle< reco::VertexCollection > &configFromOriginalVertexCollection, const edm::Event &iEvent)
 This is the real constructor to be used. More...
 
 OniaVtxReProducer (const edm::ParameterSet &configByHand)
 This is only for testing. More...
 

Private Member Functions

void configure (const edm::ParameterSet &iConfig)
 

Private Attributes

std::auto_ptr
< PrimaryVertexProducerAlgorithm
algo_
 
edm::InputTag beamSpotTag_
 
edm::ParameterSet config_
 
edm::InputTag tracksTag_
 

Detailed Description

Definition at line 15 of file OniaVtxReProducer.h.

Constructor & Destructor Documentation

OniaVtxReProducer::OniaVtxReProducer ( const edm::Handle< reco::VertexCollection > &  configFromOriginalVertexCollection,
const edm::Event iEvent 
)

This is the real constructor to be used.

Definition at line 11 of file OniaVtxReProducer.cc.

References beamSpotTag_, configure(), Exception, edm::Provenance::friendlyClassName(), edm::Event::getProvenance(), HLT_25ns10e33_v2_cff::InputTag, edm::Provenance::moduleLabel(), edm::moduleName(), edm::parameterSet(), edm::ProductProvenance::parentage(), parents, edm::Parentage::parents(), edm::Provenance::processName(), edm::Provenance::productInstanceName(), edm::Provenance::productProvenance(), edm::HandleBase::provenance(), and tracksTag_.

12 {
13  const edm::Provenance *prov = handle.provenance();
14  if (prov == 0) throw cms::Exception("CorruptData") << "Vertex handle doesn't have provenance.";
15  edm::ParameterSet psetFromProvenance = edm::parameterSet(*prov);
16 
17  bool is_primary_available = false;
18  const edm::Provenance *parent_prov = prov;
19  if (edm::moduleName(*prov) != "PrimaryVertexProducer") {
20  std::vector<edm::BranchID> parents = prov->productProvenance()->parentage().parents();
21  for (std::vector<edm::BranchID>::const_iterator it = parents.begin(), ed = parents.end(); it != ed; ++it) {
22  edm::Provenance parprov = iEvent.getProvenance(*it);
23  if (parprov.friendlyClassName() == "recoVertexs") { // for AOD actually this the parent we should look for
24  parent_prov = &parprov;
25  psetFromProvenance = edm::parameterSet(parprov);
26  is_primary_available = true;
27  break;
28  }
29  }
30  } else is_primary_available = true;
31  if (is_primary_available) prov = parent_prov;
32  else throw cms::Exception("Configuration") << "Vertices to re-produce don't come from a PrimaryVertexProducer \n";
33 
34  configure(psetFromProvenance);
35 
36  // Now we also dig out the ProcessName used for the reco::Tracks and reco::Vertices
37  std::vector<edm::BranchID> parents = prov->productProvenance()->parentage().parents();
38  bool foundTracks = false;
39  bool foundBeamSpot = false;
40  for (std::vector<edm::BranchID>::const_iterator it = parents.begin(), ed = parents.end(); it != ed; ++it) {
41  edm::Provenance parprov = iEvent.getProvenance(*it);
42  if (parprov.friendlyClassName() == "recoTracks") {
43  tracksTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
44  foundTracks = true;
45  if (parprov.moduleLabel() != "generalTracks") foundTracks = false; // this is necessary since we are asking for that in onia2mumu
46  } else if (parprov.friendlyClassName() == "recoBeamSpot") {
47  beamSpotTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
48  foundBeamSpot = true;
49  if (parprov.moduleLabel() != "offlineBeamSpot") foundBeamSpot = false; // this is necessary since we are asking for that in onia2mumu
50  }
51  }
52  if (!foundTracks || !foundBeamSpot) {
53  //edm::LogWarning("OniaVtxReProducer_MissingParentage") <<
54  throw cms::Exception("Configuration") <<
55  "Can't find correct parentage info for vertex collection inputs: " << (foundTracks ? "" : "generalTracks ") << (foundBeamSpot ? "" : "offlineBeamSpot") << "\n";
56  }
57 
58 }
TPRegexp parents
Definition: eve_filter.cc:21
ProductProvenance const * productProvenance() const
Definition: Provenance.cc:28
std::string const & processName() const
Definition: Provenance.h:52
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
tuple handle
Definition: patZpeak.py:22
void configure(const edm::ParameterSet &iConfig)
std::string const & friendlyClassName() const
Definition: Provenance.h:54
std::string const & moduleLabel() const
Definition: Provenance.h:51
edm::InputTag tracksTag_
Parentage const & parentage() const
edm::InputTag beamSpotTag_
std::string const & productInstanceName() const
Definition: Provenance.h:53
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:80
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
OniaVtxReProducer::OniaVtxReProducer ( const edm::ParameterSet configByHand)
inline

This is only for testing.

Definition at line 20 of file OniaVtxReProducer.h.

References configure().

20 { configure(configByHand); }
void configure(const edm::ParameterSet &iConfig)

Member Function Documentation

void OniaVtxReProducer::configure ( const edm::ParameterSet iConfig)
private

Definition at line 61 of file OniaVtxReProducer.cc.

References algo_, beamSpotTag_, config_, edm::ParameterSet::getParameter(), and tracksTag_.

Referenced by OniaVtxReProducer().

62 {
63  config_ = iConfig;
64  tracksTag_ = iConfig.getParameter<edm::InputTag>("TrackLabel");
65  beamSpotTag_ = iConfig.getParameter<edm::InputTag>("beamSpotLabel");
66  algo_.reset(new PrimaryVertexProducerAlgorithm(iConfig));
67 }
T getParameter(std::string const &) const
std::auto_ptr< PrimaryVertexProducerAlgorithm > algo_
edm::ParameterSet config_
edm::InputTag tracksTag_
edm::InputTag beamSpotTag_
const edm::InputTag& OniaVtxReProducer::inputBeamSpot ( ) const
inline

Get the InputTag of the BeamSpot used in the VertexProducer.

Definition at line 32 of file OniaVtxReProducer.h.

References beamSpotTag_.

32 { return beamSpotTag_; }
edm::InputTag beamSpotTag_
const edm::ParameterSet& OniaVtxReProducer::inputConfig ( ) const
inline

Get the configuration used in the VertexProducer.

Definition at line 26 of file OniaVtxReProducer.h.

References config_.

26 { return config_; }
edm::ParameterSet config_
const edm::InputTag& OniaVtxReProducer::inputTracks ( ) const
inline

Get the InputTag of the TrackCollection used in the VertexProducer.

Definition at line 29 of file OniaVtxReProducer.h.

References tracksTag_.

29 { return tracksTag_; }
edm::InputTag tracksTag_
std::vector< TransientVertex > OniaVtxReProducer::makeVertices ( const reco::TrackCollection tracks,
const reco::BeamSpot bs,
const edm::EventSetup iSetup 
) const

Make the vertices.

Definition at line 70 of file OniaVtxReProducer.cc.

References algo_, and edm::EventSetup::get().

73 {
75  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
76 
77  std::vector<reco::TransientTrack> t_tks; t_tks.reserve(tracks.size());
78  for (reco::TrackCollection::const_iterator it = tracks.begin(), ed = tracks.end(); it != ed; ++it) {
79  t_tks.push_back((*theB).build(*it));
80  t_tks.back().setBeamSpot(bs);
81  }
82 
83  return algo_->vertices(t_tks, bs,"AdaptiveVertexFitter");
84 }
std::auto_ptr< PrimaryVertexProducerAlgorithm > algo_
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:56

Member Data Documentation

std::auto_ptr<PrimaryVertexProducerAlgorithm> OniaVtxReProducer::algo_
private

Definition at line 39 of file OniaVtxReProducer.h.

Referenced by configure(), and makeVertices().

edm::InputTag OniaVtxReProducer::beamSpotTag_
private

Definition at line 38 of file OniaVtxReProducer.h.

Referenced by configure(), inputBeamSpot(), and OniaVtxReProducer().

edm::ParameterSet OniaVtxReProducer::config_
private

Definition at line 36 of file OniaVtxReProducer.h.

Referenced by configure(), and inputConfig().

edm::InputTag OniaVtxReProducer::tracksTag_
private

Definition at line 37 of file OniaVtxReProducer.h.

Referenced by configure(), inputTracks(), and OniaVtxReProducer().