CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
PrimaryVertexProducer Class Reference

#include <RecoVertex/PrimaryVertexProducer/src/PrimaryVertexProducer.cc>

Inheritance diagram for PrimaryVertexProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

edm::ParameterSet config () const
 
 PrimaryVertexProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PrimaryVertexProducer ()
 
- 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 ()
 

Public Attributes

edm::InputTag beamSpotLabel
 
edm::InputTag trackLabel
 

Private Attributes

bool fVerbose
 
PrimaryVertexProducerAlgorithm theAlgo
 
edm::ParameterSet theConfig
 

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

Description: steers tracker primary vertex reconstruction and storage

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file PrimaryVertexProducer.h.

Constructor & Destructor Documentation

PrimaryVertexProducer::PrimaryVertexProducer ( const edm::ParameterSet conf)
explicit

Definition at line 30 of file PrimaryVertexProducer.cc.

References beamSpotLabel, fVerbose, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and trackLabel.

31  : theAlgo(conf), theConfig(conf)
32 {
33  edm::LogInfo("PVDebugInfo")
34  << "Initializing PV producer " << "\n";
35  fVerbose=conf.getUntrackedParameter<bool>("verbose", false);
36  trackLabel = conf.getParameter<edm::InputTag>("TrackLabel");
37  beamSpotLabel = conf.getParameter<edm::InputTag>("beamSpotLabel");
38 
39  produces<reco::VertexCollection>();
40 
41 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet theConfig
PrimaryVertexProducerAlgorithm theAlgo
PrimaryVertexProducer::~PrimaryVertexProducer ( )

Definition at line 44 of file PrimaryVertexProducer.cc.

44 {}

Member Function Documentation

edm::ParameterSet PrimaryVertexProducer::config ( void  ) const
inline

Definition at line 48 of file PrimaryVertexProducer.h.

References theConfig.

48 { return theConfig; }
edm::ParameterSet theConfig
void PrimaryVertexProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 52 of file PrimaryVertexProducer.cc.

References beamSpotLabel, gather_cfg::cout, fVerbose, edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::put(), query::result, theAlgo, trackLabel, v, and PrimaryVertexProducerAlgorithm::vertices().

53 {
54  using namespace edm;
55 
56  std::auto_ptr<reco::VertexCollection> result(new reco::VertexCollection);
58 
59  // get the BeamSpot, it will alwys be needed, even when not used as a constraint
60  reco::BeamSpot vertexBeamSpot;
61  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
62  iEvent.getByLabel(beamSpotLabel,recoBeamSpotHandle);
63  if (recoBeamSpotHandle.isValid()){
64  vertexBeamSpot = *recoBeamSpotHandle;
65  }else{
66  edm::LogError("UnusableBeamSpot") << "No beam spot available from EventSetup";
67  }
68 
69 
70 
71  // get RECO tracks from the event
72  // `tks` can be used as a ptr to a reco::TrackCollection
74  iEvent.getByLabel(trackLabel, tks);
75 
76 
77  // interface RECO tracks to vertex reconstruction
79  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
80  std::vector<reco::TransientTrack> t_tks = (*theB).build(tks, vertexBeamSpot);
81  if(fVerbose) {std::cout << "RecoVertex/PrimaryVertexProducer"
82  << "Found: " << t_tks.size() << " reconstructed tracks" << "\n";
83  }
84 
85 
86  // call vertex reconstruction
87  std::vector<TransientVertex> t_vts = theAlgo.vertices(t_tks, vertexBeamSpot);
88  if(fVerbose){
89  std::cout <<"RecoVertex/PrimaryVertexProducer: "
90  << " found " << t_vts.size() << " reconstructed vertices" << "\n";
91  }
92 
93  // convert transient vertices returned by the theAlgo to (reco) vertices
94  for (std::vector<TransientVertex>::const_iterator iv = t_vts.begin();
95  iv != t_vts.end(); iv++) {
96  reco::Vertex v = *iv;
97  vColl.push_back(v);
98  }
99 
100  if (vColl.empty()) {
101  GlobalError bse(vertexBeamSpot.rotatedCovariance3D());
102  if ( (bse.cxx() <= 0.) ||
103  (bse.cyy() <= 0.) ||
104  (bse.czz() <= 0.) ) {
106  we(0,0)=10000; we(1,1)=10000; we(2,2)=10000;
107  vColl.push_back(reco::Vertex(vertexBeamSpot.position(), we,0.,0.,0));
108  if(fVerbose){
109  std::cout <<"RecoVertex/PrimaryVertexProducer: "
110  << "Beamspot with invalid errors "<<bse.matrix()<<std::endl;
111  std::cout << "Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
112  }
113  } else {
114  vColl.push_back(reco::Vertex(vertexBeamSpot.position(),
115  vertexBeamSpot.rotatedCovariance3D(),0.,0.,0));
116  if(fVerbose){
117  std::cout <<"RecoVertex/PrimaryVertexProducer: "
118  << " will put Vertex derived from BeamSpot into Event.\n";
119  }
120  }
121  }
122 
123  if(fVerbose){
124  int ivtx=0;
125  for(reco::VertexCollection::const_iterator v=vColl.begin();
126  v!=vColl.end(); ++v){
127  std::cout << "recvtx "<< ivtx++
128  << "#trk " << std::setw(3) << v->tracksSize()
129  << " chi2 " << std::setw(4) << v->chi2()
130  << " ndof " << std::setw(3) << v->ndof()
131  << " x " << std::setw(6) << v->position().x()
132  << " dx " << std::setw(6) << v->xError()
133  << " y " << std::setw(6) << v->position().y()
134  << " dy " << std::setw(6) << v->yError()
135  << " z " << std::setw(6) << v->position().z()
136  << " dz " << std::setw(6) << v->zError()
137  << std::endl;
138  }
139  }
140 
141 
142  *result = vColl;
143  // iEvent.put(result, "PrimaryVertex");
144  iEvent.put(result);
145 
146 }
double zError() const
error on z
Definition: Vertex.h:105
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const Point & position() const
position
Definition: Vertex.h:93
virtual std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
tuple result
Definition: query.py:137
double chi2() const
chi-squares
Definition: Vertex.h:82
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
double ndof() const
Definition: Vertex.h:89
double xError() const
error on x
Definition: Vertex.h:101
const T & get() const
Definition: EventSetup.h:55
PrimaryVertexProducerAlgorithm theAlgo
tuple cout
Definition: gather_cfg.py:41
mathSSE::Vec4< T > v
double yError() const
error on y
Definition: Vertex.h:103
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:35

Member Data Documentation

edm::InputTag PrimaryVertexProducer::beamSpotLabel

Definition at line 50 of file PrimaryVertexProducer.h.

Referenced by PrimaryVertexProducer(), and produce().

bool PrimaryVertexProducer::fVerbose
private

Definition at line 58 of file PrimaryVertexProducer.h.

Referenced by PrimaryVertexProducer(), and produce().

PrimaryVertexProducerAlgorithm PrimaryVertexProducer::theAlgo
private

Definition at line 55 of file PrimaryVertexProducer.h.

Referenced by produce().

edm::ParameterSet PrimaryVertexProducer::theConfig
private

Definition at line 57 of file PrimaryVertexProducer.h.

Referenced by config().

edm::InputTag PrimaryVertexProducer::trackLabel

Definition at line 49 of file PrimaryVertexProducer.h.

Referenced by PrimaryVertexProducer(), and produce().