Method called before the event loop.
233 using namespace reco;
235 edm::LogInfo(
"MuonTrackValidator") <<
"\n====================================================" <<
"\n"
236 <<
"Analyzing new event" <<
"\n"
237 <<
"====================================================\n" <<
"\n";
254 for (
unsigned int ww=0;ww<
associators.size();ww++){
255 for (
unsigned int www=0;www<
label.size();www++){
263 unsigned int trackCollectionSize = 0;
274 trackCollectionSize = trackCollection->size();
278 <<
label[www].process()<<
":"
279 <<
label[www].label()<<
":"
280 <<
label[www].instance()<<
" with "
283 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
284 recSimColl=
associator[ww]->associateRecoToSim(trackCollection,
287 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
288 simRecColl=
associator[ww]->associateSimToReco(trackCollection,
294 <<
label[www].process()<<
":"
295 <<
label[www].label()<<
":"
296 <<
label[www].instance()<<
" with "
303 simRecColl= *(simtorecoCollectionH.
product());
307 recSimColl= *(recotosimCollectionH.
product());
317 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
321 bool TP_is_matched =
false;
323 bool Quality05 =
false;
324 bool Quality075 =
false;
342 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
343 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/
sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
349 momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
350 vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
351 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
352 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
354 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #"<<tpr.key();
361 std::vector<std::pair<RefToBase<Track>,
double> > rt;
362 if(simRecColl.
find(tpr) != simRecColl.
end()){
363 rt = (std::vector<std::pair<RefToBase<Track>,
double> >) simRecColl[tpr];
366 edm::LogVerbatim(
"MuonTrackValidator")<<
"-----------------------------associated Track #"<<assoc_recoTrack.
key();
367 TP_is_matched =
true;
369 quality = rt.begin()->second;
371 <<
" with pt=" <<
sqrt(momentumTP.perp2())
372 <<
" associated with quality:" << quality <<
"\n";
374 if (quality > 0.75) {
378 else if (quality > 0.5) {
385 <<
"TrackingParticle #" << tpr.key()
386 <<
" with pt,eta,phi: "
387 <<
sqrt(momentumTP.perp2()) <<
" , "
388 << momentumTP.eta() <<
" , "
389 << momentumTP.phi() <<
" , "
390 <<
" NOT associated to any reco::Track" <<
"\n";
405 else if (Quality05) {
425 else if (Quality05) {
446 else if (Quality05) {
496 nSimHits= tpr.get()->numberOfHits();
499 nSimHits= tpr.get()->numberOfHits() - tpr.get()->numberOfTrackerHits();
502 nSimHits=tpr.get()->numberOfTrackerHits();
507 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N simhits = "<< nSimHits<<
"\n";
525 <<
label[www].process()<<
":"
526 <<
label[www].label()<<
":"
527 <<
label[www].instance()
528 <<
": " << trackCollectionSize <<
"\n";
532 bool Track_is_matched =
false;
536 std::vector<std::pair<TrackingParticleRef, double> > tp;
541 edm::LogVerbatim(
"MuonTrackValidator")<<
"----------------------------------------Track #"<< track.key();
543 if(recSimColl.
find(track) != recSimColl.
end()) {
544 tp = recSimColl[track];
545 if (tp.size() != 0) {
546 tpr = tp.begin()->first;
548 if(simRecColl.
find(tpr) != simRecColl.
end()) {
549 std::vector<std::pair<RefToBase<Track>,
double> > track_checkback = simRecColl[tpr];
551 assoc_track_checkback = track_checkback.begin()->first;
553 if ( assoc_track_checkback.
key() == track.key() ) {
554 edm::LogVerbatim(
"MuonTrackValidator")<<
"------------------associated TrackingParticle #"<<tpr.
key();
555 Track_is_matched =
true;
557 double Purity = tp.begin()->second;
558 double Quality = track_checkback.begin()->second;
559 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
560 <<
" associated with quality:" << Purity <<
"\n";
568 <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt() <<
" NOT associated to any TrackingParticle" <<
"\n";
572 if(recSimColl.
find(track) != recSimColl.
end()){
573 tp = recSimColl[track];
575 Track_is_matched =
true;
576 tpr = tp.begin()->first;
578 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
579 <<
" associated with quality:" << tp.begin()->second <<
"\n";
582 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
583 <<
" NOT associated to any TrackingParticle" <<
"\n";
592 if (Track_is_matched) {
602 if (Track_is_matched) {
613 if (Track_is_matched) {
623 if (Track_is_matched) {
633 if (Track_is_matched) {
643 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N valid rechits = "<< (int)track->found() <<
"\n";
647 if (!Track_is_matched)
continue;
651 double assocChi2 = -tp.begin()->second;
655 else if (
associators[ww]==
"TrackAssociatorByHits"){
656 double fraction = tp.begin()->second;
662 h_nchi2[
w]->Fill(track->normalizedChi2());
663 h_nchi2_prob[
w]->Fill(TMath::Prob(track->chi2(),(int)track->ndof()));
664 h_hits[
w]->Fill(track->numberOfValidHits());
666 chi2_vs_nhits[
w]->Fill(track->numberOfValidHits(),track->normalizedChi2());
672 double ptSim =
sqrt(momentumTP.perp2());
673 double qoverpSim = tpr->charge()/
sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
674 double thetaSim = momentumTP.theta();
675 double lambdaSim =
M_PI/2-momentumTP.theta();
676 double phiSim = momentumTP.phi();
677 double dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
678 double dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
684 double qoverpErrorRec(0);
686 double ptErrorRec(0);
688 double lambdaErrorRec(0);
690 double phiErrorRec(0);
696 gsfTrack =
dynamic_cast<const GsfTrack*
>(&(*track));
697 if (gsfTrack==0)
edm::LogInfo(
"MuonTrackValidator") <<
"Trying to access mode for a non-GsfTrack";
702 getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec,
703 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
709 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
712 double thetaRec = track->theta();
713 double ptError = ptErrorRec;
714 double ptres = ptRec - ptSim;
715 double etares = track->eta()-momentumTP.Eta();
716 double dxyRec = track->dxy(bs.position());
717 double dzRec = track->dz(bs.position());
719 double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
720 double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
721 double phiDiff = phiRec - phiSim;
723 if (phiDiff >0.) phiDiff = phiDiff - 2.*
M_PI;
724 else phiDiff = phiDiff + 2.*
M_PI;
726 double phiPull=phiDiff/phiErrorRec;
727 double dxyPull=(dxyRec-dxySim)/track->dxyError();
728 double dzPull=(dzRec-dzSim)/track->dzError();
730 double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*
731 ((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
732 double contrib_dxy = ((dxyRec-dxySim)/track->dxyError())*((dxyRec-dxySim)/track->dxyError())/5;
733 double contrib_dz = ((dzRec-dzSim)/track->dzError())*((dzRec-dzSim)/track->dzError())/5;
734 double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*
735 ((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
736 double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
738 LogTrace(
"MuonTrackValidator") <<
"assocChi2=" << tp.begin()->second <<
"\n"
740 <<
"ptREC=" << ptRec <<
"\n"
741 <<
"etaREC=" << track->eta() <<
"\n"
742 <<
"qoverpREC=" << qoverpRec <<
"\n"
743 <<
"dxyREC=" << dxyRec <<
"\n"
744 <<
"dzREC=" << dzRec <<
"\n"
745 <<
"thetaREC=" << track->theta() <<
"\n"
746 <<
"phiREC=" << phiRec <<
"\n"
748 <<
"qoverpError()=" << qoverpErrorRec <<
"\n"
749 <<
"dxyError()=" << track->dxyError() <<
"\n"
750 <<
"dzError()=" << track->dzError() <<
"\n"
751 <<
"thetaError()=" << lambdaErrorRec <<
"\n"
752 <<
"phiError()=" << phiErrorRec <<
"\n"
754 <<
"ptSIM=" << ptSim <<
"\n"
755 <<
"etaSIM=" << momentumTP.Eta() <<
"\n"
756 <<
"qoverpSIM=" << qoverpSim <<
"\n"
757 <<
"dxySIM=" << dxySim <<
"\n"
758 <<
"dzSIM=" << dzSim <<
"\n"
759 <<
"thetaSIM=" <<
M_PI/2-lambdaSim <<
"\n"
760 <<
"phiSIM=" << phiSim <<
"\n"
762 <<
"contrib_Qoverp=" << contrib_Qoverp <<
"\n"
763 <<
"contrib_dxy=" << contrib_dxy <<
"\n"
764 <<
"contrib_dz=" << contrib_dz <<
"\n"
765 <<
"contrib_theta=" << contrib_theta <<
"\n"
766 <<
"contrib_phi=" << contrib_phi <<
"\n"
768 <<
"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<
"\n";
777 h_pt[
w]->Fill(ptres/ptError);
825 nSimHits= tpr.
get()->numberOfHits();
828 nSimHits= tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
831 nSimHits=tpr.
get()->numberOfTrackerHits();
838 LogTrace(
"MuonTrackValidator") <<
"exception found: " << e.
what() <<
"\n";
844 <<
"Total Associated (simToReco): " << ats <<
"\n"
845 <<
"Total Reconstructed: " << rT <<
"\n"
846 <<
"Total Associated (recoToSim): " << at <<
"\n"
847 <<
"Total Fakes: " << rT-at <<
"\n";
virtual char const * what() const
std::vector< MonitorElement * > nrecHit_vs_nsimHit_sim2rec
std::vector< std::vector< int > > totASS_zpos
std::vector< MonitorElement * > h_PurityVsQuality
std::vector< std::vector< int > > totASSeta_Quality05
std::vector< std::vector< int > > totREC_phi
std::vector< MonitorElement * > etares_vs_eta
std::vector< MonitorElement * > nrecHit_vs_nsimHit_rec2sim
std::vector< MonitorElement * > ptres_vs_phi
std::vector< std::vector< int > > totASS2_hit
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > track_Collection_Token
std::vector< std::vector< int > > totRECpT
std::vector< TrackingParticle > TrackingParticleCollection
std::vector< std::vector< int > > totREC_dz
std::vector< MonitorElement * > nrec_vs_nsim
const_iterator end() const
last iterator over the map (read only)
std::vector< MonitorElement * > h_pullDz
std::vector< MonitorElement * > h_etaSIM
bool ignoremissingtkcollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< MonitorElement * > h_fakes
std::vector< MonitorElement * > ptres_vs_eta
std::vector< MonitorElement * > cotThetares_vs_eta
virtual double getEta(double eta)
std::vector< MonitorElement * > h_eta
std::vector< MonitorElement * > phimean_vs_eta_phi
Point vertex() const
Parent vertex position.
Sin< T >::type sin(const T &t)
std::vector< std::vector< int > > totASS_dz
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< std::vector< double > > etaintervals
std::vector< MonitorElement * > h_pt
std::vector< MonitorElement * > phires_vs_pt
std::vector< MonitorElement * > h_pullQoverp
std::string parametersDefiner
std::vector< MonitorElement * > h_assochi2_prob
std::vector< std::vector< int > > totSIM_zpos
std::vector< std::vector< int > > totASS2_dz
std::vector< MonitorElement * > cotThetares_vs_pt
std::vector< MonitorElement * > dxyres_vs_eta
std::vector< std::vector< int > > totASS_phi_Quality05
std::vector< MonitorElement * > dzres_vs_pt
std::vector< MonitorElement * > h_tracks
std::vector< MonitorElement * > dzres_vs_eta
void getRecoMomentum(const reco::Track &track, double &pt, double &ptError, double &qoverp, double &qoverpError, double &lambda, double &lambdaError, double &phi, double &phiError) const
retrieval of reconstructed momentum components from reco::Track (== mean values for GSF) ...
std::vector< std::vector< double > > dxyintervals
std::vector< MonitorElement * > nDThits_vs_eta
std::vector< std::vector< int > > totASS_phi
std::vector< MonitorElement * > thetapull_vs_phi
std::vector< std::vector< int > > totASS_dxy
std::vector< MonitorElement * > h_assochi2
std::vector< MonitorElement * > chi2_vs_phi
std::vector< std::vector< int > > totSIM_dxy
std::vector< MonitorElement * > chi2_vs_nhits
math::XYZPointD Point
point in the space
std::vector< std::vector< int > > totASSeta_Quality075
std::vector< MonitorElement * > nhits_vs_eta
std::vector< MonitorElement * > phires_vs_phi
virtual double getPt(double pt)
CosmicTrackingParticleSelector cosmictpSelector
std::vector< MonitorElement * > nhits_vs_phi
std::vector< std::vector< int > > totASS2pT
std::vector< MonitorElement * > h_vertposSIM
edm::EDGetTokenT< TrackingParticleCollection > tp_fake_Token
std::vector< MonitorElement * > dxyres_vs_pt
std::vector< edm::InputTag > label
std::vector< MonitorElement * > h_assocSharedHit
std::vector< MonitorElement * > h_nchi2
std::vector< std::vector< double > > pTintervals
void post_insert()
post insert action
std::vector< std::vector< int > > totASS2eta
std::vector< std::vector< int > > totSIMpT
std::vector< std::vector< int > > totREC_dxy
std::vector< MonitorElement * > h_pullPhi
std::vector< std::vector< int > > totSIM_hit
std::vector< MonitorElement * > h_nchi2_prob
std::vector< MonitorElement * > ptpull_vs_eta
Cos< T >::type cos(const T &t)
std::vector< std::vector< int > > totASSpT
std::vector< MonitorElement * > dxypull_vs_eta
Abs< T >::type abs(const T &t)
std::vector< std::vector< int > > totASS_phi_Quality075
unsigned short numberOfValidHits() const
number of valid hits found
std::vector< MonitorElement * > h_pullTheta
std::vector< std::vector< int > > totSIM_vertpos
std::vector< std::vector< int > > totASSpT_Quality05
std::vector< std::vector< int > > totREC_hit
std::vector< MonitorElement * > phipull_vs_eta
std::vector< std::vector< int > > totSIMeta
std::vector< std::vector< int > > totASS2_dxy
std::vector< MonitorElement * > thetapull_vs_eta
std::vector< MonitorElement * > h_charge
std::vector< MonitorElement * > ptmean_vs_eta_phi
std::vector< std::vector< int > > totASS2_phi
std::vector< std::vector< double > > phiintervals
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimCollection_Token
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoCollection_Token
std::vector< std::vector< int > > totASSpT_Quality075
std::vector< MonitorElement * > h_pullDxy
std::vector< MonitorElement * > h_tracksSIM
key_type key() const
Accessor for product key.
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
T const * product() const
std::vector< std::vector< int > > totSIM_phi
std::vector< MonitorElement * > h_hits
std::vector< MonitorElement * > h_losthits
std::vector< MonitorElement * > ptpull_vs_phi
std::vector< std::vector< double > > tmp
edm::InputTag associatormap
std::vector< std::vector< int > > totASSeta
std::vector< MonitorElement * > ptres_vs_pt
std::vector< const TrackAssociatorBase * > associator
std::vector< std::vector< int > > totRECeta
std::vector< std::vector< double > > vertposintervals
std::vector< std::vector< double > > dzintervals
std::vector< MonitorElement * > phires_vs_eta
std::vector< MonitorElement * > h_ptSIM
Vector momentum() const
spatial momentum vector
Monte Carlo truth information used for tracking validation.
std::vector< std::vector< double > > zposintervals
std::vector< MonitorElement * > h_assocFraction
math::XYZVectorD Vector
point in the space
std::vector< std::vector< int > > totSIM_dz
std::vector< std::string > associators
T const * get() const
Returns C++ pointer to the item.
bool BiDirectional_RecoToSim_association
std::vector< MonitorElement * > nlosthits_vs_eta
std::vector< MonitorElement * > dzpull_vs_eta
edm::EDGetTokenT< TrackingParticleCollection > tp_effic_Token
std::vector< MonitorElement * > nRPChits_vs_eta
std::vector< std::vector< int > > totASS_vertpos
std::vector< std::vector< int > > totASS_hit
std::vector< MonitorElement * > nCSChits_vs_eta
std::vector< MonitorElement * > phipull_vs_phi
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token