Skip to content

Commit

Permalink
Merge pull request #10688 from makortel/trackingHLTValidationCleanup
Browse files Browse the repository at this point in the history
Tracking HLT validation cleanup
  • Loading branch information
cmsbuild committed Aug 16, 2015
2 parents 7a57508 + 8d351cf commit 69140a1
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 164 deletions.
6 changes: 3 additions & 3 deletions HLTriggerOffline/Common/python/HLTValidationHarvest_cff.py
Expand Up @@ -17,7 +17,7 @@
from HLTriggerOffline.Btag.HltBtagPostValidation_cff import *

hltpostvalidation = cms.Sequence(
postProcessorHLTtracking
postProcessorHLTtrackingSequence
+postProcessorHLTvertexing
+HLTMuonPostVal
+HLTTauPostVal
Expand Down Expand Up @@ -52,7 +52,7 @@
)

hltpostvalidation_preprod = cms.Sequence(
postProcessorHLTtracking
postProcessorHLTtrackingSequence
+postProcessorHLTvertexing
+HLTTauPostVal
+heavyFlavorValidationHarvestingSequence
Expand All @@ -61,6 +61,6 @@
)

hltpostvalidation_prod = cms.Sequence(
postProcessorHLTtracking
postProcessorHLTtrackingSequence
+postProcessorHLTvertexing
)
2 changes: 2 additions & 0 deletions Validation/RecoTrack/interface/MultiTrackValidator.h
Expand Up @@ -31,7 +31,9 @@ class MultiTrackValidator : public DQMEDAnalyzer, protected MultiTrackValidatorB
//these are used by MTVGenPs
bool UseAssociators;
const bool parametersDefinerIsCosmic_;
const bool calculateDrSingleCollection_;
const bool doPlotsOnlyForTruePV_;
const bool doSummaryPlots_;
const bool doSimPlots_;
const bool doSimTrackPlots_;
const bool doRecoTrackPlots_;
Expand Down
84 changes: 50 additions & 34 deletions Validation/RecoTrack/plugins/MultiTrackValidator.cc
Expand Up @@ -45,7 +45,9 @@ typedef edm::Ref<edm::HepMCProduct, HepMC::GenParticle > GenParticleRef;
MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset):
MultiTrackValidatorBase(pset,consumesCollector()),
parametersDefinerIsCosmic_(parametersDefiner == "CosmicParametersDefinerForTP"),
calculateDrSingleCollection_(pset.getUntrackedParameter<bool>("calculateDrSingleCollection")),
doPlotsOnlyForTruePV_(pset.getUntrackedParameter<bool>("doPlotsOnlyForTruePV")),
doSummaryPlots_(pset.getUntrackedParameter<bool>("doSummaryPlots")),
doSimPlots_(pset.getUntrackedParameter<bool>("doSimPlots")),
doSimTrackPlots_(pset.getUntrackedParameter<bool>("doSimTrackPlots")),
doRecoTrackPlots_(pset.getUntrackedParameter<bool>("doRecoTrackPlots")),
Expand Down Expand Up @@ -123,7 +125,9 @@ MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset):

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

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

if(UseAssociators) {
for (auto const& src: associators) {
Expand Down Expand Up @@ -171,19 +175,21 @@ void MultiTrackValidator::bookHistograms(DQMStore::IBooker& ibook, edm::Run cons
// FIXME: these need to be moved to a subdirectory whose name depends on the associator
ibook.setCurrentFolder(dirName_);

if(doSimTrackPlots_) {
h_assoc_coll.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
h_simul_coll.push_back(binLabels( ibook.book1D("num_simul_coll", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
if(doSummaryPlots_) {
if(doSimTrackPlots_) {
h_assoc_coll.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
h_simul_coll.push_back(binLabels( ibook.book1D("num_simul_coll", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));

h_assoc_coll_allPt.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll_allPt", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
h_simul_coll_allPt.push_back(binLabels( ibook.book1D("num_simul_coll_allPt", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));
h_assoc_coll_allPt.push_back(binLabels( ibook.book1D("num_assoc(simToReco)_coll_allPt", "N of associated (simToReco) tracks vs track collection", nintColl, minColl, maxColl) ));
h_simul_coll_allPt.push_back(binLabels( ibook.book1D("num_simul_coll_allPt", "N of simulated tracks vs track collection", nintColl, minColl, maxColl) ));

}
if(doRecoTrackPlots_) {
h_reco_coll.push_back(binLabels( ibook.book1D("num_reco_coll", "N of reco track vs track collection", nintColl, minColl, maxColl) ));
h_assoc2_coll.push_back(binLabels( ibook.book1D("num_assoc(recoToSim)_coll", "N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
h_looper_coll.push_back(binLabels( ibook.book1D("num_duplicate_coll", "N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
h_pileup_coll.push_back(binLabels( ibook.book1D("num_pileup_coll", "N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
}
if(doRecoTrackPlots_) {
h_reco_coll.push_back(binLabels( ibook.book1D("num_reco_coll", "N of reco track vs track collection", nintColl, minColl, maxColl) ));
h_assoc2_coll.push_back(binLabels( ibook.book1D("num_assoc(recoToSim)_coll", "N of associated (recoToSim) tracks vs track collection", nintColl, minColl, maxColl) ));
h_looper_coll.push_back(binLabels( ibook.book1D("num_duplicate_coll", "N of associated (recoToSim) looper tracks vs track collection", nintColl, minColl, maxColl) ));
h_pileup_coll.push_back(binLabels( ibook.book1D("num_pileup_coll", "N of associated (recoToSim) pileup tracks vs track collection", nintColl, minColl, maxColl) ));
}
}

for (unsigned int www=0;www<label.size();www++){
Expand Down Expand Up @@ -432,7 +438,9 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
}

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

// dE/dx
// at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
Expand Down Expand Up @@ -618,16 +626,18 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
sts++;
if(matchedTrackPointer)
asts++;
if(dRtpSelectorNoPtCut(tp)) {
h_simul_coll_allPt[ww]->Fill(www);
if (matchedTrackPointer) {
h_assoc_coll_allPt[ww]->Fill(www);
}

if(dRtpSelector(tp)) {
h_simul_coll[ww]->Fill(www);
if(doSummaryPlots_) {
if(dRtpSelectorNoPtCut(tp)) {
h_simul_coll_allPt[ww]->Fill(www);
if (matchedTrackPointer) {
h_assoc_coll[ww]->Fill(www);
h_assoc_coll_allPt[ww]->Fill(www);
}

if(dRtpSelector(tp)) {
h_simul_coll[ww]->Fill(www);
if (matchedTrackPointer) {
h_assoc_coll[ww]->Fill(www);
}
}
}
}
Expand All @@ -653,11 +663,15 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
int rT(0); //This counter counts the number of recoTracks in general

//calculate dR for tracks
const edm::View<Track> *trackCollectionDr = trackCollection.product();
if(calculateDrSingleCollection_) {
trackCollectionDr = trackCollectionForDrCalculation.product();
}
float dR_trk[trackCollection->size()];
int i=0;
float etaL[trackCollectionForDrCalculation->size()];
float phiL[trackCollectionForDrCalculation->size()];
for (auto const & track2 : *trackCollectionForDrCalculation) {
float etaL[trackCollectionDr->size()];
float phiL[trackCollectionDr->size()];
for (auto const & track2 : *trackCollectionDr) {
auto && p = track2.momentum();
etaL[i] = etaFromXYZ(p.x(),p.y(),p.z());
phiL[i] = atan2f(p.y(),p.x());
Expand All @@ -669,7 +683,7 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup
auto && p = track.momentum();
float eta = etaFromXYZ(p.x(),p.y(),p.z());
float phi = atan2f(p.y(),p.x());
for(View<Track>::size_type j=0; j<trackCollectionForDrCalculation->size(); ++j){
for(View<Track>::size_type j=0; j<trackCollectionDr->size(); ++j){
auto dR_tmp = reco::deltaR2(eta, phi, etaL[j], phiL[j]);
if ( (dR_tmp<dR) & (dR_tmp>std::numeric_limits<float>::min())) dR=dR_tmp;
}
Expand Down Expand Up @@ -714,14 +728,16 @@ void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup

double dR=dR_trk[i];
histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(), thePVposition, isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), nSimHits, sharedFraction, dR);
h_reco_coll[ww]->Fill(www);
if(isSimMatched) {
h_assoc2_coll[ww]->Fill(www);
if(numAssocRecoTracks>1) {
h_looper_coll[ww]->Fill(www);
}
else if(!isSigSimMatched) {
h_pileup_coll[ww]->Fill(www);
if(doSummaryPlots_) {
h_reco_coll[ww]->Fill(www);
if(isSimMatched) {
h_assoc2_coll[ww]->Fill(www);
if(numAssocRecoTracks>1) {
h_looper_coll[ww]->Fill(www);
}
else if(!isSigSimMatched) {
h_pileup_coll[ww]->Fill(www);
}
}
}

Expand Down
74 changes: 15 additions & 59 deletions Validation/RecoTrack/python/HLTmultiTrackValidator_cff.py
@@ -1,67 +1,23 @@
import FWCore.ParameterSet.Config as cms

from Validation.RecoTrack.HLTmultiTrackValidator_cfi import *
hltPixelTracksV = hltMultiTrackValidator.clone()
hltPixelTracksV.label = cms.VInputTag(cms.InputTag("hltPixelTracks"))
hltPixelTracksV.trackCollectionForDrCalculation = cms.InputTag("hltPixelTracks")

hltIter0V = hltMultiTrackValidator.clone()
hltIter0V.label = cms.VInputTag( cms.InputTag("hltIter0PFlowTrackSelectionHighPurity") )
hltIter0V.trackCollectionForDrCalculation = cms.InputTag("hltIter0PFlowTrackSelectionHighPurity")

hltIter1V = hltMultiTrackValidator.clone()
hltIter1V.label = cms.VInputTag( cms.InputTag("hltIter1PFlowTrackSelectionHighPurity") )
hltIter1V.trackCollectionForDrCalculation = cms.InputTag("hltIter1PFlowTrackSelectionHighPurity")

hltIter1MergedV = hltMultiTrackValidator.clone()
hltIter1MergedV.label = cms.VInputTag( cms.InputTag("hltIter1Merged") )
hltIter1MergedV.trackCollectionForDrCalculation = cms.InputTag("hltIter1Merged")

hltIter2V = hltMultiTrackValidator.clone()
hltIter2V.label = cms.VInputTag( cms.InputTag("hltIter2PFlowTrackSelectionHighPurity") )
hltIter2V.trackCollectionForDrCalculation = cms.InputTag("hltIter2PFlowTrackSelectionHighPurity")

hltIter2MergedV = hltMultiTrackValidator.clone()
hltIter2MergedV.label = cms.VInputTag( cms.InputTag("hltIter2Merged") )
hltIter2MergedV.trackCollectionForDrCalculation = cms.InputTag("hltIter2Merged")

hltIter3V = hltMultiTrackValidator.clone()
hltIter3V.label = cms.VInputTag( cms.InputTag("hltIter3PFlowTrackSelectionHighPurity") )
hltIter3V.trackCollectionForDrCalculation = cms.InputTag("hltIter3PFlowTrackSelectionHighPurity")

hltIter3MergedV = hltMultiTrackValidator.clone()
hltIter3MergedV.label = cms.VInputTag( cms.InputTag("hltIter3Merged") )
hltIter3MergedV.trackCollectionForDrCalculation = cms.InputTag("hltIter3Merged")

hltIter4V = hltMultiTrackValidator.clone()
hltIter4V.label = cms.VInputTag( cms.InputTag("hltIter4PFlowTrackSelectionHighPurity") )
hltIter4V.trackCollectionForDrCalculation = cms.InputTag("hltIter4PFlowTrackSelectionHighPurity")

hltIter4MergedV = hltMultiTrackValidator.clone()
hltIter4MergedV.label = cms.VInputTag( cms.InputTag("hltIter4Merged") )
hltIter4MergedV.trackCollectionForDrCalculation = cms.InputTag("hltIter4Merged")

from Validation.RecoTrack.cutsTPEffic_cfi import *
from Validation.RecoTrack.cutsTPFake_cfi import *

from SimGeneral.TrackingAnalysis.simHitTPAssociation_cfi import *
hltTrackValidator = hltMultiTrackValidator.clone(
label = [
"hltPixelTracks",
"hltIter0PFlowTrackSelectionHighPurity",
"hltIter1PFlowTrackSelectionHighPurity",
"hltIter1Merged",
"hltIter2PFlowTrackSelectionHighPurity",
"hltIter2Merged",
# "hltIter3PFlowTrackSelectionHighPurity",
# "hltIter3Merged",
# "hltIter4PFlowTrackSelectionHighPurity",
# "hltIter4Merged",
]
)

hltMultiTrackValidation = cms.Sequence(
# simHitTPAssocProducer
# +
hltTPClusterProducer
# + tpToHLTtracksAssociationSequence # not needed because MTV is configured to use the associators in itself, instead we need the hltTrackAssociatorByHits
+ hltTrackAssociatorByHits
+ cms.ignore(cutsTPEffic)
+ cms.ignore(cutsTPFake)
+ hltPixelTracksV
+ hltIter0V
+ hltIter1V
+ hltIter1MergedV
+ hltIter2V
+ hltIter2MergedV
# + hltIter3V
# + hltIter3MergedV
# + hltIter4V
# + hltIter4MergedV
+ hltTrackValidator
)
2 changes: 1 addition & 1 deletion Validation/RecoTrack/python/HLTmultiTrackValidator_cfi.py
Expand Up @@ -27,7 +27,7 @@
hltMultiTrackValidator.parametersDefiner = cms.string('hltLhcParametersDefinerForTP')
#hltMultiTrackValidator.parametersDefiner = cms.string('LhcParametersDefinerForTP')
### for fake rate vs dR ###
hltMultiTrackValidator.trackCollectionForDrCalculation = cms.InputTag("hltPixelTracks")
hltMultiTrackValidator.calculateDrSingleCollection = False
hltMultiTrackValidator.ignoremissingtrackcollection = cms.untracked.bool(True)

hltMultiTrackValidator.UseAssociators = True
Expand Down

0 comments on commit 69140a1

Please sign in to comment.