-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MTD TDR Reconstruction + MTD Track Association BDT #28815
Changes from all commits
2d922a3
f79a5f9
70df858
de07f69
e479e16
a5c0d82
ef85193
71b0d07
491d468
25f208d
1e64154
0040676
ce23d1d
50a51d4
3f05707
61f775f
b04490c
ca8c653
6566048
4cce131
6c3b270
15a7fb5
f6caa8e
e2abc64
fd68170
6b41c7d
1a41a1d
d4a01be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from RecoMTD.TrackExtender.trackExtenderWithMTD_cfi import * | ||
from RecoMTD.TimingIDTools.mtdTrackQualityMVA_cfi import * | ||
|
||
fastTimingGlobalRecoTask = cms.Task(trackExtenderWithMTD) | ||
fastTimingGlobalRecoTask = cms.Task(trackExtenderWithMTD,mtdTrackQualityMVA) | ||
fastTimingGlobalReco = cms.Sequence(fastTimingGlobalRecoTask) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="DataFormats/TrackReco"/> | ||
<use name="DataFormats/BeamSpot"/> | ||
<use name="DataFormats/RecoCandidate"/> | ||
<use name="DataFormats/Candidate"/> | ||
<use name="DataFormats/VertexReco"/> | ||
<use name="CommonTools/MVAUtils"/> | ||
|
||
<export> | ||
<lib name="1"/> | ||
</export> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef RECOMTD_TIMINGIDTOOLS_MTDTRACKQUALITYMVA | ||
#define RECOMTD_TIMINGIDTOOLS_MTDTRACKQUALITYMVA | ||
|
||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
#include "DataFormats/Common/interface/ValueMap.h" | ||
|
||
#include "CommonTools/MVAUtils/interface/TMVAEvaluator.h" | ||
|
||
#define MTDTRACKQUALITYMVA_VARS(MTDBDTVAR) \ | ||
MTDBDTVAR(pt) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the arguments didn't need to have MTD in the prefix, but it's fine. |
||
MTDBDTVAR(eta) \ | ||
MTDBDTVAR(phi) \ | ||
MTDBDTVAR(chi2) \ | ||
MTDBDTVAR(ndof) \ | ||
MTDBDTVAR(numberOfValidHits) \ | ||
MTDBDTVAR(numberOfValidPixelBarrelHits) \ | ||
MTDBDTVAR(numberOfValidPixelEndcapHits) \ | ||
MTDBDTVAR(btlMatchChi2) \ | ||
MTDBDTVAR(btlMatchTimeChi2) \ | ||
MTDBDTVAR(etlMatchChi2) \ | ||
MTDBDTVAR(etlMatchTimeChi2) \ | ||
MTDBDTVAR(mtdt) \ | ||
MTDBDTVAR(path_len) | ||
|
||
#define MTDBDTVAR_ENUM(ENUM) ENUM, | ||
#define MTDBDTVAR_STRING(STRING) #STRING, | ||
|
||
class MTDTrackQualityMVA { | ||
public: | ||
//---ctors--- | ||
MTDTrackQualityMVA(std::string weights_file); | ||
|
||
enum class VarID { MTDTRACKQUALITYMVA_VARS(MTDBDTVAR_ENUM) }; | ||
|
||
//---getters--- | ||
// 4D | ||
float operator()(const reco::TrackRef& trk, | ||
const reco::TrackRef& ext_trk, | ||
const edm::ValueMap<float>& btl_chi2s, | ||
const edm::ValueMap<float>& btl_time_chi2s, | ||
const edm::ValueMap<float>& etl_chi2s, | ||
const edm::ValueMap<float>& etl_time_chi2s, | ||
const edm::ValueMap<float>& tmtds, | ||
const edm::ValueMap<float>& trk_lengths) const; | ||
|
||
private: | ||
std::vector<std::string> vars_, spec_vars_; | ||
std::unique_ptr<TMVAEvaluator> mva_; | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<library name="RecoMTDTimingIDTools_plugins" file="*.cc"> | ||
<use name="FWCore/Framework"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, all "use" statements can be outside of the "library" section. shouldn't there be a @makortel @smuzaffar is this flag not needed anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slava77 , in Yes the |
||
<use name="FWCore/ParameterSet"/> | ||
<use name="DataFormats/TrackReco"/> | ||
<use name="DataFormats/BeamSpot"/> | ||
<use name="DataFormats/RecoCandidate"/> | ||
<use name="DataFormats/Candidate"/> | ||
<use name="DataFormats/VertexReco"/> | ||
<use name="CommonTools/MVAUtils"/> | ||
<use name="RecoMTD/TimingIDTools"/> | ||
</library> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
|
||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
#include "DataFormats/Common/interface/ValueMap.h" | ||
#include "DataFormats/BeamSpot/interface/BeamSpot.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
|
||
#include "RecoMTD/TimingIDTools/interface/MTDTrackQualityMVA.h" | ||
|
||
using namespace std; | ||
using namespace edm; | ||
|
||
class MTDTrackQualityMVAProducer : public edm::stream::EDProducer<> { | ||
public: | ||
MTDTrackQualityMVAProducer(const ParameterSet& pset); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
template <class H, class T> | ||
void fillValueMap(edm::Event& iEvent, | ||
const edm::Handle<H>& handle, | ||
const std::vector<T>& vec, | ||
const std::string& name) const; | ||
|
||
void produce(edm::Event& ev, const edm::EventSetup& es) final; | ||
|
||
private: | ||
static constexpr char mvaName[] = "mtdQualMVA"; | ||
|
||
edm::EDGetTokenT<reco::TrackCollection> tracksToken_; | ||
edm::EDGetTokenT<reco::TrackCollection> tracksMTDToken_; | ||
|
||
edm::EDGetTokenT<edm::ValueMap<float>> btlMatchChi2Token_; | ||
edm::EDGetTokenT<edm::ValueMap<float>> btlMatchTimeChi2Token_; | ||
edm::EDGetTokenT<edm::ValueMap<float>> etlMatchChi2Token_; | ||
edm::EDGetTokenT<edm::ValueMap<float>> etlMatchTimeChi2Token_; | ||
edm::EDGetTokenT<edm::ValueMap<float>> mtdTimeToken_; | ||
edm::EDGetTokenT<edm::ValueMap<float>> pathLengthToken_; | ||
edm::EDGetTokenT<edm::ValueMap<int>> trackAssocToken_; | ||
|
||
MTDTrackQualityMVA mva_; | ||
}; | ||
|
||
MTDTrackQualityMVAProducer::MTDTrackQualityMVAProducer(const ParameterSet& iConfig) | ||
: tracksToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksSrc"))), | ||
tracksMTDToken_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksMTDSrc"))), | ||
btlMatchChi2Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("btlMatchChi2Src"))), | ||
btlMatchTimeChi2Token_( | ||
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("btlMatchTimeChi2Src"))), | ||
etlMatchChi2Token_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("etlMatchChi2Src"))), | ||
etlMatchTimeChi2Token_( | ||
consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("etlMatchTimeChi2Src"))), | ||
mtdTimeToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("mtdTimeSrc"))), | ||
pathLengthToken_(consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("pathLengthSrc"))), | ||
trackAssocToken_(consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("trackAssocSrc"))), | ||
mva_(iConfig.getParameter<edm::FileInPath>("qualityBDT_weights_file").fullPath()) { | ||
produces<edm::ValueMap<float>>(mvaName); | ||
} | ||
|
||
// Configuration descriptions | ||
void MTDTrackQualityMVAProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("tracksSrc", edm::InputTag("generalTracks"))->setComment("Input tracks collection"); | ||
desc.add<edm::InputTag>("tracksMTDSrc", edm::InputTag("trackExtenderWithMTD")) | ||
->setComment("Input tracks collection for MTD extended tracks"); | ||
desc.add<edm::InputTag>("btlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchChi2")) | ||
->setComment("BTL Chi2 Matching value Map"); | ||
desc.add<edm::InputTag>("btlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "btlMatchTimeChi2")) | ||
->setComment("BTL Chi2 Matching value Map"); | ||
desc.add<edm::InputTag>("etlMatchChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchChi2")) | ||
->setComment("ETL Chi2 Matching value Map"); | ||
desc.add<edm::InputTag>("etlMatchTimeChi2Src", edm::InputTag("trackExtenderWithMTD", "etlMatchTimeChi2")) | ||
->setComment("ETL Chi2 Matching value Map"); | ||
desc.add<edm::InputTag>("mtdTimeSrc", edm::InputTag("trackExtenderWithMTD", "tmtd")) | ||
->setComment("MTD TIme value Map"); | ||
desc.add<edm::InputTag>("pathLengthSrc", edm::InputTag("trackExtenderWithMTD", "pathLength")) | ||
->setComment("MTD PathLength value Map"); | ||
desc.add<edm::InputTag>("trackAssocSrc", edm::InputTag("trackExtenderWithMTD", "generalTrackassoc")) | ||
->setComment("Association between General and MTD Extended tracks"); | ||
desc.add<edm::FileInPath>("qualityBDT_weights_file", | ||
edm::FileInPath("RecoMTD/TimingIDTools/data/clf4D_MTDquality_bo.xml")) | ||
->setComment("Track MTD quality BDT weights"); | ||
descriptions.add("mtdTrackQualityMVAProducer", desc); | ||
} | ||
|
||
template <class H, class T> | ||
void MTDTrackQualityMVAProducer::fillValueMap(edm::Event& iEvent, | ||
const edm::Handle<H>& handle, | ||
const std::vector<T>& vec, | ||
const std::string& name) const { | ||
auto out = std::make_unique<edm::ValueMap<T>>(); | ||
typename edm::ValueMap<T>::Filler filler(*out); | ||
filler.insert(handle, vec.begin(), vec.end()); | ||
filler.fill(); | ||
iEvent.put(std::move(out), name); | ||
} | ||
|
||
void MTDTrackQualityMVAProducer::produce(edm::Event& ev, const edm::EventSetup& es) { | ||
edm::Handle<reco::TrackCollection> tracksH; | ||
ev.getByToken(tracksToken_, tracksH); | ||
const auto& tracks = *tracksH; | ||
|
||
edm::Handle<reco::TrackCollection> 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& mtdTime = ev.get(mtdTimeToken_); | ||
|
||
std::vector<float> mvaOutRaw; | ||
|
||
//Loop over tracks collection | ||
for (unsigned int itrack = 0; itrack < tracks.size(); ++itrack) { | ||
const reco::TrackRef trackref(tracksH, itrack); | ||
if (trackAssoc[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)); | ||
} | ||
} | ||
fillValueMap(ev, tracksH, mvaOutRaw, mvaName); | ||
} | ||
|
||
//define this as a plug-in | ||
#include <FWCore/Framework/interface/MakerMacros.h> | ||
DEFINE_FWK_MODULE(MTDTrackQualityMVAProducer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ class TOFPIDProducer : public edm::stream::EDProducer<> { | |
double maxDz_; | ||
double maxDtSignificance_; | ||
double minProbHeavy_; | ||
double fixedT0Error_; | ||
}; | ||
|
||
TOFPIDProducer::TOFPIDProducer(const ParameterSet& iConfig) | ||
|
@@ -67,7 +68,8 @@ TOFPIDProducer::TOFPIDProducer(const ParameterSet& iConfig) | |
vtxMaxSigmaT_(iConfig.getParameter<double>("vtxMaxSigmaT")), | ||
maxDz_(iConfig.getParameter<double>("maxDz")), | ||
maxDtSignificance_(iConfig.getParameter<double>("maxDtSignificance")), | ||
minProbHeavy_(iConfig.getParameter<double>("minProbHeavy")) { | ||
minProbHeavy_(iConfig.getParameter<double>("minProbHeavy")), | ||
fixedT0Error_(iConfig.getParameter<double>("fixedT0Error")) { | ||
produces<edm::ValueMap<float>>(t0Name); | ||
produces<edm::ValueMap<float>>(sigmat0Name); | ||
produces<edm::ValueMap<float>>(t0safeName); | ||
|
@@ -93,7 +95,7 @@ void TOFPIDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptio | |
->setComment("Input ValueMap for track path lengh from beamline to MTD"); | ||
desc.add<edm::InputTag>("pSrc", edm::InputTag("trackExtenderWithMTD:generalTrackp")) | ||
->setComment("Input ValueMap for track momentum magnitude (normally from refit with MTD hits)"); | ||
desc.add<edm::InputTag>("vtxsSrc", edm::InputTag("unsortedOfflinePrimaryVertices4DnoPID")) | ||
desc.add<edm::InputTag>("vtxsSrc", edm::InputTag("unsortedOfflinePrimaryVertices4DwithPID")) | ||
->setComment("Input primary vertex collection"); | ||
desc.add<double>("vtxMaxSigmaT", 0.025) | ||
->setComment("Maximum primary vertex time uncertainty for use in particle id [ns]"); | ||
|
@@ -104,6 +106,7 @@ void TOFPIDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptio | |
"Maximum distance in time (normalized by uncertainty) for track-primary vertex association for particle id"); | ||
desc.add<double>("minProbHeavy", 0.75) | ||
->setComment("Minimum probability for a particle to be a kaon or proton before reassigning the timestamp"); | ||
desc.add<double>("fixedT0Error", 0.)->setComment("Use a fixed T0 uncertainty [ns]"); | ||
|
||
descriptions.add("tofPIDProducer", desc); | ||
} | ||
|
@@ -174,7 +177,7 @@ void TOFPIDProducer::produce(edm::Event& ev, const edm::EventSetup& es) { | |
float t0 = t0In[trackref]; | ||
float t0safe = t0; | ||
float sigmat0safe = sigmat0In[trackref]; | ||
float sigmatmtd = sigmatmtdIn[trackref]; | ||
float sigmatmtd = (sigmatmtdIn[trackref] > 0. && fixedT0Error_ > 0.) ? fixedT0Error_ : sigmatmtdIn[trackref]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking: is it correct here to require that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we want to keep the sigmatmd = 0 when to time is associated |
||
float sigmat0 = sigmatmtd; | ||
|
||
float prob_pi = -1.; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from RecoMTD.TimingIDTools.mtdTrackQualityMVAProducer_cfi import * | ||
|
||
mtdTrackQualityMVA = mtdTrackQualityMVAProducer.clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic in the ::produce suggests that both should be not empty ==> use
&&
.Also, apparently, the conditions should include
&& storeTiming_