CMS 3D CMS Logo

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