Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:39

0001 //-------------------------------------------------
0002 //
0003 /**  \class DTBtiChip
0004  *
0005  *   Implementation of DTBtiChip trigger algorithm
0006  *   Internally uses DTBtiHit to store muon digis
0007  *
0008  *
0009  *
0010  *   \author S. Vanini
0011  */
0012 //
0013 //--------------------------------------------------
0014 #ifndef DT_BTI_CHIP_H
0015 #define DT_BTI_CHIP_H
0016 
0017 //------------------------------------
0018 // Collaborating Class Declarations --
0019 //------------------------------------
0020 class DTBtiHit;
0021 class DTBtiTrig;
0022 class DTBtiTrigData;
0023 class DTDigi;
0024 
0025 //----------------------
0026 // Base Class Headers --
0027 //----------------------
0028 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0029 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0030 #include "DataFormats/MuonDetId/interface/DTBtiId.h"
0031 #include "L1Trigger/DTUtilities/interface/DTTrigGeom.h"
0032 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfig.h"
0033 #include "L1TriggerConfig/DTTPGConfig/interface/BitArray.h"
0034 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigBti.h"
0035 #include "L1Trigger/DTBti/interface/DTBtiCard.h"
0036 
0037 //---------------
0038 // C++ Headers --
0039 //---------------
0040 #include <vector>
0041 #include <memory>
0042 #include <array>
0043 
0044 //              ---------------------
0045 //              -- Class Interface --
0046 //              ---------------------
0047 
0048 class DTBtiChip {
0049 public:
0050   //! original constructor
0051   //DTBtiChip(DTTrigGeom* geom, int supl, int n);
0052 
0053   //! new constructor with configuration
0054   DTBtiChip(DTBtiCard* card, DTTrigGeom* geom, int supl, int n, DTConfigBti* _config);
0055 
0056   //! Copy constructor
0057   DTBtiChip(DTBtiChip&& bti) = delete;
0058   DTBtiChip(DTBtiChip const& bti) = delete;
0059 
0060   //! Destructor
0061   ~DTBtiChip();
0062 
0063   //! Assignment operator
0064   DTBtiChip& operator=(DTBtiChip&& bti) = delete;
0065   DTBtiChip& operator=(DTBtiChip const& bti) = delete;
0066 
0067   //! Add a digi to the DTBtiChip
0068   void add_digi(int cell, const DTDigi* digi);
0069 
0070   //! Add a clock digi to the DTBtiChip
0071   void add_digi_clock(int cell, int clock_digi);
0072 
0073   //! get digi vector - SV 28/XI/02
0074   std::vector<const DTDigi*> const& get_CellDigis(int cell) const { return _digis[cell]; }
0075 
0076   //! Run DTBtiChip algorithm
0077   void run();
0078 
0079   //! delete hits and triggers
0080   void clear();
0081 
0082   //! Add a DTBtiChip trigger
0083   //! (normally used by DTBtiChip itself - may be used for debugging by other classes)
0084   void addTrig(int step, std::unique_ptr<DTBtiTrig> btitrig);
0085 
0086   // Public const methods
0087 
0088   //! Return DTBtiChip number
0089   inline int number() const { return _id.bti(); }
0090 
0091   //! Return superlayer
0092   inline int superlayer() const { return _id.superlayer(); }
0093 
0094   //! Position in chamber frame (x is the one of first traco in slave plane)
0095   inline LocalPoint localPosition() const { return _geom->localPosition(_id); }
0096 
0097   //! Position in CMS frame
0098   inline GlobalPoint CMSPosition() const { return _geom->CMSPosition(_id); }
0099 
0100   //! Number of cells with hits
0101   int nCellHit() const;
0102 
0103   //! Number of triggers found
0104   int nTrig(int step) const;
0105 
0106   //  // Return the trigger vector
0107   std::vector<std::unique_ptr<DTBtiTrig>> const& trigList(int step) const;
0108 
0109   //! Return the requested trigger
0110   DTBtiTrig const* trigger(int step, unsigned n) const;
0111 
0112   //! Return the data part of the requested trigger
0113   DTBtiTrigData triggerData(int step, unsigned n) const;
0114 
0115   //! Configuration set
0116   //inline DTConfig* config() const { return _geom->config(); }
0117 
0118   //! testing DTConfigBti
0119   inline DTConfigBti* config() const { return _config; }
0120 
0121   //! Return trigger geometry
0122   inline DTTrigGeom* geom() const { return _geom; }
0123 
0124   //! Return the DTBtiChip Id
0125   inline DTBtiId id() const { return _id; }
0126 
0127   //! Return wheel number
0128   inline int wheel() const { return _geom->wheel(); }
0129 
0130   //! Return station number
0131   inline int station() const { return _geom->station(); }
0132 
0133   //! Return sector number
0134   inline int sector() const { return _geom->sector(); }
0135 
0136   void init_clock();  // initialization from clocks
0137 
0138 private:
0139   void init();  // initialization
0140   void tick();  // next step (80 MHz)
0141   // return current step (40MHz)
0142   inline int currentStep() const { return (int)(((float)(_curStep) + 0.5) / 2); }
0143   inline int currentIntStep() const { return _curStep; }                     // int. step (80MHz)
0144   void computeSums();                                                        // compute sums and diffs
0145   void sum(const int s, const int a, const int b);                           //   "     a sum and dif
0146   void computeEqs();                                                         // compute X and K equat.
0147   void findTrig();                                                           // find triggers
0148   int keepTrig(const int eq, const int acp, const int code);                 // find  a trigger
0149   int keepTrigPatt(int flag, const int eq, const int pattType, int hlflag);  //SV
0150   bool matchEq(float eqA, float eqB, int AC);
0151   void acceptMask(BitArray<80>* BitArrPtr, int k, int accep);
0152   void doLTS();  // adjacent LTRIG suppression
0153   int store(const int eq,
0154             const int code,
0155             const int K,
0156             const int X,
0157             float KeqAB = 0.,
0158             float KeqBC = 0.,
0159             float KeqCD = 0.,
0160             float KeqAC = 0.,
0161             float KeqBD = 0.,
0162             float KeqAD = 0.);
0163   void eraseTrigger(int step, unsigned n);  // Erase the requested trigger
0164   void setSnap();
0165   void reSumSet();  //remainder table compute
0166   int reSum(int a, int b) { return reSumAr[a][b + 2]; }
0167   int reSum23(int a, int b) { return reSumAr23[a][b + 2]; }
0168 
0169 private:
0170   // parent card
0171   DTBtiCard* _card;
0172 
0173   DTTrigGeom* _geom;
0174   DTConfigBti* _config;
0175 
0176   DTBtiId _id;
0177 
0178   // input data from DTDigis
0179   std::array<std::vector<const DTDigi*>, 9> _digis;
0180   // input data from clock digis
0181   std::array<std::vector<int>, 9> _digis_clock;
0182 
0183   // output data (ordered by step number)
0184   std::array<std::vector<std::unique_ptr<DTBtiTrig>>, DTConfig::NSTEPL - DTConfig::NSTEPF + 1> _trigs;
0185 
0186   // internal use variables
0187   int _curStep;                                 // current step
0188   std::array<std::vector<DTBtiHit*>, 9> _hits;  // current hits in cells
0189   std::array<int, 9> _thisStepUsedTimes;        // current used times in cells (JTRIG)
0190   std::array<DTBtiHit*, 9> _thisStepUsedHit;    // link to currently used hits
0191   int _nStepUsedHits;                           // number of currently used hits
0192   std::array<float, 25> _sums, _difs;           // time sums and differences
0193   float _Keq[32][6];                            // The K equations
0194   float _Xeq[32][2];                            // The X equations
0195   int _MinKAcc;                                 // min K value accepted by DTBtiChip
0196   int _MaxKAcc;                                 // max K value accepted by DTBtiChip
0197   int _MinKleftTraco;                           // K limits for left traco
0198   int _MaxKleftTraco;
0199   int _MinKcenterTraco;  // K limits for center traco
0200   int _MaxKcenterTraco;
0201   int _MinKrightTraco;  // K limits for right traco
0202   int _MaxKrightTraco;
0203 
0204   float _XeqAC_patt0, _XeqBD_patt0;  // special pattern 0 X equations
0205   float _XeqAB_patt0, _XeqCD_patt0;
0206 
0207   float _KTR[32][2];                    //
0208   float _JTR[32][3];                    //
0209   int init_done;                        // initialization flag
0210   std::array<int, 9> _busyStart_clock;  // SV - busy wire flag
0211 
0212   //snap register variables
0213   int ST43, RE43, ST23, RE23, ST, ST2, ST3, ST4, ST5, ST7;
0214   //remainder table
0215   int reSumAr[3][5];
0216   int reSumAr23[3][5];
0217 };
0218 #endif