diff --git a/Configuration/PyReleaseValidation/python/relval_2017.py b/Configuration/PyReleaseValidation/python/relval_2017.py
index 55f33022e2e40..68bb0323078a1 100644
--- a/Configuration/PyReleaseValidation/python/relval_2017.py
+++ b/Configuration/PyReleaseValidation/python/relval_2017.py
@@ -23,6 +23,7 @@
# he collapse: TTbar, TTbar PU, TTbar design
# ParkingBPH: TTbar
# 2021 (ZMM, TTbar, ZEE, MinBias, TTbar PU, TTbar PU premix, ZEE PU, TTbar design)
+# (TTbar trackingMkFit)
# 2023 (TTbar, TTbar PU, TTbar PU premix)
# 2024 (TTbar, TTbar PU, TTbar PU premix)
numWFIB = [10001.0,10002.0,10003.0,10004.0,10005.0,10006.0,10007.0,10008.0,10009.0,10059.0,10071.0,
@@ -34,6 +35,7 @@
10824.6,11024.6,11224.6,
10824.8,
11650.0,11634.0,11646.0,11640.0,11834.0,11834.99,11846.0,12024.0,
+ 11634.7,
12434.0,12634.0,12634.99,
12834.0,13034.0,13034.99]
for numWF in numWFIB:
diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py
index f619829abf873..fe78cc98c8726 100644
--- a/Configuration/PyReleaseValidation/python/relval_steps.py
+++ b/Configuration/PyReleaseValidation/python/relval_steps.py
@@ -2090,6 +2090,9 @@ def gen2018HiMix(fragment,howMuch):
step3_trackingLowPU = {
'--era': 'Run2_2016_trackingLowPU'
}
+step3_trackingMkFit = {
+ '--customise': 'RecoTracker/MkFit/customizeInitialStepToMkFit.customizeInitialStepToMkFit'
+}
step3_HIPM = {
'--era': 'Run2_2016_HIPM'
}
@@ -3240,6 +3243,10 @@ def gen2018HiMix(fragment,howMuch):
if 'Reco' in step and upgradeStepDict[step][k]['--era']=='Run2_2017':
upgradeStepDict[stepName][k] = merge([{'--era': 'Run2_2017_trackingLowPU'}, upgradeStepDict[step][k]])
+ for step in upgradeSteps['trackingMkFit']['steps']:
+ stepName = step + upgradeSteps['trackingMkFit']['suffix']
+ if 'Reco' in step: upgradeStepDict[stepName][k] = merge([step3_trackingMkFit, upgradeStepDict[step][k]])
+
for step in upgradeSteps['Neutron']['steps']:
if 'GenSim' in step:
custNew = "SimG4Core/Application/NeutronBGforMuonsXS_cff.customise"
diff --git a/Configuration/PyReleaseValidation/python/relval_upgrade.py b/Configuration/PyReleaseValidation/python/relval_upgrade.py
index c48247d4e08e8..3c22488676614 100644
--- a/Configuration/PyReleaseValidation/python/relval_upgrade.py
+++ b/Configuration/PyReleaseValidation/python/relval_upgrade.py
@@ -73,7 +73,7 @@ def makeStepName(key,frag,step,suffix):
# special workflows for tracker
if (upgradeDatasetFromFragment[frag]=="TTbar_13" or upgradeDatasetFromFragment[frag]=="TTbar_14TeV") and not 'PU' in key and hasHarvest:
# skip ALCA and Nano
- trackingVariations = ['trackingOnly','trackingRun2','trackingOnlyRun2','trackingLowPU','pixelTrackingOnly']
+ trackingVariations = ['trackingOnly','trackingRun2','trackingOnlyRun2','trackingLowPU','pixelTrackingOnly','trackingMkFit']
for tv in trackingVariations:
stepList[tv] = [s for s in stepList[tv] if (("ALCA" not in s) and ("Nano" not in s))]
workflows[numWF+upgradeSteps['trackingOnly']['offset']] = [ upgradeDatasetFromFragment[frag], stepList['trackingOnly']]
@@ -82,6 +82,8 @@ def makeStepName(key,frag,step,suffix):
workflows[numWF+upgradeSteps[tv]['offset']] = [ upgradeDatasetFromFragment[frag], stepList[tv]]
elif '2018' in key:
workflows[numWF+upgradeSteps['pixelTrackingOnly']['offset']] = [ upgradeDatasetFromFragment[frag], stepList['pixelTrackingOnly']]
+ elif '2021' in key:
+ workflows[numWF+upgradeSteps['trackingMkFit']['offset']] = [ upgradeDatasetFromFragment[frag], stepList['trackingMkFit']]
# special workflows for HGCAL/TICL
if (upgradeDatasetFromFragment[frag]=="CloseByParticleGun") and ('2026' in key):
diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py
index 30179cd68e939..93896bb950664 100644
--- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py
+++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py
@@ -188,6 +188,15 @@
'suffix' : '_heCollapse',
'offset' : 0.6,
}
+upgradeSteps['trackingMkFit'] = {
+ 'steps' : [
+ 'RecoFull',
+ 'RecoFullGlobal',
+ ],
+ 'PU' : [],
+ 'suffix' : '_trackingMkFit',
+ 'offset' : 0.7,
+}
upgradeSteps['ParkingBPH'] = {
'steps' : [
'RecoFull',
diff --git a/RecoTracker/MkFit/BuildFile.xml b/RecoTracker/MkFit/BuildFile.xml
new file mode 100644
index 0000000000000..46570ba3ef629
--- /dev/null
+++ b/RecoTracker/MkFit/BuildFile.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/RecoTracker/MkFit/README.md b/RecoTracker/MkFit/README.md
new file mode 100644
index 0000000000000..11bc66edf6800
--- /dev/null
+++ b/RecoTracker/MkFit/README.md
@@ -0,0 +1,30 @@
+# mkFit
+
+This package holds the glue modules for running
+[mkFit](http://trackreco.github.io/) within CMSSW.
+
+Note that at the moment there may be only one `MkFitProducer` in a
+single job. This restriction will be removed in the future.
+
+Also note that at the moment the mkFit works only with the CMS phase1
+tracker detector. Support for the phase2 tracker will be added later.
+
+## Customize functions for runTheMatrix workflows (offline reconstruction)
+
+* `RecoTracker/MkFit/customizeInitialStepToMkFit.customizeInitialStepToMkFit`
+ * Replaces initialStep track building module with `mkFit`.
+* `RecoTracker/MkFit/customizeInitialStepOnly.customizeInitialStepOnly`
+ * Run only the initialStep tracking. In practice this configuration
+ runs the initialStepPreSplitting iteration, but named as
+ initialStep. MultiTrackValidator is included, and configured to
+ monitor initialStep. Intended to provide the minimal configuration
+ for CMSSW tests.
+* `RecoTracker/MkFit/customizeInitialStepOnly.customizeInitialStepOnlyNoMTV`
+ * Otherwise same as `customizeInitialStepOnly` except drops
+ MultiTrackValidator. Intended for profiling.
+
+
+These can be used with e.g.
+```bash
+$ runTheMatrix.py -l --apply 2 --command "--customise RecoTracker/MkFit/customizeInitialStepToMkFit.customizeInitialStepToMkFit"
+```
\ No newline at end of file
diff --git a/RecoTracker/MkFit/interface/MkFitHitIndexMap.h b/RecoTracker/MkFit/interface/MkFitHitIndexMap.h
new file mode 100644
index 0000000000000..c7b6eea50263a
--- /dev/null
+++ b/RecoTracker/MkFit/interface/MkFitHitIndexMap.h
@@ -0,0 +1,86 @@
+#ifndef RecoTracker_MkFit_MkFitHitIndexMap_h
+#define RecoTracker_MkFit_MkFitHitIndexMap_h
+
+#include "DataFormats/Provenance/interface/ProductID.h"
+
+#include
+
+class TrackingRecHit;
+
+/**
+ * This class provides mappings
+ * - from CMSSW(ProductID, cluster index) to mkFit(layer index, hit index)
+ * - from mkFit(layer index, hit index) to pointer to CMSSW hit
+ */
+class MkFitHitIndexMap {
+public:
+ // This class holds the index and layer of a hit in the hit data
+ // structure passed to mkFit
+ class MkFitHit {
+ public:
+ MkFitHit() = default;
+ explicit MkFitHit(int i, int l) : index_{i}, layer_{l} {}
+
+ int index() const { return index_; }
+ int layer() const { return layer_; }
+
+ private:
+ int index_ = -1;
+ int layer_ = -1;
+ };
+
+ MkFitHitIndexMap() = default;
+
+ /**
+ * Can be used to preallocate the internal vectors for CMSSW->mkFit mapping
+ */
+ void resizeByClusterIndex(edm::ProductID id, size_t clusterIndex);
+
+ /**
+ * Can be used to preallocate the internal vectors for mkFit->CMSSW mapping
+ *
+ * \param layer Layer index (in mkFit convention)
+ * \param additionalSize Number of additional elements to make space for
+ */
+ void increaseLayerSize(int layer, size_t additionalSize);
+
+ /**
+ * Inserts a new hit in the mapping
+ *
+ * \param id ProductID of the cluster collection
+ * \param clusterIndex Index of the cluster in the cluster collection
+ * \param hit Index and layer of the hit in the mkFit hit data structure
+ * \param hitPtr Pointer to the TrackingRecHit
+ */
+ void insert(edm::ProductID id, size_t clusterIndex, MkFitHit hit, const TrackingRecHit* hitPtr);
+
+ /// Get mkFit hit index and layer
+ const MkFitHit& mkFitHit(edm::ProductID id, size_t clusterIndex) const;
+
+ /// Get CMSSW hit pointer
+ const TrackingRecHit* hitPtr(MkFitHit hit) const { return mkFitToCMSSW_.at(hit.layer()).at(hit.index()).ptr; }
+
+ /// Get CMSSW cluster index (currently used only for debugging)
+ size_t clusterIndex(MkFitHit hit) const { return mkFitToCMSSW_.at(hit.layer()).at(hit.index()).clusterIndex; }
+
+private:
+ // Helper struct to map (edm::ProductID, cluster index) to MkFitHit
+ struct ClusterToMkFitHit {
+ explicit ClusterToMkFitHit(edm::ProductID id) : productID(id) {}
+ edm::ProductID productID;
+ std::vector mkFitHits; // indexed by cluster index
+ };
+
+ // Helper struct to map MkFitHit to (TrackingRecHit *, cluster index)
+ struct CMSSWHit {
+ CMSSWHit() = default;
+ explicit CMSSWHit(const TrackingRecHit* p, size_t i) : ptr{p}, clusterIndex{i} {}
+ const TrackingRecHit* ptr = nullptr;
+ size_t clusterIndex = 0;
+ };
+
+ std::vector cmsswToMkFit_; // mapping from CMSSW(ProductID, cluster index) -> mkFit(index, layer)
+ std::vector > mkFitToCMSSW_; // reverse mapping, mkFit(layer, index) -> CMSSW hit
+};
+
+#endif
diff --git a/RecoTracker/MkFit/interface/MkFitInputWrapper.h b/RecoTracker/MkFit/interface/MkFitInputWrapper.h
new file mode 100644
index 0000000000000..ae17cf6e32584
--- /dev/null
+++ b/RecoTracker/MkFit/interface/MkFitInputWrapper.h
@@ -0,0 +1,44 @@
+#ifndef RecoTracker_MkFit_MkFitInputWrapper_h
+#define RecoTracker_MkFit_MkFitInputWrapper_h
+
+#include "RecoTracker/MkFit/interface/MkFitHitIndexMap.h"
+
+#include
+#include
+
+namespace mkfit {
+ class Hit;
+ class Track;
+ class LayerNumberConverter;
+ using HitVec = std::vector;
+ using TrackVec = std::vector