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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 HIBestVertexProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 ~HIBestVertexProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void beginJob ()
 

Private Attributes

edm::InputTag theAdaptiveVertexCollection
 
edm::InputTag theBeamSpotTag
 
edm::ParameterSet theConfig
 
edm::InputTag theMedianVertexCollection
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 9 of file HIBestVertexProducer.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file HIBestVertexProducer.cc.

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

Definition at line 30 of file HIBestVertexProducer.cc.

31 {
32 }

Member Function Documentation

void HIBestVertexProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 35 of file HIBestVertexProducer.cc.

36 {
37 }
void HIBestVertexProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 41 of file HIBestVertexProducer.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), edm::Event::getByLabel(), 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().

42 {
43 
44  // 1. use best adaptive vertex preferentially
45  // 2. use median vertex in case where adaptive algorithm failed
46  // 3. use beamspot if netither vertexing method succeeds
47 
48  // New vertex collection
49  std::auto_ptr<reco::VertexCollection> newVertexCollection(new reco::VertexCollection);
50 
51  //** Get precise adaptive vertex **/
54  const reco::VertexCollection *vertices1 = vc1.product();
55 
56  if(vertices1->size()==0)
57  LogError("HeavyIonVertexing") << "adaptive vertex collection is empty!" << endl;
58 
59  if(vertices1->begin()->zError()<3) {
60 
61  reco::VertexCollection::const_iterator vertex1 = vertices1->begin();
62  newVertexCollection->push_back(*vertex1);
63 
64  LogInfo("HeavyIonVertexing") << "adaptive vertex:\n vz = ("
65  << vertex1->x() << ", " << vertex1->y() << ", " << vertex1->z() << ")"
66  << "\n error = ("
67  << vertex1->xError() << ", " << vertex1->yError() << ", "
68  << vertex1->zError() << ")" << endl;
69  } else {
70 
71  //** Get fast median vertex **/
74  const reco::VertexCollection * vertices2 = vc2.product();
75 
76  //** Get beam spot position and error **/
78  edm::Handle<reco::BeamSpot> beamSpotHandle;
79  ev.getByLabel(theBeamSpotTag, beamSpotHandle);
80 
81  if( beamSpotHandle.isValid() )
82  beamSpot = *beamSpotHandle;
83  else
84  LogError("HeavyIonVertexing") << "no beamspot with name: '" << theBeamSpotTag << "'" << endl;
85 
86  if(vertices2->size() > 0) {
87 
88  reco::VertexCollection::const_iterator vertex2 = vertices2->begin();
90  err(0,0)=pow(beamSpot.BeamWidthX(),2);
91  err(1,1)=pow(beamSpot.BeamWidthY(),2);
92  err(2,2)=pow(vertex2->zError(),2);
93  reco::Vertex newVertex(reco::Vertex::Point(beamSpot.x0(),beamSpot.y0(),vertex2->z()),
94  err, 0, 1, 1);
95  newVertexCollection->push_back(newVertex);
96 
97  LogInfo("HeavyIonVertexing") << "median vertex + beamspot: \n position = ("
98  << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")"
99  << "\n error = ("
100  << newVertex.xError() << ", " << newVertex.yError() << ", "
101  << newVertex.zError() << ")" << endl;
102 
103  } else {
104 
106  err(0,0)=pow(beamSpot.BeamWidthX(),2);
107  err(1,1)=pow(beamSpot.BeamWidthY(),2);
108  err(2,2)=pow(beamSpot.sigmaZ(),2);
109  reco::Vertex newVertex(beamSpot.position(),
110  err, 0, 0, 1);
111  newVertexCollection->push_back(newVertex);
112 
113  LogInfo("HeavyIonVertexing") << "beam spot: \n position = ("
114  << newVertex.x() << ", " << newVertex.y() << ", " << newVertex.z() << ")"
115  << "\n error = ("
116  << newVertex.xError() << ", " << newVertex.yError() << ", "
117  << newVertex.zError() << ")" << endl;
118 
119  }
120 
121  }
122 
123  // put new vertex collection into event
124  ev.put(newVertexCollection);
125 
126 }
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
edm::InputTag theAdaptiveVertexCollection
edm::InputTag theMedianVertexCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:87
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double sigmaZ() const
sigma z
Definition: BeamSpot.h:81
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:89
T const * product() const
Definition: Handle.h:74
double y0() const
y coordinate
Definition: BeamSpot.h:67
const Point & position() const
position
Definition: BeamSpot.h:63
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double x0() const
x coordinate
Definition: BeamSpot.h:65

Member Data Documentation

edm::InputTag HIBestVertexProducer::theAdaptiveVertexCollection
private

Definition at line 21 of file HIBestVertexProducer.h.

edm::InputTag HIBestVertexProducer::theBeamSpotTag
private

Definition at line 19 of file HIBestVertexProducer.h.

edm::ParameterSet HIBestVertexProducer::theConfig
private

Definition at line 18 of file HIBestVertexProducer.h.

edm::InputTag HIBestVertexProducer::theMedianVertexCollection
private

Definition at line 20 of file HIBestVertexProducer.h.