CMS 3D CMS Logo

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

#include <HIBestVertexProducer.h>

Inheritance diagram for HIBestVertexProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HIBestVertexProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~HIBestVertexProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob ()
 

Private Attributes

edm::EDGetTokenT< reco::VertexCollectiontheAdaptiveVertexCollection
 
edm::EDGetTokenT< reco::BeamSpottheBeamSpotTag
 
edm::ParameterSet theConfig
 
edm::EDGetTokenT< reco::VertexCollectiontheMedianVertexCollection
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 12 of file HIBestVertexProducer.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file HIBestVertexProducer.cc.

17  : theConfig(ps),
18  theBeamSpotTag(consumes<reco::BeamSpot>(ps.getParameter<edm::InputTag>("beamSpotLabel"))),
19  theMedianVertexCollection(consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("medianVertexCollection"))),
20  theAdaptiveVertexCollection(consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("adaptiveVertexCollection")))
21 {
22  produces<reco::VertexCollection>();
23 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > theAdaptiveVertexCollection
edm::ParameterSet theConfig
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotTag
edm::EDGetTokenT< reco::VertexCollection > theMedianVertexCollection
HIBestVertexProducer::~HIBestVertexProducer ( )

Definition at line 27 of file HIBestVertexProducer.cc.

28 {
29 }

Member Function Documentation

void HIBestVertexProducer::beginJob ( void  )
private

Definition at line 32 of file HIBestVertexProducer.cc.

References produce().

33 {
34 }
void HIBestVertexProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Definition at line 38 of file HIBestVertexProducer.cc.

References ecalDrivenElectronSeedsParameters_cff::beamSpot, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), edm::Event::getByToken(), edm::HandleBase::isValid(), eostools::move(), reco::BeamSpot::position(), funct::pow(), edm::Handle< T >::product(), edm::Event::put(), reco::BeamSpot::sigmaZ(), reco::BeamSpot::x0(), and reco::BeamSpot::y0().

Referenced by beginJob().

39 {
40 
41  // 1. use best adaptive vertex preferentially
42  // 2. use median vertex in case where adaptive algorithm failed
43  // 3. use beamspot if netither vertexing method succeeds
44 
45  // New vertex collection
46  auto newVertexCollection = std::make_unique<reco::VertexCollection>();
47 
48  //** Get precise adaptive vertex **/
51  const reco::VertexCollection *vertices1 = vc1.product();
52 
53  if(vertices1->size()==0)
54  LogError("HeavyIonVertexing") << "adaptive vertex collection is empty!" << endl;
55 
56  if(vertices1->begin()->zError()<3) {
57 
58  reco::VertexCollection::const_iterator vertex1 = vertices1->begin();
59  newVertexCollection->push_back(*vertex1);
60 
61  LogInfo("HeavyIonVertexing") << "adaptive vertex:\n vz = ("
62  << vertex1->x() << ", " << vertex1->y() << ", " << vertex1->z() << ")"
63  << "\n error = ("
64  << vertex1->xError() << ", " << vertex1->yError() << ", "
65  << vertex1->zError() << ")" << endl;
66  } else {
67 
68  //** Get fast median vertex **/
71  const reco::VertexCollection * vertices2 = vc2.product();
72 
73  //** Get beam spot position and error **/
75  edm::Handle<reco::BeamSpot> beamSpotHandle;
76  ev.getByToken(theBeamSpotTag, beamSpotHandle);
77 
78  if( beamSpotHandle.isValid() )
79  beamSpot = *beamSpotHandle;
80  else
81  LogError("HeavyIonVertexing") << "no beamspot found " << endl;
82 
83  if(vertices2->size() > 0) {
84 
85  reco::VertexCollection::const_iterator vertex2 = vertices2->begin();
87  err(0,0)=pow(beamSpot.BeamWidthX(),2);
88  err(1,1)=pow(beamSpot.BeamWidthY(),2);
89  err(2,2)=pow(vertex2->zError(),2);
90  reco::Vertex newVertex(reco::Vertex::Point(beamSpot.x0(),beamSpot.y0(),vertex2->z()),
91  err, 0, 1, 1);
92  newVertexCollection->push_back(newVertex);
93 
94  LogInfo("HeavyIonVertexing") << "median vertex + beamspot: \n position = ("
95  << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")"
96  << "\n error = ("
97  << newVertex.xError() << ", " << newVertex.yError() << ", "
98  << newVertex.zError() << ")" << endl;
99 
100  } else {
101 
103  err(0,0)=pow(beamSpot.BeamWidthX(),2);
104  err(1,1)=pow(beamSpot.BeamWidthY(),2);
105  err(2,2)=pow(beamSpot.sigmaZ(),2);
106  reco::Vertex newVertex(beamSpot.position(),
107  err, 0, 0, 1);
108  newVertexCollection->push_back(newVertex);
109 
110  LogInfo("HeavyIonVertexing") << "beam spot: \n position = ("
111  << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")"
112  << "\n error = ("
113  << newVertex.xError() << ", " << newVertex.yError() << ", "
114  << newVertex.zError() << ")" << endl;
115 
116  }
117 
118  }
119 
120  // put new vertex collection into event
121  ev.put(std::move(newVertexCollection));
122 
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::VertexCollection > theAdaptiveVertexCollection
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotTag
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< reco::VertexCollection > theMedianVertexCollection
T const * product() const
Definition: Handle.h:81
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
double y0() const
y coordinate
Definition: BeamSpot.h:66
const Point & position() const
position
Definition: BeamSpot.h:62
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
double x0() const
x coordinate
Definition: BeamSpot.h:64

Member Data Documentation

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

Definition at line 24 of file HIBestVertexProducer.h.

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

Definition at line 22 of file HIBestVertexProducer.h.

edm::ParameterSet HIBestVertexProducer::theConfig
private

Definition at line 21 of file HIBestVertexProducer.h.

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

Definition at line 23 of file HIBestVertexProducer.h.