Method called before the event loop.
228 using namespace reco;
230 edm::LogInfo(
"MuonTrackValidator") <<
"\n====================================================" <<
"\n"
231 <<
"Analyzing new event" <<
"\n"
232 <<
"====================================================\n" <<
"\n";
235 std::unique_ptr<ParametersDefinerForTP> Cosmic_parametersDefinerTP;
245 Cosmic_parametersDefinerTP = _Cosmic_parametersDefinerTP->clone();
250 Cosmic_parametersDefinerTP->initEvent(simHitsTPAssoc);
269 std::vector<const reco::TrackToTrackingParticleAssociator*> associator;
274 associator.push_back( theAssociator.
product() );
279 for (
unsigned int ww=0;ww<
associators.size();ww++){
280 for (
unsigned int www=0;www<
label.size();www++){
288 unsigned int trackCollectionSize = 0;
299 trackCollectionSize = trackCollection->size();
304 <<
label[www].process()<<
":"
305 <<
label[www].label()<<
":"
306 <<
label[www].instance()<<
" with "
309 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
310 recSimColl=associator[ww]->associateRecoToSim(trackCollection,
312 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
313 simRecColl=associator[ww]->associateSimToReco(trackCollection,
318 <<
label[www].process()<<
":"
319 <<
label[www].label()<<
":"
320 <<
label[www].instance()<<
" with "
327 simRecColl= *(simtorecoCollectionH.
product());
331 recSimColl= *(recotosimCollectionH.
product());
340 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
344 bool TP_is_matched =
false;
346 bool Quality05 =
false;
347 bool Quality075 =
false;
361 LogTrace(
"MuonTrackValidator") <<
"TrackingParticle "<<
i;
367 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
368 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y()) /
369 sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
376 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr);
377 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
378 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
379 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y()) /
380 sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
382 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #"<<tpr.key();
383 edm::LogVerbatim(
"MuonTrackValidator") <<
"momentumTP: pt = "<<
sqrt(momentumTP.perp2())<<
", pz = "<<momentumTP.z()
384 <<
", \t vertexTP: radius = "<<
sqrt(vertexTP.perp2())<<
", z = "<<vertexTP.z() <<
"\n";
391 std::vector<std::pair<RefToBase<Track>,
double> > rt;
392 if(simRecColl.
find(tpr) != simRecColl.
end()){
393 rt = (std::vector<std::pair<RefToBase<Track>,
double> >) simRecColl[tpr];
396 edm::LogVerbatim(
"MuonTrackValidator")<<
"-----------------------------associated Track #"<<assoc_recoTrack.
key();
397 TP_is_matched =
true;
399 quality = rt.begin()->second;
401 <<
" with pt=" <<
sqrt(momentumTP.perp2())
402 <<
" associated with quality:" << quality <<
"\n";
404 if (quality > 0.75) {
408 else if (quality > 0.5) {
415 <<
"TrackingParticle #" << tpr.key()
416 <<
" with pt,eta,phi: "
417 <<
sqrt(momentumTP.perp2()) <<
" , "
418 << momentumTP.eta() <<
" , "
419 << momentumTP.phi() <<
" , "
420 <<
" NOT associated to any reco::Track" <<
"\n";
435 else if (Quality05) {
455 else if (Quality05) {
475 else if (Quality05) {
525 nSimHits= tpr.get()->numberOfHits();
528 nSimHits= tpr.get()->numberOfHits() - tpr.get()->numberOfTrackerHits();
531 nSimHits=tpr.get()->numberOfTrackerHits();
535 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N simhits = "<< nSimHits<<
"\n";
552 <<
label[www].process()<<
":"
553 <<
label[www].label()<<
":"
554 <<
label[www].instance()
555 <<
": " << trackCollectionSize <<
"\n";
559 bool Track_is_matched =
false;
563 std::vector<std::pair<TrackingParticleRef, double> > tp;
568 edm::LogVerbatim(
"MuonTrackValidator")<<
"----------------------------------------Track #"<< track.key();
570 if(recSimColl.
find(track) != recSimColl.
end()) {
571 tp = recSimColl[track];
572 if (tp.size() != 0) {
573 tpr = tp.begin()->first;
575 if(simRecColl.
find(tpr) != simRecColl.
end()) {
576 std::vector<std::pair<RefToBase<Track>,
double> > track_checkback = simRecColl[tpr];
578 assoc_track_checkback = track_checkback.begin()->first;
580 if ( assoc_track_checkback.
key() == track.key() ) {
581 edm::LogVerbatim(
"MuonTrackValidator")<<
"------------------associated TrackingParticle #"<<tpr.
key();
582 Track_is_matched =
true;
584 double Purity = tp.begin()->second;
585 double Quality = track_checkback.begin()->second;
586 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
587 <<
" associated with quality:" << Purity <<
"\n";
594 if (!Track_is_matched)
596 <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt() <<
" NOT associated to any TrackingParticle" <<
"\n";
600 if(recSimColl.
find(track) != recSimColl.
end()){
601 tp = recSimColl[track];
603 Track_is_matched =
true;
604 tpr = tp.begin()->first;
606 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
607 <<
" associated with quality:" << tp.begin()->second <<
"\n";
610 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
611 <<
" NOT associated to any TrackingParticle" <<
"\n";
620 if (Track_is_matched) {
630 if (Track_is_matched) {
640 if (Track_is_matched) {
650 if (Track_is_matched) {
660 if (Track_is_matched) {
670 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N valid rechits = "<< (int)track->found() <<
"\n";
680 if (! (Track_is_matched &&
tpSelector(*tpp)) )
continue;
682 momentumTP = Lhc_parametersDefinerTP->
momentum(event,setup,tpr) ;
683 vertexTP = Lhc_parametersDefinerTP->vertex(event,setup,tpr);
688 if (! (Track_is_matched &&
cosmictpSelector(tpr,&bs,event,setup)) )
continue;
690 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr) ;
691 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
697 double assocChi2 = -tp.begin()->second;
701 else if (
associators[ww]==
"trackAssociatorByHits"){
702 double fraction = tp.begin()->second;
708 h_nchi2[
w]->Fill(track->normalizedChi2());
709 h_nchi2_prob[
w]->Fill(TMath::Prob(track->chi2(),(int)track->ndof()));
710 h_hits[
w]->Fill(track->numberOfValidHits());
712 chi2_vs_nhits[
w]->Fill(track->numberOfValidHits(),track->normalizedChi2());
715 double ptSim =
sqrt(momentumTP.perp2());
716 double qoverpSim = tpr->charge()/
sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
717 double thetaSim = momentumTP.theta();
718 double lambdaSim =
M_PI/2-momentumTP.theta();
719 double phiSim = momentumTP.phi();
720 double dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
721 double dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y()) /
722 sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
728 double qoverpErrorRec(0);
730 double ptErrorRec(0);
732 double lambdaErrorRec(0);
734 double phiErrorRec(0);
739 gsfTrack =
dynamic_cast<const GsfTrack*
>(&(*track));
740 if (gsfTrack==0)
edm::LogInfo(
"MuonTrackValidator") <<
"Trying to access mode for a non-GsfTrack";
745 getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec,
746 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
752 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
755 double thetaRec = track->theta();
756 double ptError = ptErrorRec;
757 double ptres = ptRec - ptSim;
758 double etares = track->eta()-momentumTP.Eta();
759 double dxyRec = track->dxy(bs.position());
760 double dzRec = track->dz(bs.position());
762 double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
763 double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
764 double phiDiff = phiRec - phiSim;
766 if (phiDiff >0.) phiDiff = phiDiff - 2.*
M_PI;
767 else phiDiff = phiDiff + 2.*
M_PI;
769 double phiPull=phiDiff/phiErrorRec;
770 double dxyPull=(dxyRec-dxySim)/track->dxyError();
771 double dzPull=(dzRec-dzSim)/track->dzError();
773 double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
774 double contrib_dxy = ((dxyRec-dxySim)/track->dxyError())*((dxyRec-dxySim)/track->dxyError())/5;
775 double contrib_dz = ((dzRec-dzSim)/track->dzError())*((dzRec-dzSim)/track->dzError())/5;
776 double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
777 double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
779 edm::LogVerbatim(
"MuonTrackValidator") <<
"assocChi2=" << tp.begin()->second <<
"\n"
781 <<
"ptREC=" << ptRec <<
"\n"
782 <<
"etaREC=" << track->eta() <<
"\n"
783 <<
"qoverpREC=" << qoverpRec <<
"\n"
784 <<
"dxyREC=" << dxyRec <<
"\n"
785 <<
"dzREC=" << dzRec <<
"\n"
786 <<
"thetaREC=" << track->theta() <<
"\n"
787 <<
"phiREC=" << phiRec <<
"\n"
789 <<
"qoverpError()=" << qoverpErrorRec <<
"\n"
790 <<
"dxyError()=" << track->dxyError() <<
"\n"
791 <<
"dzError()=" << track->dzError() <<
"\n"
792 <<
"thetaError()=" << lambdaErrorRec <<
"\n"
793 <<
"phiError()=" << phiErrorRec <<
"\n"
795 <<
"ptSIM=" << ptSim <<
"\n"
796 <<
"etaSIM=" << momentumTP.Eta() <<
"\n"
797 <<
"qoverpSIM=" << qoverpSim <<
"\n"
798 <<
"dxySIM=" << dxySim <<
"\n"
799 <<
"dzSIM=" << dzSim <<
"\n"
800 <<
"thetaSIM=" <<
M_PI/2-lambdaSim <<
"\n"
801 <<
"phiSIM=" << phiSim <<
"\n"
803 <<
"contrib_Qoverp=" << contrib_Qoverp <<
"\n"
804 <<
"contrib_dxy=" << contrib_dxy <<
"\n"
805 <<
"contrib_dz=" << contrib_dz <<
"\n"
806 <<
"contrib_theta=" << contrib_theta <<
"\n"
807 <<
"contrib_phi=" << contrib_phi <<
"\n"
809 <<
"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<
"\n";
817 h_pt[
w]->Fill(ptres/ptError);
864 nSimHits= tpr.
get()->numberOfHits();
867 nSimHits= tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
870 nSimHits=tpr.
get()->numberOfTrackerHits();
880 <<
"Total Associated (simToReco): " << ats <<
"\n"
881 <<
"Total Reconstructed: " << rT <<
"\n"
882 <<
"Total Associated (recoToSim): " << at <<
"\n"
883 <<
"Total Fakes: " << rT-at <<
"\n";
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
edm::EDGetTokenT< SimHitTPAssociationProducer::SimHitTPAssociationList > _simHitTpMapTag
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
void initEvent(edm::Handle< SimHitTPAssociationProducer::SimHitTPAssociationList > simHitsTPAssocToSet) const
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