diff --git a/RecoLocalFastTime/Configuration/python/RecoLocalFastTime_EventContent_cff.py b/RecoLocalFastTime/Configuration/python/RecoLocalFastTime_EventContent_cff.py index 44ea32fd320bf..dd8ce385f0c3f 100644 --- a/RecoLocalFastTime/Configuration/python/RecoLocalFastTime_EventContent_cff.py +++ b/RecoLocalFastTime/Configuration/python/RecoLocalFastTime_EventContent_cff.py @@ -1,25 +1,24 @@ import FWCore.ParameterSet.Config as cms -#FEVT -RecoLocalFastTimeFEVT = cms.PSet( - outputCommands = cms.untracked.vstring( - 'keep *_mtdUncalibratedRecHits_*_*', - 'keep *_mtdRecHits_*_*', - 'keep *_mtdClusters_*_*', - 'keep *_mtdTrackingRecHits_*_*' - ) +#AOD content +RecoLocalFastTimeAOD = cms.PSet( + outputCommands = cms.untracked.vstring() ) + #RECO content RecoLocalFastTimeRECO = cms.PSet( outputCommands = cms.untracked.vstring( - 'keep *_mtdRecHits_*_*', - 'keep *_mtdClusters_*_*', - ) + 'keep *_mtdRecHits_*_*', + 'keep *_mtdClusters_*_*', + ) ) -#AOD content -RecoLocalFastTimeAOD = cms.PSet( +RecoLocalFastTimeRECO.outputCommands.extend(RecoLocalFastTimeAOD.outputCommands) + +#FEVT +RecoLocalFastTimeFEVT = cms.PSet( outputCommands = cms.untracked.vstring( - 'keep *_mtdClusters_*_*', + 'keep *_mtdUncalibratedRecHits_*_*', + 'keep *_mtdTrackingRecHits_*_*', ) ) - +RecoLocalFastTimeFEVT.outputCommands.extend(RecoLocalFastTimeRECO.outputCommands) diff --git a/RecoMTD/Configuration/python/RecoMTD_EventContent_cff.py b/RecoMTD/Configuration/python/RecoMTD_EventContent_cff.py index bc036dbbb9e95..8f1e2dc5cbdb3 100644 --- a/RecoMTD/Configuration/python/RecoMTD_EventContent_cff.py +++ b/RecoMTD/Configuration/python/RecoMTD_EventContent_cff.py @@ -3,18 +3,22 @@ #AOD RecoMTDAOD = cms.PSet( outputCommands = cms.untracked.vstring( - 'keep *_trackExtenderWithMTD_*_*', + 'keep intedmValueMap_trackExtenderWithMTD_*_*', + 'keep floatedmValueMap_trackExtenderWithMTD_*_*', 'keep *_mtdTrackQualityMVA_*_*') ) #RECO content RecoMTDRECO = cms.PSet( - outputCommands = cms.untracked.vstring() + outputCommands = cms.untracked.vstring( + 'keep recoTrack*_trackExtenderWithMTD_*_*', + 'keep TrackingRecHitsOwned_trackExtenderWithMTD_*_*', + ) ) RecoMTDRECO.outputCommands.extend(RecoMTDAOD.outputCommands) #FEVT content RecoMTDFEVT = cms.PSet( - outputCommands = cms.untracked.vstring() + outputCommands = cms.untracked.vstring() ) RecoMTDFEVT.outputCommands.extend(RecoMTDRECO.outputCommands) diff --git a/RecoMTD/TimingIDTools/interface/MTDTrackQualityMVA.h b/RecoMTD/TimingIDTools/interface/MTDTrackQualityMVA.h index 46d9191906c8d..4d31e1acdeff0 100644 --- a/RecoMTD/TimingIDTools/interface/MTDTrackQualityMVA.h +++ b/RecoMTD/TimingIDTools/interface/MTDTrackQualityMVA.h @@ -38,7 +38,8 @@ class MTDTrackQualityMVA { //---getters--- // 4D float operator()(const reco::TrackRef& trk, - const reco::TrackRef& ext_trk, + const edm::ValueMap& npixBarrels, + const edm::ValueMap& npixEndcaps, const edm::ValueMap& btl_chi2s, const edm::ValueMap& btl_time_chi2s, const edm::ValueMap& etl_chi2s, diff --git a/RecoMTD/TimingIDTools/plugins/MTDTrackQualityMVAProducer.cc b/RecoMTD/TimingIDTools/plugins/MTDTrackQualityMVAProducer.cc index 37152256f1a9e..54fd444fe946d 100644 --- a/RecoMTD/TimingIDTools/plugins/MTDTrackQualityMVAProducer.cc +++ b/RecoMTD/TimingIDTools/plugins/MTDTrackQualityMVAProducer.cc @@ -44,14 +44,14 @@ class MTDTrackQualityMVAProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT> etlMatchTimeChi2Token_; edm::EDGetTokenT> mtdTimeToken_; edm::EDGetTokenT> pathLengthToken_; - edm::EDGetTokenT> trackAssocToken_; + edm::EDGetTokenT> npixBarrelToken_; + edm::EDGetTokenT> npixEndcapToken_; MTDTrackQualityMVA mva_; }; MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer(const ParameterSet& iConfig) : tracksToken_(consumes(iConfig.getParameter("tracksSrc"))), - tracksMTDToken_(consumes(iConfig.getParameter("tracksMTDSrc"))), btlMatchChi2Token_(consumes>(iConfig.getParameter("btlMatchChi2Src"))), btlMatchTimeChi2Token_( consumes>(iConfig.getParameter("btlMatchTimeChi2Src"))), @@ -60,7 +60,8 @@ MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer(const ParameterSet& iConf consumes>(iConfig.getParameter("etlMatchTimeChi2Src"))), mtdTimeToken_(consumes>(iConfig.getParameter("mtdTimeSrc"))), pathLengthToken_(consumes>(iConfig.getParameter("pathLengthSrc"))), - trackAssocToken_(consumes>(iConfig.getParameter("trackAssocSrc"))), + npixBarrelToken_(consumes>(iConfig.getParameter("npixBarrelSrc"))), + npixEndcapToken_(consumes>(iConfig.getParameter("npixEndcapSrc"))), mva_(iConfig.getParameter("qualityBDT_weights_file").fullPath()) { produces>(mvaName); } @@ -69,8 +70,6 @@ MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer(const ParameterSet& iConf void MTDTrackQualityMVAProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("tracksSrc", edm::InputTag("generalTracks"))->setComment("Input tracks collection"); - desc.add("tracksMTDSrc", edm::InputTag("trackExtenderWithMTD")) - ->setComment("Input tracks collection for MTD extended tracks"); desc.add("btlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchChi2")) ->setComment("BTL Chi2 Matching value Map"); desc.add("btlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchTimeChi2")) @@ -79,12 +78,14 @@ void MTDTrackQualityMVAProducer::fillDescriptions(edm::ConfigurationDescriptions ->setComment("ETL Chi2 Matching value Map"); desc.add("etlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchTimeChi2")) ->setComment("ETL Chi2 Matching value Map"); - desc.add("mtdTimeSrc", edm::InputTag("trackExtenderWithMTD", "tmtd")) + desc.add("mtdTimeSrc", edm::InputTag("trackExtenderWithMTD", "generalTracktmtd")) ->setComment("MTD TIme value Map"); - desc.add("pathLengthSrc", edm::InputTag("trackExtenderWithMTD", "pathLength")) + desc.add("pathLengthSrc", edm::InputTag("trackExtenderWithMTD", "generalTrackPathLength")) ->setComment("MTD PathLength value Map"); - desc.add("trackAssocSrc", edm::InputTag("trackExtenderWithMTD", "generalTrackassoc")) - ->setComment("Association between General and MTD Extended tracks"); + desc.add("npixBarrelSrc", edm::InputTag("trackExtenderWithMTD", "npixBarrel")) + ->setComment("# of Barrel pixel associated to refitted tracks"); + desc.add("npixEndcapSrc", edm::InputTag("trackExtenderWithMTD", "npixEndcap")) + ->setComment("# of Endcap pixel associated to refitted tracks"); desc.add("qualityBDT_weights_file", edm::FileInPath("RecoMTD/TimingIDTools/data/clf4D_MTDquality_bo.xml")) ->setComment("Track MTD quality BDT weights"); @@ -108,15 +109,13 @@ void MTDTrackQualityMVAProducer::produce(edm::Event& ev, const edm::EventSetup& ev.getByToken(tracksToken_, tracksH); const auto& tracks = *tracksH; - edm::Handle tracksMTDH; - ev.getByToken(tracksMTDToken_, tracksMTDH); - const auto& btlMatchChi2 = ev.get(btlMatchChi2Token_); const auto& btlMatchTimeChi2 = ev.get(btlMatchTimeChi2Token_); const auto& etlMatchChi2 = ev.get(etlMatchChi2Token_); const auto& etlMatchTimeChi2 = ev.get(etlMatchTimeChi2Token_); const auto& pathLength = ev.get(pathLengthToken_); - const auto& trackAssoc = ev.get(trackAssocToken_); + const auto& npixBarrel = ev.get(npixBarrelToken_); + const auto& npixEndcap = ev.get(npixEndcapToken_); const auto& mtdTime = ev.get(mtdTimeToken_); std::vector mvaOutRaw; @@ -124,12 +123,18 @@ void MTDTrackQualityMVAProducer::produce(edm::Event& ev, const edm::EventSetup& //Loop over tracks collection for (unsigned int itrack = 0; itrack < tracks.size(); ++itrack) { const reco::TrackRef trackref(tracksH, itrack); - if (trackAssoc[trackref] == -1) + if (pathLength[trackref] == -1.) mvaOutRaw.push_back(-1.); else { - const reco::TrackRef mtdTrackref = reco::TrackRef(tracksMTDH, trackAssoc[trackref]); - mvaOutRaw.push_back(mva_( - trackref, mtdTrackref, btlMatchChi2, btlMatchTimeChi2, etlMatchChi2, etlMatchTimeChi2, mtdTime, pathLength)); + mvaOutRaw.push_back(mva_(trackref, + npixBarrel, + npixEndcap, + btlMatchChi2, + btlMatchTimeChi2, + etlMatchChi2, + etlMatchTimeChi2, + mtdTime, + pathLength)); } } fillValueMap(ev, tracksH, mvaOutRaw, mvaName); diff --git a/RecoMTD/TimingIDTools/src/MTDTrackQualityMVA.cc b/RecoMTD/TimingIDTools/src/MTDTrackQualityMVA.cc index 26f7255cb7741..f3a5cc0db37f8 100644 --- a/RecoMTD/TimingIDTools/src/MTDTrackQualityMVA.cc +++ b/RecoMTD/TimingIDTools/src/MTDTrackQualityMVA.cc @@ -13,15 +13,14 @@ MTDTrackQualityMVA::MTDTrackQualityMVA(std::string weights_file) { } float MTDTrackQualityMVA::operator()(const reco::TrackRef& trk, - const reco::TrackRef& ext_trk, + const edm::ValueMap& npixBarrels, + const edm::ValueMap& npixEndcaps, const edm::ValueMap& btl_chi2s, const edm::ValueMap& btl_time_chi2s, const edm::ValueMap& etl_chi2s, const edm::ValueMap& etl_time_chi2s, const edm::ValueMap& tmtds, const edm::ValueMap& trk_lengths) const { - const auto& pattern = ext_trk->hitPattern(); - std::map vars; //---training performed only above 0.5 GeV @@ -30,23 +29,21 @@ float MTDTrackQualityMVA::operator()(const reco::TrackRef& trk, return -1; //---training performed only for tracks with MTD hits - if (tmtds[ext_trk] > 0) { + if (tmtds[trk] > 0) { vars.emplace(vars_[int(VarID::pt)], trk->pt()); vars.emplace(vars_[int(VarID::eta)], trk->eta()); vars.emplace(vars_[int(VarID::phi)], trk->phi()); vars.emplace(vars_[int(VarID::chi2)], trk->chi2()); vars.emplace(vars_[int(VarID::ndof)], trk->ndof()); vars.emplace(vars_[int(VarID::numberOfValidHits)], trk->numberOfValidHits()); - vars.emplace(vars_[int(VarID::numberOfValidPixelBarrelHits)], pattern.numberOfValidPixelBarrelHits()); - vars.emplace(vars_[int(VarID::numberOfValidPixelEndcapHits)], pattern.numberOfValidPixelEndcapHits()); - vars.emplace(vars_[int(VarID::btlMatchChi2)], btl_chi2s.contains(ext_trk.id()) ? btl_chi2s[ext_trk] : -1); - vars.emplace(vars_[int(VarID::btlMatchTimeChi2)], - btl_time_chi2s.contains(ext_trk.id()) ? btl_time_chi2s[ext_trk] : -1); - vars.emplace(vars_[int(VarID::etlMatchChi2)], etl_chi2s.contains(ext_trk.id()) ? etl_chi2s[ext_trk] : -1); - vars.emplace(vars_[int(VarID::etlMatchTimeChi2)], - etl_time_chi2s.contains(ext_trk.id()) ? etl_time_chi2s[ext_trk] : -1); - vars.emplace(vars_[int(VarID::mtdt)], tmtds[ext_trk]); - vars.emplace(vars_[int(VarID::path_len)], trk_lengths[ext_trk]); + vars.emplace(vars_[int(VarID::numberOfValidPixelBarrelHits)], npixBarrels[trk]); + vars.emplace(vars_[int(VarID::numberOfValidPixelEndcapHits)], npixEndcaps[trk]); + vars.emplace(vars_[int(VarID::btlMatchChi2)], btl_chi2s.contains(trk.id()) ? btl_chi2s[trk] : -1); + vars.emplace(vars_[int(VarID::btlMatchTimeChi2)], btl_time_chi2s.contains(trk.id()) ? btl_time_chi2s[trk] : -1); + vars.emplace(vars_[int(VarID::etlMatchChi2)], etl_chi2s.contains(trk.id()) ? etl_chi2s[trk] : -1); + vars.emplace(vars_[int(VarID::etlMatchTimeChi2)], etl_time_chi2s.contains(trk.id()) ? etl_time_chi2s[trk] : -1); + vars.emplace(vars_[int(VarID::mtdt)], tmtds[trk]); + vars.emplace(vars_[int(VarID::path_len)], trk_lengths[trk]); return 1. / (1 + sqrt(2 / (1 + mva_->evaluate(vars, false)) - 1)); //return values between 0-1 (probability) } else return -1; diff --git a/RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc b/RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc index afaa27d3695f2..b69ebc1227664 100644 --- a/RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc +++ b/RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc @@ -371,9 +371,8 @@ class TrackExtenderWithMTDT : public edm::stream::EDProducer<> { edm::EDPutToken etlMatchChi2Token; edm::EDPutToken btlMatchTimeChi2Token; edm::EDPutToken etlMatchTimeChi2Token; - edm::EDPutToken pathLengthToken; - edm::EDPutToken tmtdToken; - edm::EDPutToken sigmatmtdToken; + edm::EDPutToken npixBarrelToken; + edm::EDPutToken npixEndcapToken; edm::EDPutToken pOrigTrkToken; edm::EDPutToken betaOrigTrkToken; edm::EDPutToken t0OrigTrkToken; @@ -455,9 +454,8 @@ TrackExtenderWithMTDT::TrackExtenderWithMTDT(const ParameterSet etlMatchChi2Token = produces>("etlMatchChi2"); btlMatchTimeChi2Token = produces>("btlMatchTimeChi2"); etlMatchTimeChi2Token = produces>("etlMatchTimeChi2"); - pathLengthToken = produces>("pathLength"); - tmtdToken = produces>("tmtd"); - sigmatmtdToken = produces>("sigmatmtd"); + npixBarrelToken = produces>("npixBarrel"); + npixEndcapToken = produces>("npixEndcap"); pOrigTrkToken = produces>("generalTrackp"); betaOrigTrkToken = produces>("generalTrackBeta"); t0OrigTrkToken = produces>("generalTrackt0"); @@ -566,9 +564,8 @@ void TrackExtenderWithMTDT::produce(edm::Event& ev, const edm:: std::vector etlMatchChi2; std::vector btlMatchTimeChi2; std::vector etlMatchTimeChi2; - std::vector pathLengthsRaw; - std::vector tmtdRaw; - std::vector sigmatmtdRaw; + std::vector npixBarrel; + std::vector npixEndcap; std::vector pOrigTrkRaw; std::vector betaOrigTrkRaw; std::vector t0OrigTrkRaw; @@ -721,9 +718,6 @@ void TrackExtenderWithMTDT::produce(edm::Event& ev, const edm:: etlMatchChi2.push_back(mETL.hit ? mETL.estChi2 : -1); btlMatchTimeChi2.push_back(mBTL.hit ? mBTL.timeChi2 : -1); etlMatchTimeChi2.push_back(mETL.hit ? mETL.timeChi2 : -1); - pathLengthsRaw.push_back(pathLength); - tmtdRaw.push_back(tmtd); - sigmatmtdRaw.push_back(sigmatmtd); pathLengthMap = pathLength; tmtdMap = tmtd; sigmatmtdMap = sigmatmtd; @@ -738,6 +732,8 @@ void TrackExtenderWithMTDT::produce(edm::Event& ev, const edm:: for (unsigned ihit = hitsstart; ihit < hitsend; ++ihit) { backtrack.appendHitPattern((*outhits)[ihit], ttopo); } + npixBarrel.push_back(backtrack.hitPattern().numberOfValidPixelBarrelHits()); + npixEndcap.push_back(backtrack.hitPattern().numberOfValidPixelEndcapHits()); } else { LogTrace("TrackExtenderWithMTD") << "Error in the MTD track refitting. This should not happen"; } @@ -751,6 +747,16 @@ void TrackExtenderWithMTDT::produce(edm::Event& ev, const edm:: tmtdOrigTrkRaw.push_back(tmtdMap); sigmatmtdOrigTrkRaw.push_back(sigmatmtdMap); assocOrigTrkRaw.push_back(iMap); + + if (iMap == -1) { + btlMatchChi2.push_back(-1.); + etlMatchChi2.push_back(-1.); + btlMatchTimeChi2.push_back(-1.); + etlMatchTimeChi2.push_back(-1.); + npixBarrel.push_back(-1.); + npixEndcap.push_back(-1.); + } + ++itrack; } @@ -758,13 +764,12 @@ void TrackExtenderWithMTDT::produce(edm::Event& ev, const edm:: ev.put(std::move(extras)); ev.put(std::move(outhits)); - fillValueMap(ev, outTrksHandle, btlMatchChi2, btlMatchChi2Token); - fillValueMap(ev, outTrksHandle, etlMatchChi2, etlMatchChi2Token); - fillValueMap(ev, outTrksHandle, btlMatchTimeChi2, btlMatchTimeChi2Token); - fillValueMap(ev, outTrksHandle, etlMatchTimeChi2, etlMatchTimeChi2Token); - fillValueMap(ev, outTrksHandle, pathLengthsRaw, pathLengthToken); - fillValueMap(ev, outTrksHandle, tmtdRaw, tmtdToken); - fillValueMap(ev, outTrksHandle, sigmatmtdRaw, sigmatmtdToken); + fillValueMap(ev, tracksH, btlMatchChi2, btlMatchChi2Token); + fillValueMap(ev, tracksH, etlMatchChi2, etlMatchChi2Token); + fillValueMap(ev, tracksH, btlMatchTimeChi2, btlMatchTimeChi2Token); + fillValueMap(ev, tracksH, etlMatchTimeChi2, etlMatchTimeChi2Token); + fillValueMap(ev, tracksH, npixBarrel, npixBarrelToken); + fillValueMap(ev, tracksH, npixEndcap, npixEndcapToken); fillValueMap(ev, tracksH, pOrigTrkRaw, pOrigTrkToken); fillValueMap(ev, tracksH, betaOrigTrkRaw, betaOrigTrkToken); fillValueMap(ev, tracksH, t0OrigTrkRaw, t0OrigTrkToken); diff --git a/Validation/MtdValidation/plugins/MtdTracksValidation.cc b/Validation/MtdValidation/plugins/MtdTracksValidation.cc index 2ae95a5fc1a59..9aa690b7fbb4a 100644 --- a/Validation/MtdValidation/plugins/MtdTracksValidation.cc +++ b/Validation/MtdValidation/plugins/MtdTracksValidation.cc @@ -169,7 +169,7 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu index++; if (trackAssoc[trackref] == -1) { - LogWarning("mtdTracks") << "Extended track not associated"; + LogInfo("mtdTracks") << "Extended track not associated"; continue; } @@ -179,8 +179,8 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu if (track.pt() < trackMinPt_) continue; - meTracktmtd_->Fill(tMtd[mtdTrackref]); - if (std::round(SigmatMtd[mtdTrackref] - Sigmat0Pid[trackref]) != 0) { + meTracktmtd_->Fill(tMtd[trackref]); + if (std::round(SigmatMtd[trackref] - Sigmat0Pid[trackref]) != 0) { LogWarning("mtdTracks") << "TimeError associated to refitted track is different from TimeError stored in tofPID " "sigmat0 ValueMap: this should not happen"; } @@ -194,7 +194,7 @@ void MtdTracksValidation::analyze(const edm::Event& iEvent, const edm::EventSetu meTrackSigmat0SafePid_->Fill(Sigmat0Safe[trackref]); meTrackMVAQual_->Fill(mtdQualMVA[trackref]); - meTrackPathLenghtvsEta_->Fill(std::abs(track.eta()), pathLength[mtdTrackref]); + meTrackPathLenghtvsEta_->Fill(std::abs(track.eta()), pathLength[trackref]); if (std::abs(track.eta()) < trackMinEta_) { // --- all BTL tracks (with and without hit in MTD) --- @@ -397,13 +397,13 @@ void MtdTracksValidation::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("inputTagG", edm::InputTag("generalTracks")); desc.add("inputTagT", edm::InputTag("trackExtenderWithMTD")); desc.add("inputTagV", edm::InputTag("offlinePrimaryVertices4D")); - desc.add("tmtd", edm::InputTag("trackExtenderWithMTD:tmtd")); - desc.add("sigmatmtd", edm::InputTag("trackExtenderWithMTD:sigmatmtd")); + desc.add("tmtd", edm::InputTag("trackExtenderWithMTD:generalTracktmtd")); + desc.add("sigmatmtd", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd")); desc.add("t0Src", edm::InputTag("trackExtenderWithMTD:generalTrackt0")); desc.add("sigmat0Src", edm::InputTag("trackExtenderWithMTD:generalTracksigmat0")); desc.add("trackAssocSrc", edm::InputTag("trackExtenderWithMTD:generalTrackassoc")) ->setComment("Association between General and MTD Extended tracks"); - desc.add("pathLengthSrc", edm::InputTag("trackExtenderWithMTD:pathLength")); + desc.add("pathLengthSrc", edm::InputTag("trackExtenderWithMTD:generalTrackPathLength")); desc.add("t0SafePID", edm::InputTag("tofPID:t0safe")); desc.add("sigmat0SafePID", edm::InputTag("tofPID:sigmat0safe")); desc.add("sigmat0PID", edm::InputTag("tofPID:sigmat0"));