CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h

Go to the documentation of this file.
00001 #ifndef CSCTriggerPrimitives_CSCCathodeLCTProcessor_h
00002 #define CSCTriggerPrimitives_CSCCathodeLCTProcessor_h
00003 
00031 #include <vector>
00032 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00033 #include <DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h>
00034 #include <DataFormats/CSCDigi/interface/CSCCLCTDigi.h>
00035 #include <CondFormats/CSCObjects/interface/CSCDBL1TPParameters.h>
00036 #include <L1Trigger/CSCCommonTrigger/interface/CSCConstants.h>
00037 
00038 class CSCCathodeLCTProcessor
00039 {
00040  public:
00042   CSCCathodeLCTProcessor(unsigned endcap, unsigned station, unsigned sector,
00043                          unsigned subsector, unsigned chamber,
00044                          const edm::ParameterSet& conf,
00045                          const edm::ParameterSet& comm);
00046 
00048   CSCCathodeLCTProcessor();
00049 
00051   void setConfigParameters(const CSCDBL1TPParameters* conf);
00052 
00054   void clear();
00055 
00058   std::vector<CSCCLCTDigi> run(const CSCComparatorDigiCollection* compdc);
00059 
00062   void run(const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00063            const std::vector<int> distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00064  
00066   bool getDigis(const CSCComparatorDigiCollection* compdc);
00067   void getDigis(const CSCComparatorDigiCollection* compdc, const CSCDetId& id);
00068 
00070   enum {MAX_CLCT_BINS = 16};
00071 
00073   CSCCLCTDigi bestCLCT[MAX_CLCT_BINS];
00074 
00076   CSCCLCTDigi secondCLCT[MAX_CLCT_BINS];
00077 
00079   std::vector<CSCCLCTDigi> readoutCLCTs();
00080 
00082   std::vector<CSCCLCTDigi> getCLCTs();
00083 
00084   std::vector<int> preTriggerBXs() const {return thePreTriggerBXs;}
00085 
00086   static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS],
00087                              int stag_time[CSCConstants::MAX_NUM_STRIPS],
00088                              int stag_digi[CSCConstants::MAX_NUM_STRIPS],
00089                              int i_distrip, bool debug = false);
00090 
00092   enum {NUM_PATTERN_STRIPS = 26};
00093   static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS];
00094   static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1];
00095 
00096   enum {NUM_PATTERN_HALFSTRIPS = 42};
00097   static const int pattern2007_offset[NUM_PATTERN_HALFSTRIPS];
00098   static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+1];
00099 
00101   enum {MAX_CFEBS = 5};
00102 
00103   // we use these next ones to address the various bits inside the array that's
00104   // used to make the cathode LCTs.
00105   enum CLCT_INDICES {CLCT_PATTERN, CLCT_BEND, CLCT_STRIP, CLCT_BX,
00106                      CLCT_STRIP_TYPE, CLCT_QUALITY, CLCT_CFEB};
00107 
00108  private:
00113   int infoV;
00114 
00116   const unsigned theEndcap;
00117   const unsigned theStation;
00118   const unsigned theSector;
00119   const unsigned theSubsector;
00120   const unsigned theTrigChamber;
00121 
00122   int numStrips;
00123   int stagger[CSCConstants::NUM_LAYERS];
00124 
00125   std::vector<CSCComparatorDigi> digiV[CSCConstants::NUM_LAYERS];
00126   std::vector<int> thePreTriggerBXs;
00127 
00129   bool isMTCC; 
00130 
00132   bool isTMB07;
00133 
00135   unsigned int fifo_tbins,  fifo_pretrig; // only for test beam mode.
00136   unsigned int hit_persist, drift_delay;
00137   unsigned int nplanes_hit_pretrig, nplanes_hit_pattern;
00138   unsigned int pid_thresh_pretrig,  min_separation;
00139 
00141   static const unsigned int def_fifo_tbins,  def_fifo_pretrig;
00142   static const unsigned int def_hit_persist, def_drift_delay;
00143   static const unsigned int def_nplanes_hit_pretrig;
00144   static const unsigned int def_nplanes_hit_pattern;
00145   static const unsigned int def_pid_thresh_pretrig, def_min_separation;
00146 
00148   void setDefaultConfigParameters();
00149 
00151   void checkConfigParameters();
00152 
00154   static const int cfeb_strips[2];
00155 
00156   //---------------- Methods common to all firmware versions ------------------
00157   void readComparatorDigis(std::vector<int>halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00158                            std::vector<int> distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00159   void readComparatorDigis(std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00160   void pulseExtension(
00161  const std::vector<int> time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00162  const int nStrips,
00163  unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00164 
00165   //------------- Functions for idealized version for MC studies --------------
00166   std::vector<CSCCLCTDigi> findLCTs(
00167      const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00168      int stripType);
00169   bool preTrigger(
00170      const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00171      const int stripType, const int nStrips, int& first_bx);
00172   void getKeyStripData(
00173      const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00174      int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7],
00175      int nStrips, int first_bx, int& best_strip, int stripType);
00176   void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS],
00177                   int bx_time, int &quality, int &bend);
00178   bool hitIsGood(int hitTime, int BX);
00179 
00180   //-------------------- Functions for pre-2007 firmware ----------------------
00181   std::vector<CSCCLCTDigi> findLCTs(
00182   const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00183   const std::vector<int> distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00184   bool preTrigger(
00185       const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00186    unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00187       const int stripType, const int nStrips,
00188       const int start_bx, int& first_bx);
00189   bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00190                      const int stripType, const int nStrips,
00191                      const unsigned int bx_time);
00192   void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00193                  int keyStrip[MAX_CFEBS], unsigned int nhits[MAX_CFEBS],
00194                  const int stripType, const int nStrips, const int bx_time);
00195   void priorityEncode(const int h_keyStrip[MAX_CFEBS],
00196                       const unsigned int h_nhits[MAX_CFEBS],
00197                       const int d_keyStrip[MAX_CFEBS],
00198                       const unsigned int d_nhits[MAX_CFEBS],
00199                       int keystrip_data[2][7]);
00200   void getKeyStripData(const unsigned int h_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00201                        const unsigned int d_pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00202                        int keystrip_data[2][7], const int first_bx);
00203   void getPattern(unsigned int pattern_num,
00204                   const int strip_value[NUM_PATTERN_STRIPS],
00205                   unsigned int& quality, unsigned int& bend);
00206 
00207   //--------------- Functions for 2007 version of the firmware ----------------
00208   std::vector<CSCCLCTDigi> findLCTs(
00209  const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00210   bool preTrigger(
00211       const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00212       const int start_bx, int& first_bx);
00213   bool ptnFinding(
00214       const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00215       const int nStrips, const unsigned int bx_time);
00216   void markBusyKeys(const int best_hstrip, const int best_patid,
00217                     int quality[CSCConstants::NUM_HALF_STRIPS]);
00218 
00219   unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS];
00220   unsigned int nhits[CSCConstants::NUM_HALF_STRIPS];
00221 
00222   //--------------------------- Auxiliary methods -----------------------------
00224   void dumpConfigParams() const;
00225 
00227   void dumpDigis(
00228       const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00229       const int stripType, const int nStrips) const;
00230 
00231   //--------------------------- Methods for tests -----------------------------
00232   void testDistripStagger();
00233   void testLCTs();
00234   void printPatterns();
00235   void testPatterns();
00236   int findNumLayersHit(std::vector<int> stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]);
00237 };
00238 
00239 #endif