From ea1f241250a6833680c31ea68113b1ba2c7a3c85 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Fri, 13 Jun 2014 11:59:47 +0200 Subject: [PATCH] add fake rate vs dr --- .../interface/MTVHistoProducerAlgo.h | 2 +- .../MTVHistoProducerAlgoForTracker.h | 6 ++-- .../RecoTrack/interface/MultiTrackValidator.h | 2 ++ .../RecoTrack/plugins/MultiTrackValidator.cc | 23 +++++++++++++-- .../plugins/MultiTrackValidatorGenPs.cc | 3 +- .../RecoTrack/plugins/TrackerSeedValidator.cc | 3 +- .../python/MultiTrackValidator_cfi.py | 3 ++ .../python/PostProcessorTracker_cfi.py | 1 + .../RecoTrack/src/MTVHistoProducerAlgo.cc | 14 +++++---- .../src/MTVHistoProducerAlgoForTracker.cc | 29 ++++++++++++------- 10 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Validation/RecoTrack/interface/MTVHistoProducerAlgo.h b/Validation/RecoTrack/interface/MTVHistoProducerAlgo.h index d04c79de45111..36a70e3cfd513 100644 --- a/Validation/RecoTrack/interface/MTVHistoProducerAlgo.h +++ b/Validation/RecoTrack/interface/MTVHistoProducerAlgo.h @@ -63,7 +63,7 @@ class MTVHistoProducerAlgo{ int numVertices, int tpbunchcrossing, int nSimHits, - double sharedFraction)=0; + double sharedFraction, double dR)=0; virtual void fill_dedx_recoTrack_histos(int count, edm::RefToBase& trackref,const std::vector< edm::ValueMap >& v_dEdx)=0; // virtual void fill_dedx_recoTrack_histos(reco::TrackRef trackref, std::vector< edm::ValueMap > v_dEdx)=0; diff --git a/Validation/RecoTrack/interface/MTVHistoProducerAlgoForTracker.h b/Validation/RecoTrack/interface/MTVHistoProducerAlgoForTracker.h index cf7ba6a69455c..973ea7e616433 100644 --- a/Validation/RecoTrack/interface/MTVHistoProducerAlgoForTracker.h +++ b/Validation/RecoTrack/interface/MTVHistoProducerAlgoForTracker.h @@ -65,7 +65,8 @@ class MTVHistoProducerAlgoForTracker: public MTVHistoProducerAlgo { int numVertices, int tpbunchcrossing, int nSimHits, - double sharedFraction); + double sharedFraction, + double dR); void fill_dedx_recoTrack_histos(int count, edm::RefToBase& trackref, const std::vector< edm::ValueMap >& v_dEdx); // void fill_dedx_recoTrack_histos(reco::TrackRef trackref, std::vector< edm::ValueMap > v_dEdx); @@ -163,7 +164,8 @@ class MTVHistoProducerAlgoForTracker: public MTVHistoProducerAlgo { std::vector h_effic_vs_dxy, h_fake_vs_dxy, h_recodxy, h_assocdxy, h_assoc2dxy, h_simuldxy, h_looperdxy, h_misiddxy, h_loopratedxy, h_misidratedxy; std::vector h_effic_vs_dz, h_fake_vs_dz, h_recodz, h_assocdz, h_assoc2dz, h_simuldz, h_looperdz, h_misiddz, h_loopratedz, h_misidratedz; - std::vector h_effic_vs_vertpos, h_effic_vs_zpos, h_effic_vs_dr, h_assocvertpos, h_simulvertpos, h_assoczpos, h_simulzpos, h_assocdr, h_simuldr; + std::vector h_effic_vs_vertpos, h_effic_vs_zpos, h_assocvertpos, h_simulvertpos, h_assoczpos, h_simulzpos; + std::vector h_effic_vs_dr, h_fakerate_vs_dr, h_assocdr, h_assoc2dr, h_simuldr, h_recodr; std::vector h_pt, h_eta, h_pullTheta,h_pullPhi,h_pullDxy,h_pullDz,h_pullQoverp; std::vector h_effic_vertcount_entire, h_fakerate_vertcount_entire, h_reco_vertcount_entire, h_assoc_vertcount_entire, h_assoc2_vertcount_entire, h_simul_vertcount_entire; std::vector h_effic_vertcount_barrel, h_fakerate_vertcount_barrel, h_reco_vertcount_barrel, h_assoc_vertcount_barrel, h_assoc2_vertcount_barrel, h_simul_vertcount_barrel; diff --git a/Validation/RecoTrack/interface/MultiTrackValidator.h b/Validation/RecoTrack/interface/MultiTrackValidator.h index d11c0273545c3..6f07675cd6194 100644 --- a/Validation/RecoTrack/interface/MultiTrackValidator.h +++ b/Validation/RecoTrack/interface/MultiTrackValidator.h @@ -49,6 +49,8 @@ class MultiTrackValidator : public thread_unsafe::DQMEDAnalyzer, protected Multi TrackingParticleSelector dRtpSelector; edm::EDGetTokenT _simHitTpMapTag; + edm::EDGetTokenT > labelTokenForDrCalculation; + }; diff --git a/Validation/RecoTrack/plugins/MultiTrackValidator.cc b/Validation/RecoTrack/plugins/MultiTrackValidator.cc index e5b624c09a29d..7415147035a06 100644 --- a/Validation/RecoTrack/plugins/MultiTrackValidator.cc +++ b/Validation/RecoTrack/plugins/MultiTrackValidator.cc @@ -94,6 +94,8 @@ MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset):MultiTra _simHitTpMapTag = mayConsume(pset.getParameter("simHitTpMapTag")); + labelTokenForDrCalculation = consumes >(pset.getParameter("trackCollectionForDrCalculation")); + if (!UseAssociators) { associators.clear(); associators.push_back(assMapInput.label()); @@ -229,6 +231,9 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup dR_tPCeff.push_back(dR); } + edm::Handle > trackCollectionForDrCalculation; + event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation); + int w=0; //counter counting the number of sets of histograms for (unsigned int ww=0;ww dR_trk; + for(View::size_type i=0; isize(); ++i){ + RefToBase track(trackCollection, i); + double dR = std::numeric_limits::max(); + for(View::size_type j=0; jsize(); ++j){ + RefToBase track2(trackCollectionForDrCalculation, j); + double dR_tmp = reco::deltaR(*track,*track2); + if (dR_tmpstd::numeric_limits::min()) dR=dR_tmp; + } + dR_trk.push_back(dR); + } + for(View::size_type i=0; isize(); ++i){ RefToBase track(trackCollection, i); @@ -464,8 +483,8 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup << " NOT associated to any TrackingParticle" << "\n"; } - - histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction); + double dR=dR_trk[i]; + histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction,dR); // dE/dx // reco::TrackRef track2 = reco::TrackRef( trackCollection, i ); diff --git a/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc b/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc index ea75abe5e3db4..73131f7c4a64c 100644 --- a/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc +++ b/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc @@ -345,7 +345,8 @@ void MultiTrackValidatorGenPs::analyze(const edm::Event& event, const edm::Event } - histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isGenMatched,isSigGenMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction); + double dR=0;//fxime + histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isGenMatched,isSigGenMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction,dR); // dE/dx // reco::TrackRef track2 = reco::TrackRef( trackCollection, i ); diff --git a/Validation/RecoTrack/plugins/TrackerSeedValidator.cc b/Validation/RecoTrack/plugins/TrackerSeedValidator.cc index 2873176ce1185..42ec18920820b 100644 --- a/Validation/RecoTrack/plugins/TrackerSeedValidator.cc +++ b/Validation/RecoTrack/plugins/TrackerSeedValidator.cc @@ -346,9 +346,10 @@ void TrackerSeedValidator::analyze(const edm::Event& event, const edm::EventSetu edm::LogVerbatim("SeedValidator") << "TrajectorySeed #" << rT << " NOT associated to any TrackingParticle" << "\n"; } + double dR = 0.;//fixme histoProducerAlgo_->fill_generic_recoTrack_histos(w,*trackFromSeed,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocSeeds, puinfo.getPU_NumInteractions(), - tpbx, nSimHits, sharedFraction); + tpbx, nSimHits, sharedFraction, dR); //Fill other histos try{ diff --git a/Validation/RecoTrack/python/MultiTrackValidator_cfi.py b/Validation/RecoTrack/python/MultiTrackValidator_cfi.py index 747af30d42764..c261563a27883 100644 --- a/Validation/RecoTrack/python/MultiTrackValidator_cfi.py +++ b/Validation/RecoTrack/python/MultiTrackValidator_cfi.py @@ -57,4 +57,7 @@ ### output configuration dirName = cms.string('Tracking/Track/'), outputFile = cms.string(''), + + ### for fake rate vs dR ### + trackCollectionForDrCalculation = cms.InputTag("generalTracks") ) diff --git a/Validation/RecoTrack/python/PostProcessorTracker_cfi.py b/Validation/RecoTrack/python/PostProcessorTracker_cfi.py index 9795044d41d3b..2a11dedb6d05a 100644 --- a/Validation/RecoTrack/python/PostProcessorTracker_cfi.py +++ b/Validation/RecoTrack/python/PostProcessorTracker_cfi.py @@ -36,6 +36,7 @@ "fakerate_vs_phi 'Fake rate vs phi' num_assoc(recoToSim)_phi num_reco_phi fake", "fakerate_vs_dxy 'Fake rate vs dxy' num_assoc(recoToSim)_dxy num_reco_dxy fake", "fakerate_vs_dz 'Fake rate vs dz' num_assoc(recoToSim)_dz num_reco_dz fake", + "fakerate_vs_dr 'Fake rate vs dr' num_assoc(recoToSim)_dr num_reco_dr fake", "fakerate_vertcount_barrel 'fake rate in barrel vs N of pileup vertices' num_assoc(recoToSim)_vertcount_barrel num_reco_vertcount_barrel fake", "fakerate_vertcount_fwdpos 'fake rate in endcap(+) vs N of pileup vertices' num_assoc(recoToSim)_vertcount_fwdpos num_reco_vertcount_fwdpos fake", "fakerate_vertcount_fwdneg 'fake rate in endcap(-) vs N of pileup vertices' num_assoc(recoToSim)_vertcount_fwdneg num_reco_vertcount_fwdneg fake" diff --git a/Validation/RecoTrack/src/MTVHistoProducerAlgo.cc b/Validation/RecoTrack/src/MTVHistoProducerAlgo.cc index 8188941386474..aaa253c21d206 100644 --- a/Validation/RecoTrack/src/MTVHistoProducerAlgo.cc +++ b/Validation/RecoTrack/src/MTVHistoProducerAlgo.cc @@ -48,18 +48,20 @@ void MTVHistoProducerAlgo::fillPlotFromPlots(MonitorElement* h, TH1* numerator, TH1* denominator, std::string type){ + assert(h->getNbinsX()==numerator->GetNbinsX()); + assert(h->getNbinsX()==denominator->GetNbinsX()); double value,err; for (int bin=1;bin<=h->getNbinsX();++bin) { - if (denominator->GetBinContent(bin)>0) { + if (denominator->GetBinContent(bin)!=0) { if (type=="effic"){ value = ((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin)); - err = sqrt( value*(1-value)/((double) denominator->GetBinContent(bin)) ); + err = sqrt( value*(1.-value)/((double) denominator->GetBinContent(bin)) ); } else if (type=="fakerate"){ - value = 1-((double) numerator->GetBinContent(bin))*1./((double) denominator->GetBinContent(bin)); - err = sqrt( value*(1-value)/(double)denominator->GetBinContent(bin) ); + value = 1.-((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin)); + err = sqrt( value*(1.-value)/(double)denominator->GetBinContent(bin) ); } else if (type=="pileup"){ - value = ((double) numerator->GetBinContent(bin))*1./((double) denominator->GetBinContent(bin)); - err = sqrt( value*(1+value)/(double) denominator->GetBinContent(bin) ); + value = ((double) numerator->GetBinContent(bin))/((double) denominator->GetBinContent(bin)); + err = sqrt( value*(1.+value)/(double) denominator->GetBinContent(bin) ); } else return; h->setBinContent(bin,value); h->setBinError(bin,err); diff --git a/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc b/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc index 3c9268676a996..fc026ae5c18d7 100644 --- a/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc +++ b/Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc @@ -479,12 +479,13 @@ void MTVHistoProducerAlgoForTracker::bookRecoHistos(DQMStore::IBooker& ibook){ nintZpos,minZpos,maxZpos) ); h_simulzpos.push_back( ibook.book1D("num_simul_zpos","N of simulated tracks vs z vert position",nintZpos,minZpos,maxZpos) ); - h_assocdr.push_back( ibook.book1D("num_assoc(simToReco)_dr", - "N of associated tracks (simToReco) vs transverse vert position", - nintdr,log10(mindr),log10(maxdr)) ); + h_recodr.push_back( ibook.book1D("num_reco_dr","N of reconstructed tracks vs dR",nintdr,log10(mindr),log10(maxdr)) ); + h_assocdr.push_back( ibook.book1D("num_assoc(simToReco)_dr","N of associated tracks (simToReco) vs dR",nintdr,log10(mindr),log10(maxdr)) ); + h_assoc2dr.push_back( ibook.book1D("num_assoc(recoToSim)_dr","N of associated tracks (recoToSim) vs dR",nintdr,log10(mindr),log10(maxdr)) ); + h_simuldr.push_back( ibook.book1D("num_simul_dr","N of simulated tracks vs dR",nintdr,log10(mindr),log10(maxdr)) ); + BinLogX(h_recodr.back()->getTH1F()); BinLogX(h_assocdr.back()->getTH1F()); - h_simuldr.push_back( ibook.book1D("num_simul_dr","N of simulated tracks vs transverse vert position", - nintdr,log10(mindr),log10(maxdr)) ); + BinLogX(h_assoc2dr.back()->getTH1F()); BinLogX(h_simuldr.back()->getTH1F()); h_reco_vertcount_entire.push_back( ibook.book1D("num_reco_vertcount_entire","N of reco tracks vs N of pileup vertices",nintVertcount,minVertcount,maxVertcount) ); @@ -737,6 +738,8 @@ void MTVHistoProducerAlgoForTracker::bookRecoHistosForStandaloneRunning(DQMStore h_fakerate_ootpu_barrel.push_back( ibook.book1D("fakerate_ootpu_barrel","Out of time pileup fake rate in barrel vs N of pileup vertices",nintVertcount,minVertcount,maxVertcount) ); h_fakerate_ootpu_fwdpos.push_back( ibook.book1D("fakerate_ootpu_fwdpos","Out of time pileup fake rate in endcap(+) vs N of pileup vertices",nintVertcount,minVertcount,maxVertcount) ); h_fakerate_ootpu_fwdneg.push_back( ibook.book1D("fakerate_ootpu_fwdneg","Out of time pileup fake rate in endcap(-) vs N of pileup vertices",nintVertcount,minVertcount,maxVertcount) ); + h_fakerate_vs_dr.push_back( ibook.book1D("fakerate_vs_dr","fakerate vs dr",nintdr,log10(mindr),log10(maxdr)) ); + BinLogX(h_fakerate_vs_dr.back()->getTH1F()); h_fomt_eta.push_back( ibook.book1D("fomt","fraction of misreconstructed tracks vs #eta",nintEta,minEta,maxEta) ); h_fomt_sig_eta.push_back( ibook.book1D("fomt_signal","fraction of misreconstructed tracks vs #eta",nintEta,minEta,maxEta) ); @@ -1055,10 +1058,11 @@ void MTVHistoProducerAlgoForTracker::fill_generic_recoTrack_histos(int count, bool isMatched, bool isSigMatched, bool isChargeMatched, - int numAssocRecoTracks, - int numVertices, - int tpbunchcrossing, int nSimHits, - double sharedFraction){ + int numAssocRecoTracks, + int numVertices, + int tpbunchcrossing, int nSimHits, + double sharedFraction, + double dR){ //Fill track algo histogram @@ -1185,6 +1189,10 @@ void MTVHistoProducerAlgoForTracker::fill_generic_recoTrack_histos(int count, } + //fakerate vs dR + h_recodr[count]->Fill(min(max(dR,h_recodr[count]->getTH1()->GetXaxis()->GetXmin()),h_recodr[count]->getTH1()->GetXaxis()->GetXmax())); + if (isMatched) h_assoc2dr[count]->Fill(min(max(dR,h_recodr[count]->getTH1()->GetXaxis()->GetXmin()),h_recodr[count]->getTH1()->GetXaxis()->GetXmax())); + } @@ -1559,7 +1567,8 @@ void MTVHistoProducerAlgoForTracker::finalHistoFits(int counter){ fillPlotFromVectors(h_misidratedz[counter],totmisid_dz[counter],totREC_dz[counter],"effic"); fillPlotFromVectors(h_effic_vs_vertpos[counter],totASS_vertpos[counter],totSIM_vertpos[counter],"effic"); fillPlotFromVectors(h_effic_vs_zpos[counter],totASS_zpos[counter],totSIM_zpos[counter],"effic"); - fillPlotFromPlots(h_effic_vs_vertpos[counter],h_assocdr[counter]->getTH1(),h_simuldr[counter]->getTH1(),"effic"); + fillPlotFromPlots(h_effic_vs_dr[counter],h_assocdr[counter]->getTH1(),h_simuldr[counter]->getTH1(),"effic"); + fillPlotFromPlots(h_fakerate_vs_dr[counter],h_assoc2dr[counter]->getTH1(),h_recodr[counter]->getTH1(),"fakerate"); fillPlotFromVectors(h_effic_vertcount_entire[counter],totASS_vertcount_entire[counter],totSIM_vertcount_entire[counter],"effic"); fillPlotFromVectors(h_effic_vertcount_barrel[counter],totASS_vertcount_barrel[counter],totSIM_vertcount_barrel[counter],"effic"); fillPlotFromVectors(h_effic_vertcount_fwdpos[counter],totASS_vertcount_fwdpos[counter],totSIM_vertcount_fwdpos[counter],"effic");