CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
PixelVertexProducer Class Reference
Inheritance diagram for PixelVertexProducer:
edm::stream::EDProducer<>

Public Member Functions

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

Private Attributes

DivisiveVertexFinderdvf_
 
const bool method2
 
const double ptMin_
 
const edm::EDGetTokenT
< reco::BeamSpot
token_BeamSpot
 
const edm::EDGetTokenT
< reco::TrackCollection
token_Tracks
 
const edm::InputTag trackCollName
 
const int verbose_
 

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

Description: This produces 1D (z only) primary vertexes using only pixel information.

Implementation: This producer can use either the Divisive Primary Vertex Finder or the Histogramming Primary Vertex Finder (currently not implemented). It relies on the PixelTripletProducer and PixelTrackProducer having already been run upstream. This is code ported from ORCA originally written by S Cucciarelli, M Konecki, D Kotlinski.

Definition at line 41 of file PixelVertexProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 62 of file PixelVertexProducer.cc.

References dvf_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ptMin_, AlCaHLTBitMon_QueryRunRegistry::string, HLT_FULL_cff::track_chi2_max, HLT_FULL_cff::track_prob_min, HLT_FULL_cff::track_pt_max, HLT_FULL_cff::track_pt_min, and verbose_.

64  : verbose_(conf.getParameter<int>("Verbosity")),
65  // 1.0 GeV
66  ptMin_(conf.getParameter<double>("PtMin")),
67  method2(conf.getParameter<bool>("Method2")),
68  trackCollName(conf.getParameter<edm::InputTag>("TrackCollection")),
69  token_Tracks(consumes<reco::TrackCollection>(trackCollName)),
70  token_BeamSpot(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("beamSpot"))) {
71  // Register my product
72  produces<reco::VertexCollection>();
73 
74  // Setup shop
75  std::string finder = conf.getParameter<std::string>("Finder"); // DivisiveVertexFinder
76  bool useError = conf.getParameter<bool>("UseError"); // true
77  bool wtAverage = conf.getParameter<bool>("WtAverage"); // true
78  double zOffset = conf.getParameter<double>("ZOffset"); // 5.0 sigma
79  double zSeparation = conf.getParameter<double>("ZSeparation"); // 0.05 cm
80  int ntrkMin = conf.getParameter<int>("NTrkMin"); // 3
81  // Tracking requirements before sending a track to be considered for vtx
82 
83  double track_pt_min = ptMin_;
84  double track_pt_max = 10.;
85  double track_chi2_max = 9999999.;
86  double track_prob_min = -1.;
87 
88  if (conf.exists("PVcomparer")) {
89  edm::ParameterSet PVcomparerPSet = conf.getParameter<edm::ParameterSet>("PVcomparer");
90  track_pt_min = PVcomparerPSet.getParameter<double>("track_pt_min");
91  if (track_pt_min != ptMin_) {
92  if (track_pt_min < ptMin_)
93  edm::LogInfo("PixelVertexProducer")
94  << "minimum track pT setting differs between PixelVertexProducer (" << ptMin_ << ") and PVcomparer ("
95  << track_pt_min << ") [PVcomparer considers tracks w/ lower threshold than PixelVertexProducer does] !!!";
96  else
97  edm::LogInfo("PixelVertexProducer") << "minimum track pT setting differs between PixelVertexProducer ("
98  << ptMin_ << ") and PVcomparer (" << track_pt_min << ") !!!";
99  }
100  track_pt_max = PVcomparerPSet.getParameter<double>("track_pt_max");
101  track_chi2_max = PVcomparerPSet.getParameter<double>("track_chi2_max");
102  track_prob_min = PVcomparerPSet.getParameter<double>("track_prob_min");
103  }
104 
105  if (finder == "DivisiveVertexFinder") {
106  if (verbose_ > 0)
107  edm::LogInfo("PixelVertexProducer") << ": Using the DivisiveVertexFinder\n";
108  dvf_ = new DivisiveVertexFinder(track_pt_min,
109  track_pt_max,
110  track_chi2_max,
111  track_prob_min,
112  zOffset,
113  ntrkMin,
114  useError,
115  zSeparation,
116  wtAverage,
117  verbose_);
118  } else { // Finder not supported, or you made a mistake in your request
119  // throw an exception once I figure out how CMSSW does this
120  }
121 }
const edm::EDGetTokenT< reco::TrackCollection > token_Tracks
bool exists(std::string const &parameterName) const
checks if a parameter exists
const edm::InputTag trackCollName
const edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
tuple track_chi2_max
tuple track_pt_min
Log< level::Info, false > LogInfo
tuple track_prob_min
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DivisiveVertexFinder * dvf_
tuple track_pt_max
PixelVertexProducer::~PixelVertexProducer ( )
override

Definition at line 123 of file PixelVertexProducer.cc.

References dvf_.

123 { delete dvf_; }
DivisiveVertexFinder * dvf_

Member Function Documentation

void PixelVertexProducer::produce ( edm::Event e,
const edm::EventSetup es 
)
override

Definition at line 125 of file PixelVertexProducer.cc.

References reco::Vertex::add(), cms::cuda::bs, HLT_FULL_cff::chi2, dvf_, reco::BeamSpot::dxdz(), reco::BeamSpot::dydz(), relativeConstraints::error, DivisiveVertexFinder::findVertexes(), DivisiveVertexFinder::findVertexesAlt(), edm::Event::getByToken(), mps_fire::i, edm::HandleBase::isValid(), method2, eostools::move(), ndof, convertSQLiteXML::ok, reco::BeamSpot::position(), edm::Handle< T >::product(), DiDispStaMuonMonitor_cfi::pt, ptMin_, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), reco::BeamSpot::rotatedCovariance3D(), edm::RefVector< C, T, F >::size(), mathSSE::sqrt(), token_BeamSpot, token_Tracks, HLT_FULL_cff::trackCollection, trackCollName, tracks, findQualityFiles::v, verbose_, x, reco::BeamSpot::x0(), y, reco::BeamSpot::y0(), z, and reco::BeamSpot::z0().

125  {
126  // First fish the pixel tracks out of the event
128  e.getByToken(token_Tracks, trackCollection);
129  const reco::TrackCollection tracks = *(trackCollection.product());
130  if (verbose_ > 0)
131  edm::LogInfo("PixelVertexProducer") << ": Found " << tracks.size() << " tracks in TrackCollection called "
132  << trackCollName << "\n";
133 
134  // Second, make a collection of pointers to the tracks we want for the vertex finder
136  for (unsigned int i = 0; i < tracks.size(); i++) {
137  if (tracks[i].pt() > ptMin_)
138  trks.push_back(reco::TrackRef(trackCollection, i));
139  }
140  if (verbose_ > 0)
141  edm::LogInfo("PixelVertexProducer") << ": Selected " << trks.size() << " of these tracks for vertexing\n";
142 
144  e.getByToken(token_BeamSpot, bsHandle);
145  math::XYZPoint myPoint(0., 0., 0.);
146  if (bsHandle.isValid())
147  //FIXME: fix last coordinate with vertex.z() at same time
148  myPoint = math::XYZPoint(bsHandle->x0(), bsHandle->y0(), 0.);
149 
150  // Third, ship these tracks off to be vertexed
151  auto vertexes = std::make_unique<reco::VertexCollection>();
152  bool ok;
153  if (method2) {
154  ok = dvf_->findVertexesAlt(trks, // input
155  *vertexes,
156  myPoint); // output
157  if (verbose_ > 0)
158  edm::LogInfo("PixelVertexProducer") << "Method2 returned status of " << ok;
159  } else {
160  ok = dvf_->findVertexes(trks, // input
161  *vertexes); // output
162  if (verbose_ > 0)
163  edm::LogInfo("PixelVertexProducer") << "Method1 returned status of " << ok;
164  }
165 
166  if (verbose_ > 0) {
167  edm::LogInfo("PixelVertexProducer") << ": Found " << vertexes->size() << " vertexes\n";
168  for (unsigned int i = 0; i < vertexes->size(); ++i) {
169  edm::LogInfo("PixelVertexProducer")
170  << "Vertex number " << i << " has " << (*vertexes)[i].tracksSize() << " tracks with a position of "
171  << (*vertexes)[i].z() << " +- " << std::sqrt((*vertexes)[i].covariance(2, 2));
172  }
173  }
174 
175  if (bsHandle.isValid()) {
176  const reco::BeamSpot& bs = *bsHandle;
177 
178  for (unsigned int i = 0; i < vertexes->size(); ++i) {
179  double z = (*vertexes)[i].z();
180  double x = bs.x0() + bs.dxdz() * (z - bs.z0());
181  double y = bs.y0() + bs.dydz() * (z - bs.z0());
183  (*vertexes)[i].error(),
184  (*vertexes)[i].chi2(),
185  (*vertexes)[i].ndof(),
186  (*vertexes)[i].tracksSize());
187  //Copy also the tracks
188  for (std::vector<reco::TrackBaseRef>::const_iterator it = (*vertexes)[i].tracks_begin();
189  it != (*vertexes)[i].tracks_end();
190  it++) {
191  v.add(*it);
192  }
193  (*vertexes)[i] = v;
194  }
195  } else {
196  edm::LogWarning("PixelVertexProducer") << "No beamspot found. Using returning vertexes with (0,0,Z) ";
197  }
198 
199  if (vertexes->empty() && bsHandle.isValid()) {
200  const reco::BeamSpot& bs = *bsHandle;
201 
203  if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
205  we(0, 0) = 10000;
206  we(1, 1) = 10000;
207  we(2, 2) = 10000;
208  vertexes->push_back(reco::Vertex(bs.position(), we, 0., 0., 0));
209 
210  edm::LogInfo("PixelVertexProducer")
211  << "No vertices found. Beamspot with invalid errors " << bse.matrix() << std::endl
212  << "Will put Vertex derived from dummy-fake BeamSpot into Event.\n"
213  << (*vertexes)[0].x() << "\n"
214  << (*vertexes)[0].y() << "\n"
215  << (*vertexes)[0].z() << "\n";
216  } else {
217  vertexes->push_back(reco::Vertex(bs.position(), bs.rotatedCovariance3D(), 0., 0., 0));
218 
219  edm::LogInfo("PixelVertexProducer") << "No vertices found. Will put Vertex derived from BeamSpot into Event:\n"
220  << (*vertexes)[0].x() << "\n"
221  << (*vertexes)[0].y() << "\n"
222  << (*vertexes)[0].z() << "\n";
223  }
224  }
225 
226  else if (vertexes->empty() && !bsHandle.isValid()) {
227  edm::LogWarning("PixelVertexProducer") << "No beamspot and no vertex found. No vertex returned.";
228  }
229 
230  e.put(std::move(vertexes));
231 }
double z0() const
z coordinate
Definition: BeamSpot.h:65
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< reco::TrackCollection > token_Tracks
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool findVertexesAlt(const reco::TrackRefVector &trks, reco::VertexCollection &vertexes, const math::XYZPoint &bs)
const edm::InputTag trackCollName
auto const & tracks
cannot be loose
const edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
double dydz() const
dydz slope
Definition: BeamSpot.h:80
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
bool findVertexes(const reco::TrackRefVector &trks, reco::VertexCollection &vertexes)
Run the divisive algorithm and return a vector of vertexes for the input track collection.
bool isValid() const
Definition: HandleBase.h:70
double dxdz() const
dxdz slope
Definition: BeamSpot.h:78
Log< level::Info, false > LogInfo
tuple trackCollection
T const * product() const
Definition: Handle.h:70
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
DivisiveVertexFinder * dvf_
double y0() const
y coordinate
Definition: BeamSpot.h:63
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:67
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
const Point & position() const
position
Definition: BeamSpot.h:59
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:73
Log< level::Warning, false > LogWarning
double x0() const
x coordinate
Definition: BeamSpot.h:61

Member Data Documentation

DivisiveVertexFinder* PixelVertexProducer::dvf_
private

Definition at line 59 of file PixelVertexProducer.cc.

Referenced by PixelVertexProducer(), produce(), and ~PixelVertexProducer().

const bool PixelVertexProducer::method2
private

Definition at line 54 of file PixelVertexProducer.cc.

Referenced by produce().

const double PixelVertexProducer::ptMin_
private

Definition at line 53 of file PixelVertexProducer.cc.

Referenced by PixelVertexProducer(), and produce().

const edm::EDGetTokenT<reco::BeamSpot> PixelVertexProducer::token_BeamSpot
private

Definition at line 57 of file PixelVertexProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::TrackCollection> PixelVertexProducer::token_Tracks
private

Definition at line 56 of file PixelVertexProducer.cc.

Referenced by produce().

const edm::InputTag PixelVertexProducer::trackCollName
private

Definition at line 55 of file PixelVertexProducer.cc.

Referenced by produce().

const int PixelVertexProducer::verbose_
private

Definition at line 51 of file PixelVertexProducer.cc.

Referenced by PixelVertexProducer(), and produce().