Skip to content
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

Update of mkFit for 12_1_0_pre3 #35199

Merged
merged 2 commits into from
Sep 10, 2021
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
1 change: 1 addition & 0 deletions RecoTracker/MkFit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $ runTheMatrix.py -l <workflow(s)> --apply 2 --command "--procModifiers tracking
* *m_require_quality_filter:* is additional post-processing required for result tracks
* *m_require_dupclean_tight:* is tight duplicate removal post-processing required for result tracks
* *m_params:* IterationParams structure for this iteration
* *m_backward_params:* IterationParams structure for backward search for this iteration
* *m_layer_configs:* std::vector of per-layer parameters

### Iteration parameters [class IterationParams]
Expand Down
2 changes: 2 additions & 0 deletions RecoTracker/MkFit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<library file="*.cc" name="RecoTrackerMkFitPlugins">
<use name="CalibFormats/SiStripObjects"/>
<use name="CalibTracker/Records"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/SiPixelObjects"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/SiStripCluster"/>
<use name="DataFormats/SiStripCommon"/>
Expand Down
127 changes: 78 additions & 49 deletions RecoTracker/MkFit/plugins/MkFitEventOfHitsProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"

#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
#include "CalibTracker/Records/interface/SiStripQualityRcd.h"

Expand Down Expand Up @@ -44,9 +47,11 @@ class MkFitEventOfHitsProducer : public edm::global::EDProducer<> {
const edm::EDGetTokenT<MkFitClusterIndexToHit> pixelClusterIndexToHitToken_;
const edm::EDGetTokenT<MkFitClusterIndexToHit> stripClusterIndexToHitToken_;
const edm::ESGetToken<MkFitGeometry, TrackerRecoGeometryRecord> mkFitGeomToken_;
edm::ESGetToken<SiStripQuality, SiStripQualityRcd> qualityToken_;
edm::ESGetToken<SiPixelQuality, SiPixelQualityRcd> pixelQualityToken_;
edm::ESGetToken<SiStripQuality, SiStripQualityRcd> stripQualityToken_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::EDPutTokenT<MkFitEventOfHits> putToken_;
const bool usePixelQualityDB_;
const bool useStripStripQualityDB_;
};

Expand All @@ -57,10 +62,15 @@ MkFitEventOfHitsProducer::MkFitEventOfHitsProducer(edm::ParameterSet const& iCon
stripClusterIndexToHitToken_{consumes(iConfig.getParameter<edm::InputTag>("stripHits"))},
mkFitGeomToken_{esConsumes()},
putToken_{produces<MkFitEventOfHits>()},
usePixelQualityDB_{iConfig.getParameter<bool>("usePixelQualityDB")},
useStripStripQualityDB_{iConfig.getParameter<bool>("useStripStripQualityDB")} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity (and not related specifically to this PR): why "StripStrip" instead of just "Strip" in the name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For good or bad, to be consistent with existing naming (in functionally similar class) in

if (pset.getParameter<bool>("UseStripStripQualityDB")) {
stripQualityFlags += MeasurementTracker::BadStrips;
if (pset.getUntrackedParameter<bool>("DebugStripStripQualityDB", false)) {
stripQualityDebugFlags += MeasurementTracker::BadStrips;
}
}

if (useStripStripQualityDB_) {
qualityToken_ = esConsumes();
if (useStripStripQualityDB_ || usePixelQualityDB_)
geomToken_ = esConsumes();
if (usePixelQualityDB_) {
pixelQualityToken_ = esConsumes();
}
if (useStripStripQualityDB_) {
stripQualityToken_ = esConsumes();
}
}

Expand All @@ -69,6 +79,7 @@ void MkFitEventOfHitsProducer::fillDescriptions(edm::ConfigurationDescriptions&

desc.add("pixelHits", edm::InputTag{"mkFitSiPixelHits"});
desc.add("stripHits", edm::InputTag{"mkFitSiStripHits"});
desc.add("usePixelQualityDB", true)->setComment("Use SiPixelQuality DB information");
desc.add("useStripStripQualityDB", true)->setComment("Use SiStrip quality DB information");

descriptions.addWithDefaultLabel(desc);
Expand All @@ -82,55 +93,73 @@ void MkFitEventOfHitsProducer::produce(edm::StreamID iID, edm::Event& iEvent, co
auto eventOfHits = std::make_unique<mkfit::EventOfHits>(mkFitGeom.trackerInfo());
mkfit::StdSeq::Cmssw_LoadHits_Begin(*eventOfHits, {&pixelHits.hits(), &stripHits.hits()});

if (useStripStripQualityDB_) {
if (usePixelQualityDB_ || useStripStripQualityDB_) {
std::vector<mkfit::DeadVec> deadvectors(mkFitGeom.layerNumberConverter().nLayers());
const auto& siStripQuality = iSetup.getData(qualityToken_);
const auto& trackerGeom = iSetup.getData(geomToken_);
const auto& badStrips = siStripQuality.getBadComponentList();
for (const auto& bs : badStrips) {
const DetId detid(bs.detid);
const auto& surf = trackerGeom.idToDet(detid)->surface();
bool isBarrel = (mkFitGeom.topology()->side(detid) == static_cast<unsigned>(TrackerDetSide::Barrel));
const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
const auto q1 = isBarrel ? surf.zSpan().first : surf.rSpan().first;
const auto q2 = isBarrel ? surf.zSpan().second : surf.rSpan().second;
if (bs.BadModule)
deadvectors[ilay].push_back({surf.phiSpan().first, surf.phiSpan().second, q1, q2});
else { //assume that BadApvs are filled in sync with BadFibers
auto const& topo = dynamic_cast<const StripTopology&>(trackerGeom.idToDet(detid)->topology());
int firstApv = -1;
int lastApv = -1;

auto addRangeAPV = [&topo, &surf, &q1, &q2](int first, int last, mkfit::DeadVec& dv) {
auto const firstPoint = surf.toGlobal(topo.localPosition(first * sistrip::STRIPS_PER_APV));
auto const lastPoint = surf.toGlobal(topo.localPosition((last + 1) * sistrip::STRIPS_PER_APV));
float phi1 = firstPoint.phi();
float phi2 = lastPoint.phi();
if (reco::deltaPhi(phi1, phi2) > 0)
std::swap(phi1, phi2);
LogTrace("SiStripBadComponents")
<< "insert bad range " << first << " to " << last << " " << phi1 << " " << phi2;
dv.push_back({phi1, phi2, q1, q2});
};

const int nApvs = topo.nstrips() / sistrip::STRIPS_PER_APV;
for (int apv = 0; apv < nApvs; ++apv) {
const bool isBad = bs.BadApvs & (1 << apv);
if (isBad) {
LogTrace("SiStripBadComponents") << "bad apv " << apv << " on " << bs.detid;
if (lastApv == -1) {
firstApv = apv;
lastApv = apv;
} else if (lastApv + 1 == apv)
lastApv++;

if (apv + 1 == nApvs)

if (usePixelQualityDB_) {
const auto& pixelQuality = iSetup.getData(pixelQualityToken_);
const auto& badPixels = pixelQuality.getBadComponentList();
for (const auto& bp : badPixels) {
const DetId detid(bp.DetID);
const auto& surf = trackerGeom.idToDet(detid)->surface();
bool isBarrel = (mkFitGeom.topology()->side(detid) == static_cast<unsigned>(TrackerDetSide::Barrel));
const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
const auto q1 = isBarrel ? surf.zSpan().first : surf.rSpan().first;
const auto q2 = isBarrel ? surf.zSpan().second : surf.rSpan().second;
if (bp.errorType == 0)
deadvectors[ilay].push_back({surf.phiSpan().first, surf.phiSpan().second, q1, q2});
}
}

if (useStripStripQualityDB_) {
const auto& siStripQuality = iSetup.getData(stripQualityToken_);
const auto& badStrips = siStripQuality.getBadComponentList();
for (const auto& bs : badStrips) {
const DetId detid(bs.detid);
const auto& surf = trackerGeom.idToDet(detid)->surface();
bool isBarrel = (mkFitGeom.topology()->side(detid) == static_cast<unsigned>(TrackerDetSide::Barrel));
const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
const auto q1 = isBarrel ? surf.zSpan().first : surf.rSpan().first;
const auto q2 = isBarrel ? surf.zSpan().second : surf.rSpan().second;
if (bs.BadModule)
deadvectors[ilay].push_back({surf.phiSpan().first, surf.phiSpan().second, q1, q2});
else { //assume that BadApvs are filled in sync with BadFibers
auto const& topo = dynamic_cast<const StripTopology&>(trackerGeom.idToDet(detid)->topology());
int firstApv = -1;
int lastApv = -1;

auto addRangeAPV = [&topo, &surf, &q1, &q2](int first, int last, mkfit::DeadVec& dv) {
auto const firstPoint = surf.toGlobal(topo.localPosition(first * sistrip::STRIPS_PER_APV));
auto const lastPoint = surf.toGlobal(topo.localPosition((last + 1) * sistrip::STRIPS_PER_APV));
float phi1 = firstPoint.phi();
float phi2 = lastPoint.phi();
if (reco::deltaPhi(phi1, phi2) > 0)
std::swap(phi1, phi2);
LogTrace("SiStripBadComponents")
<< "insert bad range " << first << " to " << last << " " << phi1 << " " << phi2;
dv.push_back({phi1, phi2, q1, q2});
};

const int nApvs = topo.nstrips() / sistrip::STRIPS_PER_APV;
for (int apv = 0; apv < nApvs; ++apv) {
const bool isBad = bs.BadApvs & (1 << apv);
if (isBad) {
LogTrace("SiStripBadComponents") << "bad apv " << apv << " on " << bs.detid;
if (lastApv == -1) {
firstApv = apv;
lastApv = apv;
} else if (lastApv + 1 == apv)
lastApv++;

if (apv + 1 == nApvs)
addRangeAPV(firstApv, lastApv, deadvectors[ilay]);
} else if (firstApv != -1) {
addRangeAPV(firstApv, lastApv, deadvectors[ilay]);
} else if (firstApv != -1) {
addRangeAPV(firstApv, lastApv, deadvectors[ilay]);
//and reset
firstApv = -1;
lastApv = -1;
//and reset
firstApv = -1;
lastApv = -1;
}
}
}
}
Expand Down
40 changes: 35 additions & 5 deletions RecoTracker/MkFit/plugins/createPhase1TrackerGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace {
sp.append_plan(47, false);
sp.fill_plan(48, 53); // TID, 6 disks (3 mono + 3 stereo)
sp.fill_plan(54, 71); // TEC, 18 disks (3 mono + 3 stereo)
sp.finalize_plan();
sp.set_iterator_limits(2, 0);
}
{
SteeringParams &sp = ic.m_steering_params[TrackerInfo::Reg_Transition_Neg];
Expand All @@ -47,7 +47,7 @@ namespace {
sp.fill_plan(48, 53); // TID, 6 disks (3 mono + 3 stereo)
sp.fill_plan(10, 17); // TOB, 8 layers (6 mono + 2 stereo)
sp.fill_plan(54, 71); // TEC, 18 disks (9 mono + 9 stereo)
sp.finalize_plan();
sp.set_iterator_limits(2, 0);
}
{
SteeringParams &sp = ic.m_steering_params[TrackerInfo::Reg_Barrel];
Expand All @@ -57,7 +57,7 @@ namespace {
sp.append_plan(3, false);
sp.fill_plan(4, 9); // TIB, 6 layers (4 mono + 2 stereo)
sp.fill_plan(10, 17); // TOB, 8 layers (6 mono + 2 stereo)
sp.finalize_plan();
sp.set_iterator_limits(2, 0);
}
{
SteeringParams &sp = ic.m_steering_params[TrackerInfo::Reg_Transition_Pos];
Expand All @@ -72,7 +72,7 @@ namespace {
sp.fill_plan(21, 26); // TID, 6 disks (3 mono + 3 stereo)
sp.fill_plan(10, 17); // TOB, 8 layers (6 mono + 2 stereo)
sp.fill_plan(27, 44); // TEC, 18 disks (9 mono + 9 stereo)
sp.finalize_plan();
sp.set_iterator_limits(2, 0);
}
{
SteeringParams &sp = ic.m_steering_params[TrackerInfo::Reg_Endcap_Pos];
Expand All @@ -84,10 +84,38 @@ namespace {
sp.append_plan(20, false);
sp.fill_plan(21, 26); // TID, 6 disks (3 mono + 3 stereo)
sp.fill_plan(27, 44); // TEC, 18 disks (9 mono + 9 stereo)
sp.finalize_plan();
sp.set_iterator_limits(2, 0);
}
}

void OverrideSteeringParams_Iter7(IterationConfig &ic) {
ic.m_backward_search = true;
ic.m_backward_params = ic.m_params;
ic.m_backward_params.maxHolesPerCand = 2;
ic.m_backward_params.maxConsecHoles = 2;
// Remove pixel layers from FwdSearch, add them to BkwSearch
auto &spv = ic.m_steering_params;
spv[TrackerInfo::Reg_Endcap_Neg].set_iterator_limits(8, 6, 19);
spv[TrackerInfo::Reg_Transition_Neg].set_iterator_limits(9, 7, 34);
spv[TrackerInfo::Reg_Barrel].set_iterator_limits(6, 4, 8);
spv[TrackerInfo::Reg_Transition_Pos].set_iterator_limits(9, 7, 34);
spv[TrackerInfo::Reg_Endcap_Pos].set_iterator_limits(8, 6, 19);
}

void OverrideSteeringParams_Iter8(IterationConfig &ic) {
ic.m_backward_search = true;
ic.m_backward_params = ic.m_params;
ic.m_backward_params.maxHolesPerCand = 2;
ic.m_backward_params.maxConsecHoles = 2;
// Remove pixel/tib/tid layers from FwdSearch, add them to BkwSearch/
auto &spv = ic.m_steering_params;
spv[TrackerInfo::Reg_Endcap_Neg].set_iterator_limits(12, 12, 24);
spv[TrackerInfo::Reg_Transition_Neg].set_iterator_limits(27, 19, 39);
spv[TrackerInfo::Reg_Barrel].set_iterator_limits(12, 10, 14);
spv[TrackerInfo::Reg_Transition_Pos].set_iterator_limits(27, 19, 39);
spv[TrackerInfo::Reg_Endcap_Pos].set_iterator_limits(12, 12, 24);
}

void partitionSeeds0(const TrackerInfo &trk_info,
const TrackVec &in_seeds,
const EventOfHits &eoh,
Expand Down Expand Up @@ -221,9 +249,11 @@ namespace mkfit {
ii[6].set_iteration_index_and_track_algorithm(6, (int)TrackBase::TrackAlgorithm::mixedTripletStep);

ii[7].Clone(ii[0]);
OverrideSteeringParams_Iter7(ii[7]);
ii[7].set_iteration_index_and_track_algorithm(7, (int)TrackBase::TrackAlgorithm::pixelLessStep);

ii[8].Clone(ii[0]);
OverrideSteeringParams_Iter8(ii[8]);
ii[8].set_iteration_index_and_track_algorithm(8, (int)TrackBase::TrackAlgorithm::tobTecStep);

ii[9].Clone(ii[0]);
Expand Down