Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-21 23:14:27

0001 #ifndef RecoTracker_MkFitCore_standalone_TrackExtra_h
0002 #define RecoTracker_MkFitCore_standalone_TrackExtra_h
0003 
0004 #include "RecoTracker/MkFitCore/interface/Track.h"
0005 
0006 #include <array>
0007 #include <map>
0008 #include <unordered_map>
0009 #include <unordered_set>
0010 
0011 namespace mkfit {
0012   //==============================================================================
0013   // ReducedTrack
0014   //==============================================================================
0015 
0016   struct ReducedTrack  // used for cmssw reco track validation
0017   {
0018   public:
0019     ReducedTrack() {}
0020     ReducedTrack(const int label, const int seedID, const SVector2& params, const float phi, const HitLayerMap& hitmap)
0021         : label_(label), seedID_(seedID), parameters_(params), phi_(phi), hitLayerMap_(hitmap) {}
0022 
0023     int label() const { return label_; }
0024     int seedID() const { return seedID_; }
0025     const SVector2& parameters() const { return parameters_; }
0026     float momPhi() const { return phi_; }
0027     const HitLayerMap& hitLayerMap() const { return hitLayerMap_; }
0028 
0029     int label_;
0030     int seedID_;
0031     SVector2 parameters_;
0032     float phi_;
0033     HitLayerMap hitLayerMap_;
0034   };
0035   typedef std::vector<ReducedTrack> RedTrackVec;
0036 
0037   typedef std::map<int, std::map<int, std::vector<int>>> LayIdxIDVecMapMap;
0038   typedef std::map<int, std::unordered_set<int>> TrkIDLaySetMap;
0039   typedef std::array<int, 2> PairIdx;
0040   typedef std::vector<PairIdx> PairIdxVec;
0041   typedef std::array<int, 3> TripletIdx;
0042   typedef std::vector<TripletIdx> TripletIdxVec;
0043 
0044   //==============================================================================
0045   // TrackExtra
0046   //==============================================================================
0047 
0048   class TrackExtra;
0049   typedef std::vector<TrackExtra> TrackExtraVec;
0050 
0051   class TrackExtra {
0052   public:
0053     TrackExtra() : seedID_(std::numeric_limits<int>::max()) {}
0054     TrackExtra(int seedID) : seedID_(seedID) {}
0055 
0056     int modifyRefTrackID(const int foundHits,
0057                          const int minHits,
0058                          const TrackVec& reftracks,
0059                          const int trueID,
0060                          const int duplicate,
0061                          int refTrackID);
0062     void setMCTrackIDInfo(const Track& trk,
0063                           const std::vector<HitVec>& layerHits,
0064                           const MCHitInfoVec& globalHitInfo,
0065                           const TrackVec& simtracks,
0066                           const bool isSeed,
0067                           const bool isPure);
0068     void setCMSSWTrackIDInfoByTrkParams(const Track& trk,
0069                                         const std::vector<HitVec>& layerHits,
0070                                         const TrackVec& cmsswtracks,
0071                                         const RedTrackVec& redcmsswtracks,
0072                                         const bool isBkFit);
0073     void setCMSSWTrackIDInfoByHits(const Track& trk,
0074                                    const LayIdxIDVecMapMap& cmsswHitIDMap,
0075                                    const TrackVec& cmsswtracks,
0076                                    const TrackExtraVec& cmsswextras,
0077                                    const RedTrackVec& redcmsswtracks,
0078                                    const int cmsswlabel);
0079     int mcTrackID() const { return mcTrackID_; }
0080     int nHitsMatched() const { return nHitsMatched_; }
0081     float fracHitsMatched() const { return fracHitsMatched_; }
0082     int seedID() const { return seedID_; }
0083     bool isDuplicate() const { return isDuplicate_; }
0084     int duplicateID() const { return duplicateID_; }
0085     void setDuplicateInfo(int duplicateID, bool isDuplicate) {
0086       duplicateID_ = duplicateID;
0087       isDuplicate_ = isDuplicate;
0088     }
0089     int cmsswTrackID() const { return cmsswTrackID_; }
0090     float helixChi2() const { return helixChi2_; }
0091     float dPhi() const { return dPhi_; }
0092     void findMatchingSeedHits(const Track& reco_trk, const Track& seed_trk, const std::vector<HitVec>& layerHits);
0093     bool isSeedHit(const int lyr, const int idx) const;
0094     int nMatchedSeedHits() const { return matchedSeedHits_.size(); }
0095 
0096     void setmcTrackID(int mcTrackID) { mcTrackID_ = mcTrackID; }
0097     void setseedID(int seedID) { seedID_ = seedID; }
0098 
0099     void addAlgo(int algo) { seedAlgos_.push_back(algo); }
0100     const std::vector<int> seedAlgos() const { return seedAlgos_; }
0101 
0102   private:
0103     friend class Track;
0104 
0105     int mcTrackID_;
0106     int nHitsMatched_;
0107     float fracHitsMatched_;
0108     int seedID_;
0109     int duplicateID_;
0110     bool isDuplicate_;
0111     int cmsswTrackID_;
0112     float helixChi2_;
0113     float dPhi_;
0114     HoTVec matchedSeedHits_;
0115     std::vector<int> seedAlgos_;
0116   };
0117 
0118   typedef std::vector<TrackState> TSVec;
0119   typedef std::vector<TSVec> TkIDToTSVecVec;
0120   typedef std::vector<std::pair<int, TrackState>> TSLayerPairVec;
0121   typedef std::vector<std::pair<int, float>> FltLayerPairVec;  // used exclusively for debugtree
0122 
0123   // Map typedefs needed for mapping different sets of tracks to another
0124   typedef std::unordered_map<int, int> TkIDToTkIDMap;
0125   typedef std::unordered_map<int, std::vector<int>> TkIDToTkIDVecMap;
0126   typedef std::unordered_map<int, TrackState> TkIDToTSMap;
0127   typedef std::unordered_map<int, TSLayerPairVec> TkIDToTSLayerPairVecMap;
0128 
0129 }  // namespace mkfit
0130 
0131 #endif