Method called before the event loop.
224 using namespace reco;
226 edm::LogInfo(
"MuonTrackValidator") <<
"\n====================================================" <<
"\n"
227 <<
"Analyzing new event" <<
"\n"
228 <<
"====================================================\n" <<
"\n";
244 std::vector<const reco::TrackToTrackingParticleAssociator*> associator;
249 associator.push_back( theAssociator.
product() );
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,
286 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
287 simRecColl=associator[ww]->associateSimToReco(trackCollection,
292 <<
label[www].process()<<
":"
293 <<
label[www].label()<<
":"
294 <<
label[www].instance()<<
" with "
301 simRecColl= *(simtorecoCollectionH.
product());
305 recSimColl= *(recotosimCollectionH.
product());
315 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
319 bool TP_is_matched =
false;
321 bool Quality05 =
false;
322 bool Quality075 =
false;
340 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
341 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/
sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
347 momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
348 vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
349 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
350 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
352 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #"<<tpr.key();
359 std::vector<std::pair<RefToBase<Track>,
double> > rt;
360 if(simRecColl.
find(tpr) != simRecColl.
end()){
361 rt = (std::vector<std::pair<RefToBase<Track>,
double> >) simRecColl[tpr];
364 edm::LogVerbatim(
"MuonTrackValidator")<<
"-----------------------------associated Track #"<<assoc_recoTrack.
key();
365 TP_is_matched =
true;
367 quality = rt.begin()->second;
369 <<
" with pt=" <<
sqrt(momentumTP.perp2())
370 <<
" associated with quality:" << quality <<
"\n";
372 if (quality > 0.75) {
376 else if (quality > 0.5) {
383 <<
"TrackingParticle #" << tpr.key()
384 <<
" with pt,eta,phi: "
385 <<
sqrt(momentumTP.perp2()) <<
" , "
386 << momentumTP.eta() <<
" , "
387 << momentumTP.phi() <<
" , "
388 <<
" NOT associated to any reco::Track" <<
"\n";
403 else if (Quality05) {
423 else if (Quality05) {
444 else if (Quality05) {
494 nSimHits= tpr.get()->numberOfHits();
497 nSimHits= tpr.get()->numberOfHits() - tpr.get()->numberOfTrackerHits();
500 nSimHits=tpr.get()->numberOfTrackerHits();
505 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N simhits = "<< nSimHits<<
"\n";
523 <<
label[www].process()<<
":"
524 <<
label[www].label()<<
":"
525 <<
label[www].instance()
526 <<
": " << trackCollectionSize <<
"\n";
530 bool Track_is_matched =
false;
534 std::vector<std::pair<TrackingParticleRef, double> > tp;
539 edm::LogVerbatim(
"MuonTrackValidator")<<
"----------------------------------------Track #"<< track.key();
541 if(recSimColl.
find(track) != recSimColl.
end()) {
542 tp = recSimColl[track];
543 if (tp.size() != 0) {
544 tpr = tp.begin()->first;
546 if(simRecColl.
find(tpr) != simRecColl.
end()) {
547 std::vector<std::pair<RefToBase<Track>,
double> > track_checkback = simRecColl[tpr];
549 assoc_track_checkback = track_checkback.begin()->first;
551 if ( assoc_track_checkback.
key() == track.key() ) {
552 edm::LogVerbatim(
"MuonTrackValidator")<<
"------------------associated TrackingParticle #"<<tpr.
key();
553 Track_is_matched =
true;
555 double Purity = tp.begin()->second;
556 double Quality = track_checkback.begin()->second;
557 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
558 <<
" associated with quality:" << Purity <<
"\n";
566 <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt() <<
" NOT associated to any TrackingParticle" <<
"\n";
570 if(recSimColl.
find(track) != recSimColl.
end()){
571 tp = recSimColl[track];
573 Track_is_matched =
true;
574 tpr = tp.begin()->first;
576 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
577 <<
" associated with quality:" << tp.begin()->second <<
"\n";
580 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
581 <<
" NOT associated to any TrackingParticle" <<
"\n";
590 if (Track_is_matched) {
600 if (Track_is_matched) {
611 if (Track_is_matched) {
621 if (Track_is_matched) {
631 if (Track_is_matched) {
641 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N valid rechits = "<< (int)track->found() <<
"\n";
645 if (!Track_is_matched)
continue;
649 double assocChi2 = -tp.begin()->second;
653 else if (
associators[ww]==
"trackAssociatorByHits"){
654 double fraction = tp.begin()->second;
660 h_nchi2[
w]->Fill(track->normalizedChi2());
661 h_nchi2_prob[
w]->Fill(TMath::Prob(track->chi2(),(int)track->ndof()));
662 h_hits[
w]->Fill(track->numberOfValidHits());
664 chi2_vs_nhits[
w]->Fill(track->numberOfValidHits(),track->normalizedChi2());
670 double ptSim =
sqrt(momentumTP.perp2());
671 double qoverpSim = tpr->charge()/
sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
672 double thetaSim = momentumTP.theta();
673 double lambdaSim =
M_PI/2-momentumTP.theta();
674 double phiSim = momentumTP.phi();
675 double dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
676 double dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/
sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
682 double qoverpErrorRec(0);
684 double ptErrorRec(0);
686 double lambdaErrorRec(0);
688 double phiErrorRec(0);
694 gsfTrack =
dynamic_cast<const GsfTrack*
>(&(*track));
695 if (gsfTrack==0)
edm::LogInfo(
"MuonTrackValidator") <<
"Trying to access mode for a non-GsfTrack";
700 getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec,
701 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
707 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
710 double thetaRec = track->theta();
711 double ptError = ptErrorRec;
712 double ptres = ptRec - ptSim;
713 double etares = track->eta()-momentumTP.Eta();
714 double dxyRec = track->dxy(bs.position());
715 double dzRec = track->dz(bs.position());
717 double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
718 double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
719 double phiDiff = phiRec - phiSim;
721 if (phiDiff >0.) phiDiff = phiDiff - 2.*
M_PI;
722 else phiDiff = phiDiff + 2.*
M_PI;
724 double phiPull=phiDiff/phiErrorRec;
725 double dxyPull=(dxyRec-dxySim)/track->dxyError();
726 double dzPull=(dzRec-dzSim)/track->dzError();
728 double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*
729 ((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
730 double contrib_dxy = ((dxyRec-dxySim)/track->dxyError())*((dxyRec-dxySim)/track->dxyError())/5;
731 double contrib_dz = ((dzRec-dzSim)/track->dzError())*((dzRec-dzSim)/track->dzError())/5;
732 double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*
733 ((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
734 double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
736 LogTrace(
"MuonTrackValidator") <<
"assocChi2=" << tp.begin()->second <<
"\n"
738 <<
"ptREC=" << ptRec <<
"\n"
739 <<
"etaREC=" << track->eta() <<
"\n"
740 <<
"qoverpREC=" << qoverpRec <<
"\n"
741 <<
"dxyREC=" << dxyRec <<
"\n"
742 <<
"dzREC=" << dzRec <<
"\n"
743 <<
"thetaREC=" << track->theta() <<
"\n"
744 <<
"phiREC=" << phiRec <<
"\n"
746 <<
"qoverpError()=" << qoverpErrorRec <<
"\n"
747 <<
"dxyError()=" << track->dxyError() <<
"\n"
748 <<
"dzError()=" << track->dzError() <<
"\n"
749 <<
"thetaError()=" << lambdaErrorRec <<
"\n"
750 <<
"phiError()=" << phiErrorRec <<
"\n"
752 <<
"ptSIM=" << ptSim <<
"\n"
753 <<
"etaSIM=" << momentumTP.Eta() <<
"\n"
754 <<
"qoverpSIM=" << qoverpSim <<
"\n"
755 <<
"dxySIM=" << dxySim <<
"\n"
756 <<
"dzSIM=" << dzSim <<
"\n"
757 <<
"thetaSIM=" <<
M_PI/2-lambdaSim <<
"\n"
758 <<
"phiSIM=" << phiSim <<
"\n"
760 <<
"contrib_Qoverp=" << contrib_Qoverp <<
"\n"
761 <<
"contrib_dxy=" << contrib_dxy <<
"\n"
762 <<
"contrib_dz=" << contrib_dz <<
"\n"
763 <<
"contrib_theta=" << contrib_theta <<
"\n"
764 <<
"contrib_phi=" << contrib_phi <<
"\n"
766 <<
"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<
"\n";
775 h_pt[
w]->Fill(ptres/ptError);
823 nSimHits= tpr.
get()->numberOfHits();
826 nSimHits= tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
829 nSimHits=tpr.
get()->numberOfTrackerHits();
836 LogTrace(
"MuonTrackValidator") <<
"exception found: " << e.
what() <<
"\n";
842 <<
"Total Associated (simToReco): " << ats <<
"\n"
843 <<
"Total Reconstructed: " << rT <<
"\n"
844 <<
"Total Associated (recoToSim): " << at <<
"\n"
845 <<
"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
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
key_type key() const
Accessor for product key.
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
T const * get() const
Returns C++ pointer to the item.
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
T const * product() const
std::vector< MonitorElement * > h_tracksSIM
std::vector< MonitorElement * > chi2_vs_eta
TrackingParticleSelector tpSelector
std::vector< std::vector< int > > totSIM_phi
Point vertex() const
Parent vertex position.
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< 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
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