From 442eda9fdbe4a714784ed1b20116a7392133adf1 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 21 Oct 2024 14:36:29 +0200 Subject: [PATCH] Update plots for sim and reco vertex densities and multiplicity --- .../plugins/Primary4DVertexHarvester.cc | 45 +++++++++++++------ .../plugins/Primary4DVertexValidation.cc | 39 +++++----------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/Validation/MtdValidation/plugins/Primary4DVertexHarvester.cc b/Validation/MtdValidation/plugins/Primary4DVertexHarvester.cc index 298ffd0802015..df6d2c3046e00 100644 --- a/Validation/MtdValidation/plugins/Primary4DVertexHarvester.cc +++ b/Validation/MtdValidation/plugins/Primary4DVertexHarvester.cc @@ -22,6 +22,7 @@ class Primary4DVertexHarvester : public DQMEDHarvester { private: void computeEfficiency1D(MonitorElement* num, MonitorElement* den, MonitorElement* result); + void scaleby(MonitorElement* h, double scale); void incrementME(MonitorElement* base, MonitorElement* toBeAdded); @@ -111,6 +112,17 @@ void Primary4DVertexHarvester::computeEfficiency1D(MonitorElement* num, MonitorE } } +void Primary4DVertexHarvester::scaleby(MonitorElement* h, double scale) { + double ent = h->getEntries(); + for (int ibin = 1; ibin <= h->getNbinsX(); ibin++) { + double eff = h->getBinContent(ibin) * scale; + double bin_err = h->getBinError(ibin) * scale; + h->setBinContent(ibin, eff); + h->setBinError(ibin, bin_err); + } + h->setEntries(ent); +} + // auxiliary method to add 1D MonitorElement toBeAdded to a base ME void Primary4DVertexHarvester::incrementME(MonitorElement* base, MonitorElement* toBeAdded) { for (int ibin = 1; ibin <= base->getNbinsX(); ibin++) { @@ -130,27 +142,32 @@ void Primary4DVertexHarvester::dqmEndJob(DQMStore::IBooker& ibook, DQMStore::IGe MonitorElement* meTrackEffEtaTot = igetter.get(folder_ + "EffEtaTot"); MonitorElement* meTrackMatchedTPEffEtaTot = igetter.get(folder_ + "MatchedTPEffEtaTot"); MonitorElement* meTrackMatchedTPEffEtaMtd = igetter.get(folder_ + "MatchedTPEffEtaMtd"); - MonitorElement* meRecoVtxVsLineDensity = igetter.get(folder_ + "RecoVtxVsLineDensity"); MonitorElement* meRecVerNumber = igetter.get(folder_ + "RecVerNumber"); + MonitorElement* meRecVerZ = igetter.get(folder_ + "recPVZ"); + MonitorElement* meRecVerT = igetter.get(folder_ + "recPVT"); + MonitorElement* meSimVerNumber = igetter.get(folder_ + "SimVerNumber"); + MonitorElement* meSimVerZ = igetter.get(folder_ + "simPVZ"); + MonitorElement* meSimVerT = igetter.get(folder_ + "simPVT"); if (!meTrackEffPtTot || !meTrackMatchedTPEffPtTot || !meTrackMatchedTPEffPtMtd || !meTrackEffEtaTot || - !meTrackMatchedTPEffEtaTot || !meTrackMatchedTPEffEtaMtd || !meRecoVtxVsLineDensity || !meRecVerNumber) { + !meTrackMatchedTPEffEtaTot || !meTrackMatchedTPEffEtaMtd || !meRecVerNumber || !meRecVerZ || !meRecVerT || + !meSimVerNumber || !meSimVerZ || !meSimVerT) { edm::LogError("Primary4DVertexHarvester") << "Monitoring histograms not found!" << std::endl; return; } - // Normalize line density plot - double nEvt = meRecVerNumber->getEntries(); - if (nEvt > 0.) { - nEvt = 1. / nEvt; - double nEntries = meRecoVtxVsLineDensity->getEntries(); - for (int ibin = 1; ibin <= meRecoVtxVsLineDensity->getNbinsX(); ibin++) { - double cont = meRecoVtxVsLineDensity->getBinContent(ibin) * nEvt; - double bin_err = meRecoVtxVsLineDensity->getBinError(ibin) * nEvt; - meRecoVtxVsLineDensity->setBinContent(ibin, cont); - meRecoVtxVsLineDensity->setBinError(ibin, bin_err); - } - meRecoVtxVsLineDensity->setEntries(nEntries); + // Normalize z,time multiplicty plots to get correct line densities + double scale = meRecVerNumber->getTH1F()->Integral(); + scale = (scale > 0.) ? 1. / scale : 0.; + if (scale > 0.) { + scaleby(meRecVerZ, scale); + scaleby(meRecVerT, scale); + } + scale = meSimVerNumber->getTH1F()->Integral(); + scale = (scale > 0.) ? 1. / scale : 0.; + if (scale > 0.) { + scaleby(meSimVerZ, scale); + scaleby(meSimVerT, scale); } // --- Book histograms diff --git a/Validation/MtdValidation/plugins/Primary4DVertexValidation.cc b/Validation/MtdValidation/plugins/Primary4DVertexValidation.cc index c9224fe918547..0db1297687b52 100644 --- a/Validation/MtdValidation/plugins/Primary4DVertexValidation.cc +++ b/Validation/MtdValidation/plugins/Primary4DVertexValidation.cc @@ -293,7 +293,6 @@ class Primary4DVertexValidation : public DQMEDAnalyzer { const double minProbHeavy_; const double trackweightTh_; const double mvaTh_; - const std::vector lineDensityPar_; const reco::RecoToSimCollection* r2s_; const reco::SimToRecoCollection* s2r_; @@ -371,7 +370,9 @@ class Primary4DVertexValidation : public DQMEDAnalyzer { MonitorElement* meRecVerNumber_; MonitorElement* meRecPVZ_; MonitorElement* meRecPVT_; + MonitorElement* meSimVerNumber_; MonitorElement* meSimPVZ_; + MonitorElement* meSimPVT_; MonitorElement* meVtxTrackMult_; MonitorElement* meVtxTrackW_; @@ -528,7 +529,6 @@ Primary4DVertexValidation::Primary4DVertexValidation(const edm::ParameterSet& iC minProbHeavy_(iConfig.getParameter("minProbHeavy")), trackweightTh_(iConfig.getParameter("trackweightTh")), mvaTh_(iConfig.getParameter("mvaTh")), - lineDensityPar_(iConfig.getParameter>("lineDensityPar")), pdtToken_(esConsumes()) { vecPileupSummaryInfoToken_ = consumes>(edm::InputTag(std::string("addPileupInfo"))); trackingParticleCollectionToken_ = @@ -696,12 +696,12 @@ void Primary4DVertexValidation::bookHistograms(DQMStore::IBooker& ibook, 20, 0, 20); - meRecoVtxVsLineDensity_ = - ibook.book1D("RecoVtxVsLineDensity", "#Reco vertices/mm/event; line density [#vtx/mm/event]", 160, 0., 4.); meRecVerNumber_ = ibook.book1D("RecVerNumber", "RECO Vertex Number: Number of vertices", 50, 0, 250); - meRecPVZ_ = ibook.book1D("recPVZ", "Weighted #Rec vertices/mm", 400, -20., 20.); + meSimVerNumber_ = ibook.book1D("SimVerNumber", "SIM Vertex Number: Number of vertices", 50, 0, 250); + meRecPVZ_ = ibook.book1D("recPVZ", "#Rec vertices/mm", 400, -20., 20.); meRecPVT_ = ibook.book1D("recPVT", "#Rec vertices/10 ps", 200, -1., 1.); - meSimPVZ_ = ibook.book1D("simPVZ", "Weighted #Sim vertices/mm", 400, -20., 20.); + meSimPVZ_ = ibook.book1D("simPVZ", "#Sim vertices/mm", 400, -20., 20.); + meSimPVT_ = ibook.book1D("simPVT", "#Sim vertices/10 ps", 200, -1., 1.); meVtxTrackMult_ = ibook.book1D("VtxTrackMult", "Log10(Vertex track multiplicity)", 80, 0.5, 2.5); meVtxTrackW_ = ibook.book1D("VtxTrackW", "Vertex track weight (all)", 50, 0., 1.); @@ -2599,23 +2599,14 @@ void Primary4DVertexValidation::analyze(const edm::Event& iEvent, const edm::Eve int other_fake = 0; int split = 0; - auto puLineDensity = [&](double z) { - // gaussian parameterization of line density vs z, z in cm, parameters in mm - double argl = (z * 10. - lineDensityPar_[1]) / lineDensityPar_[2]; - return lineDensityPar_[0] * exp(-0.5 * argl * argl); - }; - meRecVerNumber_->Fill(recopv.size()); for (unsigned int ir = 0; ir < recopv.size(); ir++) { if (recopv.at(ir).ndof > selNdof_) { - meRecoVtxVsLineDensity_->Fill(puLineDensity(recopv.at(ir).z)); - meRecPVZ_->Fill(recopv.at(ir).z, 1. / puLineDensity(recopv.at(ir).z)); + meRecPVZ_->Fill(recopv.at(ir).z); if (recopv.at(ir).recVtx->tError() > 0.) { meRecPVT_->Fill(recopv.at(ir).recVtx->t()); } LogTrace("Primary4DVertexValidation") << "************* IR: " << ir; - LogTrace("Primary4DVertexValidation") - << "z: " << recopv.at(ir).z << " corresponding to line density: " << puLineDensity(recopv.at(ir).z); LogTrace("Primary4DVertexValidation") << "is_real: " << recopv.at(ir).is_real(); LogTrace("Primary4DVertexValidation") << "is_fake: " << recopv.at(ir).is_fake(); LogTrace("Primary4DVertexValidation") << "is_signal: " << recopv.at(ir).is_signal(); @@ -2646,12 +2637,10 @@ void Primary4DVertexValidation::analyze(const edm::Event& iEvent, const edm::Eve mePUvsSplitV_->Fill(simpv.size(), split); // fill vertices histograms here in a new loop + meSimVerNumber_->Fill(simpv.size()); for (unsigned int is = 0; is < simpv.size(); is++) { - // protect against particle guns with very displaced vertices - if (edm::isNotFinite(1. / puLineDensity(simpv.at(is).z))) { - continue; - } - meSimPVZ_->Fill(simpv.at(is).z, 1. / puLineDensity(simpv.at(is).z)); + meSimPVZ_->Fill(simpv.at(is).z); + meSimPVT_->Fill(simpv.at(is).t * simUnit_); if (is == 0 && optionalPlots_) { meSimPosInSimOrigCollection_->Fill(simpv.at(is).OriginalIndex); } @@ -2788,14 +2777,6 @@ void Primary4DVertexValidation::fillDescriptions(edm::ConfigurationDescriptions& desc.add("trackweightTh", 0.5); desc.add("mvaTh", 0.8); desc.add("minProbHeavy", 0.75); - - //lineDensity parameters have been obtained by fitting the distribution of the z position of the vertices, - //using a 200k single mu ptGun sample (gaussian fit) - std::vector lDP; - lDP.push_back(1.87); - lDP.push_back(0.); - lDP.push_back(42.5); - desc.add>("lineDensityPar", lDP); descriptions.add("vertices4DValid", desc); }