CMS 3D CMS Logo

CSCMotherboardME3141.cc
Go to the documentation of this file.
3 
5  unsigned sector, unsigned subsector,
6  unsigned chamber,
7  const edm::ParameterSet& conf) :
8  CSCUpgradeMotherboard(endcap, station, sector, subsector, chamber, conf)
9  , allLCTs(match_trig_window_size)
10 {
11 }
12 
16 {
17 }
18 
20 {
21 }
22 
24 {
26 
27  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++) {
28  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++) {
29  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++) {
30  allLCTs(bx,mbx,i).clear();
31  }
32  }
33  }
34 }
35 
36 
37 void
39  const CSCComparatorDigiCollection* compdc)
40 {
41  clear();
42 
43  if (!( alct and clct))
44  {
45  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
46  << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
47  return;
48  }
49 
50  alct->setCSCGeometry(csc_g);
51  clct->setCSCGeometry(csc_g);
52 
53  alctV = alct->run(wiredc); // run anodeLCT
54  clctV = clct->run(compdc); // run cathodeLCT
55 
56  // if there are no ALCTs and no CLCTs, it does not make sense to run this TMB
57  if (alctV.empty() and clctV.empty()) return;
58 
59  int used_clct_mask[20];
60  for (int c=0;c<20;++c) used_clct_mask[c]=0;
61 
62  // ALCT centric matching
63  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++)
64  {
65  if (alct->bestALCT[bx_alct].isValid())
66  {
67  const int bx_clct_start(bx_alct - match_trig_window_size/2 - alctClctOffset);
68  const int bx_clct_stop(bx_alct + match_trig_window_size/2 - alctClctOffset);
69 
70  if (debug_matching){
71  LogTrace("CSCMotherboardME3141") << "========================================================================" << std::endl;
72  LogTrace("CSCMotherboardME3141") << "ALCT-CLCT matching in ME34/1 chamber: " << cscChamber->id() << std::endl;
73  LogTrace("CSCMotherboardME3141") << "------------------------------------------------------------------------" << std::endl;
74  LogTrace("CSCMotherboardME3141") << "+++ Best ALCT Details: ";
75  alct->bestALCT[bx_alct].print();
76  LogTrace("CSCMotherboardME3141") << "+++ Second ALCT Details: ";
77  alct->secondALCT[bx_alct].print();
78 
79  LogTrace("CSCMotherboardME3141") << "------------------------------------------------------------------------" << std::endl;
80  LogTrace("CSCMotherboardME3141") << "Attempt ALCT-CLCT matching in ME34/13 in bx range: [" << bx_clct_start << "," << bx_clct_stop << "]" << std::endl;
81  }
82 
83  // ALCT-to-CLCT
84  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
85  {
86  if (bx_clct < 0 or bx_clct >= CSCConstants::MAX_CLCT_TBINS) continue;
87  if (drop_used_clcts and used_clct_mask[bx_clct]) continue;
88  if (clct->bestCLCT[bx_clct].isValid())
89  {
90  if (debug_matching) LogTrace("CSCMotherboardME3141") << "++Valid ME21 CLCT: " << clct->bestCLCT[bx_clct] << std::endl;
91 
92  int mbx = bx_clct-bx_clct_start;
93  CSCMotherboardME3141::correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
94  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
95  allLCTs(bx_alct,mbx,0), allLCTs(bx_alct,mbx,1));
96  if (infoV > 1)
97  LogTrace("CSCMotherboardME3141") << "Successful ALCT-CLCT match in ME21: bx_alct = " << bx_alct
98  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
99  << "]; bx_clct = " << bx_clct << std::endl;
100  LogTrace("CSCMotherboardME3141") << "+++ Best CLCT Details: ";
101  clct->bestCLCT[bx_clct].print();
102  LogTrace("CSCMotherboardME3141") << "+++ Second CLCT Details: ";
103  clct->secondCLCT[bx_clct].print();
104  if (allLCTs(bx_alct,mbx,0).isValid()) {
105  used_clct_mask[bx_clct] += 1;
106  if (match_earliest_clct_only) break;
107  }
108  }
109  }
110  }
111  }
112 
113  // reduction of nLCTs per each BX
114  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
115  {
116  // counting
117  unsigned int n=0;
118  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
119  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
120  {
121  int cbx = bx + mbx - match_trig_window_size/2;
122  if (allLCTs(bx,mbx,i).isValid())
123  {
124  ++n;
125  if (infoV > 0) LogDebug("CSCMotherboardME3141")
126  << "LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs(bx,mbx,i)<<std::endl;
127  }
128  }
129 
130  // some simple cross-bx sorting algorithms
131  if (tmb_cross_bx_algo == 1 and (n>2))
132  {
133  n=0;
134  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
135  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
136  {
137  if (allLCTs(bx,pref[mbx],i).isValid())
138  {
139  n++;
140  if (n>2) allLCTs(bx,pref[mbx],i).clear();
141  }
142  }
143 
144  n=0;
145  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
146  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
147  {
148  int cbx = bx + mbx - match_trig_window_size/2;
149  if (allLCTs(bx,mbx,i).isValid())
150  {
151  n++;
152  if (infoV > 0) LogDebug("CSCMotherboardME3141")
153  << "LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs(bx,mbx,i)<< std::endl;
154  }
155  }
156  if (infoV > 0 and n>0) LogDebug("CSCMotherboardME3141")
157  <<"bx "<<bx<<" nnLCT:"<<n<<" "<<n<<std::endl;
158  } // x-bx sorting
159  }
160 
161  bool first = true;
162  unsigned int n=0;
163  for (const auto& p : readoutLCTs()) {
164  if (debug_matching and first){
165  LogTrace("CSCMotherboardME3141") << "========================================================================" << std::endl;
166  LogTrace("CSCMotherboardME3141") << "Counting the final LCTs" << std::endl;
167  LogTrace("CSCMotherboardME3141") << "========================================================================" << std::endl;
168  first = false;
169  LogTrace("CSCMotherboardME3141") << "tmb_cross_bx_algo: " << tmb_cross_bx_algo << std::endl;
170  }
171  n++;
172  if (debug_matching)
173  LogTrace("CSCMotherboardME3141") << "LCT "<<n<<" " << p <<std::endl;
174  }
175 }
176 
178  const CSCCLCTDigi& bCLCT, const CSCCLCTDigi& sCLCT,
179  CSCCorrelatedLCTDigi& lct1, CSCCorrelatedLCTDigi& lct2) const
180 {
181  CSCALCTDigi bestALCT = bALCT;
182  CSCALCTDigi secondALCT = sALCT;
183  CSCCLCTDigi bestCLCT = bCLCT;
184  CSCCLCTDigi secondCLCT = sCLCT;
185 
186  const bool anodeBestValid = bestALCT.isValid();
187  const bool anodeSecondValid = secondALCT.isValid();
188  const bool cathodeBestValid = bestCLCT.isValid();
189  const bool cathodeSecondValid = secondCLCT.isValid();
190 
191  if (anodeBestValid and !anodeSecondValid) secondALCT = bestALCT;
192  if (!anodeBestValid and anodeSecondValid) bestALCT = secondALCT;
193  if (cathodeBestValid and !cathodeSecondValid) secondCLCT = bestCLCT;
194  if (!cathodeBestValid and cathodeSecondValid) bestCLCT = secondCLCT;
195 
196  // ALCT-CLCT matching conditions are defined by "trig_enable" configuration
197  // parameters.
198  if ((alct_trig_enable and bestALCT.isValid()) or
199  (clct_trig_enable and bestCLCT.isValid()) or
200  (match_trig_enable and bestALCT.isValid() and bestCLCT.isValid())){
201  lct1 = constructLCTs(bestALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
202  }
203 
204  if (((secondALCT != bestALCT) or (secondCLCT != bestCLCT)) and
205  ((alct_trig_enable and secondALCT.isValid()) or
206  (clct_trig_enable and secondCLCT.isValid()) or
207  (match_trig_enable and secondALCT.isValid() and secondCLCT.isValid()))){
208  lct2 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
209  }
210 }
211 
212 //readout LCTs
213 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME3141::readoutLCTs() const
214 {
215  std::vector<CSCCorrelatedLCTDigi> result;
216  allLCTs.getMatched(result);
218  return result;
219 }
#define LogDebug(id)
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc)
unsigned int clct_trig_enable
unsigned int match_trig_window_size
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:37
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:30
unsigned int alctClctOffset
static bool sortLCTsByQuality(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
int pref[CSCConstants::MAX_LCT_TBINS]
const CSCChamber * cscChamber
std::vector< CSCALCTDigi > alctV
void sortLCTs(std::vector< CSCCorrelatedLCTDigi > &lcts, bool(*sorter)(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)) const
const CSCGeometry * csc_g
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
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:30
unsigned int match_trig_enable
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, int type, int trknmb) const
#define LogTrace(id)
void getMatched(std::vector< CSCCorrelatedLCTDigi > &) const
std::vector< CSCCLCTDigi > clctV
unsigned int alct_trig_enable
std::unique_ptr< CSCAnodeLCTProcessor > alct
std::unique_ptr< CSCCathodeLCTProcessor > clct
void correlateLCTs(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
std::vector< CSCCorrelatedLCTDigi > readoutLCTs() const