CMS 3D CMS Logo

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::unique_ptr< PrimaryVertexProducerAlgorithmalgo_
 
edm::InputTag beamSpotTag_
 
edm::ParameterSet config_
 
edm::InputTag tracksTag_
 

Detailed Description

Definition at line 15 of file OniaVtxReProducer.h.

Constructor & Destructor Documentation

◆ OniaVtxReProducer() [1/2]

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.

11  {
12  const edm::Provenance *prov = handle.provenance();
13  if (prov == nullptr)
14  throw cms::Exception("CorruptData") << "Vertex handle doesn't have provenance.";
15  edm::ParameterSet psetFromProvenance = edm::parameterSet(*prov, iEvent.processHistory());
16 
17  bool is_primary_available = false;
18  const edm::Provenance *parent_prov = prov;
19  if (edm::moduleName(*prov, iEvent.processHistory()) != "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, iEvent.processHistory());
26  is_primary_available = true;
27  break;
28  }
29  }
30  } else
31  is_primary_available = true;
32  if (is_primary_available)
33  prov = parent_prov;
34  else
35  throw cms::Exception("Configuration") << "Vertices to re-produce don't come from a PrimaryVertexProducer \n";
36 
37  configure(psetFromProvenance);
38 
39  // Now we also dig out the ProcessName used for the reco::Tracks and reco::Vertices
40  std::vector<edm::BranchID> parents = prov->productProvenance()->parentage().parents();
41  bool foundTracks = false;
42  bool foundBeamSpot = false;
43  for (std::vector<edm::BranchID>::const_iterator it = parents.begin(), ed = parents.end(); it != ed; ++it) {
44  edm::Provenance parprov = iEvent.getProvenance(*it);
45  if (parprov.friendlyClassName() == "recoTracks") {
46  tracksTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
47  foundTracks = true;
48  if (parprov.moduleLabel() != "generalTracks")
49  foundTracks = false; // this is necessary since we are asking for that in onia2mumu
50  } else if (parprov.friendlyClassName() == "recoBeamSpot") {
51  beamSpotTag_ = edm::InputTag(parprov.moduleLabel(), parprov.productInstanceName(), parprov.processName());
52  foundBeamSpot = true;
53  if (parprov.moduleLabel() != "offlineBeamSpot")
54  foundBeamSpot = false; // this is necessary since we are asking for that in onia2mumu
55  }
56  }
57  if (!foundTracks || !foundBeamSpot) {
58  //edm::LogWarning("OniaVtxReProducer_MissingParentage") <<
59  throw cms::Exception("Configuration")
60  << "Can't find correct parentage info for vertex collection inputs: " << (foundTracks ? "" : "generalTracks ")
61  << (foundBeamSpot ? "" : "offlineBeamSpot") << "\n";
62  }
63 }

References beamSpotTag_, configure(), Exception, edm::Provenance::friendlyClassName(), patZpeak::handle, iEvent, HLT_2018_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(), and tracksTag_.

◆ OniaVtxReProducer() [2/2]

OniaVtxReProducer::OniaVtxReProducer ( const edm::ParameterSet configByHand)
inline

This is only for testing.

Definition at line 21 of file OniaVtxReProducer.h.

21 { configure(configByHand); }

References configure().

Member Function Documentation

◆ configure()

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

Definition at line 65 of file OniaVtxReProducer.cc.

65  {
66  config_ = iConfig;
67  tracksTag_ = iConfig.getParameter<edm::InputTag>("TrackLabel");
68  beamSpotTag_ = iConfig.getParameter<edm::InputTag>("beamSpotLabel");
69  algo_.reset(new PrimaryVertexProducerAlgorithm(iConfig));
70 }

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

Referenced by OniaVtxReProducer().

◆ inputBeamSpot()

const edm::InputTag& OniaVtxReProducer::inputBeamSpot ( ) const
inline

Get the InputTag of the BeamSpot used in the VertexProducer.

Definition at line 35 of file OniaVtxReProducer.h.

35 { return beamSpotTag_; }

References beamSpotTag_.

◆ inputConfig()

const edm::ParameterSet& OniaVtxReProducer::inputConfig ( ) const
inline

Get the configuration used in the VertexProducer.

Definition at line 29 of file OniaVtxReProducer.h.

29 { return config_; }

References config_.

◆ inputTracks()

const edm::InputTag& OniaVtxReProducer::inputTracks ( ) const
inline

Get the InputTag of the TrackCollection used in the VertexProducer.

Definition at line 32 of file OniaVtxReProducer.h.

32 { return tracksTag_; }

References tracksTag_.

◆ makeVertices()

std::vector< TransientVertex > OniaVtxReProducer::makeVertices ( const reco::TrackCollection tracks,
const reco::BeamSpot bs,
const edm::EventSetup iSetup 
) const

Make the vertices.

Definition at line 72 of file OniaVtxReProducer.cc.

74  {
76  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theB);
77 
78  std::vector<reco::TransientTrack> t_tks;
79  t_tks.reserve(tracks.size());
80  for (reco::TrackCollection::const_iterator it = tracks.begin(), ed = tracks.end(); it != ed; ++it) {
81  t_tks.push_back((*theB).build(*it));
82  t_tks.back().setBeamSpot(bs);
83  }
84 
85  return algo_->vertices(t_tks, bs, "AdaptiveVertexFitter");
86 }

References algo_, cms::cuda::bs, edm::EventSetup::get(), get, and PDWG_EXOHSCP_cff::tracks.

Referenced by Onia2MuMuPAT::produce().

Member Data Documentation

◆ algo_

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

Definition at line 43 of file OniaVtxReProducer.h.

Referenced by configure(), and makeVertices().

◆ beamSpotTag_

edm::InputTag OniaVtxReProducer::beamSpotTag_
private

Definition at line 42 of file OniaVtxReProducer.h.

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

◆ config_

edm::ParameterSet OniaVtxReProducer::config_
private

Definition at line 40 of file OniaVtxReProducer.h.

Referenced by configure(), and inputConfig().

◆ tracksTag_

edm::InputTag OniaVtxReProducer::tracksTag_
private

Definition at line 41 of file OniaVtxReProducer.h.

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

edm::Provenance::moduleLabel
std::string const & moduleLabel() const
Definition: Provenance.h:55
edm::Parentage::parents
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
OniaVtxReProducer::algo_
std::unique_ptr< PrimaryVertexProducerAlgorithm > algo_
Definition: OniaVtxReProducer.h:43
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
patZpeak.handle
handle
Definition: patZpeak.py:23
OniaVtxReProducer::beamSpotTag_
edm::InputTag beamSpotTag_
Definition: OniaVtxReProducer.h:42
edm::Provenance::productProvenance
ProductProvenance const * productProvenance() const
Definition: Provenance.cc:26
OniaVtxReProducer::configure
void configure(const edm::ParameterSet &iConfig)
Definition: OniaVtxReProducer.cc:65
cms::cuda::bs
bs
Definition: HistoContainer.h:127
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::Provenance::processName
std::string const & processName() const
Definition: Provenance.h:57
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< TransientTrackBuilder >
edm::Provenance::productInstanceName
std::string const & productInstanceName() const
Definition: Provenance.h:58
OniaVtxReProducer::config_
edm::ParameterSet config_
Definition: OniaVtxReProducer.h:40
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
iEvent
int iEvent
Definition: GenABIO.cc:224
OniaVtxReProducer::tracksTag_
edm::InputTag tracksTag_
Definition: OniaVtxReProducer.h:41
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
PrimaryVertexProducerAlgorithm
Definition: PrimaryVertexProducerAlgorithm.h:57
edm::Provenance::friendlyClassName
std::string const & friendlyClassName() const
Definition: Provenance.h:59
Exception
Definition: hltDiff.cc:246
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
edm::ProductProvenance::parentage
Parentage const & parentage() const
Definition: ProductProvenance.cc:40
edm::moduleName
std::string moduleName(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:27
parents
TPRegexp parents
Definition: eve_filter.cc:21
edm::Provenance
Definition: Provenance.h:34
edm::InputTag
Definition: InputTag.h:15