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 modules and test configs from makortel:mkfit_1040p1 #3

Merged
merged 52 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
77b9e00
First skeleton of the producer
makortel Mar 21, 2018
1437c4f
Convert all the input from CMSSW to mkfit (=hits and seeds)
makortel May 16, 2018
dadc57c
Convert the mkfit output to CMSSW TrackCandidates
makortel Jun 7, 2018
77ab7a4
Add seed cleaning option
makortel Jun 12, 2018
8aab04b
Add option to do backward fit in MkFit
makortel Jun 13, 2018
349c9d7
Silence mkfit printouts by default
makortel Jun 13, 2018
7000405
Sort hits by simple navigation order
makortel Jun 20, 2018
9435325
Try again after dropping last hit if bwd propagation fails
makortel Jun 20, 2018
e0ff016
Improve the starting state propagation logic
makortel Jun 21, 2018
72af925
Change defaults
makortel Oct 12, 2018
eb19293
Customization to run only initialstep
makortel Dec 21, 2018
c6f493c
Add customize function to disable validation
makortel Dec 28, 2018
f9b2527
Implemented CCC (#10)
areinsvo Jan 18, 2019
113b6ac
Split input and output conversions to their own modules
makortel Feb 6, 2019
120cf10
Do not take a reference to a member of a temporary
makortel Feb 13, 2019
f84041b
Migrate trackingNtuple_cff to Tasks
makortel Feb 27, 2019
2ab4be5
Fix CCC
makortel Feb 27, 2019
ddd42d7
Add a flag to disable strip rechit matching
makortel Mar 7, 2019
60debcc
Use also the fourth hit of pixel track for the seed
makortel Mar 11, 2019
9d6537c
Add reco and HLT configuration files
makortel Mar 11, 2019
f60063d
Reduce unnecessary computations in input conversion
makortel Mar 15, 2019
c2353f8
Use phase1 MTV customizations also for HLT
makortel Mar 26, 2019
580aa2a
Fix the use of input and hlt_validation_cff
makortel Mar 29, 2019
7b425ff
Remove additional unnecessary globalPosition calls
makortel Mar 31, 2019
0b846a7
Remove unnecessary TTRH building
makortel Mar 31, 2019
69af78f
Add online-cut plots to plotting
makortel Apr 1, 2019
2418a09
Update paths
makortel Sep 4, 2019
f51b678
Move move constructors and assignment operators out-of-line
makortel Sep 4, 2019
2fca6f7
Sort BuildFile
makortel Sep 4, 2019
2b0e219
More consistent capitalization of mkFit
makortel Sep 4, 2019
3593a6c
Improve comments
makortel Sep 4, 2019
d57bc4a
Move number of layers check out of the call_once, remove commented code
makortel Sep 4, 2019
0a56388
Merge MkFitOutputConverter::backwardFitImpl() with backwardFit()
makortel Sep 4, 2019
fea6d11
Remove unnecessary commented code
makortel Sep 4, 2019
32fff9b
Replace hardcoding with calls to mkfit::LayerNumberConverter
makortel Sep 4, 2019
2d96c71
Shorten lines
makortel Sep 4, 2019
32b7784
Deduce layer side from detid, and avoid unnecessarily repeated call t…
makortel Sep 4, 2019
493d669
Make strip cluster charge cut configurable, default being 'SiStripClu…
makortel Sep 4, 2019
7cfa142
Preallocate memory for hit index mapping structure
makortel Sep 4, 2019
e45094d
Rename MkFitIndexLayer to MkFitHitIndexMap
makortel Sep 4, 2019
e4ddf6e
Rename MkFitHitIndexMap internals and interface for better self-docum…
makortel Sep 4, 2019
cf02a27
Simplify the DetLayer vector creation even more
makortel Sep 9, 2019
5389310
Fix subdet == TOB case
makortel Sep 12, 2019
19fbaf4
Throw an exception for an invalid mkFit layer index
makortel Sep 13, 2019
e171b64
Fix HLT configuration for minGoodStripCharge
makortel Sep 13, 2019
537067a
Add configuration option for duplicate removal, enable by default
makortel Sep 13, 2019
1cff8af
Move all geometry-related stuff to an ESProduct
makortel Oct 3, 2019
b21035b
Migrate to the updated hit interface
makortel Oct 4, 2019
5d234eb
Compute cluster charge only once, dereference Refs only once)
makortel Oct 10, 2019
a08bcc4
A hashmap per layer is a bit faster
makortel Oct 10, 2019
70ad5a9
Make the inclusion of fourth hit of pixel track in seeds configurable…
makortel Nov 12, 2019
782b5b8
For now, comment out disabling seed cleaning for triplet seeds
makortel Nov 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SiStripRecHitConverterAlgorithm
bool isMasked(const SiStripCluster &cluster, bool bad128StripBlocks[6]) const;
bool useModule(const uint32_t id) const;

bool useQuality, maskBad128StripBlocks;
bool useQuality, maskBad128StripBlocks, doMatching;
uint32_t tracker_cache_id, cpe_cache_id, quality_cache_id;
edm::ESInputTag cpeTag, matcherTag, qualityTag;
edm::ESHandle<TrackerGeometry> tracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ SiStripRecHitConverter::SiStripRecHitConverter(edm::ParameterSet const& conf)
: recHitConverterAlgorithm(conf) ,
matchedRecHitsTag( conf.getParameter<std::string>( "matchedRecHits" ) ),
rphiRecHitsTag( conf.getParameter<std::string>( "rphiRecHits" ) ),
stereoRecHitsTag( conf.getParameter<std::string>( "stereoRecHits" ) )
stereoRecHitsTag( conf.getParameter<std::string>( "stereoRecHits" ) ),
doMatching(conf.getParameter<bool>("doMatching"))
{
clusterProducer = consumes<edmNew::DetSetVector<SiStripCluster> >(conf.getParameter<edm::InputTag>("ClusterProducer"));

produces<SiStripMatchedRecHit2DCollection>( matchedRecHitsTag );
produces<SiStripRecHit2DCollection>( rphiRecHitsTag );
produces<SiStripRecHit2DCollection>( stereoRecHitsTag );
produces<SiStripRecHit2DCollection>( rphiRecHitsTag + "Unmatched" );
produces<SiStripRecHit2DCollection>( stereoRecHitsTag + "Unmatched" );
if(doMatching) {
produces<SiStripMatchedRecHit2DCollection>( matchedRecHitsTag );
produces<SiStripRecHit2DCollection>( rphiRecHitsTag + "Unmatched" );
produces<SiStripRecHit2DCollection>( stereoRecHitsTag + "Unmatched" );
}
}

void SiStripRecHitConverter::
Expand All @@ -30,10 +33,11 @@ produce(edm::Event& e, const edm::EventSetup& es)
<< output.rphi->dataSize() << " clusters in mono detectors\n"
<< output.stereo->dataSize() << " clusters in partners stereo detectors\n";

e.put(std::move(output.matched), matchedRecHitsTag);
e.put(std::move(output.rphi), rphiRecHitsTag );
e.put(std::move(output.stereo), stereoRecHitsTag );
e.put(std::move(output.rphiUnmatched), rphiRecHitsTag + "Unmatched");
e.put(std::move(output.stereoUnmatched), stereoRecHitsTag + "Unmatched");

if(doMatching) {
e.put(std::move(output.matched), matchedRecHitsTag);
e.put(std::move(output.rphiUnmatched), rphiRecHitsTag + "Unmatched");
e.put(std::move(output.stereoUnmatched), stereoRecHitsTag + "Unmatched");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class SiStripRecHitConverter : public edm::stream::EDProducer<>
SiStripRecHitConverterAlgorithm recHitConverterAlgorithm;
std::string matchedRecHitsTag, rphiRecHitsTag, stereoRecHitsTag;
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusterProducer;

bool doMatching;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
rphiRecHits = cms.string('rphiRecHit'),
stereoRecHits = cms.string('stereoRecHit'),
matchedRecHits = cms.string('matchedRecHit'),
VerbosityLevel = cms.untracked.int32(1)
VerbosityLevel = cms.untracked.int32(1),
doMatching = cms.bool(True),
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TYPELOOKUP_DATA_REG(SiStripRecHitMatcher);
SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm(const edm::ParameterSet& conf) :
useQuality(conf.getParameter<bool>("useSiStripQuality")),
maskBad128StripBlocks( conf.existsAs<bool>("MaskBadAPVFibers") && conf.getParameter<bool>("MaskBadAPVFibers")),
doMatching(conf.getParameter<bool>("doMatching")),
tracker_cache_id(0),
cpe_cache_id(0),
quality_cache_id(0),
Expand Down Expand Up @@ -80,7 +81,9 @@ run(edm::Handle<edmNew::DetSetVector<SiStripCluster> > inputhandle, products& ou

if (collector.empty()) collector.abort();
}
match(output,trackdirection);
if(doMatching) {
match(output,trackdirection);
}
}


Expand Down
11 changes: 11 additions & 0 deletions RecoTracker/MkFit/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<use name="DataFormats/Provenance"/>
<use name="DataFormats/TrackerCommon"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="RecoTracker/TkDetLayers"/>
<use name="mkfit"/>
<use name="rootcore"/>
<export>
<lib name="RecoTrackerMkFit"/>
</export>
28 changes: 28 additions & 0 deletions RecoTracker/MkFit/interface/MkFitEventWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef RecoTracker_MkFit_MkFitEventWrapper_h
#define RecoTracker_MkFit_MkFitEventWrapper_h

#include "RecoTracker/MkFit/interface/MkFitIndexLayer.h"

namespace mkfit {
class Event;
class TrackVec;
}

class MkFitEventWrapper {
public:
MkFitEventWrapper();
MkFitEventWrapper(MkFitIndexLayer&& indexLayers);
~MkFitEventWrapper();

MkFitEventWrapper(MkFitEventWrapper&&) = default;
MkFitEventWrapper& operator=(MkFitEventWrapper&&) = default;

MkFitIndexLayer const& indexLayers() const { return indexLayer_; }

private:
MkFitIndexLayuer indexLayers_; //!
Event event_; //!
TrackVec seeds_; //!
};

#endif
38 changes: 38 additions & 0 deletions RecoTracker/MkFit/interface/MkFitGeometry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef RecoTracker_MkFit_MkFitGeometry_h
#define RecoTracker_MkFit_MkFitGeometry_h

#include <memory>
#include <unordered_map>
#include <vector>

namespace mkfit {
class LayerNumberConverter;
}

class DetLayer;
class GeometricSearchTracker;
class TrackerGeometry;
class TrackerTopology;

/**
* Collection of geometry-related objects for mkFit
*/
class MkFitGeometry {
public:
explicit MkFitGeometry(const TrackerGeometry& geom, const GeometricSearchTracker& tracker, const TrackerTopology& ttopo);
~MkFitGeometry();

mkfit::LayerNumberConverter const& layerNumberConverter() const { return *lnc_; }
const std::vector<const DetLayer *>& detLayers() const { return dets_; }
unsigned int uniqueIdInLayer(int layer, unsigned int detId) const {
return detIdToShortId_.at(layer).at(detId);
}

private:
std::unique_ptr<mkfit::LayerNumberConverter> lnc_; // for pimpl pattern
std::vector<const DetLayer *> dets_;
std::vector<std::unordered_map<unsigned int, unsigned int>> detIdToShortId_;
};

#endif

87 changes: 87 additions & 0 deletions RecoTracker/MkFit/interface/MkFitHitIndexMap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#ifndef RecoTracker_MkFit_MkFitHitIndexMap_h
#define RecoTracker_MkFit_MkFitHitIndexMap_h

#include "DataFormats/Provenance/interface/ProductID.h"

#include <vector>

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<MkFitHit> 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<ClusterToMkFitHit> cmsswToMkFit_; // mapping from CMSSW(ProductID, cluster index) -> mkFit(index, layer)
std::vector<std::vector<CMSSWHit> > mkFitToCMSSW_; // reverse mapping, mkFit(layer, index) -> CMSSW hit
};


#endif
40 changes: 40 additions & 0 deletions RecoTracker/MkFit/interface/MkFitInputWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef RecoTracker_MkFit_MkFitInputWrapper_h
#define RecoTracker_MkFit_MkFitInputWrapper_h

#include "RecoTracker/MkFit/interface/MkFitHitIndexMap.h"

#include <memory>
#include <vector>

namespace mkfit {
class Hit;
class Track;
class LayerNumberConverter;
using HitVec = std::vector<Hit>;
using TrackVec = std::vector<Track>;
}

class MkFitInputWrapper {
public:
MkFitInputWrapper();
MkFitInputWrapper(MkFitHitIndexMap&& hitIndexMap,
std::vector<mkfit::HitVec>&& hits,
mkfit::TrackVec&& seeds);
~MkFitInputWrapper();

MkFitInputWrapper(MkFitInputWrapper const&) = delete;
MkFitInputWrapper& operator=(MkFitInputWrapper const&) = delete;
MkFitInputWrapper(MkFitInputWrapper&&);
MkFitInputWrapper& operator=(MkFitInputWrapper&&);

MkFitHitIndexMap const& hitIndexMap() const { return hitIndexMap_; }
mkfit::TrackVec const& seeds() const { return *seeds_; }
std::vector<mkfit::HitVec> const& hits() const { return hits_; }

private:
MkFitHitIndexMap hitIndexMap_;
std::vector<mkfit::HitVec> hits_;
std::unique_ptr<mkfit::TrackVec> seeds_; // for pimpl pattern
};

#endif
30 changes: 30 additions & 0 deletions RecoTracker/MkFit/interface/MkFitOutputWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef RecoTracker_MkFit_MkFitOutputWrapper_h
#define RecoTracker_MkFit_MkFitOutputWrapper_h

#include <vector>

namespace mkfit {
class Track;
using TrackVec = std::vector<Track>;
}

class MkFitOutputWrapper {
public:
MkFitOutputWrapper();
MkFitOutputWrapper(mkfit::TrackVec&& candidateTracks, mkfit::TrackVec&& fitTracks);
~MkFitOutputWrapper();

MkFitOutputWrapper(MkFitOutputWrapper const&) = delete;
MkFitOutputWrapper& operator=(MkFitOutputWrapper const&) = delete;
MkFitOutputWrapper(MkFitOutputWrapper&&);
MkFitOutputWrapper& operator=(MkFitOutputWrapper&&);

mkfit::TrackVec const& candidateTracks() const { return candidateTracks_; }
mkfit::TrackVec const& fitTracks() const { return fitTracks_; }

private:
mkfit::TrackVec candidateTracks_; //!
mkfit::TrackVec fitTracks_; //!
};

#endif
27 changes: 27 additions & 0 deletions RecoTracker/MkFit/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<library file="*.cc" name="RecoTrackerMkFitPlugins">
<use name="DataFormats/TrackCandidate"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/TrackerCommon"/>
<use name="DataFormats/TrackerRecHit2D"/>
<use name="DataFormats/TrajectorySeed"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="RecoTracker/MeasurementDet"/>
<use name="RecoTracker/MkFit"/>
<use name="RecoTracker/TkDetLayers"/>
<use name="RecoTracker/TransientTrackingRecHit"/>
<use name="TrackingTools/GeomPropagators"/>
<use name="TrackingTools/KalmanUpdators"/>
<use name="TrackingTools/MaterialEffects"/>
<use name="TrackingTools/Records"/>
<use name="TrackingTools/TrackFitters"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="TrackingTools/TransientTrackingRecHit"/>
<use name="mkfit"/>
<use name="rootmath"/>
<flags EDM_PLUGIN="1"/>
</library>