91 std::map<unsigned int, double>
wnt;
92 std::map<unsigned int, double>
wos;
98 void addTrack(
unsigned int irecv,
double twos,
double twt) {
100 if (
wnt.find(irecv) ==
wnt.end()) {
107 if (
wos.find(irecv) ==
wos.end()) {
139 std::map<unsigned int, double>
wos;
140 std::map<unsigned int, double>
wnt;
168 if (
wnt.find(iev) ==
wnt.end()) {
175 if (
wos.find(iev) ==
wos.end()) {
193 std::vector<simPrimaryVertex>&,
212 static constexpr
double c_ = 2.99792458e1;
213 static constexpr
double mvaL_ = 0.5;
214 static constexpr
double mvaH_ = 0.8;
318 trackweightTh_(iConfig.getParameter<double>(
"trackweightTh")),
319 mvaTh_(iConfig.getParameter<double>(
"mvaTh")),
320 lineDensityPar_(iConfig.getParameter<std::
vector<double>>(
"lineDensityPar")),
321 use_only_charged_tracks_(iConfig.getParameter<bool>(
"useOnlyChargedTracks")),
322 debug_(iConfig.getUntrackedParameter<bool>(
"debug")),
323 optionalPlots_(iConfig.getUntrackedParameter<bool>(
"optionalPlots")) {
357 ibook.
book1D(
"MVAMatchedEffPtTot",
"Pt of tracks associated to LV matched to TP; track pt [GeV] ", 110, 0., 11.);
359 "MVAMatchedEffPtMtd",
"Pt of tracks associated to LV matched to TP with time; track pt [GeV] ", 110, 0., 11.);
361 ibook.
book1D(
"MVAMatchedEffEtaTot",
"Pt of tracks associated to LV matched to TP; track eta ", 66, 0., 3.3);
363 "MVAMatchedEffEtaMtd",
"Pt of tracks associated to LV matched to TP with time; track eta ", 66, 0., 3.3);
365 "MVATrackRes",
"t_{rec} - t_{sim} for tracks from LV MVA sel.; t_{rec} - t_{sim} [ns] ", 120, -0.15, 0.15);
366 meTrackResTot_ = ibook.
book1D(
"TrackRes",
"t_{rec} - t_{sim} for tracks; t_{rec} - t_{sim} [ns] ", 120, -0.15, 0.15);
368 "TrackRes-LowMVA",
"t_{rec} - t_{sim} for tracks with MVA < 0.5; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
370 "TrackRes-MediumMVA",
"t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
372 "TrackRes-HighMVA",
"t_{rec} - t_{sim} for tracks with MVA > 0.8; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
375 "TrackResMass-LowMVA",
"t_{rec} - t_{est} for tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ", 100, -1., 1.);
377 "t_{rec} - t_{est} for tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
382 "TrackResMass-HighMVA",
"t_{rec} - t_{est} for tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ", 100, -1., 1.);
384 "TrackResMassTrue-LowMVA",
"t_{est} - t_{sim} for tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ", 100, -1., 1.);
386 "t_{est} - t_{sim} for tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
391 "t_{est} - t_{sim} for tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
397 ibook.
book1D(
"MVATrackPull",
"Pull for tracks from LV MAV sel.; (t_{rec}-t_{sim})/#sigma_{t}", 50, -5., 5.);
398 meTrackPullTot_ = ibook.
book1D(
"TrackPull",
"Pull for tracks; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
400 ibook.
book1D(
"TrackPull-LowMVA",
"Pull for tracks with MVA < 0.5; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
402 "TrackPull-MediumMVA",
"Pull for tracks with 0.5 < MVA < 0.8; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
404 ibook.
book1D(
"TrackPull-HighMVA",
"Pull for tracks with MVA > 0.8; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
406 "MVATrackZposResTot",
"Z_{PCA} - Z_{sim} for tracks from LV MVA sel.;Z_{PCA} - Z_{sim} [cm] ", 50, -0.1, 0.1);
408 ibook.
book1D(
"TrackZposResTot",
"Z_{PCA} - Z_{sim} for tracks;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
410 "TrackZposRes-LowMVA",
"Z_{PCA} - Z_{sim} for tracks with MVA < 0.5;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
412 "Z_{PCA} - Z_{sim} for tracks with 0.5 < MVA < 0.8 ;Z_{PCA} - Z_{sim} [cm] ",
417 "TrackZposRes-HighMVA",
"Z_{PCA} - Z_{sim} for tracks with MVA > 0.8 ;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
419 ibook.
book1D(
"Track3DposRes-LowMVA",
420 "3dPos_{PCA} - 3dPos_{sim} for tracks with MVA < 0.5 ;3dPos_{PCA} - 3dPos_{sim} [cm] ",
425 ibook.
book1D(
"Track3DposRes-MediumMVA",
426 "3dPos_{PCA} - 3dPos_{sim} for tracks with 0.5 < MVA < 0.8 ;3dPos_{PCA} - 3dPos_{sim} [cm] ",
431 ibook.
book1D(
"Track3DposRes-HighMVA",
432 "3dPos_{PCA} - 3dPos_{sim} for tracks with MVA > 0.8;3dPos_{PCA} - 3dPos_{sim} [cm] ",
436 meTimeRes_ = ibook.
book1D(
"TimeRes",
"t_{rec} - t_{sim} ;t_{rec} - t_{sim} [ns] ", 40, -0.2, 0.2);
437 meTimePull_ = ibook.
book1D(
"TimePull",
"Pull; t_{rec} - t_{sim}/#sigma_{t rec}", 100, -10., 10.);
439 ibook.
book1D(
"TimeSignalRes",
"t_{rec} - t_{sim} for signal ;t_{rec} - t_{sim} [ns] ", 40, -0.2, 0.2);
441 ibook.
book1D(
"TimeSignalPull",
"Pull for signal; t_{rec} - t_{sim}/#sigma_{t rec}", 100, -10., 10.);
443 ibook.
bookProfile(
"PUvsReal",
"#PU vertices vs #real matched vertices;#PU;#real ", 100, 0, 300, 100, 0, 200);
445 "PUvsOtherFake",
"#PU vertices vs #other fake matched vertices;#PU;#other fake ", 100, 0, 300, 100, 0, 20);
447 ibook.
bookProfile(
"PUvsSplit",
"#PU vertices vs #split matched vertices;#PU;#split ", 100, 0, 300, 100, 0, 20);
448 meMatchQual_ = ibook.
book1D(
"MatchQuality",
"RECO-SIM vertex match quality; ", 8, 0, 8.);
452 meDeltaTrealreal_ = ibook.
book1D(
"DeltaTrealreal",
"#Delta T real-real; |#Delta T (r-r)| [sigma]", 60, 0., 30.);
453 meDeltaTfakefake_ = ibook.
book1D(
"DeltaTfakefake",
"#Delta T fake-fake; |#Delta T (f-f)| [sigma]", 60, 0., 30.);
454 meDeltaTfakereal_ = ibook.
book1D(
"DeltaTfakereal",
"#Delta T fake-real; |#Delta T (f-r)| [sigma]", 60, 0., 30.);
457 "RecoPosInSimCollection",
"Sim signal vertex index associated to Reco signal vertex; Sim PV index", 200, 0, 200);
459 ibook.
book1D(
"RecoPosInRecoOrigCollection",
"Reco signal index in OrigCollection; Reco index", 200, 0, 200);
461 ibook.
book1D(
"SimPosInSimOrigCollection",
"Sim signal index in OrigCollection; Sim index", 200, 0, 200);
464 ibook.
book1D(
"RecoPVPosSignal",
"Position in reco collection of PV associated to sim signal", 200, 0, 200);
466 ibook.
book1D(
"RecoPVPosSignalNotHighestPt",
467 "Position in reco collection of PV associated to sim signal not highest Pt",
472 ibook.
book1D(
"RecoVtxVsLineDensity",
"#Reco vertices/mm/event; line density [#vtx/mm/event]", 160, 0., 4.);
473 meRecVerNumber_ = ibook.
book1D(
"RecVerNumber",
"RECO Vertex Number: Number of vertices", 50, 0, 250);
474 meRecPVZ_ = ibook.
book1D(
"recPVZ",
"Weighted #Rec vertices/mm", 400, -20., 20.);
475 meRecPVT_ = ibook.
book1D(
"recPVT",
"#Rec vertices/10 ps", 200, -1., 1.);
476 meSimPVZ_ = ibook.
book1D(
"simPVZ",
"Weighted #Sim vertices/mm", 400, -20., 20.);
480 "TrackResLowP",
"t_{rec} - t_{sim} for tracks with p < 2 GeV; t_{rec} - t_{sim} [ns] ", 70, -0.15, 0.15);
482 ibook.
book1D(
"TrackResLowP-LowMVA",
483 "t_{rec} - t_{sim} for tracks with MVA < 0.5 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
488 ibook.
book1D(
"TrackResLowP-MediumMVA",
489 "t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
494 ibook.
book1D(
"TrackResLowP-HighMVA",
495 "t_{rec} - t_{sim} for tracks with MVA > 0.8 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
500 "TrackResHighP",
"t_{rec} - t_{sim} for tracks with p > 2 GeV; t_{rec} - t_{sim} [ns] ", 70, -0.15, 0.15);
502 ibook.
book1D(
"TrackResHighP-LowMVA",
503 "t_{rec} - t_{sim} for tracks with MVA < 0.5 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
508 ibook.
book1D(
"TrackResHighP-MediumMVA",
509 "t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
514 ibook.
book1D(
"TrackResHighP-HighMVA",
515 "t_{rec} - t_{sim} for tracks with MVA > 0.8 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
520 ibook.
book1D(
"TrackPullLowP",
"Pull for tracks with p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
522 "Pull for tracks with MVA < 0.5 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
527 "Pull for tracks with 0.5 < MVA < 0.8 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
532 "Pull for tracks with MVA > 0.8 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
537 ibook.
book1D(
"TrackPullHighP",
"Pull for tracks with p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
539 "Pull for tracks with MVA < 0.5 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
544 ibook.
book1D(
"TrackPullHighP-MediumMVA",
545 "Pull for tracks with 0.5 < MVA < 0.8 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
550 "Pull for tracks with MVA > 0.8 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
556 ibook.
book1D(
"TrackResMass-Protons-LowMVA",
557 "t_{rec} - t_{est} for proton tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ",
562 ibook.
book1D(
"TrackResMass-Protons-MediumMVA",
563 "t_{rec} - t_{est} for proton tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
568 ibook.
book1D(
"TrackResMass-Protons-HighMVA",
569 "t_{rec} - t_{est} for proton tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ",
574 ibook.
book1D(
"TrackResMassTrue-Protons-LowMVA",
575 "t_{est} - t_{sim} for proton tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ",
580 ibook.
book1D(
"TrackResMassTrue-Protons-MediumMVA",
581 "t_{est} - t_{sim} for proton tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
586 ibook.
book1D(
"TrackResMassTrue-Protons-HighMVA",
587 "t_{est} - t_{sim} for proton tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
593 "t_{rec} - t_{est} for pion tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ",
598 ibook.
book1D(
"TrackResMass-Pions-MediumMVA",
599 "t_{rec} - t_{est} for pion tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
604 "t_{rec} - t_{est} for pion tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ",
609 ibook.
book1D(
"TrackResMassTrue-Pions-LowMVA",
610 "t_{est} - t_{sim} for pion tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ",
615 ibook.
book1D(
"TrackResMassTrue-Pions-MediumMVA",
616 "t_{est} - t_{sim} for pion tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
621 ibook.
book1D(
"TrackResMassTrue-Pions-HighMVA",
622 "t_{est} - t_{sim} for pion tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
637 for (
const auto&
tp :
found->val) {
638 if (
tp.first->eventId().bunchCrossing() == 0 &&
tp.first->eventId().event() == 0)
655 for (
const auto&
tp :
found->val) {
656 if (std::find_if(vsim->daughterTracks_begin(), vsim->daughterTracks_end(), [&](
const TrackingParticleRef& vtp) {
657 return tp.first == vtp;
658 }) != vsim->daughterTracks_end())
667 if (time > 0 && pathlength > 0 && mass > 0) {
668 double gammasq = 1. + momentum * momentum / (mass *
mass);
670 double t_est = time - (pathlength /
v);
702 std::vector<Primary4DVertexValidation::simPrimaryVertex> simpv;
703 int current_event = -1;
705 for (TrackingVertexCollection::const_iterator
v = tVC->begin();
v != tVC->end(); ++
v) {
707 if (
v->eventId().bunchCrossing() != 0)
709 if (
v->eventId().event() != current_event) {
710 current_event =
v->eventId().event();
719 simPrimaryVertex sv(
v->position().x(),
v->position().y(),
v->position().z(),
v->position().t());
722 sv.OriginalIndex =
s;
726 assert((**iTrack).eventId().bunchCrossing() == 0);
729 for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin(); v0 != simpv.end(); v0++) {
730 if ((sv.eventId == v0->eventId) && (
std::abs(sv.x - v0->x) < 1
e-5) && (
std::abs(sv.y - v0->y) < 1
e-5) &&
744 auto momentum = (*(*iTP)).momentum();
745 const reco::Track* matched_best_reco_track =
nullptr;
746 double match_quality = -1;
750 matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
751 match_quality = (*s2r_)[*iTP][0].second;
754 vp->
ptot.setPx(vp->
ptot.x() + momentum.x());
755 vp->
ptot.setPy(vp->
ptot.y() + momentum.y());
756 vp->
ptot.setPz(vp->
ptot.z() + momentum.z());
757 vp->
ptot.setE(vp->
ptot.e() + (**iTP).energy());
758 vp->
ptsq += ((**iTP).pt() * (**iTP).pt());
760 if (matched_best_reco_track) {
780 auto prev_z = simpv.back().z;
782 vsim.closest_vertex_distance_z =
std::abs(vsim.z - prev_z);
786 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
787 std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
789 for (; vsim2 != simpv.end(); vsim2++) {
792 vsim->closest_vertex_distance_z =
std::min(vsim->closest_vertex_distance_z, distance);
793 vsim2->closest_vertex_distance_z =
std::min(vsim2->closest_vertex_distance_z, distance);
803 std::vector<Primary4DVertexValidation::recoPrimaryVertex> recopv;
805 for (
auto v = tVC->begin();
v != tVC->end(); ++
v) {
810 if (
v->isFake() || !
v->isValid())
817 sv.OriginalIndex =
r;
819 recopv.push_back(sv);
823 for (
auto iTrack =
v->tracks_begin(); iTrack !=
v->tracks_end(); ++iTrack) {
824 auto momentum = (*(*iTrack)).innerMomentum();
825 if (momentum.mag2() == 0)
826 momentum = (*(*iTrack)).momentum();
828 vp->
ptsq += (momentum.perp2());
845 auto prev_z = recopv.back().z;
847 vreco.closest_vertex_distance_z =
std::abs(vreco.z - prev_z);
850 for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin(); vreco != recopv.end(); vreco++) {
851 std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
853 for (; vreco2 != recopv.end(); vreco2++) {
856 vreco->closest_vertex_distance_z =
std::min(vreco->closest_vertex_distance_z, distance);
857 vreco2->closest_vertex_distance_z =
std::min(vreco2->closest_vertex_distance_z, distance);
865 std::vector<simPrimaryVertex>& simpv,
869 for (
auto vv : simpv) {
873 for (
auto rv : recopv) {
878 for (
unsigned int iv = 0;
iv < recopv.size();
iv++) {
881 for (
unsigned int iev = 0;
iev < simpv.size();
iev++) {
889 double pt = (*iTrack)->pt();
893 if (MVA[(*iTrack)] <
mvaTh_)
897 if (tp_info !=
nullptr) {
898 double dz2_beam =
pow((*BS).BeamWidthX() *
cos((*iTrack)->phi()) /
tan((*iTrack)->theta()), 2) +
899 pow((*BS).BeamWidthY() *
sin((*iTrack)->phi()) /
tan((*iTrack)->theta()), 2);
900 double dz2 =
pow((*iTrack)->dzError(), 2) + dz2_beam +
905 if (sigmat0[(*iTrack)] > 0) {
906 double sigmaZ = (*BS).sigmaZ();
907 double sigmaT = sigmaZ /
c_;
908 wos = wos / erf(sigmat0[(*iTrack)] / sigmaT);
910 simpv.at(
iev).addTrack(
iv, wos, wnt);
911 recopv.at(
iv).addTrack(
iev, wos, wnt);
919 if ((evwos > 0) && (evwos > recopv.at(
iv).maxwos) && (evnt > 1)) {
920 recopv.at(
iv).wosmatch =
iev;
921 recopv.at(
iv).maxwos = evwos;
922 recopv.at(
iv).maxwosnt = evnt;
924 simpv.at(
iev).wos_dominated_recv.push_back(
iv);
925 simpv.at(
iev).nwosmatch++;
929 if ((evnt > 0) && (evwnt > recopv.at(
iv).maxwnt)) {
930 recopv.at(
iv).wntmatch =
iev;
931 recopv.at(
iv).maxwnt = evwnt;
938 for (
auto& vrec : recopv) {
940 vrec.matchQuality = 0;
942 unsigned int iev = 0;
943 for (
auto& vv : simpv) {
946 edm::LogPrint(
"Primary4DVertexValidation") <<
"wos_dominated_recv.size: " << vv.wos_dominated_recv.size();
948 for (
unsigned int i = 0;
i < vv.wos_dominated_recv.size();
i++) {
949 auto recov = vv.wos_dominated_recv.at(
i);
952 <<
"index of reco vertex: " << recov <<
" that has a wos: " << vv.wos.at(recov) <<
" at position " <<
i;
960 for (
unsigned int rank = 1; rank <
maxRank_; rank++) {
961 for (
unsigned int iev = 0; iev < simpv.size(); iev++) {
964 if (simpv.at(iev).nwosmatch == 0)
966 if (simpv.at(iev).nwosmatch > rank)
969 for (
unsigned int k = 0;
k < simpv.at(iev).wos_dominated_recv.size();
k++) {
970 unsigned int rec = simpv.at(iev).wos_dominated_recv.at(
k);
971 auto vrec = recopv.at(rec);
976 if ((iv ==
NOT_MATCHED) || simpv.at(iev).wos.at(rec) > simpv.at(iev).wos.at(iv)) {
982 recopv.at(iv).sim =
iev;
983 simpv.at(iev).rec =
iv;
984 recopv.at(iv).matchQuality = rank;
985 simpv.at(iev).matchQuality = rank;
992 unsigned int ntry = 0;
995 for (
unsigned int iev = 0; iev < simpv.size(); iev++) {
996 if ((simpv.at(iev).rec !=
NOT_MATCHED) || (simpv.at(iev).wos.empty()))
1000 for (
auto rv : simpv.at(iev).wos) {
1001 if ((rec ==
NOT_MATCHED) || (rv.second > simpv.at(iev).wos.at(rec))) {
1007 for (
auto rv : simpv.at(iev).wnt) {
1008 if ((rec ==
NOT_MATCHED) || (rv.second > simpv.at(iev).wnt.at(rec))) {
1021 for (
auto sv : recopv.at(rec).wos) {
1024 if ((rec2sim ==
NOT_MATCHED) || (sv.second > recopv.at(rec).wos.at(rec2sim))) {
1028 if (iev == rec2sim) {
1030 recopv.at(rec).sim =
iev;
1031 recopv.at(rec).matchQuality =
maxRank_;
1032 simpv.at(iev).rec = rec;
1033 simpv.at(iev).matchQuality =
maxRank_;
1049 using namespace reco;
1051 std::vector<float> pileUpInfo_z;
1056 for (
auto const& pu_info : *puinfoH.product()) {
1057 if (pu_info.getBunchCrossing() == 0) {
1058 pileUpInfo_z = pu_info.getPU_zpositions();
1066 if (!TPCollectionH.isValid())
1067 edm::LogWarning(
"Primary4DVertexValidation") <<
"TPCollectionH is not valid";
1071 if (!TVCollectionH.isValid())
1072 edm::LogWarning(
"Primary4DVertexValidation") <<
"TVCollectionH is not valid";
1076 if (simToRecoH.isValid())
1077 s2r_ = simToRecoH.product();
1079 edm::LogWarning(
"Primary4DVertexValidation") <<
"simToRecoH is not valid";
1083 if (recoToSimH.isValid())
1084 r2s_ = recoToSimH.product();
1086 edm::LogWarning(
"Primary4DVertexValidation") <<
"recoToSimH is not valid";
1090 if (!BeamSpotH.isValid())
1091 edm::LogWarning(
"Primary4DVertexValidation") <<
"BeamSpotH is not valid";
1093 std::vector<simPrimaryVertex> simpv;
1096 bool signal_is_highest_pt =
1098 return lhs.ptsq < rhs.ptsq;
1099 }) == simpv.begin();
1101 std::vector<recoPrimaryVertex> recopv;
1104 if (!recVtxs.isValid())
1105 edm::LogWarning(
"Primary4DVertexValidation") <<
"recVtxs is not valid";
1117 matchReco2Sim(recopv, simpv, sigmat0Safe, mtdQualMVA, BeamSpotH);
1120 for (
unsigned int iv = 0;
iv < recopv.size();
iv++) {
1123 for (
unsigned int iev = 0;
iev < simpv.size();
iev++) {
1124 auto vsim = simpv.at(
iev).sim_vertex;
1126 bool selectedVtxMatching = recopv.at(
iv).sim ==
iev && simpv.at(
iev).rec ==
iv &&
1127 simpv.at(
iev).eventId.bunchCrossing() == 0 && simpv.at(
iev).eventId.event() == 0 &&
1128 recopv.at(
iv).OriginalIndex == 0;
1129 if (selectedVtxMatching && !recopv.at(
iv).is_signal()) {
1131 <<
"Reco vtx leading match inconsistent: BX/ID " << simpv.at(
iev).eventId.bunchCrossing() <<
" "
1132 << simpv.at(
iev).eventId.event();
1134 double vzsim = simpv.at(
iev).z;
1138 if (trackAssoc[*iTrack] == -1) {
1139 LogTrace(
"mtdTracks") <<
"Extended track not associated";
1146 bool selectRecoTrk =
mvaRecSel(**iTrack, *vertex, t0Safe[*iTrack], sigmat0Safe[*iTrack]);
1147 if (selectedVtxMatching && selectRecoTrk) {
1153 if (tp_info !=
nullptr) {
1154 double mass = (*tp_info)->mass();
1155 double tsim = (*tp_info)->parentVertex()->position().t() *
simUnit_;
1156 double tEst =
timeFromTrueMass(mass, pathLength[*iTrack], momentum[*iTrack], time[*iTrack]);
1158 double xsim = (*tp_info)->parentVertex()->position().x();
1159 double ysim = (*tp_info)->parentVertex()->position().y();
1160 double zsim = (*tp_info)->parentVertex()->position().z();
1161 double xPCA = (*iTrack)->vx();
1162 double yPCA = (*iTrack)->vy();
1163 double zPCA = (*iTrack)->vz();
1165 double dZ = zPCA - zsim;
1166 double d3D =
std::sqrt((xPCA - xsim) * (xPCA - xsim) + (yPCA - ysim) * (yPCA - ysim) + dZ * dZ);
1168 if ((xPCA - xsim) * ((*tp_info)->px()) + (yPCA - ysim) * ((*tp_info)->py()) + dZ * ((*tp_info)->pz()) < 0.) {
1172 bool selectTP =
mvaTPSel(**tp_info);
1174 if (selectedVtxMatching && selectRecoTrk && selectTP) {
1180 if (sigmat0Safe[*iTrack] == -1)
1183 if (selectedVtxMatching && selectRecoTrk && selectTP) {
1192 if ((*iTrack)->p() <= 2) {
1200 if (mtdQualMVA[(*iTrack)] <
mvaL_) {
1211 if ((*iTrack)->p() <= 2) {
1214 }
else if ((*iTrack)->p() > 2) {
1220 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1223 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1229 }
else if (mtdQualMVA[(*iTrack)] >
mvaL_ && mtdQualMVA[(*iTrack)] <
mvaH_) {
1240 if ((*iTrack)->p() <= 2) {
1243 }
else if ((*iTrack)->p() > 2) {
1249 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1252 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1258 }
else if (mtdQualMVA[(*iTrack)] >
mvaH_) {
1269 if ((*iTrack)->p() <= 2) {
1272 }
else if ((*iTrack)->p() > 2) {
1278 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1281 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1297 auto puLineDensity = [&](
double z) {
1304 for (
unsigned int ir = 0; ir < recopv.size(); ir++) {
1306 meRecPVZ_->
Fill(recopv.at(ir).z, 1. / puLineDensity(recopv.at(ir).z));
1307 if (recopv.at(ir).recVtx->tError() > 0.) {
1311 edm::LogPrint(
"Primary4DVertexValidation") <<
"************* IR: " << ir;
1313 <<
"z: " << recopv.at(ir).z <<
" corresponding to line density: " << puLineDensity(recopv.at(ir).z);
1314 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_real: " << recopv.at(ir).is_real();
1315 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_fake: " << recopv.at(ir).is_fake();
1316 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_signal: " << recopv.at(ir).is_signal();
1317 edm::LogPrint(
"Primary4DVertexValidation") <<
"split_from: " << recopv.at(ir).split_from();
1318 edm::LogPrint(
"Primary4DVertexValidation") <<
"other fake: " << recopv.at(ir).other_fake();
1320 if (recopv.at(ir).is_real())
1322 if (recopv.at(ir).is_fake())
1324 if (recopv.at(ir).other_fake())
1326 if (recopv.at(ir).split_from() != -1) {
1332 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_real: " << real;
1333 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_fake: " << fake;
1335 edm::LogPrint(
"Primary4DVertexValidation") <<
"other fake: " << other_fake;
1339 for (
unsigned int is = 0; is < simpv.size(); is++) {
1340 meSimPVZ_->
Fill(simpv.at(is).z, 1. / puLineDensity(simpv.at(is).z));
1347 edm::LogPrint(
"Primary4DVertexValidation") <<
"sim vertex: " << is <<
" is not matched with any reco";
1352 for (
unsigned int ir = 0; ir < recopv.size(); ir++) {
1353 if (recopv.at(ir).sim == is && simpv.at(is).rec == ir) {
1363 recopv.at(ir).recVtx->tError());
1369 if (simpv.at(is).eventId.bunchCrossing() == 0 && simpv.at(is).eventId.event() == 0) {
1370 if (!recopv.at(ir).is_signal()) {
1372 <<
"Reco vtx leading match inconsistent: BX/ID " << simpv.at(is).eventId.bunchCrossing() <<
" "
1373 << simpv.at(is).eventId.event();
1376 recopv.at(ir).OriginalIndex);
1377 if (!signal_is_highest_pt) {
1379 recopv.at(ir).OriginalIndex);
1384 edm::LogPrint(
"Primary4DVertexValidation") <<
"*** Matching RECO: " << ir <<
"with SIM: " << is <<
" ***";
1385 edm::LogPrint(
"Primary4DVertexValidation") <<
"Match Quality is " << recopv.at(ir).matchQuality;
1393 for (
unsigned int iv = 0;
iv < recVtxs->size() - 1;
iv++) {
1395 double mindistance_realreal = 1e10;
1397 for (
unsigned int jv =
iv; jv < recVtxs->size(); jv++) {
1398 if ((!(jv ==
iv)) &&
select(recVtxs->at(jv))) {
1399 double dz = recVtxs->at(
iv).z() - recVtxs->at(jv).z();
1400 double dtsigma =
std::sqrt(recVtxs->at(
iv).covariance(3, 3) + recVtxs->at(jv).covariance(3, 3));
1402 ? (recVtxs->at(
iv).t() - recVtxs->at(jv).t()) / dtsigma
1404 if (recopv.at(
iv).is_real() && recopv.at(jv).is_real()) {
1410 mindistance_realreal =
dz;
1412 }
else if (recopv.at(
iv).is_fake() && recopv.at(jv).is_fake()) {
1421 double mindistance_fakereal = 1e10;
1422 double mindistance_realfake = 1e10;
1423 for (
unsigned int jv = 0; jv < recVtxs->size(); jv++) {
1424 if ((!(jv ==
iv)) &&
select(recVtxs->at(jv))) {
1425 double dz = recVtxs->at(
iv).z() - recVtxs->at(jv).z();
1426 double dtsigma =
std::sqrt(recVtxs->at(
iv).covariance(3, 3) + recVtxs->at(jv).covariance(3, 3));
1428 ? (recVtxs->at(
iv).t() - recVtxs->at(jv).t()) / dtsigma
1430 if (recopv.at(
iv).is_fake() && recopv.at(jv).is_real()) {
1436 mindistance_fakereal =
dz;
1440 if (recopv.at(
iv).is_real() && recopv.at(jv).is_fake() && (
std::abs(dz) <
std::abs(mindistance_realfake))) {
1441 mindistance_realfake =
dz;
1460 ->setComment(
"Association between General and MTD Extended tracks");
1468 desc.
add<
bool>(
"useOnlyChargedTracks",
true);
1471 desc.
add<
double>(
"trackweightTh", 0.5);
1472 desc.
add<
double>(
"mvaTh", 0.01);
1476 std::vector<double> lDP;
1477 lDP.push_back(1.87);
1479 lDP.push_back(42.5);
1480 desc.
add<std::vector<double>>(
"lineDensityPar", lDP);
1481 descriptions.
add(
"vertices4D", desc);
1496 const double& st0) {
1500 match = match &&
std::abs(t0 - vtx.
t()) < 3. * st0;
MonitorElement * meTrackResLowPTot_
MonitorElement * meMatchQual_
edm::EDGetTokenT< edm::View< reco::Vertex > > Rec4DVerToken_
MonitorElement * meRecoPVPosSignal_
std::vector< unsigned int > wos_dominated_recv
MonitorElement * meMVATrackEffEtaTot_
MonitorElement * meRecPVT_
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexCollectionToken_
const bool mvaTPSel(const TrackingParticle &)
MonitorElement * meMVATrackMatchedEffEtaTot_
double closest_vertex_distance_z
static constexpr double etacutREC_
MonitorElement * meTrackResTot_
MonitorElement * mePUvsRealV_
MonitorElement * meTrackResLowP_[3]
MonitorElement * meTimeRes_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
MonitorElement * meDeltaTrealreal_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleCollectionToken_
TrackingVertexRef sim_vertex
virtual void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< edm::ValueMap< float > > sigmat0SafePidToken_
const_iterator end() const
last iterator over the map (read only)
static constexpr double selNdof_
std::vector< Primary4DVertexValidation::simPrimaryVertex > getSimPVs(const edm::Handle< TrackingVertexCollection > &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * meTimeSignalRes_
edm::EDGetTokenT< reco::BeamSpot > RecBeamSpotToken_
MonitorElement * meTrackPullTot_
static constexpr double pTcut_
int num_matched_sim_tracks
#define DEFINE_FWK_MODULE(type)
bool select(const reco::Vertex &, int level=0)
void matchReco2Sim(std::vector< recoPrimaryVertex > &, std::vector< simPrimaryVertex > &, const edm::ValueMap< float > &, const edm::ValueMap< float > &, const edm::Handle< reco::BeamSpot > &)
Sin< T >::type sin(const T &t)
edm::RefToBase< reco::Vertex > VertexBaseRef
persistent reference to a Vertex, using views
const_iterator find(const key_type &k) const
find element with specified reference key
bool matchRecoTrack2SimSignal(const reco::TrackBaseRef &)
MonitorElement * meDeltaZfakereal_
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
static constexpr double etacutGEN_
MonitorElement * meTrackZposRes_[3]
Exp< T >::type exp(const T &t)
MonitorElement * meSimPVZ_
const std::string folder_
int status() const
Status word.
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::ValueMap< float > > timeToken_
std::vector< Primary4DVertexValidation::recoPrimaryVertex > getRecoPVs(const edm::Handle< edm::View< reco::Vertex >> &)
MonitorElement * meTrackZposResTot_
MonitorElement * meTrackResMassProtons_[3]
MonitorElement * meTrackResMassTrueProtons_[3]
std::map< unsigned int, double > wnt
MonitorElement * meRecoPosInSimCollection_
std::map< unsigned int, double > wos
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
MonitorElement * meRecoPVPosSignalNotHighestPt_
MonitorElement * meMVATrackEffPtTot_
static constexpr double simUnit_
double timeFromTrueMass(double, double, double, double)
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
unsigned int matchQuality
double eta() const
pseudorapidity of momentum vector
math::XYZTLorentzVector LorentzVector
static constexpr double c_
void addTrack(unsigned int irecv, double twos, double twt)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
MonitorElement * meMVATrackMatchedEffPtMtd_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * meMVATrackResTot_
MonitorElement * meTrackResHighPTot_
Primary4DVertexValidation(const edm::ParameterSet &)
double pt() const
track transverse momentum
MonitorElement * meTrackPull_[3]
Cos< T >::type cos(const T &t)
MonitorElement * meTrackPullHighPTot_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
trackRef_iterator tracks_end() const
last iterator over tracks
double z() const
z coordinate
bool use_only_charged_tracks_
bool get(ProductID const &oid, Handle< PROD > &result) const
MonitorElement * meTimePull_
edm::EDGetTokenT< edm::ValueMap< float > > momentumToken_
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
MonitorElement * meDeltaZrealreal_
MonitorElement * meTrackResMassTruePions_[3]
unsigned int matchQuality
MonitorElement * meTimeSignalPull_
recoPrimaryVertex(double x1, double y1, double z1)
static constexpr double maxTry_
edm::EDGetTokenT< reco::TrackCollection > RecTrackToken_
trackRef_iterator tracks_begin() const
first iterator over tracks
ParameterDescriptionBase * add(U const &iLabel, T const &value)
MonitorElement * meMVATrackMatchedEffPtTot_
const std::vector< double > lineDensityPar_
Log< level::Warning, true > LogPrint
const reco::RecoToSimCollection * r2s_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > vecPileupSummaryInfoToken_
simPrimaryVertex(double x1, double y1, double z1, double t1)
static constexpr double deltaZcut_
const reco::Vertex * recVtx
const bool mvaRecSel(const reco::TrackBase &, const reco::Vertex &, const double &, const double &)
edm::Ref< TrackingVertexCollection > TrackingVertexRef
MonitorElement * meRecoPosInRecoOrigCollection_
MonitorElement * meMVATrackZposResTot_
MonitorElement * meTrackResMassTrue_[3]
double vz() const
z coordinate of the reference point on track
static constexpr unsigned int NOT_MATCHED
MonitorElement * meRecPVZ_
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoAssociationToken_
edm::EDGetTokenT< edm::ValueMap< int > > trackAssocToken_
static constexpr double mvaH_
MonitorElement * meMVATrackMatchedEffEtaMtd_
int num_matched_reco_tracks
std::map< unsigned int, double > wnt
static constexpr double mvaL_
std::map< unsigned int, double > wos
float average_match_quality
const edm::Ref< std::vector< TrackingParticle > > * getMatchedTP(const reco::TrackBaseRef &, const TrackingVertexRef &)
reco::VertexBaseRef recVtxRef
static constexpr double maxRank_
~Primary4DVertexValidation() override
MonitorElement * meSimPosInSimOrigCollection_
T getParameter(std::string const &) const
MonitorElement * meTrack3DposRes_[3]
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const double trackweightTh_
double eta() const
Momentum pseudorapidity. Note this is taken from the first SimTrack only.
void addTrack(unsigned int iev, double twos, double wt)
double closest_vertex_distance_z
MonitorElement * meTrackPullLowPTot_
MonitorElement * meDeltaZfakefake_
const reco::SimToRecoCollection * s2r_
MonitorElement * meMVATrackPullTot_
Monte Carlo truth information used for tracking validation.
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimAssociationToken_
MonitorElement * meRecoVtxVsLineDensity_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
MonitorElement * meTrackRes_[3]
Log< level::Warning, false > LogWarning
MonitorElement * meTrackResMassPions_[3]
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int iev
edm::EDGetTokenT< edm::ValueMap< float > > t0SafePidToken_
static constexpr double zWosMatchMax_
MonitorElement * meTrackResHighP_[3]
MonitorElement * meTrackResMass_[3]
Power< A, B >::type pow(const A &a, const B &b)
MonitorElement * meTrackPullHighP_[3]
MonitorElement * mePUvsSplitV_
MonitorElement * meRecVerNumber_
MonitorElement * mePUvsOtherFakeV_
edm::EDGetTokenT< edm::ValueMap< float > > trackMVAQualToken_
MonitorElement * meTrackPullLowP_[3]
double t() const
t coordinate
edm::EDGetTokenT< edm::ValueMap< float > > pathLengthToken_
MonitorElement * meDeltaTfakereal_
MonitorElement * meDeltaTfakefake_