Skip to content

Commit

Permalink
add fake rate vs dr
Browse files Browse the repository at this point in the history
  • Loading branch information
cerati committed Jun 13, 2014
1 parent b0c0489 commit ea1f241
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Validation/RecoTrack/interface/MTVHistoProducerAlgo.h
Expand Up @@ -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<reco::Track>& trackref,const std::vector< edm::ValueMap<reco::DeDxData> >& v_dEdx)=0;
// virtual void fill_dedx_recoTrack_histos(reco::TrackRef trackref, std::vector< edm::ValueMap<reco::DeDxData> > v_dEdx)=0;
Expand Down
Expand Up @@ -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<reco::Track>& trackref, const std::vector< edm::ValueMap<reco::DeDxData> >& v_dEdx);
// void fill_dedx_recoTrack_histos(reco::TrackRef trackref, std::vector< edm::ValueMap<reco::DeDxData> > v_dEdx);
Expand Down Expand Up @@ -163,7 +164,8 @@ class MTVHistoProducerAlgoForTracker: public MTVHistoProducerAlgo {
std::vector<MonitorElement*> 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<MonitorElement*> 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<MonitorElement*> 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<MonitorElement*> h_effic_vs_vertpos, h_effic_vs_zpos, h_assocvertpos, h_simulvertpos, h_assoczpos, h_simulzpos;
std::vector<MonitorElement*> h_effic_vs_dr, h_fakerate_vs_dr, h_assocdr, h_assoc2dr, h_simuldr, h_recodr;
std::vector<MonitorElement*> h_pt, h_eta, h_pullTheta,h_pullPhi,h_pullDxy,h_pullDz,h_pullQoverp;
std::vector<MonitorElement*> 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<MonitorElement*> h_effic_vertcount_barrel, h_fakerate_vertcount_barrel, h_reco_vertcount_barrel, h_assoc_vertcount_barrel, h_assoc2_vertcount_barrel, h_simul_vertcount_barrel;
Expand Down
2 changes: 2 additions & 0 deletions Validation/RecoTrack/interface/MultiTrackValidator.h
Expand Up @@ -49,6 +49,8 @@ class MultiTrackValidator : public thread_unsafe::DQMEDAnalyzer, protected Multi
TrackingParticleSelector dRtpSelector;

edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> _simHitTpMapTag;
edm::EDGetTokenT<edm::View<reco::Track> > labelTokenForDrCalculation;

};


Expand Down
23 changes: 21 additions & 2 deletions Validation/RecoTrack/plugins/MultiTrackValidator.cc
Expand Up @@ -94,6 +94,8 @@ MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset):MultiTra

_simHitTpMapTag = mayConsume<SimHitTPAssociationProducer::SimHitTPAssociationList>(pset.getParameter<edm::InputTag>("simHitTpMapTag"));

labelTokenForDrCalculation = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("trackCollectionForDrCalculation"));

if (!UseAssociators) {
associators.clear();
associators.push_back(assMapInput.label());
Expand Down Expand Up @@ -229,6 +231,9 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
dR_tPCeff.push_back(dR);
}

edm::Handle<View<Track> > trackCollectionForDrCalculation;
event.getByToken(labelTokenForDrCalculation, trackCollectionForDrCalculation);

int w=0; //counter counting the number of sets of histograms
for (unsigned int ww=0;ww<associators.size();ww++){
for (unsigned int www=0;www<label.size();www++){
Expand Down Expand Up @@ -424,6 +429,20 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
}
//end dE/dx


//calculate dR for tracks
std::vector<double> dR_trk;
for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
RefToBase<Track> track(trackCollection, i);
double dR = std::numeric_limits<double>::max();
for(View<Track>::size_type j=0; j<trackCollectionForDrCalculation->size(); ++j){
RefToBase<Track> track2(trackCollectionForDrCalculation, j);
double dR_tmp = reco::deltaR(*track,*track2);
if (dR_tmp<dR && dR_tmp>std::numeric_limits<double>::min()) dR=dR_tmp;
}
dR_trk.push_back(dR);
}

for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){

RefToBase<Track> track(trackCollection, i);
Expand Down Expand Up @@ -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 );
Expand Down
3 changes: 2 additions & 1 deletion Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc
Expand Up @@ -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 );
Expand Down
3 changes: 2 additions & 1 deletion Validation/RecoTrack/plugins/TrackerSeedValidator.cc
Expand Up @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions Validation/RecoTrack/python/MultiTrackValidator_cfi.py
Expand Up @@ -57,4 +57,7 @@
### output configuration
dirName = cms.string('Tracking/Track/'),
outputFile = cms.string(''),

### for fake rate vs dR ###
trackCollectionForDrCalculation = cms.InputTag("generalTracks")
)
1 change: 1 addition & 0 deletions Validation/RecoTrack/python/PostProcessorTracker_cfi.py
Expand Up @@ -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"
Expand Down
14 changes: 8 additions & 6 deletions Validation/RecoTrack/src/MTVHistoProducerAlgo.cc
Expand Up @@ -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);
Expand Down
29 changes: 19 additions & 10 deletions Validation/RecoTrack/src/MTVHistoProducerAlgoForTracker.cc
Expand Up @@ -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) );
Expand Down Expand Up @@ -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) );
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()));

}


Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit ea1f241

Please sign in to comment.