CMS 3D CMS Logo

CSCUpgradeMotherboard.h
Go to the documentation of this file.
1 #ifndef L1Trigger_CSCTriggerPrimitives_CSCUpgradeMotherboard_h
2 #define L1Trigger_CSCTriggerPrimitives_CSCUpgradeMotherboard_h
3 
16 
17 // generic container type
18 namespace{
19 
20 // first: raw detid, second: digi
21 template <class T>
22 using match = std::pair<unsigned int, T>;
23 
24 // vector of template above
25 template <class T>
26 using matches = std::vector<std::pair<unsigned int, T> >;
27 
28 // first: BX number, second: vector of template above
29 template <class T>
30 using matchesBX = std::map<int, std::vector<std::pair<unsigned int, T> > >;
31 
32 }
33 
35 {
36 public:
37 
40  class LCTContainer {
41  public:
42  // constructor
43  LCTContainer(unsigned int trig_window_size);
44 
45  // access the LCT in a particular ALCT BX, a particular CLCT matched BX
46  // and particular LCT number
47  CSCCorrelatedLCTDigi& operator()(int bx, int match_bx, int lct);
48 
49  // get the matching LCTs for a certain ALCT BX
50  void getTimeMatched(const int bx, std::vector<CSCCorrelatedLCTDigi>&) const;
51 
52  // get all LCTs in the 16 BX readout window
53  void getMatched(std::vector<CSCCorrelatedLCTDigi>&) const;
54 
55  // clear the array with stubs
56  void clear();
57 
58  // array with stored LCTs
59  // 1st index: depth of pipeline that stores the ALCT and CLCT
60  // 2nd index: BX number of the ALCT-CLCT match in the matching window
61  // 3rd index: LCT number in the time bin
63 
64  // matching trigger window
65  const unsigned int match_trig_window_size_;
66  };
67 
68  // standard constructor
69  CSCUpgradeMotherboard(unsigned endcap, unsigned station, unsigned sector,
70  unsigned subsector, unsigned chamber,
71  const edm::ParameterSet& conf);
72 
73  //Default constructor for testing
75 
76  ~CSCUpgradeMotherboard() override;
77 
78  // Empty the LCT container
79  void clear();
80 
81  // Compare two matches of type <ID,DIGI>
82  // The template is match<GEMPadDigi> or match<GEMCoPadDigi>
83  template <class S>
84  bool compare(const S& p, const S& q) const;
85 
86  // Get the common matches of type <ID,DIGI>. Could be more than 1
87  // The template is matches<GEMPadDigi> or matches<GEMCoPadDigi>
88  template <class S>
89  void intersection(const S& d1, const S& d2, S& result) const;
90 
92  static bool sortLCTsByQuality(const CSCCorrelatedLCTDigi&,
93  const CSCCorrelatedLCTDigi&);
94  static bool sortLCTsByGEMDphi(const CSCCorrelatedLCTDigi&,
95  const CSCCorrelatedLCTDigi&);
96  // generic sorting function
97  // provide an LCT collection and a sorting function
98  void sortLCTs(std::vector<CSCCorrelatedLCTDigi>& lcts,
99  bool (*sorter)(const CSCCorrelatedLCTDigi&,
100  const CSCCorrelatedLCTDigi&)) const;
101 
103  enum CSCPart getCSCPart(int keystrip) const;
104 
105  // functions to setup geometry and LUTs
106  void setupGeometry();
107  void debugLUTs();
108 
109  // run TMB with GEM pad clusters as input
110  void run(const CSCWireDigiCollection* wiredc,
111  const CSCComparatorDigiCollection* compdc) override;
112 
113  /* readout the two best LCTs in this CSC */
114  std::vector<CSCCorrelatedLCTDigi> readoutLCTs() const override;
115 
116  protected:
117 
118  void correlateLCTs(const CSCALCTDigi& bestALCT, const CSCALCTDigi& secondALCT,
119  const CSCCLCTDigi& bestCLCT, const CSCCLCTDigi& secondCLCT,
120  CSCCorrelatedLCTDigi& lct1, CSCCorrelatedLCTDigi& lct2) const;
121 
123 
124  void setPrefIndex();
125 
129 
130  std::unique_ptr<CSCUpgradeMotherboardLUTGenerator> generator_;
131 
134 
137 
138  /* type of algorithm to sort the stubs */
139  unsigned int tmb_cross_bx_algo;
140 
142  unsigned int max_lcts;
143 
144  // debug gem matching
146 
147  // check look-up-tables
149 };
150 
151 template <class S>
152 bool CSCUpgradeMotherboard::compare(const S& p, const S& q) const
153 {
154  return (p.first == q.first) and (p.second == q.second);
155 }
156 
157 template <class S>
158 void CSCUpgradeMotherboard::intersection(const S& d1, const S& d2, S& result) const
159 {
160  for (const auto& p: d1){
161  for (const auto& q: d2){
162  if (compare(p,q)){
163  result.push_back(p);
164  }
165  }
166  }
167  }
168 
169 #endif
CSCCorrelatedLCTDigi data[CSCConstants::MAX_LCT_TBINS][CSCConstants::MAX_MATCH_WINDOW_SIZE][CSCConstants::MAX_LCTS_PER_CSC]
std::unique_ptr< CSCUpgradeMotherboardLUTGenerator > generator_
bool compare(const S &p, const S &q) const
static bool sortLCTsByQuality(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
int pref[CSCConstants::MAX_LCT_TBINS]
void sortLCTs(std::vector< CSCCorrelatedLCTDigi > &lcts, bool(*sorter)(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)) const
LCTContainer(unsigned int trig_window_size)
static bool sortLCTsByGEMDphi(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
void getTimeMatched(const int bx, std::vector< CSCCorrelatedLCTDigi > &) const
CSCCorrelatedLCTDigi & operator()(int bx, int match_bx, int lct)
void correlateLCTs(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
void getMatched(std::vector< CSCCorrelatedLCTDigi > &) const
std::vector< CSCCorrelatedLCTDigi > readoutLCTs() const override
void intersection(const S &d1, const S &d2, S &result) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc) override
enum CSCPart getCSCPart(int keystrip) const