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

[MkFit] Phase2 geometry & String configurable standard functions #39866

Merged
merged 24 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a273b50
Support extraction and binary dump of phase2 tracker geometry.
osschar Jun 21, 2022
393a9cc
Add stubs for iteration specific seed cleaning, filtering and duplica…
osschar Jun 28, 2022
5a7c6e8
Generate dict and link it with WriteMemoryFile binary.
osschar Jul 12, 2022
51a92f0
update file version (Hit layout changed since v6)
slava77devel Jul 12, 2022
3fa8752
write phase2 bin files; detect from the input branches
slava77devel Jul 12, 2022
31cf842
Put write-bin-file dict pcm into top-level directory; remove Ice/ ref…
osschar Jul 12, 2022
6ffe10f
First mkFit runs with Phase2 data / geometry!
osschar Jul 14, 2022
26d66ba
Prototype for standard functions catalog, implemented for partition-s…
osschar Oct 14, 2022
7bf5fdc
Make seed-cleaners and duplicate-filters use std::functions, update c…
osschar Oct 19, 2022
21cdd1f
* Rename typedefs for duplicate-cleaning functions from filter_duplic…
osschar Oct 19, 2022
f6b3600
Standard function interface for quality candidate filters.
osschar Oct 21, 2022
406d7ee
Final cleanups for std functions, docs.
osschar Oct 21, 2022
3b3802d
code-checks and code-format
osschar Oct 26, 2022
58f08ea
Add missing include for header checks.
osschar Oct 27, 2022
75f8778
Rename files, functions, and tags including 2017/2029 to phase1/phase2.
osschar Oct 31, 2022
f714fee
code-format, too long lines after string replace
osschar Oct 31, 2022
821d184
Use CMS_SA_ALLOW to silence static analyser warnings for static objec…
osschar Nov 3, 2022
c964a73
Fix static analyser warnings -- use const ptrs.
osschar Nov 3, 2022
529b93b
Apply suggestions by @mmusich to dumpMkFitGeometryPhase2.py, symmetri…
osschar Nov 3, 2022
567404c
Roll back correct mkFit modifiers, extend unit test to also try dumpi…
osschar Nov 3, 2022
60d3d90
use named constants in phase-2 seed partitioner layers
slava77 Nov 12, 2022
21beaac
code-checks
slava77 Nov 12, 2022
7bbc436
add clarification comments
slava77 Nov 17, 2022
8ab5c78
code-checks
slava77 Nov 17, 2022
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
54 changes: 33 additions & 21 deletions RecoTracker/MkFit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,41 @@ $ runTheMatrix.py -l <workflow(s)> --apply 2 --command "--procModifiers tracking

* *m_track_algorithm:* CMSSW track algorithm (used internally for reporting and consistency checks)
* *m_requires_seed_hit_sorting:* do hits on seed tracks need to be sorted (required for seeds that include strip layers)
* *m_requires_quality_filter:* is additional post-processing required for result tracks
* *m_requires_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

#### Seed cleaning params (based on elliptical dR-dz cut) [in class IterationConfig]

* *m_seed_cleaner_name:* name of standard function to call for seed cleaning; if not set or empty seed cleaning is not performed
* *sc_ptthr_hpt:* pT threshold used to tighten seed cleaning requirements
* *sc_drmax_bh:* dR cut used for seed tracks with std::fabs(eta)<0.9 and pT > c_ptthr_hpt
* *sc_dzmax_bh:* dz cut used for seed tracks with std::fabs(eta)<0.9 and pT > c_ptthr_hpt
* *sc_drmax_eh:* dR cut used for seed tracks with std::fabs(eta)>0.9 and pT > c_ptthr_hpt
* *sc_dzmax_eh:* dz cut used for seed tracks with std::fabs(eta)>0.9 and pT > c_ptthr_hpt
* *sc_drmax_bl:* dR cut used for seed tracks with std::fabs(eta)<0.9 and pT < c_ptthr_hpt
* *sc_dzmax_bl:* dz cut used for seed tracks with std::fabs(eta)<0.9 and pT < c_ptthr_hpt
* *sc_drmax_el:* dR cut used for seed tracks with std::fabs(eta)>0.9 and pT < c_ptthr_hpt
* *sc_dzmax_el:* dz cut used for seed tracks with std::fabs(eta)>0.9 and pT < c_ptthr_hpt

#### Seed partitioning params [in class IterationConfig]

* *m_seed_partitioner_name:* name of standard function to call for seed partitioning

#### Pre / post backward-fit candidate top-level params [in class IterationConfig]

* *m_pre_bkfit_filter_name:* name of standard function used for candidate filtering after forward
search but before backward fit; if not set or empty no candidate filtering is performed at this stage
* *m_post_bkfit_filter_name:* name of standard function used for candidate filtering after backward fit; if not set or empty no candidate filtering is performed at this stage

#### Duplicate cleaning parameters [in class IterationConfig]

* *m_duplicate_cleaner_name:* name of standard function used for duplicate cleaning; if not set or empty duplicate cleaning is not performed
* *dc_fracSharedHits:* min fraction of shared hits to determine duplicate track candidate
* *dc_drth_central:* dR cut used to identify duplicate candidates if std::abs(cotan(theta))<1.99 (abs(eta)<1.44)
* *dc_drth_obarrel:* dR cut used to identify duplicate candidates if 1.99<std::abs(cotan(theta))<6.05 (1.44<abs(eta)<2.5)
* *dc_drth_forward:* dR cut used to identify duplicate candidates if std::abs(cotan(theta))>6.05 (abs(eta)>2.5)

### Iteration parameters [class IterationParams]

* *nlayers_per_seed:* internal mkFit parameter used for standalone validation
Expand All @@ -63,25 +92,8 @@ $ runTheMatrix.py -l <workflow(s)> --apply 2 --command "--procModifiers tracking
* *chi2CutOverlap:* chi2 cut for accepting an overlap hit (currently NOT used)
* *pTCutOverlap:* pT cut below which the overlap hits are not picked up

#### Seed cleaning params (based on elliptical dR-dz cut)

* *c_ptthr_hpt:* pT threshold used to tighten seed cleaning requirements
* *c_drmax_bh:* dR cut used for seed tracks with std::fabs(eta)<0.9 and pT > c_ptthr_hpt
* *c_dzmax_bh:* dz cut used for seed tracks with std::fabs(eta)<0.9 and pT > c_ptthr_hpt
* *c_drmax_eh:* dR cut used for seed tracks with std::fabs(eta)>0.9 and pT > c_ptthr_hpt
* *c_dzmax_eh:* dz cut used for seed tracks with std::fabs(eta)>0.9 and pT > c_ptthr_hpt
* *c_drmax_bl:* dR cut used for seed tracks with std::fabs(eta)<0.9 and pT < c_ptthr_hpt
* *c_dzmax_bl:* dz cut used for seed tracks with std::fabs(eta)<0.9 and pT < c_ptthr_hpt
* *c_drmax_el:* dR cut used for seed tracks with std::fabs(eta)>0.9 and pT < c_ptthr_hpt
* *c_dzmax_el:* dz cut used for seed tracks with std::fabs(eta)>0.9 and pT < c_ptthr_hpt

#### Duplicate cleaning parameters

* *minHitsQF:* min number of hits on track candidate to apply duplicate cleaning based on fraction of shared hits
* *fracSharedHits:* min fraction of shared hits to determine duplicate track candidate
* *drth_central:* dR cut used to identify duplicate candidates if std::abs(cotan(theta))<1.99 (abs(eta)<1.44)
* *drth_obarrel:* dR cut used to identify duplicate candidates if 1.99<std::abs(cotan(theta))<6.05 (1.44<abs(eta)<2.5)
* *drth_forward:* dR cut used to identify duplicate candidates if std::abs(cotan(theta))>6.05 (abs(eta)>2.5)
#### Pre / post backward-fit candidate filtering params
* *minHitsQF:* minimum number of hits, interpretation depends on particular filtering function used

### Per-layer parameters [class IterationLayerConfig]

Expand Down
3 changes: 2 additions & 1 deletion RecoTracker/MkFit/interface/MkFitGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class MkFitGeometry {
explicit MkFitGeometry(const TrackerGeometry& geom,
const GeometricSearchTracker& tracker,
const TrackerTopology& ttopo,
std::unique_ptr<mkfit::TrackerInfo> trackerInfo);
std::unique_ptr<mkfit::TrackerInfo> trackerInfo,
const mkfit::LayerNumberConverter& layNConv);
~MkFitGeometry();

int mkFitLayerNumber(DetId detId) const;
Expand Down
97 changes: 75 additions & 22 deletions RecoTracker/MkFit/plugins/MkFitGeometryESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <sstream>

// #define DUMP_MKF_GEO

//------------------------------------------------------------------------------

class MkFitGeometryESProducer : public edm::ESProducer {
Expand Down Expand Up @@ -192,7 +194,9 @@ void MkFitGeometryESProducer::fillShapeAndPlacement(const GeomDet *det,
xy[3][1] = -par[3];
dz = par[2];

// printf("TRAP 0x%x %f %f %f %f\n", detid.rawId(), par[0], par[1], par[2], par[3]);
#ifdef DUMP_MKF_GEO
printf("TRAP 0x%x %f %f %f %f ", detid.rawId(), par[0], par[1], par[2], par[3]);
#endif
} else if (const RectangularPlaneBounds *b2 = dynamic_cast<const RectangularPlaneBounds *>(b)) {
// Rectangular
float dx = b2->width() * 0.5; // half width
Expand All @@ -207,7 +211,9 @@ void MkFitGeometryESProducer::fillShapeAndPlacement(const GeomDet *det,
xy[3][1] = -dy;
dz = b2->thickness() * 0.5; // half thickness

// printf("RECT 0x%x %f %f %f\n", detid.rawId(), dx, dy, dz);
#ifdef DUMP_MKF_GEO
printf("RECT 0x%x %f %f %f ", detid.rawId(), dx, dy, dz);
#endif
} else {
throw cms::Exception("UnimplementedFeature") << "unsupported Bounds class";
}
Expand All @@ -219,6 +225,14 @@ void MkFitGeometryESProducer::fillShapeAndPlacement(const GeomDet *det,
useMatched,
trackerTopo_->isStereo(detid),
trackerTopo_->side(detid) == static_cast<unsigned>(TrackerDetSide::PosEndcap));
#ifdef DUMP_MKF_GEO
printf(" subdet=%d layer=%d side=%d is_stereo=%d --> mkflayer=%d\n",
detid.subdetId(),
trackerTopo_->layer(detid),
trackerTopo_->side(detid),
trackerTopo_->isStereo(detid),
lay);
#endif

mkfit::LayerInfo &layer_info = trk_info.layer_nc(lay);
if (lgc_map) {
Expand Down Expand Up @@ -252,51 +266,64 @@ void MkFitGeometryESProducer::fillShapeAndPlacement(const GeomDet *det,

//==============================================================================

// Ideally these functions would also:
// 0. Setup LayerInfo data (which is now done in auto-generated code).
// Some data-members are a bit over specific, esp/ bools for CMS sub-detectors.
// 1. Establish short module ids (now done in MkFitGeometry constructor).
// 2. Store module normal and strip direction vectors
// 3. ? Any other information ?
// These functions do the following:
// 0. Detect bounding cylinder of each layer.
// 1. Setup LayerInfo data.
// 2. Establish short module ids.
// 3. Store module normal and strip direction vectors.
// 4. Extract stereo coverage holes where they exist (TEC, all but last 3 double-layers).
//
// Plugin DumpMkFitGeometry.cc can then be used to export this for stand-alone.
// Would also need to be picked up with tk-ntuple converter (to get module ids as
// they will now be used as indices into module info vectors).
//
// An attempt at export cmsRun config is in python/dumpMkFitGeometry.py
// See python/dumpMkFitGeometry.py and dumpMkFitGeometryPhase2.py

void MkFitGeometryESProducer::addPixBGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addPixBGeometry\n\n");
#endif
for (auto &det : trackerGeom_->detsPXB()) {
fillShapeAndPlacement(det, trk_info);
}
}

void MkFitGeometryESProducer::addPixEGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addPixEGeometry\n\n");
#endif
for (auto &det : trackerGeom_->detsPXF()) {
fillShapeAndPlacement(det, trk_info);
}
}

void MkFitGeometryESProducer::addTIBGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addTIBGeometry\n\n");
#endif
for (auto &det : trackerGeom_->detsTIB()) {
fillShapeAndPlacement(det, trk_info);
}
}

void MkFitGeometryESProducer::addTOBGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addTOBGeometry\n\n");
#endif
for (auto &det : trackerGeom_->detsTOB()) {
fillShapeAndPlacement(det, trk_info);
}
}

void MkFitGeometryESProducer::addTIDGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addTIDGeometry\n\n");
#endif
for (auto &det : trackerGeom_->detsTID()) {
fillShapeAndPlacement(det, trk_info);
}
}

void MkFitGeometryESProducer::addTECGeometry(mkfit::TrackerInfo &trk_info) {
#ifdef DUMP_MKF_GEO
printf("\n*** addTECGeometry\n\n");
#endif
// For TEC we also need to discover hole in radial extents.
layer_gap_map_t lgc_map;
for (auto &det : trackerGeom_->detsTEC()) {
Expand Down Expand Up @@ -330,6 +357,15 @@ namespace {
// PIXE-, TID-, TEC-
1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5
};
const float phase2QBins[] = {
// TODO: Review these numbers.
// PIXB, TOB
2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0,
// PIXE+, TEC+
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6,
// PIXE-, TEC-
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6
};
}
// clang-format on
//------------------------------------------------------------------------------
Expand All @@ -340,13 +376,19 @@ std::unique_ptr<MkFitGeometry> MkFitGeometryESProducer::produce(const TrackerRec
trackerGeom_ = &iRecord.get(geomToken_);
trackerTopo_ = &iRecord.get(ttopoToken_);

const float *qBinDefaults = nullptr;

// std::string path = "Geometry/TrackerCommonData/data/";
if (trackerGeom_->isThere(GeomDetEnumerators::P1PXB) || trackerGeom_->isThere(GeomDetEnumerators::P1PXEC)) {
edm::LogInfo("MkFitGeometryESProducer") << "Extracting PhaseI geometry";
trackerInfo->create_layers(18, 27, 27);
qBinDefaults = phase1QBins;
} else if (trackerGeom_->isThere(GeomDetEnumerators::P2PXB) || trackerGeom_->isThere(GeomDetEnumerators::P2PXEC) ||
trackerGeom_->isThere(GeomDetEnumerators::P2OTB) || trackerGeom_->isThere(GeomDetEnumerators::P2OTEC)) {
throw cms::Exception("UnimplementedFeature") << "PhaseII geometry extraction";
edm::LogInfo("MkFitGeometryESProducer") << "Extracting PhaseII geometry";
layerNrConv_.reset(mkfit::TkLayout::phase2);
trackerInfo->create_layers(16, 22, 22);
qBinDefaults = phase2QBins;
} else {
throw cms::Exception("UnimplementedFeature") << "unsupported / unknowen geometry version";
}
Expand All @@ -358,27 +400,38 @@ std::unique_ptr<MkFitGeometry> MkFitGeometryESProducer::produce(const TrackerRec
std::numeric_limits<float>::max(), 0, std::numeric_limits<float>::max(), -std::numeric_limits<float>::max());
li.reserve_modules(256);
}
// This is sort of CMS-2017 specific ... but fireworks code uses it for PhaseII as well.
// This is sort of CMS-phase1 specific ... but fireworks code uses it for PhaseII as well.
addPixBGeometry(*trackerInfo);
addPixEGeometry(*trackerInfo);
addTIBGeometry(*trackerInfo);
addTIDGeometry(*trackerInfo);
addTOBGeometry(*trackerInfo);
addTECGeometry(*trackerInfo);

// r_in/out kept as squres until here, root them
// r_in/out kept as squares until here, root them
unsigned int n_mod = 0;
for (int i = 0; i < trackerInfo->n_layers(); ++i) {
auto &li = trackerInfo->layer_nc(i);
li.set_r_in_out(std::sqrt(li.rin()), std::sqrt(li.rout()));
li.set_propagate_to(li.is_barrel() ? li.r_mean() : li.z_mean());
li.set_q_bin(phase1QBins[i]);
li.set_q_bin(qBinDefaults[i]);
unsigned int maxsid = li.shrink_modules();
// Make sure the short id fits in the 12 bits...
assert(maxsid < 1u << 11);
}

return std::make_unique<MkFitGeometry>(
iRecord.get(geomToken_), iRecord.get(trackerToken_), iRecord.get(ttopoToken_), std::move(trackerInfo));
n_mod += maxsid;

// Make sure the short id fits in the 14 bits...
assert(maxsid < 1u << 13);
assert(n_mod > 0);
}
#ifdef DUMP_MKF_GEO
printf("Total number of modules %u, 14-bits fit up to %u modules\n", n_mod, 1u << 13);
#endif

return std::make_unique<MkFitGeometry>(iRecord.get(geomToken_),
iRecord.get(trackerToken_),
iRecord.get(ttopoToken_),
std::move(trackerInfo),
layerNrConv_);
}

DEFINE_FWK_EVENTSETUP_MODULE(MkFitGeometryESProducer);
Loading