CMS 3D CMS Logo

CSCMotherboardME3141RPC.cc
Go to the documentation of this file.
8 #include "boost/container/flat_set.hpp"
9 
11 { 0,2.421},{ 1,2.415},{ 2,2.406},{ 3,2.397},{ 4,2.388},{ 5,2.379},{ 6,2.371},{ 7,2.362},
12 { 8,2.353},{ 9,2.345},{10,2.336},{11,2.328},{12,2.319},{13,2.311},{14,2.303},{15,2.295},
13 {16,2.287},{17,2.279},{18,2.271},{19,2.263},{20,2.255},{21,2.248},{22,2.240},{23,2.232},
14 {24,2.225},{25,2.217},{26,2.210},{27,2.203},{28,2.195},{29,2.188},{30,2.181},{31,2.174},
15 {32,2.169},{33,2.157},{34,2.151},{35,2.142},{36,2.134},{37,2.126},{38,2.118},{39,2.110},
16 {40,2.102},{41,2.094},{42,2.087},{43,2.079},{44,2.071},{45,2.064},{46,2.056},{47,2.049},
17 {48,2.041},{49,2.034},{50,2.027},{51,2.019},{52,2.012},{53,2.005},{54,1.998},{55,1.991},
18 {56,1.984},{57,1.977},{58,1.970},{59,1.964},{60,1.957},{61,1.950},{62,1.944},{63,1.937},
19 {64,1.932},{65,1.922},{66,1.917},{67,1.911},{68,1.905},{69,1.898},{70,1.892},{71,1.886},
20 {72,1.880},{73,1.874},{74,1.868},{75,1.861},{76,1.855},{77,1.850},{78,1.844},{79,1.838},
21 {80,1.832},{81,1.826},{82,1.820},{83,1.815},{84,1.809},{85,1.803},{86,1.798},{87,1.792},
22 {88,1.787},{89,1.781},{90,1.776},{91,1.770},{92,1.765},{93,1.759},{94,1.754},{95,1.749},
23 };
24 
26 { 0,2.447},{ 1,2.441},{ 2,2.432},{ 3,2.423},{ 4,2.414},{ 5,2.405},{ 6,2.396},{ 7,2.388},
27 { 8,2.379},{ 9,2.371},{10,2.362},{11,2.354},{12,2.345},{13,2.337},{14,2.329},{15,2.321},
28 {16,2.313},{17,2.305},{18,2.297},{19,2.289},{20,2.281},{21,2.273},{22,2.266},{23,2.258},
29 {24,2.251},{25,2.243},{26,2.236},{27,2.228},{28,2.221},{29,2.214},{30,2.207},{31,2.200},
30 {32,2.195},{33,2.183},{34,2.176},{35,2.168},{36,2.160},{37,2.152},{38,2.144},{39,2.136},
31 {40,2.128},{41,2.120},{42,2.112},{43,2.104},{44,2.097},{45,2.089},{46,2.082},{47,2.074},
32 {48,2.067},{49,2.059},{50,2.052},{51,2.045},{52,2.038},{53,2.031},{54,2.023},{55,2.016},
33 {56,2.009},{57,2.003},{58,1.996},{59,1.989},{60,1.982},{61,1.975},{62,1.969},{63,1.962},
34 {64,1.957},{65,1.948},{66,1.943},{67,1.936},{68,1.930},{69,1.924},{70,1.917},{71,1.911},
35 {72,1.905},{73,1.899},{74,1.893},{75,1.887},{76,1.881},{77,1.875},{78,1.869},{79,1.863},
36 {80,1.857},{81,1.851},{82,1.845},{83,1.840},{84,1.834},{85,1.828},{86,1.823},{87,1.817},
37 {88,1.811},{89,1.806},{90,1.800},{91,1.795},{92,1.790},{93,1.784},{94,1.779},{95,1.774},
38 };
39 
41 { 0,2.399},{ 1,2.394},{ 2,2.386},{ 3,2.378},{ 4,2.370},{ 5,2.362},{ 6,2.354},{ 7,2.346},
42 { 8,2.339},{ 9,2.331},{10,2.323},{11,2.316},{12,2.308},{13,2.301},{14,2.293},{15,2.286},
43 {16,2.279},{17,2.272},{18,2.264},{19,2.257},{20,2.250},{21,2.243},{22,2.236},{23,2.229},
44 {24,2.223},{25,2.216},{26,2.209},{27,2.202},{28,2.196},{29,2.189},{30,2.183},{31,2.176},
45 {32,2.172},{33,2.161},{34,2.157},{35,2.150},{36,2.144},{37,2.138},{38,2.132},{39,2.126},
46 {40,2.119},{41,2.113},{42,2.107},{43,2.101},{44,2.095},{45,2.089},{46,2.083},{47,2.078},
47 {48,2.072},{49,2.066},{50,2.060},{51,2.055},{52,2.049},{53,2.043},{54,2.038},{55,2.032},
48 {56,2.027},{57,2.021},{58,2.016},{59,2.010},{60,2.005},{61,1.999},{62,1.994},{63,1.989},
49 {64,1.985},{65,1.977},{66,1.973},{67,1.968},{68,1.963},{69,1.958},{70,1.953},{71,1.947},
50 {72,1.942},{73,1.937},{74,1.932},{75,1.928},{76,1.923},{77,1.918},{78,1.913},{79,1.908},
51 {80,1.903},{81,1.898},{82,1.894},{83,1.889},{84,1.884},{85,1.879},{86,1.875},{87,1.870},
52 {88,1.866},{89,1.861},{90,1.856},{91,1.852},{92,1.847},{93,1.843},{94,1.838},{95,1.834},
53 };
54 
56 { 0,2.423},{ 1,2.418},{ 2,2.410},{ 3,2.402},{ 4,2.394},{ 5,2.386},{ 6,2.378},{ 7,2.370},
57 { 8,2.362},{ 9,2.355},{10,2.347},{11,2.339},{12,2.332},{13,2.324},{14,2.317},{15,2.310},
58 {16,2.302},{17,2.295},{18,2.288},{19,2.281},{20,2.274},{21,2.267},{22,2.260},{23,2.253},
59 {24,2.246},{25,2.239},{26,2.233},{27,2.226},{28,2.219},{29,2.213},{30,2.206},{31,2.199},
60 {32,2.195},{33,2.185},{34,2.180},{35,2.174},{36,2.168},{37,2.161},{38,2.155},{39,2.149},
61 {40,2.143},{41,2.137},{42,2.131},{43,2.125},{44,2.119},{45,2.113},{46,2.107},{47,2.101},
62 {48,2.095},{49,2.089},{50,2.084},{51,2.078},{52,2.072},{53,2.067},{54,2.061},{55,2.055},
63 {56,2.050},{57,2.044},{58,2.039},{59,2.033},{60,2.028},{61,2.023},{62,2.017},{63,2.012},
64 {64,2.008},{65,2.000},{66,1.996},{67,1.991},{68,1.986},{69,1.981},{70,1.976},{71,1.971},
65 {72,1.966},{73,1.961},{74,1.956},{75,1.951},{76,1.946},{77,1.941},{78,1.936},{79,1.931},
66 {80,1.926},{81,1.921},{82,1.917},{83,1.912},{84,1.907},{85,1.902},{86,1.898},{87,1.893},
67 {88,1.889},{89,1.884},{90,1.879},{91,1.875},{92,1.870},{93,1.866},{94,1.861},{95,1.857},
68 };
69 
70 // LUT with bending angles of the RPC-CSC high efficiency patterns (98%)
71 // 1st index: pt value = {5,10,15,20,30,40}
72 // 2nd index: bending angle for odd numbered chambers
73 // 3rd index: bending angle for even numbered chambers
75  {3., 0.02203511, 0.00930056},
76  {5., 0.02203511, 0.00930056},
77  {7 , 0.0182579 , 0.00790009},
78  {10., 0.01066000, 0.00483286},
79  {15., 0.00722795, 0.00363230},
80  {20., 0.00562598, 0.00304878},
81  {30., 0.00416544, 0.00253782},
82  {40., 0.00342827, 0.00230833} };
83 
85  {3., 0.02203511, 0.00930056},
86  {5., 0.02203511, 0.00930056},
87  {7 , 0.0182579 , 0.00790009},
88  {10., 0.01066000, 0.00483286},
89  {15., 0.00722795, 0.00363230},
90  {20., 0.00562598, 0.00304878},
91  {30., 0.00416544, 0.00253782},
92  {40., 0.00342827, 0.00230833} };
93 
95  unsigned sector, unsigned subsector,
96  unsigned chamber,
97  const edm::ParameterSet& conf) :
98  CSCMotherboard(endcap, station, sector, subsector, chamber, conf)
99 {
100  const edm::ParameterSet commonParams(conf.getParameter<edm::ParameterSet>("commonParam"));
101  runME3141ILT_ = commonParams.getParameter<bool>("runME3141ILT");
102 
103  if (!isSLHC) edm::LogError("L1CSCTPEmulatorConfigError")
104  << "+++ Upgrade CSCMotherboardME3141RPC constructed while isSLHC is not set! +++\n";
105 
106  const edm::ParameterSet me3141tmbParams(conf.getParameter<edm::ParameterSet>("me3141tmbSLHCRPC"));
107 
108  // whether to not reuse CLCTs that were used by previous matching ALCTs
109  // in ALCT-to-CLCT algorithm
110  drop_used_clcts = me3141tmbParams.getParameter<bool>("tmbDropUsedClcts");
111 
112  match_earliest_clct_me3141_only = me3141tmbParams.getParameter<bool>("matchEarliestClctME3141Only");
113 
114  tmb_cross_bx_algo = me3141tmbParams.getParameter<unsigned int>("tmbCrossBxAlgorithm");
115 
116  // maximum lcts per BX in ME2
117  max_me3141_lcts = me3141tmbParams.getParameter<unsigned int>("maxME3141LCTs");
118 
120  for (unsigned int m=2; m<match_trig_window_size; m+=2)
121  {
122  pref[m-1] = pref[0] - m/2;
123  pref[m] = pref[0] + m/2;
124  }
125 
126  //----------------------------------------------------------------------------------------//
127 
128  // R P C - C S C I N T E G R A T E D L O C A L A L G O R I T H M
129 
130  //----------------------------------------------------------------------------------------//
131 
132  // debug
133  debug_luts_ = me3141tmbParams.getParameter<bool>("debugLUTs");
134  debug_rpc_matching_ = me3141tmbParams.getParameter<bool>("debugMatching");
135 
136  // deltas used to match to RPC digis
137  maxDeltaBXRPC_ = me3141tmbParams.getParameter<int>("maxDeltaBXRPC");
138  maxDeltaStripRPCOdd_ = me3141tmbParams.getParameter<int>("maxDeltaStripRPCOdd");
139  maxDeltaStripRPCEven_ = me3141tmbParams.getParameter<int>("maxDeltaStripRPCEven");
140  maxDeltaWg_ = me3141tmbParams.getParameter<int>("maxDeltaWg");
141 
142  // use "old" or "new" dataformat for integrated LCTs?
143  useOldLCTDataFormat_ = me3141tmbParams.getParameter<bool>("useOldLCTDataFormat");
144 
145  // drop low quality stubs if they don't have RPCs
146  dropLowQualityCLCTsNoRPCs_ = me3141tmbParams.getParameter<bool>("dropLowQualityCLCTsNoRPCs");
147 
148  // build LCT from CLCT and RPC
149  buildLCTfromALCTandRPC_ = me3141tmbParams.getParameter<bool>("buildLCTfromALCTandRPC");
150  buildLCTfromCLCTandRPC_ = me3141tmbParams.getParameter<bool>("buildLCTfromCLCTandRPC");
151  buildLCTfromLowQstubandRPC_ = me3141tmbParams.getParameter<bool>("buildLCTfromLowQstubandRPC");
152 
153  // promote ALCT-RPC pattern
154  promoteALCTRPCpattern_ = me3141tmbParams.getParameter<bool>("promoteALCTRPCpattern");
155 
156  // promote ALCT-CLCT-RPC quality
157  promoteALCTRPCquality_ = me3141tmbParams.getParameter<bool>("promoteALCTRPCquality");
158  promoteCLCTRPCquality_ = me3141tmbParams.getParameter<bool>("promoteCLCTRPCquality");
159 }
160 
162 {
163 }
164 
166 {
168 
169  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
170  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
171  for (int i=0;i<2;i++)
172  allLCTs[bx][mbx][i].clear();
173 
174  rpcRollToEtaLimits_.clear();
175  cscWgToRpcRoll_.clear();
176  rpcStripToCscHs_.clear();
177  cscHsToRpcStrip_.clear();
178  rpcDigis_.clear();
179 }
180 
181 void
183  const CSCComparatorDigiCollection* compdc,
184  const RPCDigiCollection* rpcDigis)
185 {
186  clear();
187 
188  if (!( alct and clct and runME3141ILT_))
189  {
190  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
191  << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
192  return;
193  }
194 
195  alctV = alct->run(wiredc); // run anodeLCT
196  clctV = clct->run(compdc); // run cathodeLCT
197 
198  bool rpcGeometryAvailable(false);
199  if (rpc_g != nullptr) {
200  if (infoV >= 0) edm::LogInfo("L1CSCTPEmulatorSetupInfo")
201  << "+++ run() called for RPC-CSC integrated trigger! +++ \n";
202  rpcGeometryAvailable = true;
203  }
204  const bool hasCorrectRPCGeometry((not rpcGeometryAvailable) or (rpcGeometryAvailable and not hasRE31andRE41()));
205 
206  // retrieve CSCChamber geometry
208  const CSCChamber* cscChamber(geo_manager->chamber(theEndcap, theStation, theSector, theSubsector, theTrigChamber));
209  const CSCDetId csc_id(cscChamber->id());
210 
211  // trigger geometry
212  const CSCLayer* keyLayer(cscChamber->layer(3));
213  const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
214  const int region((theEndcap == 1) ? 1: -1);
215  const bool isEven(csc_id.chamber()%2==0);
216  const int csc_trig_sect(CSCTriggerNumbering::triggerSectorFromLabels(csc_id));
217  const int csc_trig_id( CSCTriggerNumbering::triggerCscIdFromLabels(csc_id));
218  const int csc_trig_chid((3*(csc_trig_sect-1)+csc_trig_id)%18 +1);
219  const int rpc_trig_sect((csc_trig_chid-1)/3+1);
220  const int rpc_trig_subsect((csc_trig_chid-1)%3+1);
221  const RPCDetId rpc_id(region,1,theStation,rpc_trig_sect,1,rpc_trig_subsect,0);
222  const RPCChamber* rpcChamber(rpc_g->chamber(rpc_id));
223 
224  if (runME3141ILT_){
225 
226  // check for RE3/1-RE4/1 geometry
227  if (hasCorrectRPCGeometry) {
228  if (infoV >= 0) edm::LogInfo("L1CSCTPEmulatorSetupError")
229  << "+++ run() called for RPC-CSC integrated trigger without valid RPC geometry! +++ \n";
230  return;
231  }
232 
233  // LUT<roll,<etaMin,etaMax> >
235 
236  if (debug_luts_){
237  std::cout << "RPC det " <<rpc_id<<" CSC det "<< csc_id << std::endl;
238  for (const auto& p : rpcRollToEtaLimits_) {
239  std::cout << "roll "<< p.first << " min eta " << (p.second).first << " max eta " << (p.second).second << std::endl;
240  }
241  }
242 
243  // loop on all wiregroups to create a LUT <WG,roll>
244  const int numberOfWG(keyLayerGeometry->numberOfWireGroups());
245  for (int i = 0; i< numberOfWG; ++i){
246  auto eta(theStation==3 ?
247  (isEven ? lut_wg_me31_eta_even[i][1] : lut_wg_me31_eta_odd[i][1]) :
248  (isEven ? lut_wg_me41_eta_even[i][1] : lut_wg_me41_eta_odd[i][1]));
250  }
251  if (debug_luts_){
252  for (const auto& p : cscWgToRpcRoll_) {
253  auto eta(theStation==3 ?
254  (isEven ? lut_wg_me31_eta_even[p.first][1] : lut_wg_me31_eta_odd[p.first][1]) :
255  (isEven ? lut_wg_me41_eta_even[p.first][1] : lut_wg_me41_eta_odd[p.first][1]));
256 
257  std::cout << "WG "<< p.first << " RPC roll " << p.second << " "
258  << rpcRollToEtaLimits_[p.second].first << " "
259  << rpcRollToEtaLimits_[p.second].second << " " << eta << std::endl;
260  }
261  }
262 
263  // pick any roll
264  auto randRoll(rpcChamber->roll(2));
265 
266  auto nStrips(keyLayerGeometry->numberOfStrips());
267  for (float i = 0; i< nStrips; i = i+0.5){
268  const LocalPoint lpCSC(keyLayerGeometry->topology()->localPosition(i));
269  const GlobalPoint gp(keyLayer->toGlobal(lpCSC));
270  const LocalPoint lpRPC(randRoll->toLocal(gp));
271  const int HS(i/0.5);
272  const bool edge(HS < 5 or HS > 155);
273  const float strip(edge ? -99 : randRoll->strip(lpRPC));
274  // HS are wrapped-around
275  cscHsToRpcStrip_[HS] = std::make_pair(std::floor(strip),std::ceil(strip));
276  }
277  if (debug_luts_){
278  std::cout << "detId " << csc_id << std::endl;
279  std::cout << "CSCHSToRPCStrip LUT in" << std::endl;
280  for (const auto& p : cscHsToRpcStrip_) {
281  std::cout << "CSC HS "<< p.first << " RPC Strip low " << (p.second).first << " RPC Strip high " << (p.second).second << std::endl;
282  }
283  }
284 
285  const int nRPCStrips(randRoll->nstrips());
286  for (int i = 0; i< nRPCStrips; ++i){
287  const LocalPoint lpRPC(randRoll->centreOfStrip(i));
288  const GlobalPoint gp(randRoll->toGlobal(lpRPC));
289  const LocalPoint lpCSC(keyLayer->toLocal(gp));
290  const float strip(keyLayerGeometry->strip(lpCSC));
291  // HS are wrapped-around
292  rpcStripToCscHs_[i] = (int) (strip - 0.25)/0.5;
293  }
294  if (debug_luts_){
295  std::cout << "detId " << csc_id << std::endl;
296  std::cout << "RPCStripToCSCHs LUT" << std::endl;
297  for (const auto& p : rpcStripToCscHs_) {
298  std::cout << "RPC Strip "<< p.first << " CSC HS: " << p.second << std::endl;
299  }
300  }
301  //select correct scenarios, even or odd
303 
304  rpcDigis_.clear();
305  retrieveRPCDigis(rpcDigis, rpc_id.rawId());
306  }
307 
308  const bool hasRPCDigis(!rpcDigis_.empty());
309 
310  int used_clct_mask[20];
311  for (int c=0;c<20;++c) used_clct_mask[c]=0;
312 
313  // ALCT centric matching
314  for (int bx_alct = 0; bx_alct < CSCAnodeLCTProcessor::MAX_ALCT_BINS; bx_alct++)
315  {
316  if (alct->bestALCT[bx_alct].isValid())
317  {
318  const int bx_clct_start(bx_alct - match_trig_window_size/2);
319  const int bx_clct_stop(bx_alct + match_trig_window_size/2);
320  if (debug_rpc_matching_){
321  std::cout << "========================================================================" << std::endl;
322  std::cout << "ALCT-CLCT matching in ME" << theStation << "/1 chamber: " << csc_id << std::endl;
323  std::cout << "------------------------------------------------------------------------" << std::endl;
324  std::cout << "+++ Best ALCT Details: " << alct->bestALCT[bx_alct] << std::endl;
325  std::cout << "+++ Second ALCT Details: " << alct->secondALCT[bx_alct] << std::endl;
326  std::cout << "------------------------------------------------------------------------" << std::endl;
327  if (hasRPCDigis) std::cout << "RPC Chamber " << rpc_id << std::endl;
328  if (hasRPCDigis) printRPCTriggerDigis(bx_clct_start, bx_clct_stop);
329 
330  std::cout << "------------------------------------------------------------------------" << std::endl;
331  std::cout << "Attempt ALCT-CLCT matching in ME" << theStation << "/1 in bx range: [" << bx_clct_start << "," << bx_clct_stop << "]" << std::endl;
332  }
333 
334  // low quality ALCT
335  const bool lowQualityALCT(alct->bestALCT[bx_alct].getQuality() == 0);
336 
337  // ALCT-to-CLCT
338  int nSuccesFulMatches = 0;
339  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
340  if (bx_clct < 0 or bx_clct >= CSCCathodeLCTProcessor::MAX_CLCT_BINS) continue;
341  if (drop_used_clcts and used_clct_mask[bx_clct]) continue;
342  if (clct->bestCLCT[bx_clct].isValid()) {
343 
344  // pick the digi that corresponds
345  auto matchingDigis(matchingRPCDigis(clct->bestCLCT[bx_clct], alct->bestALCT[bx_alct], rpcDigis_[bx_alct], false));
346 
347  // clct quality
348  const int quality(clct->bestCLCT[bx_clct].getQuality());
349  // low quality ALCT or CLCT
350  const bool lowQuality(quality<4 or lowQualityALCT);
351 
352  if (runME3141ILT_ and dropLowQualityCLCTsNoRPCs_ and lowQuality and hasRPCDigis){
353  int nFound(!matchingDigis.empty());
354  const bool clctInEdge(clct->bestCLCT[bx_clct].getKeyStrip() < 5 or clct->bestCLCT[bx_clct].getKeyStrip() > 155);
355  if (clctInEdge){
356  if (debug_rpc_matching_) std::cout << "\tInfo: low quality ALCT or CLCT in CSC chamber edge, don't care about RPC digis" << std::endl;
357  }
358  else {
359  if (nFound != 0){
360  if (debug_rpc_matching_) std::cout << "\tInfo: low quality ALCT or CLCT with " << nFound << " matching RPC trigger digis" << std::endl;
361  }
362  else {
363  if (debug_rpc_matching_) std::cout << "\tWarning: low quality ALCT or CLCT without matching RPC trigger digi" << std::endl;
364  continue;
365  }
366  }
367  }
368 
369  int mbx = bx_clct-bx_clct_start;
370  correlateLCTsRPC(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
371  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
372  allLCTs[bx_alct][mbx][0], allLCTs[bx_alct][mbx][1], matchingDigis);
373  ++nSuccesFulMatches;
374  if (debug_rpc_matching_) {
375  // if (infoV > 1) LogTrace("CSCMotherboard")
376  std::cout
377  << "Successful ALCT-CLCT match: bx_clct = " << bx_clct
378  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
379  << "]; bx_alct = " << bx_alct << std::endl;
380  std::cout << "+++ Best CLCT Details: " << clct->secondCLCT[bx_clct]<< std::endl;
381  std::cout << "+++ Second CLCT Details: " << clct->secondCLCT[bx_clct]<< std::endl;
382  }
383  if (allLCTs[bx_alct][mbx][0].isValid()) {
384  used_clct_mask[bx_clct] += 1;
386  }
387  }
388  }
389  // ALCT-RPC digi matching
390  int nSuccesFulRPCMatches = 0;
391  if (runME3141ILT_ and nSuccesFulMatches==0 and buildLCTfromALCTandRPC_ and hasRPCDigis){
392  if (debug_rpc_matching_) std::cout << "++No valid ALCT-CLCT matches in ME"<<theStation<<"1" << std::endl;
393  for (int bx_rpc = bx_clct_start; bx_rpc <= bx_clct_stop; bx_rpc++) {
394  if (lowQualityALCT and !buildLCTfromLowQstubandRPC_) continue; // build lct from low-Q ALCTs and rpc if para is set true
395  if (not hasRPCDigis) continue;
396 
397  // find the best matching copad - first one
398  auto digis(matchingRPCDigis(alct->bestALCT[bx_alct], rpcDigis_[bx_rpc], true));
399  if (debug_rpc_matching_) std::cout << "\t++Number of matching RPC Digis in BX " << bx_alct << " : "<< digis.size() << std::endl;
400  if (digis.empty()) continue;
401 
402  correlateLCTsRPC(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
403  digis.at(0).second, allLCTs[bx_alct][0][0], allLCTs[bx_alct][0][1]);
404  if (allLCTs[bx_alct][0][0].isValid()) {
405  ++nSuccesFulRPCMatches;
407  }
408  if (debug_rpc_matching_) {
409  std::cout << "Successful ALCT-RPC digi match in ME"<<theStation<<"1: bx_alct = " << bx_alct << std::endl << std::endl;
410  std::cout << "------------------------------------------------------------------------" << std::endl << std::endl;
411  }
412  }
413  }
414  }
415  else{
416  auto digis(rpcDigis_[bx_alct]);
417  if (runME3141ILT_ and !digis.empty() and buildLCTfromCLCTandRPC_) {
418  //const int bx_clct_start(bx_alct - match_trig_window_size/2);
419  //const int bx_clct_stop(bx_alct + match_trig_window_size/2);
420  // RPC-to-CLCT
421  int nSuccesFulMatches = 0;
422  // for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
423  // {
424  // if (bx_clct < 0 or bx_clct >= CSCCathodeLCTProcessor::MAX_CLCT_BINS) continue;
425  if (drop_used_clcts and used_clct_mask[bx_alct]) continue;
426  if (clct->bestCLCT[bx_alct].isValid())
427  {
428  if (debug_rpc_matching_){
429  std::cout << "========================================================================" << std::endl;
430  std::cout << "RPC-CLCT matching in ME" << theStation << "/1 chamber: " << cscChamber->id() << " in bx: "<<bx_alct<< std::endl;
431  std::cout << "------------------------------------------------------------------------" << std::endl;
432  }
433  const int quality(clct->bestCLCT[bx_alct].getQuality());
434  // we also use low-Q stubs for the time being
435  if (quality < 4 and !buildLCTfromLowQstubandRPC_) continue;
436 
437  ++nSuccesFulMatches;
438 
439  int mbx = std::abs(clct->bestCLCT[bx_alct].getBX()-bx_alct);
440  int bx_rpc = lct_central_bx;
441  correlateLCTsRPC(clct->bestCLCT[bx_alct], clct->secondCLCT[bx_alct], digis[0].second, RPCDetId(digis[0].first).roll(),
442  allLCTs[bx_rpc][mbx][0], allLCTs[bx_rpc][mbx][1]);
443  if (debug_rpc_matching_) {
444  // if (infoV > 1) LogTrace("CSCMotherboard")
445  std::cout << "Successful RPC-CLCT match in ME"<<theStation<<"/1: bx_alct = " << bx_alct
446  << std::endl;
447  std::cout << "+++ Best CLCT Details: "<< clct->bestCLCT[bx_alct]<< std::endl;
448  std::cout << "+++ Second CLCT Details: " << clct->secondCLCT[bx_alct]<< std::endl;
449  }
450  if (allLCTs[bx_rpc][mbx][0].isValid()) {
451  used_clct_mask[bx_alct] += 1;
453  }
454  }
455  }
456  }
457  }
458 
459  // reduction of nLCTs per each BX
460  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
461  {
462  // counting
463  unsigned int n=0;
464  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
465  for (int i=0;i<2;i++)
466  {
467  int cbx = bx + mbx - match_trig_window_size/2;
468  if (allLCTs[bx][mbx][i].isValid())
469  {
470  ++n;
471  if (infoV > 0) LogDebug("CSCMotherboard")
472  << "LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs[bx][mbx][i]<<std::endl;
473  }
474  }
475 
476  // some simple cross-bx sorting algorithms
477  if (tmb_cross_bx_algo == 1 and (n>2))
478  {
479  n=0;
480  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
481  for (int i=0;i<2;i++)
482  {
483  if (allLCTs[bx][pref[mbx]][i].isValid())
484  {
485  n++;
486  if (n>2) allLCTs[bx][pref[mbx]][i].clear();
487  }
488  }
489 
490  n=0;
491  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
492  for (int i=0;i<2;i++)
493  {
494  int cbx = bx + mbx - match_trig_window_size/2;
495  if (allLCTs[bx][mbx][i].isValid())
496  {
497  n++;
498  if (infoV > 0) LogDebug("CSCMotherboard")
499  << "LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs[bx][mbx][i]<<std::endl;
500  }
501  }
502  if (infoV > 0 and n>0) LogDebug("CSCMotherboard")
503  <<"bx "<<bx<<" nnLCT:"<<n<<" "<<n<<std::endl;
504  } // x-bx sorting
505  }
506 
507  bool first = true;
508  unsigned int n=0;
509  for (const auto& p : readoutLCTs()) {
510  if (debug_rpc_matching_ and first){
511  std::cout << "========================================================================" << std::endl;
512  std::cout << "Counting the final LCTs" << std::endl;
513  std::cout << "========================================================================" << std::endl;
514  first = false;
515  std::cout << "tmb_cross_bx_algo: " << tmb_cross_bx_algo << std::endl;
516  }
517  n++;
519  std::cout << "LCT "<<n<<" " << p <<std::endl;
520  }
521 }
522 
523 // check that the RE31 and RE41 chambers are really there
525 {
526  // just pick two random chambers
527  auto aRE31(rpc_g->chamber(RPCDetId(1,1,3,2,1,1,0)));
528  auto aRE41(rpc_g->chamber(RPCDetId(-1,1,4,3,1,2,0)));
529  return aRE31 and aRE41;
530 }
531 
532 
533 std::map<int,std::pair<double,double> > CSCMotherboardME3141RPC::createRPCRollLUT(RPCDetId id)
534 {
535  std::map<int,std::pair<double,double> > result;
536 
537  auto chamber(rpc_g->chamber(id));
538  if (chamber==nullptr) return result;
539 
540  for(int i = 1; i<= chamber->nrolls(); ++i){
541  auto roll(chamber->roll(i));
542  if (roll==nullptr) continue;
543 
544  const float half_striplength(roll->specs()->specificTopology().stripLength()/2.);
545  const LocalPoint lp_top(0., half_striplength, 0.);
546  const LocalPoint lp_bottom(0., -half_striplength, 0.);
547  const GlobalPoint gp_top(roll->toGlobal(lp_top));
548  const GlobalPoint gp_bottom(roll->toGlobal(lp_bottom));
549  //result[i] = std::make_pair(floorf(gp_top.eta() * 100) / 100, ceilf(gp_bottom.eta() * 100) / 100);
550  result[i] = std::make_pair(std::abs(gp_top.eta()), std::abs(gp_bottom.eta()));
551  }
552  return result;
553 }
554 
555 
557 {
558  int result = -99;
559  for (const auto& p : rpcRollToEtaLimits_) {
560  const float minEta((p.second).first);
561  const float maxEta((p.second).second);
562  if (minEta <= eta and eta <= maxEta) {
563  result = p.first;
564  break;
565  }
566  }
567  return result;
568 }
569 
570 
572 {
573  if (rpcDigis == nullptr) return;
574 
575  auto chamber(rpc_g->chamber(RPCDetId(id)));
576  for (auto roll : chamber->rolls()) {
577  RPCDetId roll_id(roll->id());
578  auto digis_in_det = rpcDigis->get(roll_id);
579  for (auto digi = digis_in_det.first; digi != digis_in_det.second; ++digi) {
580  const int bx_shifted(lct_central_bx + digi->bx());
581  for (int bx = bx_shifted - maxDeltaBXRPC_;bx <= bx_shifted + maxDeltaBXRPC_; ++bx) {
582  rpcDigis_[bx].push_back(std::make_pair(roll_id(), *digi));
583  }
584  }
585  }
586 }
587 
588 
589 void CSCMotherboardME3141RPC::printRPCTriggerDigis(int bx_start, int bx_stop)
590 {
591  std::cout << "------------------------------------------------------------------------" << std::endl;
592  bool first = true;
593  for (int bx = bx_start; bx <= bx_stop; bx++) {
594  std::vector<std::pair<unsigned int, const RPCDigi> > in_strips = rpcDigis_[bx];
595  if (first) {
596  std::cout << "* RPC trigger digis: " << std::endl;
597  }
598  first = false;
599  std::cout << "N(digis) BX " << bx << " : " << in_strips.size() << std::endl;
600  for (const auto& digi : in_strips){
601  const auto roll_id(RPCDetId(digi.first));
602  std::cout << "\tdetId " << digi.first << " " << roll_id << ", digi = " << digi.second.strip() << ", BX = " << digi.second.bx() + 6 << std::endl;
603  }
604  }
605 }
606 
607 
610 {
612 
613  const int lowStrip(cscHsToRpcStrip_[clct.getKeyStrip()].first);
614  const int highStrip(cscHsToRpcStrip_[clct.getKeyStrip()].second);
615  const bool debug(false);
616  if (debug) std::cout << "lowStrip " << lowStrip << " highStrip " << highStrip << " delta strip " << maxDeltaStripRPC_ <<std::endl;
617  for (const auto& p: digis){
618  auto strip((p.second).strip());
619  if (debug) std::cout << "strip " << strip << std::endl;
620  if (std::abs(lowStrip - strip) <= maxDeltaStripRPC_ or std::abs(strip - highStrip) <= maxDeltaStripRPC_){
621  if (debug) std::cout << "++Matches! " << std::endl;
622  result.push_back(p);
623  if (first) return result;
624  }
625  }
626  return result;
627 }
628 
629 
632 {
634 
635  int Wg = alct.getKeyWG();
636  std::vector<int> Rolls;
637  Rolls.push_back(cscWgToRpcRoll_[Wg]);
639  Rolls.push_back(cscWgToRpcRoll_[Wg-maxDeltaWg_]);
640  if ((unsigned int)(Wg+maxDeltaWg_)<cscWgToRpcRoll_.size() && cscWgToRpcRoll_[Wg] != cscWgToRpcRoll_[Wg+maxDeltaWg_])
641  Rolls.push_back(cscWgToRpcRoll_[Wg+maxDeltaWg_]);
642 
643  const bool debug(false);
644  if (debug) std::cout << "ALCT keyWG " << alct.getKeyWG() << std::endl;
645  for (auto alctRoll : Rolls)
646  {
647  if (debug) std::cout << " roll " << alctRoll << std::endl;
648  for (const auto& p: digis){
649  auto digiRoll(RPCDetId(p.first).roll());
650  if (debug) std::cout << "Candidate ALCT: " << digiRoll << std::endl;
651  if (alctRoll != digiRoll) continue;
652  if (debug) std::cout << "++Matches! " << std::endl;
653  result.push_back(p);
654  if (first) return result;
655  }
656  }
657  return result;
658 }
659 
660 
663 {
665 
666  // Fetch all (!) digis matching to ALCTs and CLCTs
667  auto digisClct(matchingRPCDigis(clct, digis, false));
668  auto digisAlct(matchingRPCDigis(alct, digis, false));
669 
670  const bool debug(false);
671  if (debug) std::cout << "-----------------------------------------------------------------------"<<std::endl;
672  // Check if the digis overlap
673  for (const auto& p : digisAlct){
674  if (debug) std::cout<< "Candidate RPC digis for ALCT: " << p.first << " " << p.second << std::endl;
675  for (auto q: digisClct){
676  if (debug) std::cout<< "++Candidate RPC digis for CLCT: " << q.first << " " << q.second << std::endl;
677  // look for exactly the same digis
678  if (p.first != q.first) continue;
679  // if (not RPCDigi(*(p.second))==*(q.second)) continue;
680  if (debug) std::cout << "++Matches! " << std::endl;
681  result.push_back(p);
682  if (first) return result;
683  }
684  }
685  if (debug) std::cout << "-----------------------------------------------------------------------"<<std::endl;
686  return result;
687 }
688 
689 unsigned int CSCMotherboardME3141RPC::findQualityRPC(const CSCALCTDigi& aLCT, const CSCCLCTDigi& cLCT, bool hasRPC)
690 {
691 
692  /*
693  Same LCT quality definition as standard LCTs
694  a4 and c4 takes RPCs into account!!!
695  */
696 
697  unsigned int quality = 0;
698 
699  if (!isTMB07) {
700  bool isDistrip = (cLCT.getStripType() == 0);
701 
702  if (aLCT.isValid() && !(cLCT.isValid())) { // no CLCT
703  if (aLCT.getAccelerator()) {quality = 1;}
704  else {quality = 3;}
705  }
706  else if (!(aLCT.isValid()) && cLCT.isValid()) { // no ALCT
707  if (isDistrip) {quality = 4;}
708  else {quality = 5;}
709  }
710  else if (aLCT.isValid() && cLCT.isValid()) { // both ALCT and CLCT
711  if (aLCT.getAccelerator()) {quality = 2;} // accelerator muon
712  else { // collision muon
713  // CLCT quality is, in fact, the number of layers hit, so subtract 3
714  // to get quality analogous to ALCT one.
715  int sumQual = aLCT.getQuality() + (cLCT.getQuality()-3);
716  if (sumQual < 1 || sumQual > 6) {
717  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
718  << "+++ findQuality: sumQual = " << sumQual << "+++ \n";
719  }
720  if (isDistrip) { // distrip pattern
721  if (sumQual == 2) {quality = 6;}
722  else if (sumQual == 3) {quality = 7;}
723  else if (sumQual == 4) {quality = 8;}
724  else if (sumQual == 5) {quality = 9;}
725  else if (sumQual == 6) {quality = 10;}
726  }
727  else { // halfstrip pattern
728  if (sumQual == 2) {quality = 11;}
729  else if (sumQual == 3) {quality = 12;}
730  else if (sumQual == 4) {quality = 13;}
731  else if (sumQual == 5) {quality = 14;}
732  else if (sumQual == 6) {quality = 15;}
733  }
734  }
735  }
736  }
737 #ifdef OLD
738  else {
739  // Temporary definition, used until July 2008.
740  // First if statement is fictitious, just to help the CSC TF emulator
741  // handle such cases (one needs to make sure they will be accounted for
742  // in the new quality definition.
743  if (!(aLCT.isValid()) || !(cLCT.isValid())) {
744  if (aLCT.isValid() && !(cLCT.isValid())) quality = 1; // no CLCT
745  else if (!(aLCT.isValid()) && cLCT.isValid()) quality = 2; // no ALCT
746  else quality = 0; // both absent; should never happen.
747  }
748  else {
749  // Sum of ALCT and CLCT quality bits. CLCT quality is, in fact, the
750  // number of layers hit, so subtract 3 to put it to the same footing as
751  // the ALCT quality.
752  int sumQual = aLCT.getQuality() + (cLCT.getQuality()-3);
753  if (sumQual < 1 || sumQual > 6) {
754  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
755  << "+++ findQuality: Unexpected sumQual = " << sumQual << "+++\n";
756  }
757 
758  // LCT quality is basically the sum of ALCT and CLCT qualities, but split
759  // in two groups depending on the CLCT pattern id (higher quality for
760  // straighter patterns).
761  int offset = 0;
762  if (cLCT.getPattern() <= 7) offset = 4;
763  else offset = 9;
764  quality = offset + sumQual;
765  }
766  }
767 #endif
768  else {
769  // 2008 definition.
770  if (!(aLCT.isValid()) || !(cLCT.isValid())) {
771  if (aLCT.isValid() && !(cLCT.isValid())) quality = 1; // no CLCT
772  else if (!(aLCT.isValid()) && cLCT.isValid()) quality = 2; // no ALCT
773  else quality = 0; // both absent; should never happen.
774  }
775  else {
776  const int pattern(cLCT.getPattern());
777  if (pattern == 1) quality = 3; // layer-trigger in CLCT
778  else {
779  // ALCT quality is the number of layers hit minus 3.
780  // CLCT quality is the number of layers hit.
781  int n_rpc = 0;
782  if (hasRPC) n_rpc = 1;
783  const bool a4((aLCT.getQuality() >= 1 and aLCT.getQuality() != 4) or
784  (aLCT.getQuality() == 4 and n_rpc >=1));
785  const bool c4((cLCT.getQuality() >= 4) or (cLCT.getQuality() >= 3 and n_rpc>=1));
786  // quality = 4; "reserved for low-quality muons in future"
787  if (!a4 && !c4) quality = 5; // marginal anode and cathode
788  else if ( a4 && !c4) quality = 6; // HQ anode, but marginal cathode
789  else if (!a4 && c4) quality = 7; // HQ cathode, but marginal anode
790  else if ( a4 && c4) {
791  if (aLCT.getAccelerator()) quality = 8; // HQ muon, but accel ALCT
792  else {
793  // quality = 9; "reserved for HQ muons with future patterns
794  // quality = 10; "reserved for HQ muons with future patterns
795  if (pattern == 2 || pattern == 3) quality = 11;
796  else if (pattern == 4 || pattern == 5) quality = 12;
797  else if (pattern == 6 || pattern == 7) quality = 13;
798  else if (pattern == 8 || pattern == 9) quality = 14;
799  else if (pattern == 10) quality = 15;
800  else {
801  if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
802  << "+++ findQuality: Unexpected CLCT pattern id = "
803  << pattern << "+++\n";
804  }
805  }
806  }
807  }
808  }
809  }
810  return quality;
811 }
812 
813 
815  CSCCLCTDigi secondCLCT,
816  RPCDigi rpcDigi, int roll,
817  CSCCorrelatedLCTDigi& lct1,
818  CSCCorrelatedLCTDigi& lct2)
819 {
820  bool cathodeBestValid = bestCLCT.isValid();
821  bool cathodeSecondValid = secondCLCT.isValid();
822 
823  if (cathodeBestValid and !cathodeSecondValid) secondCLCT = bestCLCT;
824  if (!cathodeBestValid and cathodeSecondValid) bestCLCT = secondCLCT;
825 
826  if ((clct_trig_enable and bestCLCT.isValid()) or
827  (match_trig_enable and bestCLCT.isValid()))
828  {
829  lct1 = constructLCTsRPC(bestCLCT, rpcDigi, roll, useOldLCTDataFormat_);
830  lct1.setTrknmb(1);
831  }
832 
833  if ((clct_trig_enable and secondCLCT.isValid()) or
834  (match_trig_enable and secondCLCT.isValid() and secondCLCT != bestCLCT))
835  {
836  lct2 = constructLCTsRPC(secondCLCT, rpcDigi, roll, useOldLCTDataFormat_);
837  lct2.setTrknmb(2);
838  }
839 }
840 
841 
843  CSCALCTDigi secondALCT,
844  RPCDigi rpcDigi,
845  CSCCorrelatedLCTDigi& lct1,
846  CSCCorrelatedLCTDigi& lct2)
847 {
848  bool anodeBestValid = bestALCT.isValid();
849  bool anodeSecondValid = secondALCT.isValid();
850 
851  if (anodeBestValid and !anodeSecondValid) secondALCT = bestALCT;
852  if (!anodeBestValid and anodeSecondValid) bestALCT = secondALCT;
853 
854  if ((alct_trig_enable and bestALCT.isValid()) or
855  (match_trig_enable and bestALCT.isValid()))
856  {
857  lct1 = constructLCTsRPC(bestALCT, rpcDigi, useOldLCTDataFormat_);
858  lct1.setTrknmb(1);
859  }
860 
861  if ((alct_trig_enable and secondALCT.isValid()) or
862  (match_trig_enable and secondALCT.isValid() and secondALCT != bestALCT))
863  {
864  lct2 = constructLCTsRPC(secondALCT, rpcDigi, useOldLCTDataFormat_);
865  lct2.setTrknmb(2);
866  }
867 }
868 
869 
871  CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT,
873  const RPCDigisBX& digis)
874 {
875  bool anodeBestValid = bestALCT.isValid();
876  bool anodeSecondValid = secondALCT.isValid();
877  bool cathodeBestValid = bestCLCT.isValid();
878  bool cathodeSecondValid = secondCLCT.isValid();
879 
880  if (anodeBestValid and !anodeSecondValid) secondALCT = bestALCT;
881  if (!anodeBestValid and anodeSecondValid) bestALCT = secondALCT;
882  if (cathodeBestValid and !cathodeSecondValid) secondCLCT = bestCLCT;
883  if (!cathodeBestValid and cathodeSecondValid) bestCLCT = secondCLCT;
884 
885  // ALCT-CLCT matching conditions are defined by "trig_enable" configuration
886  // parameters.
887  if ((alct_trig_enable and bestALCT.isValid()) or
888  (clct_trig_enable and bestCLCT.isValid()) or
889  (match_trig_enable and bestALCT.isValid() and bestCLCT.isValid())){
890  lct1 = constructLCTsRPC(bestALCT, bestCLCT, digis);
891  lct1.setTrknmb(1);
892  }
893 
894  if (((secondALCT != bestALCT) or (secondCLCT != bestCLCT)) and
895  ((alct_trig_enable and secondALCT.isValid()) or
896  (clct_trig_enable and secondCLCT.isValid()) or
897  (match_trig_enable and secondALCT.isValid() and secondCLCT.isValid()))){
898  lct2 = constructLCTsRPC(secondALCT, secondCLCT, digis);
899  lct2.setTrknmb(2);
900  }
901 }
902 
904 {
905  // CLCT pattern number
906  unsigned int pattern = encodePattern(cLCT.getPattern(), cLCT.getStripType());
907 
908  // LCT quality number
909  unsigned int quality = findQualityRPC(aLCT, cLCT, !digis.empty());
910 
911  // Bunch crossing: get it from cathode LCT if anode LCT is not there.
912  int bx = aLCT.isValid() ? aLCT.getBX() : cLCT.getBX();
913  if (!digis.empty()) bx = lct_central_bx + digis[0].second.bx(); // fix this!!!
914 
915  // construct correlated LCT; temporarily assign track number of 0.
916  int trknmb = 0;
917  CSCCorrelatedLCTDigi thisLCT(trknmb, 1, quality, aLCT.getKeyWG(),
918  cLCT.getKeyStrip(), pattern, cLCT.getBend(),
919  bx, 0, 0, 0, theTrigChamber);
920  return thisLCT;
921 }
922 
923 
925  const RPCDigi& rpc, int roll,
926  bool oldDataFormat)
927 {
928  if (oldDataFormat){
929  // CLCT pattern number - for the time being, do not include RPCs in the pattern
930  unsigned int pattern = encodePattern(clct.getPattern(), clct.getStripType());
931 
932  // LCT quality number - dummy quality
933  unsigned int quality = promoteCLCTRPCquality_ ? 14 : 11;
934 
935  // Bunch crossing: pick RPC bx
936  int bx = rpc.bx() + lct_central_bx;
937 
938  // pick a random WG in the roll range
939  int wg(4);
940 
941  // construct correlated LCT; temporarily assign track number of 0.
942  return CSCCorrelatedLCTDigi(0, 1, quality, wg, clct.getKeyStrip(), pattern, clct.getBend(), bx, 0, 0, 0, theTrigChamber);
943  }
944  else {
945  // CLCT pattern number - no pattern
946  unsigned int pattern = 0;//encodePatternRPC(clct.getPattern(), clct.getStripType());
947 
948  // LCT quality number - dummy quality
949  unsigned int quality = 5;//findQualityRPC(alct, rpc);
950 
951  // Bunch crossing: get it from cathode LCT if anode LCT is not there.
952  int bx = rpc.bx() + lct_central_bx;;
953 
954  // ALCT WG
955  int wg(0);
956 
957  // construct correlated LCT; temporarily assign track number of 0.
958  return CSCCorrelatedLCTDigi(0, 1, quality, wg, 0, pattern, 0, bx, 0, 0, 0, theTrigChamber);
959  }
960 }
961 
962 
964  const RPCDigi& rpc,
965  bool oldDataFormat)
966 {
967  if (oldDataFormat){
968  // CLCT pattern number - set it to a highest value
969  // hack to get LCTs in the CSCTF
970  unsigned int pattern = promoteALCTRPCpattern_ ? 10 : 0;
971 
972  // LCT quality number - set it to a very high value
973  // hack to get LCTs in the CSCTF
974  unsigned int quality = promoteALCTRPCquality_ ? 14 : 11;
975 
976  // Bunch crossing
977  int bx = rpc.bx() + lct_central_bx;
978 
979  // get keyStrip from LUT
980  int keyStrip = rpcStripToCscHs_[rpc.strip()];
981 
982  // get wiregroup from ALCT
983  int wg = alct.getKeyWG();
984 
985  // construct correlated LCT; temporarily assign track number of 0.
986  return CSCCorrelatedLCTDigi(0, 1, quality, wg, keyStrip, pattern, 0, bx, 0, 0, 0, theTrigChamber);
987  }
988  else {
989  // CLCT pattern number - no pattern
990  unsigned int pattern = 0;
991 
992  // LCT quality number
993  unsigned int quality = 1;
994 
995  // Bunch crossing
996  int bx = rpc.bx() + lct_central_bx;
997 
998  // get keyStrip from LUT
999  int keyStrip = rpcStripToCscHs_[rpc.strip()];
1000  // get wiregroup from ALCT
1001  int wg = alct.getKeyWG();
1002 
1003  // construct correlated LCT; temporarily assign track number of 0.
1004  return CSCCorrelatedLCTDigi(0, 1, quality, wg, keyStrip, pattern, 0, bx, 0, 0, 0, theTrigChamber);
1005  }
1006 }
1007 
1008 
1009 //readout LCTs
1010 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME3141RPC::readoutLCTs()
1011 {
1012  return getLCTs();
1013 }
1014 
1015 //getLCTs when we use different sort algorithm
1016 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME3141RPC::getLCTs()
1017 {
1018  std::vector<CSCCorrelatedLCTDigi> result;
1019  for (int bx = 0; bx < MAX_LCT_BINS; bx++) {
1020  std::vector<CSCCorrelatedLCTDigi> tmpV;
1021  if (tmb_cross_bx_algo == 3) {
1022  tmpV = sortLCTsByQuality(bx);
1023  result.insert(result.end(), tmpV.begin(), tmpV.end());
1024  }
1025  else {
1026  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
1027  for (int i=0;i<2;i++) {
1028  if (allLCTs[bx][mbx][i].isValid()) {
1029  result.push_back(allLCTs[bx][mbx][i]);
1030  }
1031  }
1032  }
1033  }
1034  }
1035  return result;
1036 }
1037 
1038 //sort LCTs by Quality in each BX
1039 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME3141RPC::sortLCTsByQuality(int bx)
1040 {
1041  std::vector<CSCCorrelatedLCTDigi> LCTs;
1042  LCTs.clear();
1043  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
1044  for (int i=0;i<2;i++)
1045  if (allLCTs[bx][mbx][i].isValid())
1046  LCTs.push_back(allLCTs[bx][mbx][i]);
1047 
1048  // return sorted vector with 2 highest quality LCTs
1049  std::sort(LCTs.begin(), LCTs.end(), CSCMotherboard::sortByQuality);
1050  if (LCTs.size()> max_me3141_lcts) LCTs.erase(LCTs.begin()+max_me3141_lcts, LCTs.end());
1051  return LCTs;
1052 }
#define LogDebug(id)
int getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:33
const unsigned theSector
T getParameter(std::string const &) const
static const double lut_wg_me41_eta_odd[96][2]
std::map< int, int > cscWgToRpcRoll_
CSCMotherboardME3141RPC(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, const edm::ParameterSet &conf)
std::map< int, int > rpcStripToCscHs_
unsigned int clct_trig_enable
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
std::vector< CSCCLCTDigi > clctV
unsigned int match_trig_window_size
int bx() const
Definition: RPCDigi.h:29
const unsigned theTrigChamber
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:30
const unsigned theEndcap
double maxEta
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
std::vector< CSCCorrelatedLCTDigi > sortLCTsByQuality(int bx)
int getStripType() const
return striptype
Definition: CSCCLCTDigi.h:39
int getBend() const
return bend
Definition: CSCCLCTDigi.h:42
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
U second(std::pair< T, U > const &p)
const RPCChamber * chamber(RPCDetId id) const
Definition: RPCGeometry.cc:71
void printRPCTriggerDigis(int minBX, int maxBx)
int strip() const
Definition: RPCDigi.h:28
int roll() const
Definition: RPCDetId.h:120
const unsigned theStation
static CSCTriggerGeomManager * get()
std::map< int, std::pair< double, double > > createRPCRollLUT(RPCDetId id)
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
std::map< int, std::pair< int, int > > cscHsToRpcStrip_
const unsigned theSubsector
int getBX() const
return BX
Definition: CSCCLCTDigi.h:51
static const double lut_wg_me41_eta_even[96][2]
unsigned int encodePattern(const int ptn, const int highPt)
static const double lut_pt_vs_dphi_rpccsc_me41[8][3]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:30
unsigned int match_trig_enable
static const double lut_wg_me31_eta_odd[96][2]
static int triggerCscIdFromLabels(int station, int ring, int chamber)
static const double lut_pt_vs_dphi_rpccsc_me31[8][3]
int getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
Definition: CSCALCTDigi.h:48
std::map< int, std::pair< double, double > > rpcRollToEtaLimits_
int getQuality() const
return quality of a pattern
Definition: CSCALCTDigi.h:33
#define debug
Definition: HDRShower.cc:19
CSCCorrelatedLCTDigi allLCTs[MAX_LCT_BINS][15][2]
int getAccelerator() const
Definition: CSCALCTDigi.h:37
static int triggerSectorFromLabels(int station, int ring, int chamber)
int getPattern() const
return pattern
Definition: CSCCLCTDigi.h:36
RPCDigisBX matchingRPCDigis(const CSCCLCTDigi &cLCT, const RPCDigisBX &digis=RPCDigisBX(), bool first=true)
unsigned int alct_trig_enable
std::vector< RPCDigiBX > RPCDigisBX
std::unique_ptr< CSCAnodeLCTProcessor > alct
void correlateLCTsRPC(CSCALCTDigi bestALCT, CSCALCTDigi secondALCT, CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2, const RPCDigisBX &digis=RPCDigisBX())
std::unique_ptr< CSCCathodeLCTProcessor > clct
std::vector< CSCALCTDigi > alctV
int getKeyStrip() const
Definition: CSCCLCTDigi.h:65
std::vector< CSCCorrelatedLCTDigi > getLCTs()
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const RPCDigiCollection *rpcDigis)
void retrieveRPCDigis(const RPCDigiCollection *digis, unsigned id)
unsigned int findQualityRPC(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, bool hasRPC)
int getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:45
CSCCorrelatedLCTDigi constructLCTsRPC(const CSCALCTDigi &alct, const CSCCLCTDigi &clct, const RPCDigisBX &digis=RPCDigisBX())
static bool sortByQuality(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
static const double lut_wg_me31_eta_even[96][2]