23 #include "TProfile2D.h" 27 #include <fmt/format.h> 28 #include <fmt/printf.h> 65 template <
typename T,
typename... Args>
135 : ndof_(iConfig.getParameter<
int>(
"ndof")),
136 errorPrinted_(
false),
137 vertexInputTag_(iConfig.getParameter<
edm::
InputTag>(
"vertexLabel")),
138 beamSpotInputTag_(iConfig.getParameter<
edm::
InputTag>(
"beamSpotLabel")),
140 scoreToken_(consumes<
VertexScore>(vertexInputTag_)),
141 beamspotToken_(consumes<
reco::
BeamSpot>(beamSpotInputTag_)),
143 vposx_(iConfig.getParameter<double>(
"Xpos")),
144 vposy_(iConfig.getParameter<double>(
"Ypos")),
145 tkNoBin_(iConfig.getParameter<
int>(
"TkSizeBin")),
146 tkNoMin_(iConfig.getParameter<double>(
"TkSizeMin")),
147 tkNoMax_(iConfig.getParameter<double>(
"TkSizeMax")),
148 dxyBin_(iConfig.getParameter<
int>(
"DxyBin")),
149 dxyMin_(iConfig.getParameter<double>(
"DxyMin")),
150 dxyMax_(iConfig.getParameter<double>(
"DxyMax")),
151 dzBin_(iConfig.getParameter<
int>(
"DzBin")),
152 dzMin_(iConfig.getParameter<double>(
"DzMin")),
153 dzMax_(iConfig.getParameter<double>(
"DzMax")),
154 phiBin_(iConfig.getParameter<
int>(
"PhiBin")),
155 phiBin2D_(iConfig.getParameter<
int>(
"PhiBin2D")),
156 phiMin_(iConfig.getParameter<double>(
"PhiMin")),
157 phiMax_(iConfig.getParameter<double>(
"PhiMax")),
158 etaBin_(iConfig.getParameter<
int>(
"EtaBin")),
159 etaBin2D_(iConfig.getParameter<
int>(
"EtaBin2D")),
160 etaMin_(iConfig.getParameter<double>(
"EtaMin")),
161 etaMax_(iConfig.getParameter<double>(
"EtaMax")),
170 bsBeamWidthX(nullptr),
171 bsBeamWidthY(nullptr),
187 dxyVsPhi_pt1(nullptr),
188 dzVsPhi_pt1(nullptr),
189 dxyVsEta_pt1(nullptr),
190 dzVsEta_pt1(nullptr),
191 dxyVsEtaVsPhi_pt1(nullptr),
192 dzVsEtaVsPhi_pt1(nullptr),
193 dxyVsPhi_pt10(nullptr),
194 dzVsPhi_pt10(nullptr),
195 dxyVsEta_pt10(nullptr),
196 dzVsEta_pt10(nullptr),
197 dxyVsEtaVsPhi_pt10(nullptr),
198 dzVsEtaVsPhi_pt10(nullptr) {
216 if (recVtxs.isValid() ==
false || beamSpotHandle.isValid() ==
false) {
218 <<
" Some products not available in the event: VertexCollection " <<
vertexInputTag_ <<
" " << recVtxs.isValid()
219 <<
" BeamSpot " <<
beamSpotInputTag_ <<
" " << beamSpotHandle.isValid() <<
". Skipping plots for this event";
225 for (
const auto &
v : *recVtxs) {
226 if (
v.tracksSize() > 0) {
227 const auto &ref =
v.trackRefAt(0);
228 if (ref.isNull() || !ref.isAvailable()) {
232 <<
" since likely the track collection the vertex has refs pointing to is missing (at least the first " 233 "TrackBaseRef is null or not available)";
246 nbvtx->Fill(recVtxs->size());
248 for (
auto const &vx : (*recVtxs)) {
249 if (vx.isValid() && !vx.isFake() && vx.ndof() >=
ndof_) {
255 if (scores.isValid() && !(*scores).empty()) {
256 auto pvScore = (*scores).get(0);
258 for (
unsigned int i = 1;
i < (*scores).size(); ++
i) {
264 if (!recVtxs->empty()) {
268 for (reco::VertexCollection::const_iterator
v = recVtxs->begin() + 1;
v != recVtxs->end(); ++
v) {
291 if (
v.tracksSize() == 0) {
296 const math::XYZPoint myVertex(
v.position().x(),
v.position().y(),
v.position().z());
299 for (
const auto &
t :
v.tracks()) {
305 const float pt =
t->pt();
311 const float eta =
t->eta();
312 const float phi =
t->phi();
313 const float w =
v.trackWeight(
t);
314 const float chi2NDF =
t->normalizedChi2();
315 const float chi2Prob = TMath::Prob(
t->chi2(),
static_cast<int>(
t->ndof()));
316 const float Dxy =
t->dxy(myVertex) *
cmToUm;
317 const float Dz =
t->dz(myVertex) *
cmToUm;
318 const float DxyErr =
t->dxyError() *
cmToUm;
319 const float DzErr =
t->dzError() *
cmToUm;
352 ntracks->Fill(static_cast<float>(
v.tracks().size()));
366 if (
v.isValid() && !
v.isFake()) {
378 xrec[
i]->Fill(
v.position().x());
379 yrec[
i]->Fill(
v.position().y());
380 zrec[
i]->Fill(
v.position().z());
399 for (
int k = 0;
k != 3;
k++) {
400 for (
int j =
k;
j != 3;
j++) {
404 if (
j ==
k &&
v.covariance(
k,
j) < 0) {
412 template <
typename T,
typename...
Args>
420 nbvtx = book<TH1I>(
"vtxNbr",
"Reconstructed Vertices in Event", 80, -0.5, 79.5);
421 nbgvtx = book<TH1I>(
"goodvtxNbr",
"Reconstructed Good Vertices in Event", 80, -0.5, 79.5);
423 nbtksinvtx[0] = book<TH1D>(
"otherVtxTrksNbr",
"Reconstructed Tracks in Vertex (other Vtx)", 40, -0.5, 99.5);
425 book<TProfile>(
"otherVtxTrksVsZ",
"Reconstructed Tracks in Vertex (other Vtx) vs Z", 80, -20., 20., 0., 100.,
"");
429 score[0] = book<TH1D>(
"otherVtxScore",
"sqrt(score) (other Vtx)", 100, 0., 400.);
430 trksWeight[0] = book<TH1D>(
"otherVtxTrksWeight",
"Total weight of Tracks in Vertex (other Vtx)", 40, 0, 100.);
431 vtxchi2[0] = book<TH1D>(
"otherVtxChi2",
"#chi^{2} (other Vtx)", 100, 0., 200.);
432 vtxndf[0] = book<TH1D>(
"otherVtxNdf",
"ndof (other Vtx)", 100, 0., 200.);
433 vtxprob[0] = book<TH1D>(
"otherVtxProb",
"#chi^{2} probability (other Vtx)", 100, 0., 1.);
434 nans[0] = book<TH1D>(
"otherVtxNans",
"Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (other Vtx)", 9, 0.5, 9.5);
436 nbtksinvtx[1] = book<TH1D>(
"tagVtxTrksNbr",
"Reconstructed Tracks in Vertex (tagged Vtx)", 100, -0.5, 99.5);
438 book<TProfile>(
"tagVtxTrksVsZ",
"Reconstructed Tracks in Vertex (tagged Vtx) vs Z", 80, -20., 20., 0., 100.,
"");
442 score[1] = book<TH1D>(
"tagVtxScore",
"sqrt(score) (tagged Vtx)", 100, 0., 400.);
443 trksWeight[1] = book<TH1D>(
"tagVtxTrksWeight",
"Total weight of Tracks in Vertex (tagged Vtx)", 100, 0, 100.);
444 vtxchi2[1] = book<TH1D>(
"tagVtxChi2",
"#chi^{2} (tagged Vtx)", 100, 0., 200.);
445 vtxndf[1] = book<TH1D>(
"tagVtxNdf",
"ndof (tagged Vtx)", 100, 0., 200.);
446 vtxprob[1] = book<TH1D>(
"tagVtxProb",
"#chi^{2} probability (tagged Vtx)", 100, 0., 1.);
447 nans[1] = book<TH1D>(
"tagVtxNans",
"Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (tagged Vtx)", 9, 0.5, 9.5);
449 xrec[0] = book<TH1D>(
"otherPosX",
"Position x Coordinate (other Vtx)", 100,
vposx_ - 0.1,
vposx_ + 0.1);
450 yrec[0] = book<TH1D>(
"otherPosY",
"Position y Coordinate (other Vtx)", 100,
vposy_ - 0.1,
vposy_ + 0.1);
451 zrec[0] = book<TH1D>(
"otherPosZ",
"Position z Coordinate (other Vtx)", 100, -20., 20.);
452 xDiff[0] = book<TH1D>(
"otherDiffX",
"X distance from BeamSpot (other Vtx)", 100, -500, 500);
453 yDiff[0] = book<TH1D>(
"otherDiffY",
"Y distance from BeamSpot (other Vtx)", 100, -500, 500);
454 xerr[0] = book<TH1D>(
"otherErrX",
"Uncertainty x Coordinate (other Vtx)", 100, 0., 100);
455 yerr[0] = book<TH1D>(
"otherErrY",
"Uncertainty y Coordinate (other Vtx)", 100, 0., 100);
456 zerr[0] = book<TH1D>(
"otherErrZ",
"Uncertainty z Coordinate (other Vtx)", 100, 0., 100);
458 "otherErrVsWeightX",
"Uncertainty x Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
460 "otherErrVsWeightY",
"Uncertainty y Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
462 "otherErrVsWeightZ",
"Uncertainty z Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
464 xrec[1] = book<TH1D>(
"tagPosX",
"Position x Coordinate (tagged Vtx)", 100,
vposx_ - 0.1,
vposx_ + 0.1);
465 yrec[1] = book<TH1D>(
"tagPosY",
"Position y Coordinate (tagged Vtx)", 100,
vposy_ - 0.1,
vposy_ + 0.1);
466 zrec[1] = book<TH1D>(
"tagPosZ",
"Position z Coordinate (tagged Vtx)", 100, -20., 20.);
467 xDiff[1] = book<TH1D>(
"tagDiffX",
"X distance from BeamSpot (tagged Vtx)", 100, -500, 500);
468 yDiff[1] = book<TH1D>(
"tagDiffY",
"Y distance from BeamSpot (tagged Vtx)", 100, -500, 500);
469 xerr[1] = book<TH1D>(
"tagErrX",
"Uncertainty x Coordinate (tagged Vtx)", 100, 0., 100);
470 yerr[1] = book<TH1D>(
"tagErrY",
"Uncertainty y Coordinate (tagged Vtx)", 100, 0., 100);
471 zerr[1] = book<TH1D>(
"tagErrZ",
"Uncertainty z Coordinate (tagged Vtx)", 100, 0., 100);
473 "tagErrVsWeightX",
"Uncertainty x Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
475 "tagErrVsWeightY",
"Uncertainty y Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
477 "tagErrVsWeightZ",
"Uncertainty z Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
479 type[0] = book<TH1D>(
"otherType",
"Vertex type (other Vtx)", 3, -0.5, 2.5);
480 type[1] = book<TH1D>(
"tagType",
"Vertex type (tagged Vtx)", 3, -0.5, 2.5);
482 for (
int i = 0;
i < 2; ++
i) {
483 type[
i]->GetXaxis()->SetBinLabel(1,
"Valid, real");
484 type[
i]->GetXaxis()->SetBinLabel(2,
"Valid, fake");
485 type[
i]->GetXaxis()->SetBinLabel(3,
"Invalid");
488 bsX = book<TH1D>(
"bsX",
"BeamSpot x0", 100,
vposx_ - 0.1,
vposx_ + 0.1);
489 bsY = book<TH1D>(
"bsY",
"BeamSpot y0", 100,
vposy_ - 0.1,
vposy_ + 0.1);
490 bsZ = book<TH1D>(
"bsZ",
"BeamSpot z0", 100, -2., 2.);
491 bsSigmaZ = book<TH1D>(
"bsSigmaZ",
"BeamSpot sigmaZ", 100, 0., 10.);
492 bsDxdz = book<TH1D>(
"bsDxdz",
"BeamSpot dxdz", 100, -0.0003, 0.0003);
493 bsDydz = book<TH1D>(
"bsDydz",
"BeamSpot dydz", 100, -0.0003, 0.0003);
494 bsBeamWidthX = book<TH1D>(
"bsBeamWidthX",
"BeamSpot BeamWidthX", 100, 0., 100.);
495 bsBeamWidthY = book<TH1D>(
"bsBeamWidthY",
"BeamSpot BeamWidthY", 100, 0., 100.);
496 bsType = book<TH1D>(
"bsType",
"BeamSpot type", 4, -1.5, 2.5);
497 bsType->GetXaxis()->SetBinLabel(1,
"Unknown");
498 bsType->GetXaxis()->SetBinLabel(2,
"Fake");
499 bsType->GetXaxis()->SetBinLabel(3,
"LHC");
500 bsType->GetXaxis()->SetBinLabel(4,
"Tracker");
507 ntracks->SetXTitle(fmt::sprintf(
"Number of %s per Event", s_1).c_str());
508 ntracks->SetYTitle(
"Number of Events");
510 weight = book<TH1D>(
"weight", fmt::sprintf(
"weight of %s", s_1).c_str(), 100, 0., 1.);
511 weight->SetXTitle(fmt::sprintf(
"weight of %s per Event", s_1).c_str());
512 weight->SetYTitle(
"Number of Events");
514 sumpt = book<TH1D>(
"sumpt", fmt::sprintf(
"#Sum p_{T} of %s", s_1).c_str(), 100, -0.5, 249.5);
515 chi2ndf = book<TH1D>(
"chi2ndf", fmt::sprintf(
"%s #chi^{2}/ndof", s_1).c_str(), 100, 0., 20.);
516 chi2prob = book<TH1D>(
"chi2prob", fmt::sprintf(
"%s #chi^{2} probability", s_1).c_str(), 100, 0., 1.);
519 dxyErr = book<TH1D>(
"dxyErr", fmt::sprintf(
"%s d_{xy} error (#mum)", s_1).c_str(), 100, 0., 2000.);
521 dzErr = book<TH1D>(
"dzErr", fmt::sprintf(
"%s d_{z} error(#mum)", s_1).c_str(), 100, 0., 10000.);
524 book<TH1D>(
"phi_pt1", fmt::sprintf(
"%s #phi; PV tracks #phi;#tracks", s_1).c_str(),
phiBin_,
phiMin_,
phiMax_);
526 book<TH1D>(
"eta_pt1", fmt::sprintf(
"%s #eta; PV tracks #eta;#tracks", s_1).c_str(),
etaBin_,
etaMin_,
etaMax_);
528 book<TH1D>(
"phi_pt10", fmt::sprintf(
"%s #phi; PV tracks #phi;#tracks", s_10).c_str(),
phiBin_,
phiMin_,
phiMax_);
530 book<TH1D>(
"eta_pt10", fmt::sprintf(
"%s #phi; PV tracks #eta;#tracks", s_10).c_str(),
etaBin_,
etaMin_,
etaMax_);
533 fmt::sprintf(
"%s d_{xy} (#mum) VS track #phi", s_1).c_str(),
539 dxyVsPhi_pt1->SetXTitle(
"PV track (p_{T} > 1 GeV) #phi");
540 dxyVsPhi_pt1->SetYTitle(
"PV track (p_{T} > 1 GeV) d_{xy} (#mum)");
543 fmt::sprintf(
"%s d_{z} (#mum) VS track #phi", s_1).c_str(),
549 dzVsPhi_pt1->SetXTitle(
"PV track (p_{T} > 1 GeV) #phi");
550 dzVsPhi_pt1->SetYTitle(
"PV track (p_{T} > 1 GeV) d_{z} (#mum)");
553 fmt::sprintf(
"%s d_{xy} (#mum) VS track #eta", s_1).c_str(),
559 dxyVsEta_pt1->SetXTitle(
"PV track (p_{T} > 1 GeV) #eta");
560 dxyVsEta_pt1->SetYTitle(
"PV track (p_{T} > 1 GeV) d_{xy} (#mum)");
563 fmt::sprintf(
"%s d_{z} (#mum) VS track #eta", s_1).c_str(),
569 dzVsEta_pt1->SetXTitle(
"PV track (p_{T} > 1 GeV) #eta");
570 dzVsEta_pt1->SetYTitle(
"PV track (p_{T} > 1 GeV) d_{z} (#mum)");
573 fmt::sprintf(
"%s d_{xy} (#mum) VS track #eta VS track #phi", s_1).c_str(),
587 fmt::sprintf(
"%s d_{z} (#mum) VS track #eta VS track #phi", s_1).c_str(),
601 fmt::sprintf(
"%s d_{xy} (#mum) VS track #phi", s_10).c_str(),
608 dxyVsPhi_pt10->SetYTitle(
"PV track (p_{T} > 10 GeV) d_{xy} (#mum)");
611 fmt::sprintf(
"%s d_{z} (#mum) VS track #phi", s_10).c_str(),
617 dzVsPhi_pt10->SetXTitle(
"PV track (p_{T} > 10 GeV) #phi");
618 dzVsPhi_pt10->SetYTitle(
"PV track (p_{T} > 10 GeV) d_{z} (#mum)");
621 fmt::sprintf(
"%s d_{xy} (#mum) VS track #eta", s_10).c_str(),
628 dxyVsEta_pt10->SetYTitle(
"PV track (p_{T} > 10 GeV) d_{xy} (#mum)");
631 fmt::sprintf(
"%s d_{z} (#mum) VS track #eta", s_10).c_str(),
637 dzVsEta_pt10->SetXTitle(
"PV track (p_{T} > 10 GeV) #eta");
638 dzVsEta_pt10->SetYTitle(
"PV track (p_{T} > 10 GeV) d_{z} (#mum)");
641 fmt::sprintf(
"%s d_{xy} (#mum) VS track #eta VS track #phi", s_10).c_str(),
655 fmt::sprintf(
"%s d_{z} (#mum) VS track #eta VS track #phi", s_10).c_str(),
672 desc.add<
int>(
"ndof", 4);
675 desc.add<
double>(
"Xpos", 0.1);
676 desc.add<
double>(
"Ypos", 0.0);
677 desc.add<
int>(
"TkSizeBin", 100);
678 desc.add<
double>(
"TkSizeMin", 499.5);
679 desc.add<
double>(
"TkSizeMax", -0.5);
680 desc.add<
int>(
"DxyBin", 100);
681 desc.add<
double>(
"DxyMin", 5000.);
682 desc.add<
double>(
"DxyMax", -5000.);
683 desc.add<
int>(
"DzBin", 100);
684 desc.add<
double>(
"DzMin", -2000.0);
685 desc.add<
double>(
"DzMax", 2000.0);
686 desc.add<
int>(
"PhiBin", 32);
687 desc.add<
int>(
"PhiBin2D", 12);
690 desc.add<
int>(
"EtaBin", 26);
691 desc.add<
int>(
"EtaBin2D", 8);
692 desc.add<
double>(
"EtaMin", -2.7);
693 desc.add<
double>(
"EtaMax", 2.7);
static const std::string kSharedResource
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T * book(const Args &...args) const
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
const edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
constexpr bool isNotFinite(T x)
const edm::EDGetTokenT< VertexScore > scoreToken_
~GeneralPurposeVertexAnalyzer() override=default
const edm::InputTag beamSpotInputTag_
std::vector< Track > TrackCollection
collection of Tracks
std::vector< Vertex > VertexCollection
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i)
void pvTracksPlots(const reco::Vertex &v)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static constexpr int cmToUm
float ChiSquaredProbability(double chiSquared, double nrDOF)
#define DEFINE_FWK_MODULE(type)
TProfile2D * dxyVsEtaVsPhi_pt1
TProfile2D * dxyVsEtaVsPhi_pt10
XYZPointD XYZPoint
point in space with cartesian internal representation
const edm::InputTag vertexInputTag_
GeneralPurposeVertexAnalyzer(const edm::ParameterSet &)
TProfile2D * dzVsEtaVsPhi_pt1
T * make(const Args &...args) const
make new ROOT object
Log< level::Warning, false > LogWarning
TProfile2D * dzVsEtaVsPhi_pt10
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
edm::Service< TFileService > fs_