CMS 3D CMS Logo

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::BeamSpottoken_BeamSpot
 
const edm::EDGetTokenT< reco::TrackCollectiontoken_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::PixelVertexProducer ( const edm::ParameterSet conf)
explicit

Definition at line 62 of file PixelVertexProducer.cc.

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

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";
109  track_pt_max,
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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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
Log< level::Info, false > LogInfo
DivisiveVertexFinder * dvf_

◆ ~PixelVertexProducer()

PixelVertexProducer::~PixelVertexProducer ( )
override

Definition at line 123 of file PixelVertexProducer.cc.

References dvf_.

123 { delete dvf_; }
DivisiveVertexFinder * dvf_

Member Function Documentation

◆ produce()

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

Definition at line 125 of file PixelVertexProducer.cc.

References cms::cuda::bs, hltPixelTracks_cff::chi2, dvf_, MillePedeFileConverter_cfg::e, relativeConstraints::error, DivisiveVertexFinder::findVertexes(), DivisiveVertexFinder::findVertexesAlt(), mps_fire::i, edm::HandleBase::isValid(), method2, eostools::move(), ndof, convertSQLiteXML::ok, DiDispStaMuonMonitor_cfi::pt, ptMin_, mathSSE::sqrt(), token_BeamSpot, token_Tracks, JetHT_cfg::trackCollection, trackCollName, pwdgSkimBPark_cfi::tracks, hltEgammaHLTExtra_cfi::trks, findQualityFiles::v, verbose_, jetsAK4_CHS_cff::vertexes, x, reco::BeamSpot::x0(), y, reco::BeamSpot::y0(), and z.

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 
202  GlobalError bse(bs.rotatedCovariance3D());
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 }
const edm::EDGetTokenT< reco::TrackCollection > token_Tracks
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
const edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
double x0() const
x coordinate
Definition: BeamSpot.h:61
T sqrt(T t)
Definition: SSEVec.h:19
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
double y0() const
y coordinate
Definition: BeamSpot.h:63
bool findVertexes(const reco::TrackRefVector &trks, reco::VertexCollection &vertexes)
Run the divisive algorithm and return a vector of vertexes for the input track collection.
trackCollection
Definition: JetHT_cfg.py:51
Log< level::Info, false > LogInfo
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool isValid() const
Definition: HandleBase.h:70
DivisiveVertexFinder * dvf_
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ dvf_

DivisiveVertexFinder* PixelVertexProducer::dvf_
private

Definition at line 59 of file PixelVertexProducer.cc.

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

◆ method2

const bool PixelVertexProducer::method2
private

Definition at line 54 of file PixelVertexProducer.cc.

Referenced by produce().

◆ ptMin_

const double PixelVertexProducer::ptMin_
private

Definition at line 53 of file PixelVertexProducer.cc.

Referenced by PixelVertexProducer(), and produce().

◆ token_BeamSpot

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

Definition at line 57 of file PixelVertexProducer.cc.

Referenced by produce().

◆ token_Tracks

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

Definition at line 56 of file PixelVertexProducer.cc.

Referenced by produce().

◆ trackCollName

const edm::InputTag PixelVertexProducer::trackCollName
private

Definition at line 55 of file PixelVertexProducer.cc.

Referenced by produce().

◆ verbose_

const int PixelVertexProducer::verbose_
private

Definition at line 51 of file PixelVertexProducer.cc.

Referenced by PixelVertexProducer(), and produce().