Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:54

0001 #ifndef L1Trigger_TrackFindingTracklet_KFin_h
0002 #define L1Trigger_TrackFindingTracklet_KFin_h
0003 
0004 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0005 #include "L1Trigger/TrackerTFP/interface/DataFormats.h"
0006 #include "L1Trigger/TrackerTFP/interface/LayerEncoding.h"
0007 #include "L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h"
0008 
0009 #include <vector>
0010 
0011 namespace trklet {
0012 
0013   /*! \class  trklet::KFin
0014    *  \brief  Class to emulate the data transformation happening betwwen DR and KF
0015    *  \author Thomas Schuh
0016    *  \date   2023, Feb
0017    */
0018   class KFin {
0019   public:
0020     KFin(const edm::ParameterSet& iConfig,
0021          const tt::Setup* setup_,
0022          const trackerTFP::DataFormats* dataFormats,
0023          const trackerTFP::LayerEncoding* layerEncoding,
0024          const ChannelAssignment* channelAssignment,
0025          int region);
0026     ~KFin() {}
0027     // read in and organize input tracks and stubs
0028     void consume(const tt::StreamsTrack& streamsTrack, const tt::StreamsStub& streamsStub);
0029     // fill output products
0030     void produce(tt::StreamsStub& accpetedStubs,
0031                  tt::StreamsTrack& acceptedTracks,
0032                  tt::StreamsStub& lostStubs,
0033                  tt::StreamsTrack& lostTracks);
0034 
0035   private:
0036     // truncates double precision of val into base precision, +1.e-12 restores robustness of addition of 2 digitised values
0037     double digi(double val, double base) const { return (floor(val / base + 1.e-12) + .5) * base; }
0038     struct Stub {
0039       Stub(const TTStubRef& ttStubRef, double r, double phi, double z, int layerId, bool psTilt, int channel)
0040           : ttStubRef_(ttStubRef), r_(r), phi_(phi), z_(z), layerId_(layerId), psTilt_(psTilt), channel_(channel) {}
0041       TTStubRef ttStubRef_;
0042       double r_;
0043       double phi_;
0044       double z_;
0045       int layerId_;
0046       bool psTilt_;
0047       int channel_;
0048       // phi uncertainty * sqrt(12) + additional terms in rad
0049       double dPhi_;
0050       // z uncertainty * sqrt(12) + additional terms in cm
0051       double dZ_;
0052     };
0053     struct Track {
0054       static constexpr int max_ = 7;
0055       Track() { stubs_.reserve(max_); }
0056       Track(const tt::FrameTrack& frame,
0057             const std::vector<Stub*>& stubs,
0058             double cot,
0059             double zT,
0060             double inv2R,
0061             int sectorEta)
0062           : frame_(frame), stubs_(stubs), cot_(cot), zT_(zT), inv2R_(inv2R), sectorEta_(sectorEta) {}
0063       tt::FrameTrack frame_;
0064       std::vector<Stub*> stubs_;
0065       double cot_;
0066       double zT_;
0067       double inv2R_;
0068       int sectorEta_;
0069     };
0070     // remove and return first element of deque, returns nullptr if empty
0071     template <class T>
0072     T* pop_front(std::deque<T*>& ts) const;
0073     // true if truncation is enbaled
0074     bool enableTruncation_;
0075     // provides run-time constants
0076     const tt::Setup* setup_;
0077     // provides dataformats
0078     const trackerTFP::DataFormats* dataFormats_;
0079     // helper class to encode layer
0080     const trackerTFP::LayerEncoding* layerEncoding_;
0081     // helper class to assign tracks to channel
0082     const ChannelAssignment* channelAssignment_;
0083     // processing region (0 - 8) aka processing phi nonant
0084     const int region_;
0085     // storage of input tracks
0086     std::vector<Track> tracks_;
0087     // storage of input stubs
0088     std::vector<Stub> stubs_;
0089     // h/w liked organized pointer to input tracks
0090     std::vector<std::vector<Track*>> input_;
0091   };
0092 
0093 }  // namespace trklet
0094 
0095 #endif