Skip to content

Commit

Permalink
Add profiles of MVA vs. track pT and eta
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Jun 29, 2017
1 parent 39675d3 commit 29cd828
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 10 deletions.
5 changes: 5 additions & 0 deletions DQM/TrackingMonitor/interface/TrackBuildingAnalyzer.h
Expand Up @@ -60,6 +60,7 @@ class TrackBuildingAnalyzer
);
void analyze
(
const edm::View<reco::Track>& trackCollection,
const std::vector<const MVACollection *>& mvaCollections,
const std::vector<const QualityMaskCollection *>& qualityMaskCollections
);
Expand Down Expand Up @@ -103,6 +104,10 @@ class TrackBuildingAnalyzer

std::vector<MonitorElement *> trackMVAs;
std::vector<MonitorElement *> trackMVAsHP;
std::vector<MonitorElement *> trackMVAsVsPtProfile;
std::vector<MonitorElement *> trackMVAsHPVsPtProfile;
std::vector<MonitorElement *> trackMVAsVsEtaProfile;
std::vector<MonitorElement *> trackMVAsHPVsEtaProfile;

std::string histname; //for naming the histograms according to algorithm used

Expand Down
1 change: 1 addition & 0 deletions DQM/TrackingMonitor/interface/TrackingMonitor.h
Expand Up @@ -99,6 +99,7 @@ class TrackingMonitor : public DQMEDAnalyzer
edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelClustersToken_;

std::vector<std::tuple<edm::EDGetTokenT<MVACollection>, edm::EDGetTokenT<QualityMaskCollection> > > mvaQualityTokens_;
edm::EDGetTokenT<edm::View<reco::Track> > mvaTrackToken_;

std::string Quality_;
std::string AlgoName_;
Expand Down
1 change: 1 addition & 0 deletions DQM/TrackingMonitor/python/TrackingMonitor_cfi.py
Expand Up @@ -12,6 +12,7 @@
SeedProducer = cms.InputTag("initialStepSeeds"),
TCProducer = cms.InputTag("initialStepTrackCandidates"),
MVAProducers = cms.vstring("initialStepClassifier1", "initialStepClassifier2"),
TrackProducerForMVA = cms.InputTag("initialStepTracks"),
ClusterLabels = cms.vstring('Tot'), # to decide which Seeds-Clusters correlation plots to have default is Total other options 'Strip', 'Pix'
beamSpot = cms.InputTag("offlineBeamSpot"),
primaryVertex = cms.InputTag('offlinePrimaryVertices'),
Expand Down
41 changes: 36 additions & 5 deletions DQM/TrackingMonitor/src/TrackBuildingAnalyzer.cc
Expand Up @@ -333,6 +333,8 @@ void TrackBuildingAnalyzer::initHisto(DQMStore::IBooker & ibooker, const edm::Pa

if(i == 1) {
trackMVAsHP.push_back(nullptr);
trackMVAsHPVsPtProfile.push_back(nullptr);
trackMVAsHPVsEtaProfile.push_back(nullptr);
}
else {
pfix = " (not loose-selected)";
Expand All @@ -341,12 +343,32 @@ void TrackBuildingAnalyzer::initHisto(DQMStore::IBooker & ibooker, const edm::Pa
trackMVAsHP.push_back(ibooker.book1D(histname+CatagoryName, histname+CatagoryName+pfix2, MVABin, MVAMin, MVAMax));
trackMVAsHP.back()->setAxisTitle("Track selection MVA"+num, 1);
trackMVAsHP.back()->setAxisTitle("Number of tracks", 2);

histname = "TrackMVA"+num+"HPVsPtProfile_"+tcProducer.label() + "_";
trackMVAsHPVsPtProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix2, TrackPtBin, TrackPtMin, TrackPtMax, MVABin, MVAMin, MVAMax));
trackMVAsHPVsPtProfile.back()->setAxisTitle("Track p_{T} (GeV/c)", 1);
trackMVAsHPVsPtProfile.back()->setAxisTitle("Track selection MVA"+num, 2);

histname = "TrackMVA"+num+"HPVsEtaProfile_"+tcProducer.label() + "_";
trackMVAsHPVsEtaProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix2, EtaBin, EtaMin, EtaMax, MVABin, MVAMin, MVAMax));
trackMVAsHPVsEtaProfile.back()->setAxisTitle("Track #eta", 1);
trackMVAsHPVsEtaProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
}

histname = "TrackMVA"+num+"_"+tcProducer.label() + "_";
trackMVAs.push_back(ibooker.book1D(histname+CatagoryName, histname+CatagoryName+pfix, MVABin, MVAMin, MVAMax));
trackMVAs.back()->setAxisTitle("Track selection MVA"+num, 1);
trackMVAs.back()->setAxisTitle("Number of tracks", 2);

histname = "TrackMVA"+num+"VsPtProfile_"+tcProducer.label() + "_";
trackMVAsVsPtProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix, TrackPtBin, TrackPtMin, TrackPtMax, MVABin, MVAMin, MVAMax));
trackMVAsVsPtProfile.back()->setAxisTitle("Track p_{T} (GeV/c)", 1);
trackMVAsVsPtProfile.back()->setAxisTitle("Track selection MVA"+num, 2);

histname = "TrackMVA"+num+"VsEtaProfile_"+tcProducer.label() + "_";
trackMVAsVsEtaProfile.push_back(ibooker.bookProfile(histname+CatagoryName, histname+CatagoryName+pfix, EtaBin, EtaMin, EtaMax, MVABin, MVAMin, MVAMax));
trackMVAsVsEtaProfile.back()->setAxisTitle("Track #eta", 1);
trackMVAsVsEtaProfile.back()->setAxisTitle("Track selection MVA"+num, 2);
}
}
}
Expand Down Expand Up @@ -479,24 +501,25 @@ namespace {
return mask & 1<<qual;
}
}
void TrackBuildingAnalyzer::analyze(const std::vector<const MVACollection *>& mvaCollections,
void TrackBuildingAnalyzer::analyze(const edm::View<reco::Track>& trackCollection,
const std::vector<const MVACollection *>& mvaCollections,
const std::vector<const QualityMaskCollection *>& qualityMaskCollections) {
if(!(doAllTCPlots || doMVAPlots))
return;
if(mvaCollections.empty() || qualityMaskCollections.empty())
if(trackCollection.empty())
return;

const auto ntracks = mvaCollections[0]->size();
const auto ntracks = trackCollection.size();
const auto nmva = mvaCollections.size();
for(const auto mva: mvaCollections) {
if(mva->size() != ntracks) {
edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of MVACollection, " << mva->size() << " differs from the size of the first collection " << ntracks;
edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of MVACollection, " << mva->size() << " differs from the size of the track collection " << ntracks;
return;
}
}
for(const auto qual: qualityMaskCollections) {
if(qual->size() != ntracks) {
edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of QualityMaskCollection, " << qual->size() << " differs from the size of the first MVACollection " << ntracks;
edm::LogError("LogicError") << "TrackBuildingAnalyzer: Incompatible size of QualityMaskCollection, " << qual->size() << " differs from the size of the track collection " << ntracks;
return;
}
}
Expand All @@ -507,13 +530,21 @@ void TrackBuildingAnalyzer::analyze(const std::vector<const MVACollection *>& mv
// not selected by MVA1 etc
bool selectedLoose = false;
bool selectedHP = false;

const auto pt = trackCollection[iTrack].pt();
const auto eta = trackCollection[iTrack].eta();

for(size_t iMVA=0; iMVA<nmva; ++iMVA) {
const auto mva = (*(mvaCollections[iMVA]))[iTrack];
if(!selectedLoose) {
trackMVAs[iMVA]->Fill(mva);
trackMVAsVsPtProfile[iMVA]->Fill(pt, mva);
trackMVAsVsEtaProfile[iMVA]->Fill(eta, mva);
}
if(iMVA >= 1 && !selectedHP) {
trackMVAsHP[iMVA]->Fill(mva);
trackMVAsHPVsPtProfile[iMVA]->Fill(pt, mva);
trackMVAsHPVsEtaProfile[iMVA]->Fill(eta, mva);
}

const auto qual = (*(qualityMaskCollections)[iMVA])[iTrack];
Expand Down
6 changes: 5 additions & 1 deletion DQM/TrackingMonitor/src/TrackingMonitor.cc
Expand Up @@ -127,6 +127,7 @@ TrackingMonitor::TrackingMonitor(const edm::ParameterSet& iConfig)
return std::make_tuple(consumes<MVACollection>(edm::InputTag(tag, "MVAValues")),
consumes<QualityMaskCollection>(edm::InputTag(tag, "QualityMasks")));
});
mvaTrackToken_ = consumes<edm::View<reco::Track> >(iConfig.getParameter<edm::InputTag>("TrackProducerForMVA"));
}

edm::InputTag stripClusterInputTag_ = iConfig.getParameter<edm::InputTag>("stripCluster");
Expand Down Expand Up @@ -868,6 +869,9 @@ void TrackingMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& i
std::vector<const MVACollection *> mvaCollections;
std::vector<const QualityMaskCollection *> qualityMaskCollections;

edm::Handle<edm::View<reco::Track> > htracks;
iEvent.getByToken(mvaTrackToken_, htracks);

edm::Handle<MVACollection> hmva;
edm::Handle<QualityMaskCollection> hqual;
for(const auto& tokenTpl: mvaQualityTokens_) {
Expand All @@ -877,7 +881,7 @@ void TrackingMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& i
mvaCollections.push_back(hmva.product());
qualityMaskCollections.push_back(hqual.product());
}
theTrackBuildingAnalyzer->analyze(mvaCollections, qualityMaskCollections);
theTrackBuildingAnalyzer->analyze(*htracks, mvaCollections, qualityMaskCollections);
}
}

Expand Down
Expand Up @@ -316,7 +316,8 @@
for step in locals()["selectedIterTrackingStep"+_postfix]:
if step in mvaSel:
locals()["TrackSeedMon"+step].doMVAPlots = True
locals()["TrackSeedMon"+step].MVAProducers = mvaSel[step]
locals()["TrackSeedMon"+step].TrackProducerForMVA = mvaSel[step][0]
locals()["TrackSeedMon"+step].MVAProducers = mvaSel[step][1]

_seq += locals()["TrackSeedMon"+step]
if _eraName == "":
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/IterativeTracking/python/iterativeTkUtils.py
Expand Up @@ -27,6 +27,6 @@ def getMVASelectors(postfix):
elif "TrackMVAClassifier" in typeName:
classifiers = [iterName]
if len(classifiers) > 0:
ret[iterName] = classifiers
ret[iterName] = (iterName+"Tracks", classifiers)

return ret
4 changes: 2 additions & 2 deletions Validation/RecoTrack/python/TrackValidation_cff.py
Expand Up @@ -214,8 +214,8 @@ def _getMVASelectors(postfix):
mvaSel = _utils.getMVASelectors(postfix)

pset = cms.untracked.PSet()
for iteration, classifiers in mvaSel.iteritems():
setattr(pset, iteration+"Tracks", cms.untracked.vstring(classifiers))
for iteration, (trackProducer, classifiers) in mvaSel.iteritems():
setattr(pset, trackProducer, cms.untracked.vstring(classifiers))
return pset
for _eraName, _postfix, _era in _relevantEras:
locals()["_mvaSelectors"+_postfix] = _getMVASelectors(_postfix)
Expand Down

0 comments on commit 29cd828

Please sign in to comment.