CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HIBestVertexProducer Class Reference

#include <HIBestVertexProducer.h>

Inheritance diagram for HIBestVertexProducer:
edm::stream::EDProducer<>

Public Member Functions

 HIBestVertexProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~HIBestVertexProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginJob ()
 

Private Attributes

edm::EDGetTokenT< reco::VertexCollectiontheAdaptiveVertexCollection
 
edm::EDGetTokenT< reco::BeamSpottheBeamSpotTag
 
edm::ParameterSet theConfig
 
edm::EDGetTokenT< reco::VertexCollectiontheFinalAdaptiveVertexCollection
 
edm::EDGetTokenT< reco::VertexCollectiontheMedianVertexCollection
 
bool theUseFinalAdaptiveVertexCollection
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 16 of file HIBestVertexProducer.h.

Constructor & Destructor Documentation

◆ HIBestVertexProducer()

HIBestVertexProducer::HIBestVertexProducer ( const edm::ParameterSet ps)
explicit

Definition at line 18 of file HIBestVertexProducer.cc.

19  : theConfig(ps),
20  theBeamSpotTag(consumes<reco::BeamSpot>(ps.getParameter<edm::InputTag>("beamSpotLabel"))),
22  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("medianVertexCollection"))),
24  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("adaptiveVertexCollection"))),
25  theUseFinalAdaptiveVertexCollection(ps.getParameter<bool>("useFinalAdaptiveVertexCollection")) {
28  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("finalAdaptiveVertexCollection"));
29  }
30  produces<reco::VertexCollection>();
31 }

References edm::ParameterSet::getParameter(), theFinalAdaptiveVertexCollection, and theUseFinalAdaptiveVertexCollection.

◆ ~HIBestVertexProducer()

HIBestVertexProducer::~HIBestVertexProducer ( )
override

Definition at line 34 of file HIBestVertexProducer.cc.

34 {}

Member Function Documentation

◆ beginJob()

void HIBestVertexProducer::beginJob ( void  )
private

Definition at line 49 of file HIBestVertexProducer.cc.

49 {}

◆ fillDescriptions()

void HIBestVertexProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 37 of file HIBestVertexProducer.cc.

37  {
39  desc.add<InputTag>("beamSpotLabel", edm::InputTag("offlineBeamSpot"));
40  desc.add<InputTag>("adaptiveVertexCollection", edm::InputTag("hiBestAdaptiveVertex"));
41  desc.add<InputTag>("medianVertexCollection", edm::InputTag("hiPixelMedianVertex"));
42  desc.add<bool>("useFinalAdaptiveVertexCollection", false);
43  desc.add<InputTag>("finalAdaptiveVertexCollection", edm::InputTag("hiBestOfflinePrimaryVertex"));
44 
45  descriptions.add("hiSelectedPixelVertex", desc);
46 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

◆ produce()

void HIBestVertexProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

Definition at line 52 of file HIBestVertexProducer.cc.

52  {
53  // 1. use best adaptive vertex preferentially
54  // 2. use median vertex in case where adaptive algorithm failed
55  // 3. use beamspot if netither vertexing method succeeds
56 
57  // New vertex collection
58  auto newVertexCollection = std::make_unique<reco::VertexCollection>();
59 
60  //** Get precise adaptive vertex **/
62  ev.getByToken(theAdaptiveVertexCollection, vc1);
63  const reco::VertexCollection* vertices1 = vc1.product();
64 
65  if (vertices1->empty())
66  LogError("HeavyIonVertexing") << "adaptive vertex collection is empty!" << endl;
67 
68  //** Final vertex collection if needed **//
69  const double maxZError = 3.0; //any vtx with error > this number is considered no good
70  bool hasFinalVertex = false;
73  ev.getByToken(theFinalAdaptiveVertexCollection, vc0);
74  const reco::VertexCollection* vertices0 = vc0.product();
75  if (vertices0->empty())
76  LogInfo("HeavyIonVertexing") << "final adaptive vertex collection is empty!" << endl;
77 
78  //if using final vertex and has a good vertex, use it
79  if (vertices0->begin()->zError() < maxZError) {
80  hasFinalVertex = true;
81  auto const& vertex0 = vertices0->front();
82  newVertexCollection->push_back(vertex0);
83  LogInfo("HeavyIonVertexing") << "adaptive vertex:\n vz = (" << vertex0.x() << ", " << vertex0.y() << ", "
84  << vertex0.z() << ")"
85  << "\n error = (" << vertex0.xError() << ", " << vertex0.yError() << ", "
86  << vertex0.zError() << ")" << endl;
87  }
88  }
89 
90  //otherwise use the pixel track adaptive vertex if it is good
91  if (!hasFinalVertex) {
92  if (vertices1->begin()->zError() < maxZError) {
93  reco::VertexCollection::const_iterator vertex1 = vertices1->begin();
94  newVertexCollection->push_back(*vertex1);
95 
96  LogInfo("HeavyIonVertexing") << "adaptive vertex:\n vz = (" << vertex1->x() << ", " << vertex1->y() << ", "
97  << vertex1->z() << ")"
98  << "\n error = (" << vertex1->xError() << ", " << vertex1->yError() << ", "
99  << vertex1->zError() << ")" << endl;
100  } else {
101  //** Get fast median vertex **/
103  ev.getByToken(theMedianVertexCollection, vc2);
104  const reco::VertexCollection* vertices2 = vc2.product();
105 
106  //** Get beam spot position and error **/
108  edm::Handle<reco::BeamSpot> beamSpotHandle;
109  ev.getByToken(theBeamSpotTag, beamSpotHandle);
110 
111  if (beamSpotHandle.isValid())
112  beamSpot = *beamSpotHandle;
113  else
114  LogError("HeavyIonVertexing") << "no beamspot found " << endl;
115 
116  if (!vertices2->empty()) {
117  reco::VertexCollection::const_iterator vertex2 = vertices2->begin();
119  err(0, 0) = pow(beamSpot.BeamWidthX(), 2);
120  err(1, 1) = pow(beamSpot.BeamWidthY(), 2);
121  err(2, 2) = pow(vertex2->zError(), 2);
122  reco::Vertex newVertex(reco::Vertex::Point(beamSpot.x0(), beamSpot.y0(), vertex2->z()), err, 0, 1, 1);
123  newVertexCollection->push_back(newVertex);
124 
125  LogInfo("HeavyIonVertexing") << "median vertex + beamspot: \n position = (" << newVertex.x() << ", "
126  << newVertex.y() << ", " << newVertex.z() << ")"
127  << "\n error = (" << newVertex.xError() << ", " << newVertex.yError() << ", "
128  << newVertex.zError() << ")" << endl;
129 
130  } else {
132  err(0, 0) = pow(beamSpot.BeamWidthX(), 2);
133  err(1, 1) = pow(beamSpot.BeamWidthY(), 2);
134  err(2, 2) = pow(beamSpot.sigmaZ(), 2);
135  reco::Vertex newVertex(beamSpot.position(), err, 0, 0, 1);
136  newVertexCollection->push_back(newVertex);
137 
138  LogInfo("HeavyIonVertexing") << "beam spot: \n position = (" << newVertex.x() << ", " << newVertex.y() << ", "
139  << newVertex.z() << ")"
140  << "\n error = (" << newVertex.xError() << ", " << newVertex.yError() << ", "
141  << newVertex.zError() << ")" << endl;
142  }
143  }
144  }
145 
146  // put new vertex collection into event
147  ev.put(std::move(newVertexCollection));
148 }

References pwdgSkimBPark_cfi::beamSpot, submitPVResolutionJobs::err, ev, edm::HandleBase::isValid(), eostools::move(), funct::pow(), edm::Handle< T >::product(), theAdaptiveVertexCollection, theBeamSpotTag, theFinalAdaptiveVertexCollection, theMedianVertexCollection, and theUseFinalAdaptiveVertexCollection.

Member Data Documentation

◆ theAdaptiveVertexCollection

edm::EDGetTokenT<reco::VertexCollection> HIBestVertexProducer::theAdaptiveVertexCollection
private

Definition at line 28 of file HIBestVertexProducer.h.

Referenced by produce().

◆ theBeamSpotTag

edm::EDGetTokenT<reco::BeamSpot> HIBestVertexProducer::theBeamSpotTag
private

Definition at line 26 of file HIBestVertexProducer.h.

Referenced by produce().

◆ theConfig

edm::ParameterSet HIBestVertexProducer::theConfig
private

Definition at line 25 of file HIBestVertexProducer.h.

◆ theFinalAdaptiveVertexCollection

edm::EDGetTokenT<reco::VertexCollection> HIBestVertexProducer::theFinalAdaptiveVertexCollection
private

Definition at line 29 of file HIBestVertexProducer.h.

Referenced by HIBestVertexProducer(), and produce().

◆ theMedianVertexCollection

edm::EDGetTokenT<reco::VertexCollection> HIBestVertexProducer::theMedianVertexCollection
private

Definition at line 27 of file HIBestVertexProducer.h.

Referenced by produce().

◆ theUseFinalAdaptiveVertexCollection

bool HIBestVertexProducer::theUseFinalAdaptiveVertexCollection
private

Definition at line 30 of file HIBestVertexProducer.h.

Referenced by HIBestVertexProducer(), and produce().

pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HIBestVertexProducer::theConfig
edm::ParameterSet theConfig
Definition: HIBestVertexProducer.h:25
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HIBestVertexProducer::theMedianVertexCollection
edm::EDGetTokenT< reco::VertexCollection > theMedianVertexCollection
Definition: HIBestVertexProducer.h:27
edm::Handle< reco::VertexCollection >
HIBestVertexProducer::theAdaptiveVertexCollection
edm::EDGetTokenT< reco::VertexCollection > theAdaptiveVertexCollection
Definition: HIBestVertexProducer.h:28
HIBestVertexProducer::theUseFinalAdaptiveVertexCollection
bool theUseFinalAdaptiveVertexCollection
Definition: HIBestVertexProducer.h:30
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::BeamSpot
Definition: BeamSpot.h:21
HIBestVertexProducer::theBeamSpotTag
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotTag
Definition: HIBestVertexProducer.h:26
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
HIBestVertexProducer::theFinalAdaptiveVertexCollection
edm::EDGetTokenT< reco::VertexCollection > theFinalAdaptiveVertexCollection
Definition: HIBestVertexProducer.h:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35