Method called before the event loop.
230 using namespace reco;
232 edm::LogInfo(
"MuonTrackValidator") <<
"\n====================================================" <<
"\n"
233 <<
"Analyzing new event" <<
"\n"
234 <<
"====================================================\n" <<
"\n";
237 std::unique_ptr<ParametersDefinerForTP> Cosmic_parametersDefinerTP;
247 Cosmic_parametersDefinerTP = _Cosmic_parametersDefinerTP->clone();
252 Cosmic_parametersDefinerTP->initEvent(simHitsTPAssoc);
271 std::vector<const reco::TrackToTrackingParticleAssociator*> associator;
276 associator.push_back( theAssociator.
product() );
281 for (
unsigned int ww=0;ww<
associators.size();ww++){
282 for (
unsigned int www=0;www<
label.size();www++){
290 unsigned int trackCollectionSize = 0;
301 trackCollectionSize = trackCollection->size();
306 <<
label[www].process()<<
":"
307 <<
label[www].label()<<
":"
308 <<
label[www].instance()<<
" with "
311 LogTrace(
"MuonTrackValidator") <<
"Calling associateRecoToSim method" <<
"\n";
312 recSimColl=associator[ww]->associateRecoToSim(trackCollection,
314 LogTrace(
"MuonTrackValidator") <<
"Calling associateSimToReco method" <<
"\n";
315 simRecColl=associator[ww]->associateSimToReco(trackCollection,
320 <<
label[www].process()<<
":"
321 <<
label[www].label()<<
":"
322 <<
label[www].instance()<<
" with "
329 simRecColl= *(simtorecoCollectionH.
product());
333 recSimColl= *(recotosimCollectionH.
product());
342 edm::LogVerbatim(
"MuonTrackValidator") <<
"\n# of TrackingParticles: " << tPCeff.size() <<
"\n";
346 bool TP_is_matched =
false;
348 bool Quality05 =
false;
349 bool Quality075 =
false;
363 LogTrace(
"MuonTrackValidator") <<
"TrackingParticle "<<
i;
369 dxySim = (-vertex.x()*
sin(momentum.phi())+vertex.y()*
cos(momentum.phi()));
370 dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y()) /
371 sqrt(momentum.perp2()) * momentum.z()/
sqrt(momentum.perp2());
378 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr);
379 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
380 dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
381 dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y()) /
382 sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
384 edm::LogVerbatim(
"MuonTrackValidator") <<
"--------------------Selected TrackingParticle #"<<tpr.key();
385 edm::LogVerbatim(
"MuonTrackValidator") <<
"momentumTP: pt = "<<
sqrt(momentumTP.perp2())<<
", pz = "<<momentumTP.z()
386 <<
", \t vertexTP: radius = "<<
sqrt(vertexTP.perp2())<<
", z = "<<vertexTP.z() <<
"\n";
393 std::vector<std::pair<RefToBase<Track>,
double> > rt;
394 if(simRecColl.
find(tpr) != simRecColl.
end()){
395 rt = (std::vector<std::pair<RefToBase<Track>,
double> >) simRecColl[tpr];
398 edm::LogVerbatim(
"MuonTrackValidator")<<
"-----------------------------associated Track #"<<assoc_recoTrack.
key();
399 TP_is_matched =
true;
401 quality = rt.begin()->second;
403 <<
" with pt=" <<
sqrt(momentumTP.perp2())
404 <<
" associated with quality:" << quality <<
"\n";
406 if (quality > 0.75) {
410 else if (quality > 0.5) {
417 <<
"TrackingParticle #" << tpr.key()
418 <<
" with pt,eta,phi: "
419 <<
sqrt(momentumTP.perp2()) <<
" , "
420 << momentumTP.eta() <<
" , "
421 << momentumTP.phi() <<
" , "
422 <<
" NOT associated to any reco::Track" <<
"\n";
437 else if (Quality05) {
457 else if (Quality05) {
477 else if (Quality05) {
527 nSimHits= tpr.get()->numberOfHits();
530 nSimHits= tpr.get()->numberOfHits() - tpr.get()->numberOfTrackerHits();
533 nSimHits=tpr.get()->numberOfTrackerHits();
537 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N simhits = "<< nSimHits<<
"\n";
554 <<
label[www].process()<<
":"
555 <<
label[www].label()<<
":"
556 <<
label[www].instance()
557 <<
": " << trackCollectionSize <<
"\n";
561 bool Track_is_matched =
false;
565 std::vector<std::pair<TrackingParticleRef, double> > tp;
570 edm::LogVerbatim(
"MuonTrackValidator")<<
"----------------------------------------Track #"<< track.key();
572 if(recSimColl.
find(track) != recSimColl.
end()) {
573 tp = recSimColl[track];
574 if (tp.size() != 0) {
575 tpr = tp.begin()->first;
577 if(simRecColl.
find(tpr) != simRecColl.
end()) {
578 std::vector<std::pair<RefToBase<Track>,
double> > track_checkback = simRecColl[tpr];
580 assoc_track_checkback = track_checkback.begin()->first;
582 if ( assoc_track_checkback.
key() == track.key() ) {
583 edm::LogVerbatim(
"MuonTrackValidator")<<
"------------------associated TrackingParticle #"<<tpr.
key();
584 Track_is_matched =
true;
586 double Purity = tp.begin()->second;
587 double Quality = track_checkback.begin()->second;
588 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
589 <<
" associated with quality:" << Purity <<
"\n";
596 if (!Track_is_matched)
598 <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt() <<
" NOT associated to any TrackingParticle" <<
"\n";
602 if(recSimColl.
find(track) != recSimColl.
end()){
603 tp = recSimColl[track];
605 Track_is_matched =
true;
606 tpr = tp.begin()->first;
608 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
609 <<
" associated with quality:" << tp.begin()->second <<
"\n";
612 edm::LogVerbatim(
"MuonTrackValidator") <<
"reco::Track #" << track.key() <<
" with pt=" << track->pt()
613 <<
" NOT associated to any TrackingParticle" <<
"\n";
622 if (Track_is_matched) {
632 if (Track_is_matched) {
642 if (Track_is_matched) {
652 if (Track_is_matched) {
662 if (Track_is_matched) {
672 edm::LogVerbatim(
"MuonTrackValidator") <<
"\t N valid rechits = "<< (int)track->found() <<
"\n";
682 if (! (Track_is_matched &&
tpSelector(*tpp)) )
continue;
684 momentumTP = Lhc_parametersDefinerTP->
momentum(event,setup,tpr) ;
685 vertexTP = Lhc_parametersDefinerTP->vertex(event,setup,tpr);
690 if (! (Track_is_matched &&
cosmictpSelector(tpr,&bs,event,setup)) )
continue;
692 momentumTP = Cosmic_parametersDefinerTP->momentum(event,setup,tpr) ;
693 vertexTP = Cosmic_parametersDefinerTP->vertex(event,setup,tpr);
699 double assocChi2 = -tp.begin()->second;
703 else if (
associators[ww]==
"trackAssociatorByHits"){
704 double fraction = tp.begin()->second;
710 h_nchi2[
w]->Fill(track->normalizedChi2());
711 h_nchi2_prob[
w]->Fill(TMath::Prob(track->chi2(),(int)track->ndof()));
712 h_hits[
w]->Fill(track->numberOfValidHits());
714 chi2_vs_nhits[
w]->Fill(track->numberOfValidHits(),track->normalizedChi2());
717 double ptSim =
sqrt(momentumTP.perp2());
718 double qoverpSim = tpr->charge()/
sqrt(momentumTP.x()*momentumTP.x()+momentumTP.y()*momentumTP.y()+momentumTP.z()*momentumTP.z());
719 double thetaSim = momentumTP.theta();
720 double lambdaSim =
M_PI/2-momentumTP.theta();
721 double phiSim = momentumTP.phi();
722 double dxySim = (-vertexTP.x()*
sin(momentumTP.phi())+vertexTP.y()*
cos(momentumTP.phi()));
723 double dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y()) /
724 sqrt(momentumTP.perp2()) * momentumTP.z()/
sqrt(momentumTP.perp2());
730 double qoverpErrorRec(0);
732 double ptErrorRec(0);
734 double lambdaErrorRec(0);
736 double phiErrorRec(0);
741 gsfTrack =
dynamic_cast<const GsfTrack*
>(&(*track));
742 if (gsfTrack==0)
edm::LogInfo(
"MuonTrackValidator") <<
"Trying to access mode for a non-GsfTrack";
747 getRecoMomentum(*gsfTrack, ptRec, ptErrorRec, qoverpRec, qoverpErrorRec,
748 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
754 lambdaRec,lambdaErrorRec, phiRec, phiErrorRec);
757 double thetaRec = track->theta();
758 double ptError = ptErrorRec;
759 double ptres = ptRec - ptSim;
760 double etares = track->eta()-momentumTP.Eta();
761 double dxyRec = track->dxy(bs.position());
762 double dzRec = track->dz(bs.position());
764 double qoverpPull=(qoverpRec-qoverpSim)/qoverpErrorRec;
765 double thetaPull=(lambdaRec-lambdaSim)/lambdaErrorRec;
766 double phiDiff = phiRec - phiSim;
768 if (phiDiff >0.) phiDiff = phiDiff - 2.*
M_PI;
769 else phiDiff = phiDiff + 2.*
M_PI;
771 double phiPull=phiDiff/phiErrorRec;
772 double dxyPull=(dxyRec-dxySim)/track->dxyError();
773 double dzPull=(dzRec-dzSim)/track->dzError();
775 double contrib_Qoverp = ((qoverpRec-qoverpSim)/qoverpErrorRec)*((qoverpRec-qoverpSim)/qoverpErrorRec)/5;
776 double contrib_dxy = ((dxyRec-dxySim)/track->dxyError())*((dxyRec-dxySim)/track->dxyError())/5;
777 double contrib_dz = ((dzRec-dzSim)/track->dzError())*((dzRec-dzSim)/track->dzError())/5;
778 double contrib_theta = ((lambdaRec-lambdaSim)/lambdaErrorRec)*((lambdaRec-lambdaSim)/lambdaErrorRec)/5;
779 double contrib_phi = (phiDiff/phiErrorRec)*(phiDiff/phiErrorRec)/5;
781 edm::LogVerbatim(
"MuonTrackValidator") <<
"assocChi2=" << tp.begin()->second <<
"\n"
783 <<
"ptREC=" << ptRec <<
"\n"
784 <<
"etaREC=" << track->eta() <<
"\n"
785 <<
"qoverpREC=" << qoverpRec <<
"\n"
786 <<
"dxyREC=" << dxyRec <<
"\n"
787 <<
"dzREC=" << dzRec <<
"\n"
788 <<
"thetaREC=" << track->theta() <<
"\n"
789 <<
"phiREC=" << phiRec <<
"\n"
791 <<
"qoverpError()=" << qoverpErrorRec <<
"\n"
792 <<
"dxyError()=" << track->dxyError() <<
"\n"
793 <<
"dzError()=" << track->dzError() <<
"\n"
794 <<
"thetaError()=" << lambdaErrorRec <<
"\n"
795 <<
"phiError()=" << phiErrorRec <<
"\n"
797 <<
"ptSIM=" << ptSim <<
"\n"
798 <<
"etaSIM=" << momentumTP.Eta() <<
"\n"
799 <<
"qoverpSIM=" << qoverpSim <<
"\n"
800 <<
"dxySIM=" << dxySim <<
"\n"
801 <<
"dzSIM=" << dzSim <<
"\n"
802 <<
"thetaSIM=" <<
M_PI/2-lambdaSim <<
"\n"
803 <<
"phiSIM=" << phiSim <<
"\n"
805 <<
"contrib_Qoverp=" << contrib_Qoverp <<
"\n"
806 <<
"contrib_dxy=" << contrib_dxy <<
"\n"
807 <<
"contrib_dz=" << contrib_dz <<
"\n"
808 <<
"contrib_theta=" << contrib_theta <<
"\n"
809 <<
"contrib_phi=" << contrib_phi <<
"\n"
811 <<
"chi2PULL="<<contrib_Qoverp+contrib_dxy+contrib_dz+contrib_theta+contrib_phi<<
"\n";
819 h_pt[
w]->Fill(ptres/ptError);
866 nSimHits= tpr.
get()->numberOfHits();
869 nSimHits= tpr.
get()->numberOfHits() - tpr.
get()->numberOfTrackerHits();
872 nSimHits=tpr.
get()->numberOfTrackerHits();
882 <<
"Total Associated (simToReco): " << ats <<
"\n"
883 <<
"Total Reconstructed: " << rT <<
"\n"
884 <<
"Total Associated (recoToSim): " << at <<
"\n"
885 <<
"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
Vector momentum() const
spatial momentum vector
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
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 * > nGEMhits_vs_eta
std::vector< MonitorElement * > nCSChits_vs_eta
std::vector< MonitorElement * > phipull_vs_phi
edm::EDGetTokenT< reco::BeamSpot > bsSrc_Token