357 using namespace reco;
359 edm::LogInfo(
"MuonTrackValidator") <<
"\n===================================================="
361 <<
"Analyzing new event"
363 <<
"====================================================\n"
367 int PU_NumInteractions(-1);
372 for (std::vector<PileupSummaryInfo>::const_iterator puInfoIt = puinfoH->begin(); puInfoIt != puinfoH->end();
374 if (puInfoIt->getBunchCrossing() == 0) {
375 PU_NumInteractions = puInfoIt->getPU_NumInteractions();
395 ptr_TPrefV = TPCollectionRefVector_H.
product();
397 event.getByToken(
tp_Token, TPCollection_H);
398 size_t nTP = TPCollection_H->size();
399 for (
size_t i = 0;
i < nTP; ++
i) {
402 ptr_TPrefV = &TPrefV;
407 bool bs_Available =
event.getByToken(
bsSrc_Token, recoBeamSpotHandle);
410 bs = *recoBeamSpotHandle;
413 std::vector<const reco::TrackToTrackingParticleAssociator*> associator;
417 event.getByLabel(associatorName, theAssociator);
418 associator.push_back(theAssociator.
product());
423 for (
unsigned int ww = 0; ww < associators.size(); ww++) {
424 for (
unsigned int www = 0; www <
label.size(); www++) {
429 unsigned int trackCollectionSize = 0;
442 trackCollectionSize = trackCollection->size();
446 <<
"Analyzing " <<
label[www].process() <<
":" <<
label[www].label() <<
":" <<
label[www].instance()
447 <<
" with " << associators[ww].c_str() <<
"\n";
449 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method"
451 recSimColl = associator[ww]->associateRecoToSim(trackCollection, TPCollection_H);
452 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method"
454 simRecColl = associator[ww]->associateSimToReco(trackCollection, TPCollection_H);
457 <<
"Analyzing " <<
label[www].process() <<
":" <<
label[www].label() <<
":" <<
label[www].instance()
463 simRecColl = *simtorecoCollectionH.
product();
467 recSimColl = *recotosimCollectionH.
product();
474 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPC.size() <<
"\n";
478 for (
size_t i = 0;
i < tPC.size();
i++) {
479 bool TP_is_matched =
false;
480 bool isChargeOK =
true;
494 LogTrace(
"MuonTrackValidator") <<
"TrackingParticle " <<
i;
518 nSimHits = tpr.
get()->numberOfHits();
520 nSimHits = tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
522 nSimHits = tpr.
get()->numberOfTrackerHits();
525 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #" << tpr.
key()
526 <<
" (N counted simhits = " << nSimHits <<
")";
528 <<
"momentumTP: pt = " <<
sqrt(momentumTP.perp2()) <<
", pz = " << momentumTP.z()
529 <<
", \t vertexTP: radius = " <<
sqrt(vertexTP.perp2()) <<
", z = " << vertexTP.z();
532 double TPeta = momentumTP.eta();
533 double xTPeta =
getEta(TPeta);
534 double TPpt =
sqrt(momentumTP.perp2());
535 double xTPpt =
getPt(TPpt);
536 double TPphi = momentumTP.phi();
537 double TPrpos =
sqrt(vertexTP.perp2());
538 double TPzpos = vertexTP.z();
540 int assoc_recoTrack_NValidHits = 0;
541 if (simRecColl.
find(tpr) != simRecColl.
end()) {
542 auto const&
rt = simRecColl[tpr];
545 TP_is_matched =
true;
547 if (assoc_recoTrack->
charge() != tpr->charge())
549 quality =
rt.begin()->second;
551 edm::LogVerbatim(
"MuonTrackValidator") <<
"-----------------------------associated to Track #"
552 << assoc_recoTrack.
key() <<
" with quality:" << quality <<
"\n";
556 <<
"TrackingParticle #" << tpr.
key() <<
" with pt,eta,phi: " <<
sqrt(momentumTP.perp2()) <<
" , "
557 << momentumTP.eta() <<
" , " << momentumTP.phi() <<
" , "
558 <<
" NOT associated to any reco::Track"
636 <<
"\n# of reco::Tracks with " <<
label[www].process() <<
":" <<
label[www].label() <<
":"
637 <<
label[www].instance() <<
": " << trackCollectionSize <<
"\n";
642 bool Track_is_matched =
false;
643 bool isChargeOK =
true;
645 int nRecHits =
track->numberOfValidHits();
648 std::vector<std::pair<TrackingParticleRef, double> >
tp;
653 edm::LogVerbatim(
"MuonTrackValidator") <<
"----------------------------------------Track #" <<
track.key()
654 <<
" (N valid rechits = " << nRecHits <<
")";
657 tp = recSimColl[
track];
659 tpr = tp.begin()->first;
661 if (simRecColl.
find(tpr) != simRecColl.
end()) {
662 auto const& assoc_track_checkback = simRecColl[tpr].
begin()->first;
664 if (assoc_track_checkback.key() ==
track.key()) {
665 Track_is_matched =
true;
667 if (
track->charge() != tpr->charge())
669 double Purity = tp.begin()->second;
672 <<
"with pt=" <<
track->pt() <<
" associated with purity:" << Purity <<
" to TrackingParticle #"
673 << tpr.
key() <<
"\n";
681 if (!Track_is_matched)
683 <<
"with pt=" <<
track->pt() <<
" NOT associated to any TrackingParticle"
689 tp = recSimColl[
track];
691 tpr = tp.begin()->first;
692 Track_is_matched =
true;
694 if (
track->charge() != tpr->charge())
697 <<
" associated with quality:" << tp.begin()->second <<
"\n";
701 <<
" NOT associated to any TrackingParticle"
706 double etaRec =
track->eta();
707 double xetaRec =
getEta(etaRec);
709 double ptRec =
track->pt();
710 double xptRec =
getPt(ptRec);
712 double qoverpRec =
track->qoverp();
713 double phiRec =
track->phi();
714 double thetaRec =
track->theta();
715 double dxyRec =
track->dxy(
bs.position());
716 double dzRec =
track->dz(
bs.position());
718 double qoverpError =
track->qoverpError();
719 double ptError =
track->ptError();
720 double thetaError =
track->thetaError();
721 double phiError =
track->phiError();
722 double dxyError =
track->dxyError();
723 double dzError =
track->dzError();
727 if (Track_is_matched) {
733 if (Track_is_matched) {
739 if (Track_is_matched) {
745 if (Track_is_matched) {
751 if (Track_is_matched) {
757 if (Track_is_matched) {
766 if (Track_is_matched) {
794 if (associators[ww] ==
"trackAssociatorByChi2") {
796 double assocChi2 = -tp.begin()->second;
799 }
else if (associators[ww] ==
"trackAssociatorByHits") {
800 double fraction = tp.begin()->second;
838 double ptSim =
sqrt(momentumTP.perp2());
839 double xptSim =
getPt(ptSim);
840 double qoverpSim = tpr->charge() /
sqrt(momentumTP.x() * momentumTP.x() + momentumTP.y() * momentumTP.y() +
841 momentumTP.z() * momentumTP.z());
842 double etaSim = momentumTP.eta();
843 double thetaSim = momentumTP.theta();
844 double phiSim = momentumTP.phi();
848 double etares = etaRec - etaSim;
849 double ptRelRes = (ptRec - ptSim) / ptSim;
850 double ptPull = (ptRec - ptSim) / ptError;
851 double qoverpPull = (qoverpRec - qoverpSim) / qoverpError;
852 double thetaPull = (thetaRec - thetaSim) / thetaError;
853 double phiDiff = phiRec - phiSim;
856 phiDiff = phiDiff - 2. *
M_PI;
858 phiDiff = phiDiff + 2. *
M_PI;
860 double phiPull = phiDiff / phiError;
861 double dxyPull = (dxyRec - dxySim) / dxyError;
862 double dzPull = (dzRec - dzSim) / dzError;
898 double contrib_Qoverp = qoverpPull * qoverpPull / 5;
899 double contrib_dxy = dxyPull * dxyPull / 5;
900 double contrib_dz = dzPull * dzPull / 5;
901 double contrib_theta = thetaPull * thetaPull / 5;
902 double contrib_phi = phiPull * phiPull / 5;
903 double assoChi2 = contrib_Qoverp + contrib_dxy + contrib_dz + contrib_theta + contrib_phi;
905 LogTrace(
"MuonTrackValidator") <<
"normalized Chi2 (track 5-dofs matching) = " << assoChi2 <<
"\n"
906 <<
"\t contrib_Qoverp = " << contrib_Qoverp <<
"\n"
907 <<
"\t contrib_theta = " << contrib_theta <<
"\n"
908 <<
"\t contrib_phi = " << contrib_phi <<
"\n"
909 <<
"\t contrib_dxy = " << contrib_dxy <<
"\n"
910 <<
"\t contrib_dz = " << contrib_dz <<
"\n";
912 LogTrace(
"MuonTrackValidator") <<
"ptRec = " << ptRec <<
"\n"
913 <<
"etaRec = " << etaRec <<
"\n"
914 <<
"qoverpRec = " << qoverpRec <<
"\n"
915 <<
"thetaRec = " << thetaRec <<
"\n"
916 <<
"phiRec = " << phiRec <<
"\n"
917 <<
"dxyRec = " << dxyRec <<
"\n"
918 <<
"dzRec = " << dzRec <<
"\n"
921 <<
"qoverpError = " << qoverpError <<
"\n"
922 <<
"thetaError = " << thetaError <<
"\n"
923 <<
"phiError = " << phiError <<
"\n"
924 <<
"dxyError = " << dxyError <<
"\n"
925 <<
"dzError = " << dzError <<
"\n"
928 <<
"ptSim = " << ptSim <<
"\n"
929 <<
"etaSim = " << etaSim <<
"\n"
930 <<
"qoverpSim = " << qoverpSim <<
"\n"
931 <<
"thetaSim = " << thetaSim <<
"\n"
932 <<
"phiSim = " << phiSim <<
"\n"
933 <<
"dxySim = " << dxySim <<
"\n"
934 <<
"dzSim = " << dzSim <<
"\n";
940 <<
"Total Associated (simToReco): " << ats <<
"\n"
941 <<
"Total Reconstructed: " << rT <<
"\n"
942 <<
"Total Associated (recoToSim): " << at <<
"\n"
943 <<
"Total Fakes: " << rT - at <<
"\n";
void fillPlotNoFlow(MonitorElement *h, T val)
std::vector< MonitorElement * > h_assoc2phi
std::vector< MonitorElement * > h_recoeta
std::vector< MonitorElement * > phipull_vs_phi
Log< level::Info, true > LogVerbatim
std::vector< MonitorElement * > h_assoc2hit
std::vector< MonitorElement * > h_PurityVsQuality
std::vector< MonitorElement * > h_etaRes
edm::EDGetTokenT< TrackingParticleRefVector > tp_refvector_Token
std::vector< MonitorElement * > h_misiddxy
std::vector< MonitorElement * > h_assochi2_prob
std::vector< MonitorElement * > h_recopT
std::unique_ptr< CosmicParametersDefinerForTP > cosmicParametersDefinerTP_
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< MonitorElement * > h_assoc2dxy
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< MonitorElement * > thetaCotres_vs_eta
Vector momentum() const
spatial momentum vector
const_iterator end() const
last iterator over the map (read only)
std::vector< MonitorElement * > h_recohit
bool ignoremissingtkcollection_
std::vector< MonitorElement * > dxyres_vs_pt
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< MonitorElement * > h_fakes
std::unique_ptr< ParametersDefinerForTP > lhcParametersDefinerTP_
std::vector< MonitorElement * > h_dxypull
uint32_t const *__restrict__ Quality * quality
std::vector< MonitorElement * > phires_vs_phi
std::vector< MonitorElement * > h_assoc2pu
Sin< T >::type sin(const T &t)
const_iterator find(const key_type &k) const
find element with specified reference key
std::string parametersDefiner
std::vector< MonitorElement * > h_nhits
std::vector< MonitorElement * > h_ptpull
std::vector< MonitorElement * > ptpull_vs_phi
key_type key() const
Accessor for product key.
std::vector< MonitorElement * > h_assoceta
std::vector< MonitorElement * > h_tracks
std::vector< MonitorElement * > nDThits_vs_eta
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > ptres_vs_eta
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
std::vector< MonitorElement * > h_simuldxy
std::vector< MonitorElement * > h_simuldz
math::XYZPointD Point
point in the space
std::vector< MonitorElement * > h_misiddz
std::vector< MonitorElement * > nhits_vs_eta
std::vector< MonitorElement * > nhits_vs_phi
std::vector< MonitorElement * > h_nchi2
std::vector< MonitorElement * > h_nmisslayers_inner
std::vector< MonitorElement * > h_qoverppull
CosmicTrackingParticleSelector cosmictpSelector
std::vector< MonitorElement * > thetapull_vs_eta
std::vector< MonitorElement * > chi2_vs_nhits
std::vector< MonitorElement * > h_misidphi
std::vector< MonitorElement * > h_simulphi
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_assocSharedHit
std::vector< MonitorElement * > thetapull_vs_phi
std::vector< MonitorElement * > h_misidpu
auto dz(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
void post_insert()
post insert action
std::vector< MonitorElement * > h_assoc2dz
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > ptres_vs_phi
std::vector< MonitorElement * > h_assocZpos
Cos< T >::type cos(const T &t)
std::vector< MonitorElement * > ptpull_vs_eta
std::vector< MonitorElement * > h_recophi
std::vector< MonitorElement * > nRecHits_vs_nSimHits
std::vector< MonitorElement * > dzres_vs_eta
Abs< T >::type abs(const T &t)
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
std::vector< MonitorElement * > nME0hits_vs_eta
unsigned short numberOfValidHits() const
number of valid hits found
std::vector< MonitorElement * > h_simulRpos
std::vector< MonitorElement * > nTRK_LayersWithMeas_vs_eta
std::vector< MonitorElement * > chi2_vs_eta
std::vector< MonitorElement * > h_simulhit
T const * get() const
Returns C++ pointer to the item.
std::vector< MonitorElement * > h_charge
std::vector< MonitorElement * > h_assocphi
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
Log< level::Info, false > LogInfo
edm::EDGetTokenT< TrackingParticleCollection > tp_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
std::vector< MonitorElement * > h_assocpT
std::vector< MonitorElement * > h_assocpu
T const * product() const
std::vector< MonitorElement * > ptres_vs_pt
std::vector< MonitorElement * > h_simulpT
std::vector< MonitorElement * > dzpull_vs_eta
std::vector< MonitorElement * > h_recodz
std::vector< MonitorElement * > phires_vs_eta
std::vector< MonitorElement * > h_misideta
std::vector< MonitorElement * > nlosthits_vs_eta
TrackingParticleSelector tpSelector
std::vector< MonitorElement * > dxypull_vs_eta
Point vertex() const
Parent vertex position.
std::vector< MonitorElement * > h_nlosthits
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > h_misidhit
std::vector< MonitorElement * > h_nmisslayers_outer
auto dxy(const T_Vertex &vertex, const T_Momentum &momentum, const T_Point &point)
edm::InputTag associatormap
double getEta(double eta)
std::vector< MonitorElement * > h_simulZpos
std::vector< MonitorElement * > h_recodxy
std::vector< MonitorElement * > h_recopu
std::vector< MonitorElement * > h_phipull
std::vector< MonitorElement * > h_assocdz
std::vector< MonitorElement * > thetaCotres_vs_pt
Monte Carlo truth information used for tracking validation.
std::vector< MonitorElement * > h_dzpull
int charge() const
track electric charge
std::vector< MonitorElement * > nPixel_LayersWithMeas_vs_eta
std::vector< MonitorElement * > h_assoc2pT
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > h_misidpT
const_iterator begin() const
first iterator over the map (read only)
std::vector< MonitorElement * > h_assocFraction
math::XYZVectorD Vector
point in the space
std::vector< MonitorElement * > chi2_vs_phi
std::vector< std::string > associators
bool BiDirectional_RecoToSim_association
std::vector< MonitorElement * > h_assocRpos
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupinfo_Token
std::vector< MonitorElement * > h_assocdxy
std::vector< MonitorElement * > h_thetapull
std::vector< MonitorElement * > nRPChits_vs_eta
std::vector< MonitorElement * > h_simulpu
edm::Ref< TrackingParticleCollection > TrackingParticleRef
std::vector< MonitorElement * > h_assochit
std::vector< MonitorElement * > nGEMhits_vs_eta
std::vector< MonitorElement * > nCSChits_vs_eta
std::vector< MonitorElement * > h_simuleta
std::vector< MonitorElement * > phipull_vs_eta
std::vector< MonitorElement * > h_assoc2eta
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token