90 std::map<unsigned int, double>
wnt;
91 std::map<unsigned int, double>
wos;
97 void addTrack(
unsigned int irecv,
double twos,
double twt) {
99 if (
wnt.find(irecv) ==
wnt.end()) {
106 if (
wos.find(irecv) ==
wos.end()) {
138 std::map<unsigned int, double>
wos;
139 std::map<unsigned int, double>
wnt;
167 if (
wnt.find(iev) ==
wnt.end()) {
174 if (
wos.find(iev) ==
wos.end()) {
192 std::vector<simPrimaryVertex>&,
211 static constexpr
double c_ = 2.99792458e1;
212 static constexpr
double mvaL_ = 0.5;
213 static constexpr
double mvaH_ = 0.8;
317 trackweightTh_(iConfig.getParameter<double>(
"trackweightTh")),
318 mvaTh_(iConfig.getParameter<double>(
"mvaTh")),
319 lineDensityPar_(iConfig.getParameter<std::
vector<double>>(
"lineDensityPar")),
320 use_only_charged_tracks_(iConfig.getParameter<bool>(
"useOnlyChargedTracks")),
321 debug_(iConfig.getUntrackedParameter<bool>(
"debug")),
322 optionalPlots_(iConfig.getUntrackedParameter<bool>(
"optionalPlots")) {
356 ibook.
book1D(
"MVAMatchedEffPtTot",
"Pt of tracks associated to LV matched to TP; track pt [GeV] ", 110, 0., 11.);
358 "MVAMatchedEffPtMtd",
"Pt of tracks associated to LV matched to TP with time; track pt [GeV] ", 110, 0., 11.);
360 ibook.
book1D(
"MVAMatchedEffEtaTot",
"Pt of tracks associated to LV matched to TP; track eta ", 66, 0., 3.3);
362 "MVAMatchedEffEtaMtd",
"Pt of tracks associated to LV matched to TP with time; track eta ", 66, 0., 3.3);
364 "MVATrackRes",
"t_{rec} - t_{sim} for tracks from LV MVA sel.; t_{rec} - t_{sim} [ns] ", 120, -0.15, 0.15);
365 meTrackResTot_ = ibook.
book1D(
"TrackRes",
"t_{rec} - t_{sim} for tracks; t_{rec} - t_{sim} [ns] ", 120, -0.15, 0.15);
367 "TrackRes-LowMVA",
"t_{rec} - t_{sim} for tracks with MVA < 0.5; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
369 "TrackRes-MediumMVA",
"t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
371 "TrackRes-HighMVA",
"t_{rec} - t_{sim} for tracks with MVA > 0.8; t_{rec} - t_{sim} [ns] ", 100, -1., 1.);
374 "TrackResMass-LowMVA",
"t_{rec} - t_{est} for tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ", 100, -1., 1.);
376 "t_{rec} - t_{est} for tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
381 "TrackResMass-HighMVA",
"t_{rec} - t_{est} for tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ", 100, -1., 1.);
383 "TrackResMassTrue-LowMVA",
"t_{est} - t_{sim} for tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ", 100, -1., 1.);
385 "t_{est} - t_{sim} for tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
390 "t_{est} - t_{sim} for tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
396 ibook.
book1D(
"MVATrackPull",
"Pull for tracks from LV MAV sel.; (t_{rec}-t_{sim})/#sigma_{t}", 50, -5., 5.);
397 meTrackPullTot_ = ibook.
book1D(
"TrackPull",
"Pull for tracks; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
399 ibook.
book1D(
"TrackPull-LowMVA",
"Pull for tracks with MVA < 0.5; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
401 "TrackPull-MediumMVA",
"Pull for tracks with 0.5 < MVA < 0.8; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
403 ibook.
book1D(
"TrackPull-HighMVA",
"Pull for tracks with MVA > 0.8; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
405 "MVATrackZposResTot",
"Z_{PCA} - Z_{sim} for tracks from LV MVA sel.;Z_{PCA} - Z_{sim} [cm] ", 50, -0.1, 0.1);
407 ibook.
book1D(
"TrackZposResTot",
"Z_{PCA} - Z_{sim} for tracks;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
409 "TrackZposRes-LowMVA",
"Z_{PCA} - Z_{sim} for tracks with MVA < 0.5;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
411 "Z_{PCA} - Z_{sim} for tracks with 0.5 < MVA < 0.8 ;Z_{PCA} - Z_{sim} [cm] ",
416 "TrackZposRes-HighMVA",
"Z_{PCA} - Z_{sim} for tracks with MVA > 0.8 ;Z_{PCA} - Z_{sim} [cm] ", 50, -0.5, 0.5);
418 ibook.
book1D(
"Track3DposRes-LowMVA",
419 "3dPos_{PCA} - 3dPos_{sim} for tracks with MVA < 0.5 ;3dPos_{PCA} - 3dPos_{sim} [cm] ",
424 ibook.
book1D(
"Track3DposRes-MediumMVA",
425 "3dPos_{PCA} - 3dPos_{sim} for tracks with 0.5 < MVA < 0.8 ;3dPos_{PCA} - 3dPos_{sim} [cm] ",
430 ibook.
book1D(
"Track3DposRes-HighMVA",
431 "3dPos_{PCA} - 3dPos_{sim} for tracks with MVA > 0.8;3dPos_{PCA} - 3dPos_{sim} [cm] ",
435 meTimeRes_ = ibook.
book1D(
"TimeRes",
"t_{rec} - t_{sim} ;t_{rec} - t_{sim} [ns] ", 40, -0.2, 0.2);
436 meTimePull_ = ibook.
book1D(
"TimePull",
"Pull; t_{rec} - t_{sim}/#sigma_{t rec}", 100, -10., 10.);
438 ibook.
book1D(
"TimeSignalRes",
"t_{rec} - t_{sim} for signal ;t_{rec} - t_{sim} [ns] ", 40, -0.2, 0.2);
440 ibook.
book1D(
"TimeSignalPull",
"Pull for signal; t_{rec} - t_{sim}/#sigma_{t rec}", 100, -10., 10.);
442 ibook.
bookProfile(
"PUvsReal",
"#PU vertices vs #real matched vertices;#PU;#real ", 100, 0, 300, 100, 0, 200);
444 "PUvsOtherFake",
"#PU vertices vs #other fake matched vertices;#PU;#other fake ", 100, 0, 300, 100, 0, 20);
446 ibook.
bookProfile(
"PUvsSplit",
"#PU vertices vs #split matched vertices;#PU;#split ", 100, 0, 300, 100, 0, 20);
447 meMatchQual_ = ibook.
book1D(
"MatchQuality",
"RECO-SIM vertex match quality; ", 8, 0, 8.);
451 meDeltaTrealreal_ = ibook.
book1D(
"DeltaTrealreal",
"#Delta T real-real; |#Delta T (r-r)| [sigma]", 60, 0., 30.);
452 meDeltaTfakefake_ = ibook.
book1D(
"DeltaTfakefake",
"#Delta T fake-fake; |#Delta T (f-f)| [sigma]", 60, 0., 30.);
453 meDeltaTfakereal_ = ibook.
book1D(
"DeltaTfakereal",
"#Delta T fake-real; |#Delta T (f-r)| [sigma]", 60, 0., 30.);
456 "RecoPosInSimCollection",
"Sim signal vertex index associated to Reco signal vertex; Sim PV index", 200, 0, 200);
458 ibook.
book1D(
"RecoPosInRecoOrigCollection",
"Reco signal index in OrigCollection; Reco index", 200, 0, 200);
460 ibook.
book1D(
"SimPosInSimOrigCollection",
"Sim signal index in OrigCollection; Sim index", 200, 0, 200);
463 ibook.
book1D(
"RecoPVPosSignal",
"Position in reco collection of PV associated to sim signal", 200, 0, 200);
465 ibook.
book1D(
"RecoPVPosSignalNotHighestPt",
466 "Position in reco collection of PV associated to sim signal not highest Pt",
471 ibook.
book1D(
"RecoVtxVsLineDensity",
"#Reco vertices/mm/event; line density [#vtx/mm/event]", 160, 0., 4.);
472 meRecVerNumber_ = ibook.
book1D(
"RecVerNumber",
"RECO Vertex Number: Number of vertices", 50, 0, 250);
473 meRecPVZ_ = ibook.
book1D(
"recPVZ",
"Weighted #Rec vertices/mm", 400, -20., 20.);
474 meRecPVT_ = ibook.
book1D(
"recPVT",
"#Rec vertices/10 ps", 200, -1., 1.);
475 meSimPVZ_ = ibook.
book1D(
"simPVZ",
"Weighted #Sim vertices/mm", 400, -20., 20.);
479 "TrackResLowP",
"t_{rec} - t_{sim} for tracks with p < 2 GeV; t_{rec} - t_{sim} [ns] ", 70, -0.15, 0.15);
481 ibook.
book1D(
"TrackResLowP-LowMVA",
482 "t_{rec} - t_{sim} for tracks with MVA < 0.5 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
487 ibook.
book1D(
"TrackResLowP-MediumMVA",
488 "t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
493 ibook.
book1D(
"TrackResLowP-HighMVA",
494 "t_{rec} - t_{sim} for tracks with MVA > 0.8 and p < 2 GeV; t_{rec} - t_{sim} [ns] ",
499 "TrackResHighP",
"t_{rec} - t_{sim} for tracks with p > 2 GeV; t_{rec} - t_{sim} [ns] ", 70, -0.15, 0.15);
501 ibook.
book1D(
"TrackResHighP-LowMVA",
502 "t_{rec} - t_{sim} for tracks with MVA < 0.5 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
507 ibook.
book1D(
"TrackResHighP-MediumMVA",
508 "t_{rec} - t_{sim} for tracks with 0.5 < MVA < 0.8 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
513 ibook.
book1D(
"TrackResHighP-HighMVA",
514 "t_{rec} - t_{sim} for tracks with MVA > 0.8 and p > 2 GeV; t_{rec} - t_{sim} [ns] ",
519 ibook.
book1D(
"TrackPullLowP",
"Pull for tracks with p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
521 "Pull for tracks with MVA < 0.5 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
526 "Pull for tracks with 0.5 < MVA < 0.8 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
531 "Pull for tracks with MVA > 0.8 and p < 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
536 ibook.
book1D(
"TrackPullHighP",
"Pull for tracks with p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}", 100, -10., 10.);
538 "Pull for tracks with MVA < 0.5 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
543 ibook.
book1D(
"TrackPullHighP-MediumMVA",
544 "Pull for tracks with 0.5 < MVA < 0.8 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
549 "Pull for tracks with MVA > 0.8 and p > 2 GeV; (t_{rec}-t_{sim})/#sigma_{t}",
555 ibook.
book1D(
"TrackResMass-Protons-LowMVA",
556 "t_{rec} - t_{est} for proton tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ",
561 ibook.
book1D(
"TrackResMass-Protons-MediumMVA",
562 "t_{rec} - t_{est} for proton tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
567 ibook.
book1D(
"TrackResMass-Protons-HighMVA",
568 "t_{rec} - t_{est} for proton tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ",
573 ibook.
book1D(
"TrackResMassTrue-Protons-LowMVA",
574 "t_{est} - t_{sim} for proton tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ",
579 ibook.
book1D(
"TrackResMassTrue-Protons-MediumMVA",
580 "t_{est} - t_{sim} for proton tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
585 ibook.
book1D(
"TrackResMassTrue-Protons-HighMVA",
586 "t_{est} - t_{sim} for proton tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
592 "t_{rec} - t_{est} for pion tracks with MVA < 0.5; t_{rec} - t_{est} [ns] ",
597 ibook.
book1D(
"TrackResMass-Pions-MediumMVA",
598 "t_{rec} - t_{est} for pion tracks with 0.5 < MVA < 0.8; t_{rec} - t_{est} [ns] ",
603 "t_{rec} - t_{est} for pion tracks with MVA > 0.8; t_{rec} - t_{est} [ns] ",
608 ibook.
book1D(
"TrackResMassTrue-Pions-LowMVA",
609 "t_{est} - t_{sim} for pion tracks with MVA < 0.5; t_{est} - t_{sim} [ns] ",
614 ibook.
book1D(
"TrackResMassTrue-Pions-MediumMVA",
615 "t_{est} - t_{sim} for pion tracks with 0.5 < MVA < 0.8; t_{est} - t_{sim} [ns] ",
620 ibook.
book1D(
"TrackResMassTrue-Pions-HighMVA",
621 "t_{est} - t_{sim} for pion tracks with MVA > 0.8; t_{est} - t_{sim} [ns] ",
636 for (
const auto&
tp :
found->val) {
637 if (
tp.first->eventId().bunchCrossing() == 0 &&
tp.first->eventId().event() == 0)
654 for (
const auto&
tp :
found->val) {
655 if (std::find_if(vsim->daughterTracks_begin(), vsim->daughterTracks_end(), [&](
const TrackingParticleRef& vtp) {
656 return tp.first == vtp;
657 }) != vsim->daughterTracks_end())
666 if (time > 0 && pathlength > 0 && mass > 0) {
667 double gammasq = 1. + momentum * momentum / (mass *
mass);
669 double t_est = time - (pathlength /
v);
701 std::vector<Primary4DVertexValidation::simPrimaryVertex> simpv;
702 int current_event = -1;
704 for (TrackingVertexCollection::const_iterator
v = tVC->begin();
v != tVC->end(); ++
v) {
706 if (
v->eventId().bunchCrossing() != 0)
708 if (
v->eventId().event() != current_event) {
709 current_event =
v->eventId().event();
718 simPrimaryVertex sv(
v->position().x(),
v->position().y(),
v->position().z(),
v->position().t());
721 sv.OriginalIndex =
s;
725 assert((**iTrack).eventId().bunchCrossing() == 0);
728 for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin(); v0 != simpv.end(); v0++) {
729 if ((sv.eventId == v0->eventId) && (
std::abs(sv.x - v0->x) < 1
e-5) && (
std::abs(sv.y - v0->y) < 1
e-5) &&
743 auto momentum = (*(*iTP)).momentum();
744 const reco::Track* matched_best_reco_track =
nullptr;
745 double match_quality = -1;
749 matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
750 match_quality = (*s2r_)[*iTP][0].second;
753 vp->
ptot.setPx(vp->
ptot.x() + momentum.x());
754 vp->
ptot.setPy(vp->
ptot.y() + momentum.y());
755 vp->
ptot.setPz(vp->
ptot.z() + momentum.z());
756 vp->
ptot.setE(vp->
ptot.e() + (**iTP).energy());
757 vp->
ptsq += ((**iTP).pt() * (**iTP).pt());
759 if (matched_best_reco_track) {
779 auto prev_z = simpv.back().z;
781 vsim.closest_vertex_distance_z =
std::abs(vsim.z - prev_z);
785 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
786 std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
788 for (; vsim2 != simpv.end(); vsim2++) {
791 vsim->closest_vertex_distance_z =
std::min(vsim->closest_vertex_distance_z, distance);
792 vsim2->closest_vertex_distance_z =
std::min(vsim2->closest_vertex_distance_z, distance);
802 std::vector<Primary4DVertexValidation::recoPrimaryVertex> recopv;
804 for (
auto v = tVC->begin();
v != tVC->end(); ++
v) {
809 if (
v->isFake() || !
v->isValid())
816 sv.OriginalIndex =
r;
818 recopv.push_back(sv);
822 for (
auto iTrack =
v->tracks_begin(); iTrack !=
v->tracks_end(); ++iTrack) {
823 auto momentum = (*(*iTrack)).innerMomentum();
824 if (momentum.mag2() == 0)
825 momentum = (*(*iTrack)).momentum();
827 vp->
ptsq += (momentum.perp2());
844 auto prev_z = recopv.back().z;
846 vreco.closest_vertex_distance_z =
std::abs(vreco.z - prev_z);
849 for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin(); vreco != recopv.end(); vreco++) {
850 std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
852 for (; vreco2 != recopv.end(); vreco2++) {
855 vreco->closest_vertex_distance_z =
std::min(vreco->closest_vertex_distance_z, distance);
856 vreco2->closest_vertex_distance_z =
std::min(vreco2->closest_vertex_distance_z, distance);
864 std::vector<simPrimaryVertex>& simpv,
868 for (
auto vv : simpv) {
872 for (
auto rv : recopv) {
877 for (
unsigned int iv = 0;
iv < recopv.size();
iv++) {
880 for (
unsigned int iev = 0;
iev < simpv.size();
iev++) {
888 double pt = (*iTrack)->pt();
892 if (MVA[(*iTrack)] <
mvaTh_)
896 if (tp_info !=
nullptr) {
897 double dz2_beam =
pow((*BS).BeamWidthX() *
cos((*iTrack)->phi()) /
tan((*iTrack)->theta()), 2) +
898 pow((*BS).BeamWidthY() *
sin((*iTrack)->phi()) /
tan((*iTrack)->theta()), 2);
899 double dz2 =
pow((*iTrack)->dzError(), 2) + dz2_beam +
904 if (sigmat0[(*iTrack)] > 0) {
905 double sigmaZ = (*BS).sigmaZ();
906 double sigmaT = sigmaZ /
c_;
907 wos = wos / erf(sigmat0[(*iTrack)] / sigmaT);
909 simpv.at(
iev).addTrack(
iv, wos, wnt);
910 recopv.at(
iv).addTrack(
iev, wos, wnt);
918 if ((evwos > 0) && (evwos > recopv.at(
iv).maxwos) && (evnt > 1)) {
919 recopv.at(
iv).wosmatch =
iev;
920 recopv.at(
iv).maxwos = evwos;
921 recopv.at(
iv).maxwosnt = evnt;
923 simpv.at(
iev).wos_dominated_recv.push_back(
iv);
924 simpv.at(
iev).nwosmatch++;
928 if ((evnt > 0) && (evwnt > recopv.at(
iv).maxwnt)) {
929 recopv.at(
iv).wntmatch =
iev;
930 recopv.at(
iv).maxwnt = evwnt;
937 for (
auto& vrec : recopv) {
939 vrec.matchQuality = 0;
941 unsigned int iev = 0;
942 for (
auto& vv : simpv) {
945 edm::LogPrint(
"Primary4DVertexValidation") <<
"wos_dominated_recv.size: " << vv.wos_dominated_recv.size();
947 for (
unsigned int i = 0;
i < vv.wos_dominated_recv.size();
i++) {
948 auto recov = vv.wos_dominated_recv.at(
i);
951 <<
"index of reco vertex: " << recov <<
" that has a wos: " << vv.wos.at(recov) <<
" at position " <<
i;
959 for (
unsigned int rank = 1; rank <
maxRank_; rank++) {
960 for (
unsigned int iev = 0; iev < simpv.size(); iev++) {
963 if (simpv.at(iev).nwosmatch == 0)
965 if (simpv.at(iev).nwosmatch > rank)
968 for (
unsigned int k = 0;
k < simpv.at(iev).wos_dominated_recv.size();
k++) {
969 unsigned int rec = simpv.at(iev).wos_dominated_recv.at(
k);
970 auto vrec = recopv.at(rec);
975 if ((iv ==
NOT_MATCHED) || simpv.at(iev).wos.at(rec) > simpv.at(iev).wos.at(iv)) {
981 recopv.at(iv).sim =
iev;
982 simpv.at(iev).rec =
iv;
983 recopv.at(iv).matchQuality = rank;
984 simpv.at(iev).matchQuality = rank;
991 unsigned int ntry = 0;
994 for (
unsigned int iev = 0; iev < simpv.size(); iev++) {
995 if ((simpv.at(iev).rec !=
NOT_MATCHED) || (simpv.at(iev).wos.empty()))
999 for (
auto rv : simpv.at(iev).wos) {
1000 if ((rec ==
NOT_MATCHED) || (rv.second > simpv.at(iev).wos.at(rec))) {
1006 for (
auto rv : simpv.at(iev).wnt) {
1007 if ((rec ==
NOT_MATCHED) || (rv.second > simpv.at(iev).wnt.at(rec))) {
1020 for (
auto sv : recopv.at(rec).wos) {
1023 if ((rec2sim ==
NOT_MATCHED) || (sv.second > recopv.at(rec).wos.at(rec2sim))) {
1027 if (iev == rec2sim) {
1029 recopv.at(rec).sim =
iev;
1030 recopv.at(rec).matchQuality =
maxRank_;
1031 simpv.at(iev).rec = rec;
1032 simpv.at(iev).matchQuality =
maxRank_;
1048 using namespace reco;
1050 std::vector<float> pileUpInfo_z;
1055 for (
auto const& pu_info : *puinfoH.product()) {
1056 if (pu_info.getBunchCrossing() == 0) {
1057 pileUpInfo_z = pu_info.getPU_zpositions();
1065 if (!TPCollectionH.isValid())
1066 edm::LogWarning(
"Primary4DVertexValidation") <<
"TPCollectionH is not valid";
1070 if (!TVCollectionH.isValid())
1071 edm::LogWarning(
"Primary4DVertexValidation") <<
"TVCollectionH is not valid";
1075 if (simToRecoH.isValid())
1076 s2r_ = simToRecoH.product();
1078 edm::LogWarning(
"Primary4DVertexValidation") <<
"simToRecoH is not valid";
1082 if (recoToSimH.isValid())
1083 r2s_ = recoToSimH.product();
1085 edm::LogWarning(
"Primary4DVertexValidation") <<
"recoToSimH is not valid";
1089 if (!BeamSpotH.isValid())
1090 edm::LogWarning(
"Primary4DVertexValidation") <<
"BeamSpotH is not valid";
1092 std::vector<simPrimaryVertex> simpv;
1095 bool signal_is_highest_pt =
1097 return lhs.ptsq < rhs.ptsq;
1098 }) == simpv.begin();
1100 std::vector<recoPrimaryVertex> recopv;
1103 if (!recVtxs.isValid())
1104 edm::LogWarning(
"Primary4DVertexValidation") <<
"recVtxs is not valid";
1116 matchReco2Sim(recopv, simpv, sigmat0Safe, mtdQualMVA, BeamSpotH);
1119 for (
unsigned int iv = 0;
iv < recopv.size();
iv++) {
1122 for (
unsigned int iev = 0;
iev < simpv.size();
iev++) {
1123 auto vsim = simpv.at(
iev).sim_vertex;
1125 bool selectedVtxMatching = recopv.at(
iv).sim ==
iev && simpv.at(
iev).rec ==
iv &&
1126 simpv.at(
iev).eventId.bunchCrossing() == 0 && simpv.at(
iev).eventId.event() == 0 &&
1127 recopv.at(
iv).OriginalIndex == 0;
1128 if (selectedVtxMatching && !recopv.at(
iv).is_signal()) {
1130 <<
"Reco vtx leading match inconsistent: BX/ID " << simpv.at(
iev).eventId.bunchCrossing() <<
" "
1131 << simpv.at(
iev).eventId.event();
1133 double vzsim = simpv.at(
iev).z;
1137 if (trackAssoc[*iTrack] == -1) {
1138 LogTrace(
"mtdTracks") <<
"Extended track not associated";
1145 bool selectRecoTrk =
mvaRecSel(**iTrack, *vertex, t0Safe[*iTrack], sigmat0Safe[*iTrack]);
1146 if (selectedVtxMatching && selectRecoTrk) {
1152 if (tp_info !=
nullptr) {
1153 double mass = (*tp_info)->mass();
1154 double tsim = (*tp_info)->parentVertex()->position().t() *
simUnit_;
1155 double tEst =
timeFromTrueMass(mass, pathLength[*iTrack], momentum[*iTrack], time[*iTrack]);
1157 double xsim = (*tp_info)->parentVertex()->position().x();
1158 double ysim = (*tp_info)->parentVertex()->position().y();
1159 double zsim = (*tp_info)->parentVertex()->position().z();
1160 double xPCA = (*iTrack)->vx();
1161 double yPCA = (*iTrack)->vy();
1162 double zPCA = (*iTrack)->vz();
1164 double dZ = zPCA - zsim;
1165 double d3D =
std::sqrt((xPCA - xsim) * (xPCA - xsim) + (yPCA - ysim) * (yPCA - ysim) + dZ * dZ);
1167 if ((xPCA - xsim) * ((*tp_info)->px()) + (yPCA - ysim) * ((*tp_info)->py()) + dZ * ((*tp_info)->pz()) < 0.) {
1171 bool selectTP =
mvaTPSel(**tp_info);
1173 if (selectedVtxMatching && selectRecoTrk && selectTP) {
1179 if (sigmat0Safe[*iTrack] == -1)
1182 if (selectedVtxMatching && selectRecoTrk && selectTP) {
1191 if ((*iTrack)->p() <= 2) {
1199 if (mtdQualMVA[(*iTrack)] <
mvaL_) {
1210 if ((*iTrack)->p() <= 2) {
1213 }
else if ((*iTrack)->p() > 2) {
1219 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1222 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1228 }
else if (mtdQualMVA[(*iTrack)] >
mvaL_ && mtdQualMVA[(*iTrack)] <
mvaH_) {
1239 if ((*iTrack)->p() <= 2) {
1242 }
else if ((*iTrack)->p() > 2) {
1248 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1251 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1257 }
else if (mtdQualMVA[(*iTrack)] >
mvaH_) {
1268 if ((*iTrack)->p() <= 2) {
1271 }
else if ((*iTrack)->p() > 2) {
1277 if (
std::abs((*tp_info)->pdgId()) == 2212) {
1280 }
else if (
std::abs((*tp_info)->pdgId()) == 211) {
1296 auto puLineDensity = [&](
double z) {
1303 for (
unsigned int ir = 0; ir < recopv.size(); ir++) {
1305 meRecPVZ_->
Fill(recopv.at(ir).z, 1. / puLineDensity(recopv.at(ir).z));
1306 if (recopv.at(ir).recVtx->tError() > 0.) {
1310 edm::LogPrint(
"Primary4DVertexValidation") <<
"************* IR: " << ir;
1312 <<
"z: " << recopv.at(ir).z <<
" corresponding to line density: " << puLineDensity(recopv.at(ir).z);
1313 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_real: " << recopv.at(ir).is_real();
1314 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_fake: " << recopv.at(ir).is_fake();
1315 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_signal: " << recopv.at(ir).is_signal();
1316 edm::LogPrint(
"Primary4DVertexValidation") <<
"split_from: " << recopv.at(ir).split_from();
1317 edm::LogPrint(
"Primary4DVertexValidation") <<
"other fake: " << recopv.at(ir).other_fake();
1319 if (recopv.at(ir).is_real())
1321 if (recopv.at(ir).is_fake())
1323 if (recopv.at(ir).other_fake())
1325 if (recopv.at(ir).split_from() != -1) {
1331 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_real: " << real;
1332 edm::LogPrint(
"Primary4DVertexValidation") <<
"is_fake: " << fake;
1334 edm::LogPrint(
"Primary4DVertexValidation") <<
"other fake: " << other_fake;
1338 for (
unsigned int is = 0; is < simpv.size(); is++) {
1339 meSimPVZ_->
Fill(simpv.at(is).z, 1. / puLineDensity(simpv.at(is).z));
1346 edm::LogPrint(
"Primary4DVertexValidation") <<
"sim vertex: " << is <<
" is not matched with any reco";
1351 for (
unsigned int ir = 0; ir < recopv.size(); ir++) {
1352 if (recopv.at(ir).sim == is && simpv.at(is).rec == ir) {
1362 recopv.at(ir).recVtx->tError());
1368 if (simpv.at(is).eventId.bunchCrossing() == 0 && simpv.at(is).eventId.event() == 0) {
1369 if (!recopv.at(ir).is_signal()) {
1371 <<
"Reco vtx leading match inconsistent: BX/ID " << simpv.at(is).eventId.bunchCrossing() <<
" "
1372 << simpv.at(is).eventId.event();
1375 recopv.at(ir).OriginalIndex);
1376 if (!signal_is_highest_pt) {
1378 recopv.at(ir).OriginalIndex);
1383 edm::LogPrint(
"Primary4DVertexValidation") <<
"*** Matching RECO: " << ir <<
"with SIM: " << is <<
" ***";
1384 edm::LogPrint(
"Primary4DVertexValidation") <<
"Match Quality is " << recopv.at(ir).matchQuality;
1392 for (
unsigned int iv = 0;
iv < recVtxs->size() - 1;
iv++) {
1394 double mindistance_realreal = 1e10;
1396 for (
unsigned int jv =
iv; jv < recVtxs->size(); jv++) {
1397 if ((!(jv ==
iv)) &&
select(recVtxs->at(jv))) {
1398 double dz = recVtxs->at(
iv).z() - recVtxs->at(jv).z();
1399 double dtsigma =
std::sqrt(recVtxs->at(
iv).covariance(3, 3) + recVtxs->at(jv).covariance(3, 3));
1401 ? (recVtxs->at(
iv).t() - recVtxs->at(jv).t()) / dtsigma
1403 if (recopv.at(
iv).is_real() && recopv.at(jv).is_real()) {
1409 mindistance_realreal =
dz;
1411 }
else if (recopv.at(
iv).is_fake() && recopv.at(jv).is_fake()) {
1420 double mindistance_fakereal = 1e10;
1421 double mindistance_realfake = 1e10;
1422 for (
unsigned int jv = 0; jv < recVtxs->size(); jv++) {
1423 if ((!(jv ==
iv)) &&
select(recVtxs->at(jv))) {
1424 double dz = recVtxs->at(
iv).z() - recVtxs->at(jv).z();
1425 double dtsigma =
std::sqrt(recVtxs->at(
iv).covariance(3, 3) + recVtxs->at(jv).covariance(3, 3));
1427 ? (recVtxs->at(
iv).t() - recVtxs->at(jv).t()) / dtsigma
1429 if (recopv.at(
iv).is_fake() && recopv.at(jv).is_real()) {
1435 mindistance_fakereal =
dz;
1439 if (recopv.at(
iv).is_real() && recopv.at(jv).is_fake() && (
std::abs(dz) <
std::abs(mindistance_realfake))) {
1440 mindistance_realfake =
dz;
1459 ->setComment(
"Association between General and MTD Extended tracks");
1467 desc.
add<
bool>(
"useOnlyChargedTracks",
true);
1470 desc.
add<
double>(
"trackweightTh", 0.5);
1471 desc.
add<
double>(
"mvaTh", 0.01);
1475 std::vector<double> lDP;
1476 lDP.push_back(1.87);
1478 lDP.push_back(42.5);
1479 desc.
add<std::vector<double>>(
"lineDensityPar", lDP);
1480 descriptions.
add(
"vertices4DValid", desc);
1495 const double& st0) {
1499 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
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int32_t int iev
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())
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_