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 17 of file HIBestVertexProducer.cc.

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

18  : theConfig(ps),
19  theBeamSpotTag(consumes<reco::BeamSpot>(ps.getParameter<edm::InputTag>("beamSpotLabel"))),
21  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("medianVertexCollection"))),
23  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("adaptiveVertexCollection"))),
24  theUseFinalAdaptiveVertexCollection(ps.getParameter<bool>("useFinalAdaptiveVertexCollection")) {
27  consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("finalAdaptiveVertexCollection"));
28  }
29  produces<reco::VertexCollection>();
30 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::VertexCollection > theAdaptiveVertexCollection
edm::ParameterSet theConfig
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotTag
edm::EDGetTokenT< reco::VertexCollection > theFinalAdaptiveVertexCollection
edm::EDGetTokenT< reco::VertexCollection > theMedianVertexCollection

◆ ~HIBestVertexProducer()

HIBestVertexProducer::~HIBestVertexProducer ( )
override

Definition at line 33 of file HIBestVertexProducer.cc.

33 {}

Member Function Documentation

◆ beginJob()

void HIBestVertexProducer::beginJob ( void  )
private

Definition at line 48 of file HIBestVertexProducer.cc.

48 {}

◆ fillDescriptions()

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

Definition at line 36 of file HIBestVertexProducer.cc.

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

36  {
38  desc.add<InputTag>("beamSpotLabel", edm::InputTag("offlineBeamSpot"));
39  desc.add<InputTag>("adaptiveVertexCollection", edm::InputTag("hiBestAdaptiveVertex"));
40  desc.add<InputTag>("medianVertexCollection", edm::InputTag("hiPixelMedianVertex"));
41  desc.add<bool>("useFinalAdaptiveVertexCollection", false);
42  desc.add<InputTag>("finalAdaptiveVertexCollection", edm::InputTag("hiBestOfflinePrimaryVertex"));
43 
44  descriptions.add("hiSelectedPixelVertex", desc);
45 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 51 of file HIBestVertexProducer.cc.

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

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

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().