Skip to content

Commit

Permalink
Add a boolean to disable MTD timing in TICL linking.
Browse files Browse the repository at this point in the history
  • Loading branch information
rovere committed Sep 11, 2023
1 parent 7bdc34f commit cc368eb
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 39 deletions.
7 changes: 4 additions & 3 deletions RecoHGCal/TICL/plugins/LinkingAlgoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ namespace ticl {
const edm::ESHandle<Propagator> propH) = 0;

virtual void linkTracksters(const edm::Handle<std::vector<reco::Track>> tkH,
const edm::ValueMap<float>& tkTime,
const edm::ValueMap<float>& tkTimeErr,
const edm::ValueMap<float>& tkTimeQual,
const edm::Handle<edm::ValueMap<float>> tkTime_h,
const edm::Handle<edm::ValueMap<float>> tkTimeErr_h,
const edm::Handle<edm::ValueMap<float>> tkTimeQual_h,
const std::vector<reco::Muon>& muons,
const edm::Handle<std::vector<Trackster>> tsH,
const bool useMTDTiming,
std::vector<TICLCandidate>& resultTracksters,
std::vector<TICLCandidate>& resultFromTracks) = 0;

Expand Down
112 changes: 85 additions & 27 deletions RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ bool LinkingAlgoByDirectionGeometric::timeAndEnergyCompatible(float &total_raw_e
const Trackster &trackster,
const float &tkT,
const float &tkTErr,
const float &tkTimeQual) {
const float &tkTimeQual,
bool useMTDTiming) {
float threshold = std::min(0.2 * trackster.raw_energy(), 10.0);

bool energyCompatible = (total_raw_energy + trackster.raw_energy() < track.p() + threshold);

if (!useMTDTiming)
return energyCompatible;

// compatible if trackster time is within 3sigma of
// track time; compatible if either: no time assigned
// to trackster or track time quality is below threshold
Expand Down Expand Up @@ -225,11 +230,12 @@ void LinkingAlgoByDirectionGeometric::buildLayers() {
}

void LinkingAlgoByDirectionGeometric::linkTracksters(const edm::Handle<std::vector<reco::Track>> tkH,
const edm::ValueMap<float> &tkTime,
const edm::ValueMap<float> &tkTimeErr,
const edm::ValueMap<float> &tkTimeQual,
const edm::Handle<edm::ValueMap<float>> tkTime_h,
const edm::Handle<edm::ValueMap<float>> tkTimeErr_h,
const edm::Handle<edm::ValueMap<float>> tkTimeQual_h,
const std::vector<reco::Muon> &muons,
const edm::Handle<std::vector<Trackster>> tsH,
const bool useMTDTiming,
std::vector<TICLCandidate> &resultLinked,
std::vector<TICLCandidate> &chargedHadronsFromTk) {
const auto &tracks = *tkH;
Expand Down Expand Up @@ -273,10 +279,17 @@ void LinkingAlgoByDirectionGeometric::linkTracksters(const edm::Handle<std::vect
// veto tracks associated to muons
int muId = PFMuonAlgo::muAssocToTrack(trackref, muons);

if (LinkingAlgoBase::algo_verbosity_ > VerbosityLevel::Advanced)
LogDebug("LinkingAlgoByDirectionGeometric")
<< "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " time " << tkTime[reco::TrackRef(tkH, i)]
<< " time qual " << tkTimeQual[reco::TrackRef(tkH, i)] << " muid " << muId << "\n";
if (LinkingAlgoBase::algo_verbosity_ > VerbosityLevel::Advanced) {
if (useMTDTiming) {
LogDebug("LinkingAlgoByDirectionGeometric")
<< "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " time "
<< (*tkTime_h)[reco::TrackRef(tkH, i)] << " time qual " << (*tkTimeQual_h)[reco::TrackRef(tkH, i)]
<< " muid " << muId << "\n";
} else {
LogDebug("LinkingAlgoByDirectionGeometric")
<< "track " << i << " - eta " << tk.eta() << " phi " << tk.phi() << " muid " << muId << "\n";
}
}

if (!cutTk_((tk)) or muId != -1)
continue;
Expand Down Expand Up @@ -391,54 +404,99 @@ void LinkingAlgoByDirectionGeometric::linkTracksters(const edm::Handle<std::vect
float total_raw_energy = 0.;

auto tkRef = reco::TrackRef(tkH, i);
auto track_time = tkTime[tkRef];
auto track_timeErr = tkTimeErr[tkRef];
auto track_timeQual = tkTimeQual[tkRef];
float track_time = 0.f;
float track_timeErr = 0.f;
float track_timeQual = 0.f;
if (useMTDTiming) {
track_time = (*tkTime_h)[tkRef];
track_timeErr = (*tkTimeErr_h)[tkRef];
track_timeQual = (*tkTimeQual_h)[tkRef];
}

for (const unsigned ts3_idx : tsNearTk[i]) { // tk -> ts
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts3_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts3_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts3_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
for (const unsigned ts2_idx : tsNearAtInt[ts3_idx]) { // ts_EM -> ts_HAD
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts2_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts2_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) { // ts_HAD -> ts_HAD
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts1_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
}
}
for (const unsigned ts1_idx : tsHadNearAtInt[ts3_idx]) { // ts_HAD -> ts_HAD
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts1_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
}
}
for (const unsigned ts4_idx : tsNearTkAtInt[i]) { // do the same for tk -> ts links at the interface
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts4_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts4_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts4_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
for (const unsigned ts2_idx : tsNearAtInt[ts4_idx]) {
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts2_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts2_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts2_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
for (const unsigned ts1_idx : tsHadNearAtInt[ts2_idx]) {
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts1_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
}
}
for (const unsigned ts1_idx : tsHadNearAtInt[ts4_idx]) {
if (timeAndEnergyCompatible(
total_raw_energy, tracks[i], tracksters[ts1_idx], track_time, track_timeErr, track_timeQual)) {
if (timeAndEnergyCompatible(total_raw_energy,
tracks[i],
tracksters[ts1_idx],
track_time,
track_timeErr,
track_timeQual,
useMTDTiming)) {
recordTrackster(ts1_idx, tracksters, tsH, chargedMask, total_raw_energy, chargedCandidate);
}
}
Expand Down
10 changes: 6 additions & 4 deletions RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ namespace ticl {
const edm::ESHandle<Propagator> propH) override;

void linkTracksters(const edm::Handle<std::vector<reco::Track>>,
const edm::ValueMap<float> &,
const edm::ValueMap<float> &,
const edm::ValueMap<float> &,
const edm::Handle<edm::ValueMap<float>>,
const edm::Handle<edm::ValueMap<float>>,
const edm::Handle<edm::ValueMap<float>>,
const std::vector<reco::Muon> &,
const edm::Handle<std::vector<Trackster>>,
const bool useMTDTiming,
std::vector<TICLCandidate> &,
std::vector<TICLCandidate> &) override;

Expand Down Expand Up @@ -66,7 +67,8 @@ namespace ticl {
const Trackster &trackster,
const float &tkTime,
const float &tkTimeErr,
const float &tkTimeQual);
const float &tkTimeQual,
bool useMTDTiming);

void recordTrackster(const unsigned ts, // trackster index
const std::vector<Trackster> &tracksters,
Expand Down
25 changes: 20 additions & 5 deletions RecoHGCal/TICL/plugins/TrackstersMergeProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class TrackstersMergeProducer : public edm::stream::EDProducer<> {
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> bfield_token_;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> propagator_token_;
const bool optimiseAcrossTracksters_;
const bool useMTDTiming_;
const int eta_bin_window_;
const int phi_bin_window_;
const double pt_sigma_high_;
Expand Down Expand Up @@ -156,6 +157,7 @@ TrackstersMergeProducer::TrackstersMergeProducer(const edm::ParameterSet &ps)
propagator_token_(
esConsumes<Propagator, TrackingComponentsRecord, edm::Transition::BeginRun>(edm::ESInputTag("", propName_))),
optimiseAcrossTracksters_(ps.getParameter<bool>("optimiseAcrossTracksters")),
useMTDTiming_(ps.getParameter<bool>("useMTDTiming")),
eta_bin_window_(ps.getParameter<int>("eta_bin_window")),
phi_bin_window_(ps.getParameter<int>("phi_bin_window")),
pt_sigma_high_(ps.getParameter<double>("pt_sigma_high")),
Expand Down Expand Up @@ -261,13 +263,25 @@ void TrackstersMergeProducer::produce(edm::Event &evt, const edm::EventSetup &es
const auto &layerClusters = evt.get(clusters_token_);
const auto &layerClustersTimes = evt.get(clustersTime_token_);
const auto &muons = evt.get(muons_token_);
const auto &trackTime = evt.get(tracks_time_token_);
const auto &trackTimeErr = evt.get(tracks_time_err_token_);
const auto &trackTimeQual = evt.get(tracks_time_quality_token_);
edm::Handle<edm::ValueMap<float>> trackTime_h;
edm::Handle<edm::ValueMap<float>> trackTimeErr_h;
edm::Handle<edm::ValueMap<float>> trackTimeQual_h;
if (useMTDTiming_) {
evt.getByToken(tracks_time_token_, trackTime_h);
evt.getByToken(tracks_time_err_token_, trackTimeErr_h);
evt.getByToken(tracks_time_quality_token_, trackTimeQual_h);
}

// Linking
linkingAlgo_->linkTracksters(
track_h, trackTime, trackTimeErr, trackTimeQual, muons, trackstersclue3d_h, *resultCandidates, *resultFromTracks);
linkingAlgo_->linkTracksters(track_h,
trackTime_h,
trackTimeErr_h,
trackTimeQual_h,
muons,
trackstersclue3d_h,
useMTDTiming_,
*resultCandidates,
*resultFromTracks);

// Print debug info
LogDebug("TrackstersMergeProducer") << "Results from the linking step : " << std::endl
Expand Down Expand Up @@ -596,6 +610,7 @@ void TrackstersMergeProducer::fillDescriptions(edm::ConfigurationDescriptions &d
desc.add<std::string>("detector", "HGCAL");
desc.add<std::string>("propagator", "PropagatorWithMaterial");
desc.add<bool>("optimiseAcrossTracksters", true);
desc.add<bool>("useMTDTiming", true);
desc.add<int>("eta_bin_window", 1);
desc.add<int>("phi_bin_window", 1);
desc.add<double>("pt_sigma_high", 2.);
Expand Down

0 comments on commit cc368eb

Please sign in to comment.