23 #include "TProfile2D.h" 27 #include <fmt/format.h> 28 #include <fmt/printf.h> 65 template <
typename T,
typename... Args>
170 (
varname_.find(
"xy") != std::string::npos) ? 2000. : 10000.);
181 IPVsPhi_->SetXTitle(
"PV track (p_{T} > 1 GeV) #phi");
193 IPVsEta_->SetXTitle(
"PV track (p_{T} > 1 GeV) #eta");
204 (
varname_.find(
"xy") != std::string::npos) ? 100. : 200.);
205 IPErrVsPhi_->SetXTitle(
"PV track (p_{T} > 1 GeV) #phi");
216 (
varname_.find(
"xy") != std::string::npos) ? 100. : 200.);
217 IPErrVsEta_->SetXTitle(
"PV track (p_{T} > 1 GeV) #eta");
247 (
varname_.find(
"xy") != std::string::npos) ? 100. : 200.);
259 ndof_(iConfig.getParameter<
int>(
"ndof")),
267 vposx_(iConfig.getParameter<double>(
"Xpos")),
268 vposy_(iConfig.getParameter<double>(
"Ypos")),
270 tkNoMin_(iConfig.getParameter<double>(
"TkSizeMin")),
271 tkNoMax_(iConfig.getParameter<double>(
"TkSizeMax")),
273 dxyMin_(iConfig.getParameter<double>(
"DxyMin")),
274 dxyMax_(iConfig.getParameter<double>(
"DxyMax")),
275 dzBin_(iConfig.getParameter<
int>(
"DzBin")),
276 dzMin_(iConfig.getParameter<double>(
"DzMin")),
277 dzMax_(iConfig.getParameter<double>(
"DzMax")),
280 phiMin_(iConfig.getParameter<double>(
"PhiMin")),
281 phiMax_(iConfig.getParameter<double>(
"PhiMax")),
284 etaMin_(iConfig.getParameter<double>(
"EtaMin")),
285 etaMax_(iConfig.getParameter<double>(
"EtaMax")),
324 if (recVtxs.isValid() ==
false || beamSpotHandle.isValid() ==
false) {
326 <<
" Some products not available in the event: VertexCollection " <<
vertexInputTag_ <<
" " << recVtxs.isValid()
327 <<
" BeamSpot " <<
beamSpotInputTag_ <<
" " << beamSpotHandle.isValid() <<
". Skipping plots for this event";
333 for (
const auto &
v : *recVtxs) {
334 if (
v.tracksSize() > 0) {
335 const auto &ref =
v.trackRefAt(0);
336 if (ref.isNull() || !ref.isAvailable()) {
340 <<
" since likely the track collection the vertex has refs pointing to is missing (at least the first " 341 "TrackBaseRef is null or not available)";
354 nbvtx->Fill(recVtxs->size());
356 for (
auto const &
vx : (*recVtxs)) {
357 if (
vx.isValid() && !
vx.isFake() &&
vx.ndof() >=
ndof_) {
363 if (scores.isValid() && !(*scores).empty()) {
364 auto pvScore = (*scores).get(0);
366 for (
unsigned int i = 1;
i < (*scores).size(); ++
i) {
372 if (!recVtxs->empty()) {
376 for (reco::VertexCollection::const_iterator
v = recVtxs->begin() + 1;
v != recVtxs->end(); ++
v) {
399 if (
v.tracksSize() == 0) {
404 const math::XYZPoint myVertex(
v.position().x(),
v.position().y(),
v.position().z());
407 for (
const auto &
t :
v.tracks()) {
413 const float pt =
t->pt();
419 const float eta =
t->eta();
420 const float phi =
t->phi();
421 const float w =
v.trackWeight(
t);
422 const float chi2NDF =
t->normalizedChi2();
423 const float chi2Prob = TMath::Prob(
t->chi2(),
static_cast<int>(
t->ndof()));
424 const float Dxy =
t->dxy(myVertex) *
cmToUm;
425 const float Dz =
t->dz(myVertex) *
cmToUm;
426 const float DxyErr =
t->dxyError() *
cmToUm;
427 const float DzErr =
t->dzError() *
cmToUm;
484 ntracks->Fill(static_cast<float>(
v.tracks().size()));
498 if (
v.isValid() && !
v.isFake()) {
510 xrec[
i]->Fill(
v.position().x());
511 yrec[
i]->Fill(
v.position().y());
512 zrec[
i]->Fill(
v.position().z());
531 for (
int k = 0;
k != 3;
k++) {
532 for (
int j =
k;
j != 3;
j++) {
536 if (
j ==
k &&
v.covariance(
k,
j) < 0) {
544 template <
typename T,
typename...
Args>
552 nbvtx = book<TH1I>(
"vtxNbr",
"Reconstructed Vertices in Event", 80, -0.5, 79.5);
553 nbgvtx = book<TH1I>(
"goodvtxNbr",
"Reconstructed Good Vertices in Event", 80, -0.5, 79.5);
555 nbtksinvtx[0] = book<TH1D>(
"otherVtxTrksNbr",
"Reconstructed Tracks in Vertex (other Vtx)", 40, -0.5, 99.5);
557 book<TProfile>(
"otherVtxTrksVsZ",
"Reconstructed Tracks in Vertex (other Vtx) vs Z", 80, -20., 20., 0., 100.,
"");
561 score[0] = book<TH1D>(
"otherVtxScore",
"sqrt(score) (other Vtx)", 100, 0., 400.);
562 trksWeight[0] = book<TH1D>(
"otherVtxTrksWeight",
"Total weight of Tracks in Vertex (other Vtx)", 40, 0, 100.);
563 vtxchi2[0] = book<TH1D>(
"otherVtxChi2",
"#chi^{2} (other Vtx)", 100, 0., 200.);
564 vtxndf[0] = book<TH1D>(
"otherVtxNdf",
"ndof (other Vtx)", 100, 0., 200.);
565 vtxprob[0] = book<TH1D>(
"otherVtxProb",
"#chi^{2} probability (other Vtx)", 100, 0., 1.);
566 nans[0] = book<TH1D>(
"otherVtxNans",
"Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (other Vtx)", 9, 0.5, 9.5);
568 nbtksinvtx[1] = book<TH1D>(
"tagVtxTrksNbr",
"Reconstructed Tracks in Vertex (tagged Vtx)", 100, -0.5, 99.5);
570 book<TProfile>(
"tagVtxTrksVsZ",
"Reconstructed Tracks in Vertex (tagged Vtx) vs Z", 80, -20., 20., 0., 100.,
"");
574 score[1] = book<TH1D>(
"tagVtxScore",
"sqrt(score) (tagged Vtx)", 100, 0., 400.);
575 trksWeight[1] = book<TH1D>(
"tagVtxTrksWeight",
"Total weight of Tracks in Vertex (tagged Vtx)", 100, 0, 100.);
576 vtxchi2[1] = book<TH1D>(
"tagVtxChi2",
"#chi^{2} (tagged Vtx)", 100, 0., 200.);
577 vtxndf[1] = book<TH1D>(
"tagVtxNdf",
"ndof (tagged Vtx)", 100, 0., 200.);
578 vtxprob[1] = book<TH1D>(
"tagVtxProb",
"#chi^{2} probability (tagged Vtx)", 100, 0., 1.);
579 nans[1] = book<TH1D>(
"tagVtxNans",
"Illegal values for x,y,z,xx,xy,xz,yy,yz,zz (tagged Vtx)", 9, 0.5, 9.5);
581 xrec[0] = book<TH1D>(
"otherPosX",
"Position x Coordinate (other Vtx)", 100,
vposx_ - 0.1,
vposx_ + 0.1);
582 yrec[0] = book<TH1D>(
"otherPosY",
"Position y Coordinate (other Vtx)", 100,
vposy_ - 0.1,
vposy_ + 0.1);
583 zrec[0] = book<TH1D>(
"otherPosZ",
"Position z Coordinate (other Vtx)", 100, -20., 20.);
584 xDiff[0] = book<TH1D>(
"otherDiffX",
"X distance from BeamSpot (other Vtx)", 100, -500, 500);
585 yDiff[0] = book<TH1D>(
"otherDiffY",
"Y distance from BeamSpot (other Vtx)", 100, -500, 500);
586 xerr[0] = book<TH1D>(
"otherErrX",
"Uncertainty x Coordinate (other Vtx)", 100, 0., 100);
587 yerr[0] = book<TH1D>(
"otherErrY",
"Uncertainty y Coordinate (other Vtx)", 100, 0., 100);
588 zerr[0] = book<TH1D>(
"otherErrZ",
"Uncertainty z Coordinate (other Vtx)", 100, 0., 100);
590 "otherErrVsWeightX",
"Uncertainty x Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
592 "otherErrVsWeightY",
"Uncertainty y Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
594 "otherErrVsWeightZ",
"Uncertainty z Coordinate vs. track weight (other Vtx)", 100, 0, 100., 100, 0., 100);
596 xrec[1] = book<TH1D>(
"tagPosX",
"Position x Coordinate (tagged Vtx)", 100,
vposx_ - 0.1,
vposx_ + 0.1);
597 yrec[1] = book<TH1D>(
"tagPosY",
"Position y Coordinate (tagged Vtx)", 100,
vposy_ - 0.1,
vposy_ + 0.1);
598 zrec[1] = book<TH1D>(
"tagPosZ",
"Position z Coordinate (tagged Vtx)", 100, -20., 20.);
599 xDiff[1] = book<TH1D>(
"tagDiffX",
"X distance from BeamSpot (tagged Vtx)", 100, -500, 500);
600 yDiff[1] = book<TH1D>(
"tagDiffY",
"Y distance from BeamSpot (tagged Vtx)", 100, -500, 500);
601 xerr[1] = book<TH1D>(
"tagErrX",
"Uncertainty x Coordinate (tagged Vtx)", 100, 0., 100);
602 yerr[1] = book<TH1D>(
"tagErrY",
"Uncertainty y Coordinate (tagged Vtx)", 100, 0., 100);
603 zerr[1] = book<TH1D>(
"tagErrZ",
"Uncertainty z Coordinate (tagged Vtx)", 100, 0., 100);
605 "tagErrVsWeightX",
"Uncertainty x Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
607 "tagErrVsWeightY",
"Uncertainty y Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
609 "tagErrVsWeightZ",
"Uncertainty z Coordinate vs. track weight (tagged Vtx)", 100, 0, 100., 100, 0., 100);
611 type[0] = book<TH1D>(
"otherType",
"Vertex type (other Vtx)", 3, -0.5, 2.5);
612 type[1] = book<TH1D>(
"tagType",
"Vertex type (tagged Vtx)", 3, -0.5, 2.5);
614 for (
int i = 0;
i < 2; ++
i) {
615 type[
i]->GetXaxis()->SetBinLabel(1,
"Valid, real");
616 type[
i]->GetXaxis()->SetBinLabel(2,
"Valid, fake");
617 type[
i]->GetXaxis()->SetBinLabel(3,
"Invalid");
620 bsX = book<TH1D>(
"bsX",
"BeamSpot x0", 100,
vposx_ - 0.1,
vposx_ + 0.1);
621 bsY = book<TH1D>(
"bsY",
"BeamSpot y0", 100,
vposy_ - 0.1,
vposy_ + 0.1);
622 bsZ = book<TH1D>(
"bsZ",
"BeamSpot z0", 100, -2., 2.);
623 bsSigmaZ = book<TH1D>(
"bsSigmaZ",
"BeamSpot sigmaZ", 100, 0., 10.);
624 bsDxdz = book<TH1D>(
"bsDxdz",
"BeamSpot dxdz", 100, -0.0003, 0.0003);
625 bsDydz = book<TH1D>(
"bsDydz",
"BeamSpot dydz", 100, -0.0003, 0.0003);
626 bsBeamWidthX = book<TH1D>(
"bsBeamWidthX",
"BeamSpot BeamWidthX", 100, 0., 100.);
627 bsBeamWidthY = book<TH1D>(
"bsBeamWidthY",
"BeamSpot BeamWidthY", 100, 0., 100.);
628 bsType = book<TH1D>(
"bsType",
"BeamSpot type", 4, -1.5, 2.5);
629 bsType->GetXaxis()->SetBinLabel(1,
"Unknown");
630 bsType->GetXaxis()->SetBinLabel(2,
"Fake");
631 bsType->GetXaxis()->SetBinLabel(3,
"LHC");
632 bsType->GetXaxis()->SetBinLabel(4,
"Tracker");
639 ntracks->SetXTitle(fmt::sprintf(
"Number of %s per Event", s_1).c_str());
640 ntracks->SetYTitle(
"Number of Events");
642 weight = book<TH1D>(
"weight", fmt::sprintf(
"weight of %s", s_1).c_str(), 100, 0., 1.);
643 weight->SetXTitle(fmt::sprintf(
"weight of %s per Event", s_1).c_str());
644 weight->SetYTitle(
"Number of Events");
646 sumpt = book<TH1D>(
"sumpt", fmt::sprintf(
"#Sum p_{T} of %s", s_1).c_str(), 100, -0.5, 249.5);
647 chi2ndf = book<TH1D>(
"chi2ndf", fmt::sprintf(
"%s #chi^{2}/ndof", s_1).c_str(), 100, 0., 20.);
648 chi2prob = book<TH1D>(
"chi2prob", fmt::sprintf(
"%s #chi^{2} probability", s_1).c_str(), 100, 0., 1.);
653 book<TH1D>(
"phi_pt1", fmt::sprintf(
"%s #phi; PV tracks #phi;#tracks", s_1).c_str(),
phiBin_,
phiMin_,
phiMax_);
655 book<TH1D>(
"eta_pt1", fmt::sprintf(
"%s #eta; PV tracks #eta;#tracks", s_1).c_str(),
etaBin_,
etaMin_,
etaMax_);
657 book<TH1D>(
"phi_pt10", fmt::sprintf(
"%s #phi; PV tracks #phi;#tracks", s_10).c_str(),
phiBin_,
phiMin_,
phiMax_);
659 book<TH1D>(
"eta_pt10", fmt::sprintf(
"%s #phi; PV tracks #eta;#tracks", s_10).c_str(),
etaBin_,
etaMin_,
etaMax_);
682 desc.add<
int>(
"ndof", 4);
685 desc.add<
double>(
"Xpos", 0.1);
686 desc.add<
double>(
"Ypos", 0.0);
687 desc.add<
int>(
"TkSizeBin", 100);
688 desc.add<
double>(
"TkSizeMin", 499.5);
689 desc.add<
double>(
"TkSizeMax", -0.5);
690 desc.add<
int>(
"DxyBin", 100);
691 desc.add<
double>(
"DxyMin", -2000.);
692 desc.add<
double>(
"DxyMax", 2000.);
693 desc.add<
int>(
"DzBin", 100);
694 desc.add<
double>(
"DzMin", -2000.0);
695 desc.add<
double>(
"DzMax", 2000.0);
696 desc.add<
int>(
"PhiBin", 32);
697 desc.add<
int>(
"PhiBin2D", 12);
700 desc.add<
int>(
"EtaBin", 26);
701 desc.add<
int>(
"EtaBin2D", 8);
702 desc.add<
double>(
"EtaMin", -2.7);
703 desc.add<
double>(
"EtaMax", 2.7);
static const std::string kSharedResource
void bookIPMonitor(const edm::ParameterSet &, const edm::Service< TFileService > fs)
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
const edm::ParameterSet conf_
std::vector< Vertex > VertexCollection
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i)
TProfile2D * IPVsEtaVsPhi_
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)
XYZPointD XYZPoint
point in space with cartesian internal representation
TProfile2D * IPErrVsEtaVsPhi_
const edm::InputTag vertexInputTag_
GeneralPurposeVertexAnalyzer(const edm::ParameterSet &)
T * make(const Args &...args) const
make new ROOT object
Log< level::Warning, false > LogWarning
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_