CMS 3D CMS Logo

CSCGEMMotherboard.h
Go to the documentation of this file.
1 #ifndef L1Trigger_CSCTriggerPrimitives_CSCGEMMotherboard_h
2 #define L1Trigger_CSCTriggerPrimitives_CSCGEMMotherboard_h
3 
9 
10 typedef match<GEMPadDigi> GEMPadDigiId;
11 typedef matches<GEMPadDigi> GEMPadDigiIds;
12 typedef matchesBX<GEMPadDigi> GEMPadDigiIdsBX;
13 
14 typedef match<GEMCoPadDigi> GEMCoPadDigiId;
15 typedef matches<GEMCoPadDigi> GEMCoPadDigiIds;
16 typedef matchesBX<GEMCoPadDigi> GEMCoPadDigiIdsBX;
17 
19 
21 {
22 public:
23 
24  CSCGEMMotherboard(unsigned endcap, unsigned station, unsigned sector,
25  unsigned subsector, unsigned chamber,
26  const edm::ParameterSet& conf);
27 
28  //Default constructor for testing
30 
31  virtual ~CSCGEMMotherboard();
32 
33  void clear();
34 
35  // TMB run modes
36  virtual void run(const CSCWireDigiCollection* wiredc,
37  const CSCComparatorDigiCollection* compdc,
38  const GEMPadDigiCollection* gemPads)=0;
39 
40  void run(const CSCWireDigiCollection* wiredc,
41  const CSCComparatorDigiCollection* compdc,
42  const GEMPadDigiClusterCollection* gemPads);
43 
45  std::unique_ptr<GEMCoPadProcessor> coPadProcessor;
46 
48  void setGEMGeometry(const GEMGeometry *g) { gem_g = g; }
49 
50 protected:
51 
52  virtual const CSCGEMMotherboardLUT* getLUT() const=0;
53 
54  int getBX(const GEMPadDigi& p);
55  int getBX(const GEMCoPadDigi& p);
56 
57  int getRoll(const GEMPadDigiId& p);
58  int getRoll(const GEMCoPadDigiId& p);
59  int getRoll(const CSCALCTDigi&);
60 
61  float getAvePad(const GEMPadDigi&);
62  float getAvePad(const GEMCoPadDigi&);
63  float getAvePad(const CSCCLCTDigi&, enum CSCPart part);
64 
65  // match ALCT/CLCT to Pad/CoPad
66  template <class T>
67  matches<T> matchingPads(const CSCALCTDigi& alct, enum CSCPart part);
68 
69  template <class T>
70  matches<T> matchingPads(const CSCCLCTDigi& clct, enum CSCPart part);
71 
72  template <class T>
73  T bestMatchingPad(const CSCALCTDigi&, const matches<T>&, enum CSCPart);
74 
75  template <class T>
76  T bestMatchingPad(const CSCCLCTDigi&, const matches<T>&, enum CSCPart);
77 
78  template <class T>
79  T bestMatchingPad(const CSCALCTDigi&, const CSCCLCTDigi&, const matches<T>&, enum CSCPart);
80 
81  template <class S, class T>
82  matches<T> matchingPads(const S& d1, const S& d2, enum CSCPart part);
83 
84  template <class T>
85  matches<T> matchingPads(const CSCCLCTDigi& clct1, const CSCALCTDigi& alct1, enum CSCPart part);
86 
87  template <class T>
88  matches<T> matchingPads(const CSCCLCTDigi& clct1, const CSCCLCTDigi& clct2,
89  const CSCALCTDigi& alct1, const CSCALCTDigi& alct2,
90  enum CSCPart part);
91 
92  template <class T>
93  void correlateLCTsGEM(T& best, T& second, const GEMCoPadDigiIds& coPads,
95  template <class T>
96  void correlateLCTsGEM(const T& best, const T& second, const GEMCoPadDigi&, const GEMCoPadDigi&,
98 
99  // specific functions
100  CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi& alct, const GEMCoPadDigi& gem, enum CSCPart, int i);
101  CSCCorrelatedLCTDigi constructLCTsGEM(const CSCCLCTDigi& clct, const GEMCoPadDigi& gem, enum CSCPart, int i);
103  const GEMCoPadDigi& gem, enum CSCPart p, int i);
105  const GEMPadDigi& gem, enum CSCPart p, int i);
106  /*
107  * General function to construct integrated stubs from CSC and GEM information.
108  * Options are:
109  * 1. ALCT-CLCT-GEMPad
110  * 2. ALCT-CLCT-GEMCoPad
111  * 3. ALCT-GEMCoPad
112  * 4. CLCT-GEMCoPad
113  */
115  const GEMPadDigi& gem1, const GEMCoPadDigi& gem2,
116  enum CSCPart p, int i);
117 
118  void retrieveGEMPads(const GEMPadDigiCollection* pads, unsigned id);
119  void retrieveGEMCoPads();
120 
121  unsigned int findQualityGEM(const CSCALCTDigi&, const CSCCLCTDigi&, int gemlayer);
122 
123  void printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart);
124  void printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart);
125 
126  bool isPadInOverlap(int roll);
127 
128  void setupGeometry();
129 
131  unsigned gemId;
132 
135 
136  std::vector<GEMCoPadDigi> gemCoPadV;
137 
138  // map< bx , vector<gemid, pad> >
141 
142  // deltas used to match to GEM pads
147 
148  // send LCT old dataformat
150 
151  // promote ALCT-GEM pattern
153 
156 
157  // LCT ghostbusting
159 };
160 
161 
162 template <class S>
163 S CSCGEMMotherboard::bestMatchingPad(const CSCALCTDigi& alct1, const matches<S>& pads, enum CSCPart)
164 {
165  S result;
166  if (not alct1.isValid()) return result;
167 
168  // return the first one with the same roll number
169  for (const auto& p: pads){
170  if (getRoll(p) == getRoll(alct1)){
171  return p.second;
172  }
173  }
174  return result;
175 }
176 
177 template <class S>
178 S CSCGEMMotherboard::bestMatchingPad(const CSCCLCTDigi& clct, const matches<S>& pads, enum CSCPart part)
179 {
180  S result;
181  if (not clct.isValid()) return result;
182 
183  // return the pad with the smallest bending angle
184  float averagePadNumberCSC = getAvePad(clct, part);
185  float minDeltaPad = 999;
186  for (const auto& p: pads){
187  float averagePadNumberGEM = getAvePad(p.second);
188  if (std::abs(averagePadNumberCSC - averagePadNumberGEM) < minDeltaPad){
189  minDeltaPad = std::abs(averagePadNumberCSC - averagePadNumberGEM);
190  result = p.second;
191  }
192  }
193  return result;
194 }
195 
196 template <class S>
198  const matches<S>& pads, enum CSCPart part)
199 {
200  S result;
201  if (not alct1.isValid() or not clct1.isValid()) return result;
202 
203  // return the pad with the smallest bending angle
204  float averagePadNumberCSC = getAvePad(clct1, part);
205  float minDeltaPad = 999;
206  for (const auto& p: pads){
207  float averagePadNumberGEM = getAvePad(p.second);
208  // add another safety to make sure that the deltaPad is not larger than max value!!!
209  if (std::abs(averagePadNumberCSC - averagePadNumberGEM) < minDeltaPad and getRoll(p) == getRoll(alct1)){
210  minDeltaPad = std::abs(averagePadNumberCSC - averagePadNumberGEM);
211  result = p.second;
212  }
213  }
214  return result;
215 }
216 
217 template <class T>
220 {
221  bool bestValid = bestLCT.isValid();
222  bool secondValid = secondLCT.isValid();
223 
224  // determine best/second
225  if (bestValid and !secondValid) secondLCT = bestLCT;
226  if (!bestValid and secondValid) bestLCT = secondLCT;
227 
228  // get best matching copad1
229  GEMCoPadDigi bestCoPad = bestMatchingPad<GEMCoPadDigi>(bestLCT, coPads, p);
230  GEMCoPadDigi secondCoPad = bestMatchingPad<GEMCoPadDigi>(secondLCT, coPads, p);
231 
232  correlateLCTsGEM(bestLCT, secondLCT, bestCoPad, secondCoPad, lct1, lct2, p);
233 }
234 
235 
236 template <>
238  const GEMCoPadDigi& bestCoPad, const GEMCoPadDigi& secondCoPad,
240 {
241  if ((alct_trig_enable and bestLCT.isValid()) or
242  (match_trig_enable and bestLCT.isValid()))
243  {
244  lct1 = constructLCTsGEM(bestLCT, bestCoPad, p, 1);
245  }
246 
247  if ((alct_trig_enable and secondLCT.isValid()) or
248  (match_trig_enable and secondLCT.isValid() and secondLCT != bestLCT))
249  {
250  lct2 = constructLCTsGEM(secondLCT, secondCoPad, p, 2);
251  }
252 }
253 
254 
255 template <>
257  const GEMCoPadDigi& bestCoPad, const GEMCoPadDigi& secondCoPad,
259 {
260  if ((clct_trig_enable and bestLCT.isValid()) or
261  (match_trig_enable and bestLCT.isValid()))
262  {
263  lct1 = constructLCTsGEM(bestLCT, bestCoPad, p, 1);
264  }
265 
266  if ((clct_trig_enable and secondLCT.isValid()) or
267  (match_trig_enable and secondLCT.isValid() and secondLCT != bestLCT))
268  {
269  lct2 = constructLCTsGEM(secondLCT, secondCoPad, p, 2);
270  }
271 }
272 
273 
274 template <>
276 {
277  matches<GEMPadDigi> result;
278  if (not alct.isValid()) return result;
279 
280  std::pair<int,int> alctRoll = (getLUT()->CSCGEMMotherboardLUT::get_csc_wg_to_gem_roll(par))[alct.getKeyWG()];
281  for (const auto& p: pads_[alct.getBX()]){
282  auto padRoll(getRoll(p));
283  // only pads in overlap are good for ME1A
284  if (part==CSCPart::ME1A and !isPadInOverlap(padRoll)) continue;
285 
286  int pad_bx = getBX(p.second)+lct_central_bx;
287  if (std::abs(alct.getBX()-pad_bx)>maxDeltaBXPad_) continue;
288 
289  if (alctRoll.first == -99 and alctRoll.second == -99) continue; //invalid region
290  else if (alctRoll.first == -99 and !(padRoll <= alctRoll.second)) continue; // top of the chamber
291  else if (alctRoll.second == -99 and !(padRoll >= alctRoll.first)) continue; // bottom of the chamber
292  else if ((alctRoll.first != -99 and alctRoll.second != -99) and // center
293  (alctRoll.first > padRoll or padRoll > alctRoll.second)) continue;
294  result.push_back(p);
295  }
296  return result;
297 }
298 
299 template <>
300 matches<GEMCoPadDigi> CSCGEMMotherboard::matchingPads(const CSCALCTDigi& alct, enum CSCPart part)
301 {
302  matches<GEMCoPadDigi> result;
303  if (not alct.isValid()) return result;
304 
305  std::pair<int,int> alctRoll = (getLUT()->CSCGEMMotherboardLUT::get_csc_wg_to_gem_roll(par))[alct.getKeyWG()];
306  for (const auto& p: coPads_[alct.getBX()]){
307  auto padRoll(getRoll(p));
308  // only pads in overlap are good for ME1A
309  if (part==CSCPart::ME1A and !isPadInOverlap(padRoll)) continue;
310 
311  int pad_bx = getBX(p.second)+lct_central_bx;
312  if (std::abs(alct.getBX()-pad_bx)>maxDeltaBXCoPad_) continue;
313 
314  if (alctRoll.first == -99 and alctRoll.second == -99) continue; //invalid region
315  else if (alctRoll.first == -99 and !(padRoll <= alctRoll.second)) continue; // top of the chamber
316  else if (alctRoll.second == -99 and !(padRoll >= alctRoll.first)) continue; // bottom of the chamber
317  else if ((alctRoll.first != -99 and alctRoll.second != -99) and // center
318  (alctRoll.first > padRoll or padRoll > alctRoll.second)) continue;
319  result.push_back(p);
320  }
321  return result;
322 }
323 
324 
325 template <>
327 {
328  matches<GEMPadDigi> result;
329  if (not clct.isValid()) return result;
330 
331  const auto& mymap = (getLUT()->get_csc_hs_to_gem_pad(par, part));
332  const int lowPad(mymap[clct.getKeyStrip()].first);
333  const int highPad(mymap[clct.getKeyStrip()].second);
334  for (const auto& p: pads_[clct.getBX()]){
335  auto padRoll(getAvePad(p.second));
336  int pad_bx = getBX(p.second)+lct_central_bx;
337  if (std::abs(clct.getBX()-pad_bx)>maxDeltaBXPad_) continue;
338  if (std::abs(lowPad - padRoll) <= maxDeltaPadL1_ or std::abs(padRoll - highPad) <= maxDeltaPadL1_){
339  result.push_back(p);
340  }
341  }
342  return result;
343 }
344 
345 
346 template <>
347 matches<GEMCoPadDigi> CSCGEMMotherboard::matchingPads(const CSCCLCTDigi& clct, enum CSCPart part)
348 {
349  matches<GEMCoPadDigi> result;
350  if (not clct.isValid()) return result;
351 
352  const auto& mymap = (getLUT()->get_csc_hs_to_gem_pad(par, part));
353  const int lowPad(mymap[clct.getKeyStrip()].first);
354  const int highPad(mymap[clct.getKeyStrip()].second);
355  for (const auto& p: coPads_[clct.getBX()]){
356  auto padRoll(getAvePad(p.second));
357  int pad_bx = getBX(p.second)+lct_central_bx;
358  if (std::abs(clct.getBX()-pad_bx)>maxDeltaBXCoPad_) continue;
359  if (std::abs(lowPad - padRoll) <= maxDeltaPadL1_ or std::abs(padRoll - highPad) <= maxDeltaPadL1_){
360  result.push_back(p);
361  }
362  }
363  return result;
364 }
365 
366 
367 template <class S, class T>
368 matches<T> CSCGEMMotherboard::matchingPads(const S& d1, const S& d2, enum CSCPart part)
369 {
370  matches<T> result, p1, p2;
371  p1 = matchingPads<T>(d1, part);
372  p2 = matchingPads<T>(d2, part);
373  result.reserve(p1.size() + p2.size());
374  result.insert(std::end(result), std::begin(p1), std::end(p1));
375  result.insert(std::end(result), std::begin(p2), std::end(p2));
376  return result;
377 }
378 
379 template <class T>
380 matches<T> CSCGEMMotherboard::matchingPads(const CSCCLCTDigi& clct1, const CSCALCTDigi& alct1, enum CSCPart part)
381 {
382  matches<T> padsClct(matchingPads<T>(clct1, part));
383  matches<T> padsAlct(matchingPads<T>(alct1, part));
384  return intersection(padsClct, padsAlct);
385 }
386 
387 template <class T>
388 matches<T> CSCGEMMotherboard::matchingPads(const CSCCLCTDigi& clct1, const CSCCLCTDigi& clct2,
389  const CSCALCTDigi& alct1, const CSCALCTDigi& alct2,
390  enum CSCPart part)
391 {
392  matches<T> padsClct(matchingPads<CSCCLCTDigi,T>(clct1, clct2, part));
393  matches<T> padsAlct(matchingPads<CSCALCTDigi,T>(alct1, alct2, part));
394  return intersection(padsClct, padsAlct);
395 }
396 
397 
398 #endif
void retrieveGEMPads(const GEMPadDigiCollection *pads, unsigned id)
match< GEMCoPadDigi > GEMCoPadDigiId
T bestMatchingPad(const CSCALCTDigi &, const matches< T > &, enum CSCPart)
unsigned int clct_trig_enable
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi &alct, const GEMCoPadDigi &gem, enum CSCPart, int i)
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:30
void setGEMGeometry(const GEMGeometry *g)
set CSC and GEM geometries for the matching needs
GEMCoPadDigiIdsBX coPads_
int getRoll(const GEMPadDigiId &p)
int getBX(const GEMPadDigi &p)
virtual ~CSCGEMMotherboard()
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
matches< GEMCoPadDigi > GEMCoPadDigiIds
void correlateLCTsGEM(T &best, T &second, const GEMCoPadDigiIds &coPads, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2, enum CSCPart)
std::vector< GEMCoPadDigi > gemCoPadV
U second(std::pair< T, U > const &p)
S intersection(const S &d1, const S &d2)
matchesBX< GEMPadDigi > GEMPadDigiIdsBX
match< GEMPadDigi > GEMPadDigiId
CSCCorrelatedLCTDigi secondLCT[MAX_LCT_BINS]
std::unique_ptr< GEMCoPadProcessor > coPadProcessor
virtual void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiCollection *gemPads)=0
virtual std::vector< std::pair< int, int > > get_csc_hs_to_gem_pad(Parity par, enum CSCPart) const =0
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int getBX() const
return BX
Definition: CSCCLCTDigi.h:51
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart)
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:30
unsigned int match_trig_enable
#define end
Definition: vmac.h:37
double p2[4]
Definition: TauolaWrapper.h:90
int getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
Definition: CSCALCTDigi.h:48
matches< T > matchingPads(const CSCALCTDigi &alct, enum CSCPart part)
matchesBX< GEMCoPadDigi > GEMCoPadDigiIdsBX
part
Definition: HCALResponse.h:20
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
unsigned int alct_trig_enable
virtual const CSCGEMMotherboardLUT * getLUT() const =0
unsigned int findQualityGEM(const CSCALCTDigi &, const CSCCLCTDigi &, int gemlayer)
GEMPadDigiIdsBX pads_
std::unique_ptr< CSCAnodeLCTProcessor > alct
#define begin
Definition: vmac.h:30
double p1[4]
Definition: TauolaWrapper.h:89
std::unique_ptr< CSCCathodeLCTProcessor > clct
matches< GEMPadDigi > GEMPadDigiIds
lctTypes
bool isPadInOverlap(int roll)
int getKeyStrip() const
Definition: CSCCLCTDigi.h:65
const GEMGeometry * gem_g
long double T
float getAvePad(const GEMPadDigi &)
int getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:45
void printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart)