Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 115 additions & 6 deletions RecoTracker/MkFit/plugins/MkFitIterationConfigESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
namespace {
using namespace mkfit;

void partitionSeeds0(const TrackerInfo &trk_info,
const TrackVec &in_seeds,
const EventOfHits &eoh,
IterationSeedPartition &part) {
[[maybe_unused]] void partitionSeeds0(const TrackerInfo &trk_info,
const TrackVec &in_seeds,
const EventOfHits &eoh,
IterationSeedPartition &part) {
const size_t size = in_seeds.size();

for (size_t i = 0; i < size; ++i) {
const Track &S = in_seeds[i];

const bool z_dir_pos = S.pz() > 0;

HitOnTrack hot = S.getLastHitOnTrack();
const auto &hot = S.getLastHitOnTrack();
const float eta = eoh[hot.layer].GetHit(hot.index).eta();

// Region to be defined by propagation / intersection tests
Expand Down Expand Up @@ -82,6 +82,115 @@ namespace {
part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta;
}
}

[[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
const TrackVec &in_seeds,
const EventOfHits &eoh,
IterationSeedPartition &part) {
const LayerInfo &tib1 = trk_info.m_layers[4];
const LayerInfo &tob1 = trk_info.m_layers[10];

const LayerInfo &tidp1 = trk_info.m_layers[21];
const LayerInfo &tidn1 = trk_info.m_layers[48];

const LayerInfo &tecp1 = trk_info.m_layers[27];
const LayerInfo &tecn1 = trk_info.m_layers[54];

// Merge first two layers to account for mono/stereo coverage.
// TrackerInfo could hold joint limits for sub-detectors.
const auto &L = trk_info.m_layers;
const float tidp_rin = std::min(L[21].m_rin, L[22].m_rin);
const float tidp_rout = std::max(L[21].m_rout, L[22].m_rout);
const float tecp_rin = std::min(L[27].m_rin, L[28].m_rin);
const float tecp_rout = std::max(L[27].m_rout, L[28].m_rout);
const float tidn_rin = std::min(L[48].m_rin, L[49].m_rin);
const float tidn_rout = std::max(L[48].m_rout, L[49].m_rout);
const float tecn_rin = std::min(L[54].m_rin, L[55].m_rin);
const float tecn_rout = std::max(L[54].m_rout, L[55].m_rout);

// Bias towards more aggressive transition-region assignemnts.
// With current tunning it seems to make things a bit worse.
const float tid_z_extra = 0.0f; // 5.0f;
const float tec_z_extra = 0.0f; // 10.0f;

const size_t size = in_seeds.size();

auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
bool inside = maxR > rin && S.zAtR(rin) < zmax;
return inside;
};

auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
bool inside = maxR > rin && S.zAtR(rin) > zmin;
return inside;
};

auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
return inside;
};

auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
return inside;
};

for (size_t i = 0; i < size; ++i) {
const Track &S = in_seeds[i];

const auto &hot = S.getLastHitOnTrack();
const float eta = eoh[hot.layer].GetHit(hot.index).eta();

// Region to be defined by propagation / intersection tests
TrackerInfo::EtaRegion reg;

// Max eta used for region sorting
constexpr float maxEta_regSort = 7.0;

const bool z_dir_pos = S.pz() > 0;
const float maxR = S.maxReachRadius();

if (z_dir_pos) {
const bool in_tib = barrel_pos_check(S, maxR, tib1.m_rin, tib1.m_zmax);
const bool in_tob = barrel_pos_check(S, maxR, tob1.m_rin, tob1.m_zmax);

if (!in_tib && !in_tob) {
reg = TrackerInfo::Reg_Endcap_Pos;
} else {
const bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.m_zmin - tid_z_extra);
const bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.m_zmin - tec_z_extra);

if (!in_tid && !in_tec) {
reg = TrackerInfo::Reg_Barrel;
} else {
reg = TrackerInfo::Reg_Transition_Pos;
}
}
} else {
const bool in_tib = barrel_neg_check(S, maxR, tib1.m_rin, tib1.m_zmin);
const bool in_tob = barrel_neg_check(S, maxR, tob1.m_rin, tob1.m_zmin);

if (!in_tib && !in_tob) {
reg = TrackerInfo::Reg_Endcap_Neg;
} else {
const bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.m_zmax + tid_z_extra);
const bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.m_zmax + tec_z_extra);

if (!in_tid && !in_tec) {
reg = TrackerInfo::Reg_Barrel;
} else {
reg = TrackerInfo::Reg_Transition_Neg;
}
}
}

part.m_region[i] = reg;

// TrackerInfo::EtaRegion is enum from 0 to 5 (Reg_Endcap_Neg,Reg_Transition_Neg,Reg_Barrel,Reg_Transition_Pos,Reg_Endcap_Pos)
// Symmetrization around TrackerInfo::Reg_Barrel for sorting is required
part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta;
}
}
} // namespace

class MkFitIterationConfigESProducer : public edm::ESProducer {
Expand Down Expand Up @@ -111,7 +220,7 @@ void MkFitIterationConfigESProducer::fillDescriptions(edm::ConfigurationDescript
std::unique_ptr<mkfit::IterationConfig> MkFitIterationConfigESProducer::produce(
const TrackerRecoGeometryRecord &iRecord) {
auto it_conf = mkfit::ConfigJson_Load_File(configFile_);
it_conf->m_partition_seeds = partitionSeeds0;
it_conf->m_partition_seeds = partitionSeeds1;
return it_conf;
}

Expand Down
30 changes: 23 additions & 7 deletions RecoTracker/MkFit/plugins/MkFitSeedConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
#include "DataFormats/TrackerRecHit2D/interface/trackerHitRTTI.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "DataFormats/TrackerCommon/interface/TrackerDetSide.h"
Expand Down Expand Up @@ -129,13 +130,28 @@ mkfit::TrackVec MkFitSeedConverter::convertSeeds(const edm::View<TrajectorySeed>
if (not trackerHitRTTI::isFromDet(recHit)) {
throw cms::Exception("Assert") << "Encountered a seed with a hit which is not trackerHitRTTI::isFromDet()";
}
const auto& clusterRef = static_cast<const BaseTrackerRecHit&>(recHit).firstClusterRef();
const auto detId = recHit.geographicalId();
const auto ilay = mkFitGeom.layerNumberConverter().convertLayerNumber(
detId.subdetId(), ttopo.layer(detId), false, ttopo.isStereo(detId), isPlusSide(detId));
LogTrace("MkFitSeedConverter") << " addin hit detid " << detId.rawId() << " index " << clusterRef.index()
<< " ilay " << ilay;
ret.back().addHitIdx(clusterRef.index(), ilay, 0); // per-hit chi2 is not known
auto& baseTrkRecHit = static_cast<const BaseTrackerRecHit&>(recHit);
if (!baseTrkRecHit.isMatched()) {
const auto& clusterRef = baseTrkRecHit.firstClusterRef();
const auto detId = recHit.geographicalId();
const auto ilay = mkFitGeom.layerNumberConverter().convertLayerNumber(
detId.subdetId(), ttopo.layer(detId), false, ttopo.isStereo(detId), isPlusSide(detId));
LogTrace("MkFitSeedConverter") << " adding hit detid " << detId.rawId() << " index " << clusterRef.index()
<< " ilay " << ilay;
ret.back().addHitIdx(clusterRef.index(), ilay, 0); // per-hit chi2 is not known
} else {
auto& matched2D = dynamic_cast<const SiStripMatchedRecHit2D&>(recHit);
const OmniClusterRef* const clRefs[2] = {&matched2D.monoClusterRef(), &matched2D.stereoClusterRef()};
const DetId detIds[2] = {matched2D.monoId(), matched2D.stereoId()};
for (int ii = 0; ii < 2; ++ii) {
const auto& detId = detIds[ii];
const auto ilay = mkFitGeom.layerNumberConverter().convertLayerNumber(
detId.subdetId(), ttopo.layer(detId), false, ttopo.isStereo(detId), isPlusSide(detId));
LogTrace("MkFitSeedConverter") << " adding matched hit detid " << detId.rawId() << " index "
<< clRefs[ii]->index() << " ilay " << ilay;
ret.back().addHitIdx(clRefs[ii]->index(), ilay, 0); // per-hit chi2 is not known
}
}
}
++seed_index;
}
Expand Down