CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PrimaryVertexResolution Class Reference
Inheritance diagram for PrimaryVertexResolution:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Classes

struct  BinningX
 
struct  BinningY
 
class  DiffPlots
 
class  Plots
 
class  Resolution
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
 PrimaryVertexResolution (const edm::ParameterSet &iConfig)
 
 ~PrimaryVertexResolution () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::vector< reco::TransientTracksortTracksByPt (const reco::Vertex &thePV, const TransientTrackBuilder &ttBuilder, const reco::BeamSpot &beamspot)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamspotSrc_
 
BinningX binningX_
 
BinningY binningY_
 
std::mt19937 engine_
 
AdaptiveVertexFitter fitter_
 
Plots hOtherV_
 
Plots hPV_
 
edm::EDGetTokenT< LumiScalersCollectionlumiScalersSrc_
 
std::string rootFolder_
 
std::string transientTrackBuilder_
 
edm::EDGetTokenT< reco::VertexCollectionvertexSrc_
 

Detailed Description

Definition at line 47 of file PrimaryVertexResolution.cc.

Constructor & Destructor Documentation

PrimaryVertexResolution::PrimaryVertexResolution ( const edm::ParameterSet iConfig)

Definition at line 274 of file PrimaryVertexResolution.cc.

274  :
275  vertexSrc_(consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertexSrc"))),
276  beamspotSrc_(consumes<reco::BeamSpot>(iConfig.getUntrackedParameter<edm::InputTag>("beamspotSrc"))),
277  lumiScalersSrc_(consumes<LumiScalersCollection>(iConfig.getUntrackedParameter<edm::InputTag>("lumiScalersSrc"))),
278  rootFolder_(iConfig.getUntrackedParameter<std::string>("rootFolder")),
279  transientTrackBuilder_(iConfig.getUntrackedParameter<std::string>("transientTrackBuilder")),
280  binningX_(iConfig),
281  binningY_(iConfig),
284 {}
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > lumiScalersSrc_
edm::EDGetTokenT< reco::VertexCollection > vertexSrc_
edm::EDGetTokenT< reco::BeamSpot > beamspotSrc_
PrimaryVertexResolution::~PrimaryVertexResolution ( )
override

Definition at line 286 of file PrimaryVertexResolution.cc.

286 {}

Member Function Documentation

void PrimaryVertexResolution::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 329 of file PrimaryVertexResolution.cc.

References beamspotSrc_, PrimaryVertexResolution::Plots::calculateAndFillResolution(), engine_, edm::EventID::event(), fitter_, edm::EventSetup::get(), edm::Event::getByToken(), hOtherV_, hPV_, edm::EventBase::id(), edm::EventID::luminosityBlock(), lumiScalersSrc_, edm::EventID::run(), reco::Vertex::size, sortTracksByPt(), reco::Vertex::tracksSize(), transientTrackBuilder_, vertexSrc_, and electrons_cff::vertices.

329  {
331  iEvent.getByToken(vertexSrc_, hvertices);
332  const reco::VertexCollection& vertices = *hvertices;
333  if(vertices.empty())
334  return;
335 
336  edm::Handle<reco::BeamSpot> hbeamspot;
337  iEvent.getByToken(beamspotSrc_, hbeamspot);
338  const reco::BeamSpot& beamspot = *hbeamspot;
339 
341  iEvent.getByToken(lumiScalersSrc_, hscalers);
342  const LumiScalersCollection& lumiScalers = *hscalers;
343 
344  edm::ESHandle<TransientTrackBuilder> ttBuilderHandle;
345  iSetup.get<TransientTrackRecord>().get(transientTrackBuilder_, ttBuilderHandle);
346  const TransientTrackBuilder& ttBuilder = *ttBuilderHandle;
347 
348  // deterministic seed from the event number
349  // should not bias the result as the event number is already
350  // assigned randomly-enough
351  engine_.seed( iEvent.id().event() + (iEvent.id().luminosityBlock()<<10) + (iEvent.id().run()<<20) );
352 
353  // The PV
354  auto iPV = cbegin(vertices);
355  const reco::Vertex& thePV = *iPV;
356  const auto nvertices = vertices.size();
357  if(thePV.tracksSize() >= 4) {
358  auto sortedTracks = sortTracksByPt(thePV, ttBuilder, beamspot);
359  hPV_.calculateAndFillResolution(sortedTracks, nvertices, lumiScalers, engine_, fitter_);
360  }
361  ++iPV;
362 
363  // Other vertices
364  for(auto endPV = cend(vertices); iPV != endPV; ++iPV) {
365  if(iPV->tracksSize() >= 4) {
366  auto sortedTracks = sortTracksByPt(*iPV, ttBuilder, beamspot);
367  hOtherV_.calculateAndFillResolution(sortedTracks, nvertices, lumiScalers, engine_, fitter_);
368  }
369  }
370 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void calculateAndFillResolution(const std::vector< reco::TransientTrack > &tracks, size_t nvertices, const LumiScalersCollection &lumiScalers, std::mt19937 &engine, AdaptiveVertexFitter &fitter)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
edm::EDGetTokenT< LumiScalersCollection > lumiScalersSrc_
edm::EDGetTokenT< reco::VertexCollection > vertexSrc_
edm::EDGetTokenT< reco::BeamSpot > beamspotSrc_
std::vector< reco::TransientTrack > sortTracksByPt(const reco::Vertex &thePV, const TransientTrackBuilder &ttBuilder, const reco::BeamSpot &beamspot)
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:71
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
void PrimaryVertexResolution::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  ,
edm::EventSetup const &   
)
override

Definition at line 321 of file PrimaryVertexResolution.cc.

References PrimaryVertexResolution::Plots::book(), hOtherV_, hPV_, rootFolder_, and DQMStore::IBooker::setCurrentFolder().

321  {
322  iBooker.setCurrentFolder(rootFolder_+"/PV");
323  hPV_.book(iBooker);
324 
325  iBooker.setCurrentFolder(rootFolder_+"/OtherV");
326  hOtherV_.book(iBooker);
327 }
void book(DQMStore::IBooker &iBooker)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void PrimaryVertexResolution::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 288 of file PrimaryVertexResolution.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), SiPixelPhase1TrackClustersV_cfi::e3, and AlCaHLTBitMon_QueryRunRegistry::string.

288  {
290  desc.addUntracked<edm::InputTag>("vertexSrc", edm::InputTag("trackingDQMgoodOfflinePrimaryVertices"));
291  desc.addUntracked<edm::InputTag>("beamspotSrc", edm::InputTag("offlineBeamSpot"));
292  desc.addUntracked<edm::InputTag>("lumiScalersSrc", edm::InputTag("scalersRawToDigi"));
293  desc.addUntracked<std::string>("rootFolder", "OfflinePV/Resolution");
294  desc.addUntracked<std::string>("transientTrackBuilder", "TransientTrackBuilder");
295 
296  // Y axes
297  desc.addUntracked<double>("maxResol", 0.02);
298  desc.addUntracked<int>("binsResol", 100);
299 
300  desc.addUntracked<double>("maxPull", 5);
301  desc.addUntracked<int>("binsPull", 100);
302 
303  // X axes
304  desc.addUntracked<double>("minNtracks", -0.5);
305  desc.addUntracked<double>("maxNtracks", 119.5);
306  desc.addUntracked<int>("binsNtracks", 60);
307 
308  desc.addUntracked<double>("minNvertices", -0.5);
309  desc.addUntracked<double>("maxNvertices", 199.5);
310  desc.addUntracked<int>("binsNvertices", 100);
311 
312  desc.addUntracked<double>("minPt", 1);
313  desc.addUntracked<double>("maxPt", 1e3);
314 
315  desc.addUntracked<double>("minLumi", 200.);
316  desc.addUntracked<double>("maxLumi", 20000.);
317 
318  descriptions.add("primaryVertexResolution", desc);
319 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< reco::TransientTrack > PrimaryVertexResolution::sortTracksByPt ( const reco::Vertex thePV,
const TransientTrackBuilder ttBuilder,
const reco::BeamSpot beamspot 
)
private

Definition at line 372 of file PrimaryVertexResolution.cc.

References a, b, TransientTrackBuilder::build(), reco::TrackBase::pt(), HiIsolationCommonParameters_cff::track, reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), reco::Vertex::tracksSize(), create_public_lumi_plots::transform, and groupFilesInBlocks::tt.

Referenced by analyze().

374  {
375  std::vector<const reco::Track *> sortedTracks;
376  sortedTracks.reserve(thePV.tracksSize());
377  std::transform(thePV.tracks_begin(), thePV.tracks_end(), std::back_inserter(sortedTracks), [](const reco::TrackBaseRef& ref) {
378  return &(*ref);
379  });
380  std::sort(sortedTracks.begin(), sortedTracks.end(), [](const reco::Track *a, const reco::Track *b) {
381  return a->pt() > b->pt();
382  });
383 
384  std::vector<reco::TransientTrack> ttracks;
385  ttracks.reserve(sortedTracks.size());
386  std::transform(sortedTracks.begin(), sortedTracks.end(), std::back_inserter(ttracks), [&](const reco::Track *track) {
387  auto tt = ttBuilder.build(track);
388  tt.setBeamSpot(beamspot);
389  return tt;
390  });
391  return ttracks;
392 }
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
reco::TransientTrack build(const reco::Track *p) const
double pt() const
track transverse momentum
Definition: TrackBase.h:660
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> PrimaryVertexResolution::beamspotSrc_
private

Definition at line 63 of file PrimaryVertexResolution.cc.

Referenced by analyze().

BinningX PrimaryVertexResolution::binningX_
private

Definition at line 264 of file PrimaryVertexResolution.cc.

Referenced by PrimaryVertexResolution::Plots::book().

BinningY PrimaryVertexResolution::binningY_
private
std::mt19937 PrimaryVertexResolution::engine_
private

Definition at line 271 of file PrimaryVertexResolution.cc.

Referenced by analyze().

AdaptiveVertexFitter PrimaryVertexResolution::fitter_
private

Definition at line 68 of file PrimaryVertexResolution.cc.

Referenced by analyze().

Plots PrimaryVertexResolution::hOtherV_
private

Definition at line 269 of file PrimaryVertexResolution.cc.

Referenced by analyze(), and bookHistograms().

Plots PrimaryVertexResolution::hPV_
private

Definition at line 268 of file PrimaryVertexResolution.cc.

Referenced by analyze(), and bookHistograms().

edm::EDGetTokenT<LumiScalersCollection> PrimaryVertexResolution::lumiScalersSrc_
private

Definition at line 64 of file PrimaryVertexResolution.cc.

Referenced by analyze().

std::string PrimaryVertexResolution::rootFolder_
private

Definition at line 65 of file PrimaryVertexResolution.cc.

Referenced by bookHistograms().

std::string PrimaryVertexResolution::transientTrackBuilder_
private

Definition at line 66 of file PrimaryVertexResolution.cc.

Referenced by analyze().

edm::EDGetTokenT<reco::VertexCollection> PrimaryVertexResolution::vertexSrc_
private

Definition at line 62 of file PrimaryVertexResolution.cc.

Referenced by analyze().