test
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
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void beginJob ()
 

Private Attributes

edm::EDGetTokenT
< reco::VertexCollection
theAdaptiveVertexCollection
 
edm::EDGetTokenT< reco::BeamSpottheBeamSpotTag
 
edm::ParameterSet theConfig
 
edm::EDGetTokenT
< reco::VertexCollection
theMedianVertexCollection
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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.

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

Implements edm::stream::EDProducerBase.

Definition at line 38 of file HIBestVertexProducer.cc.

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

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  std::auto_ptr<reco::VertexCollection> newVertexCollection(new 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(newVertexCollection);
122 
123 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
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.