00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h>
00040 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00041 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00042
00043
00044 const unsigned int CSCMotherboard::def_mpc_block_me1a = 1;
00045 const unsigned int CSCMotherboard::def_alct_trig_enable = 0;
00046 const unsigned int CSCMotherboard::def_clct_trig_enable = 0;
00047 const unsigned int CSCMotherboard::def_match_trig_enable = 1;
00048 const unsigned int CSCMotherboard::def_match_trig_window_size = 7;
00049 const unsigned int CSCMotherboard::def_tmb_l1a_window_size = 7;
00050
00051 CSCMotherboard::CSCMotherboard(unsigned endcap, unsigned station,
00052 unsigned sector, unsigned subsector,
00053 unsigned chamber,
00054 const edm::ParameterSet& conf) :
00055 theEndcap(endcap), theStation(station), theSector(sector),
00056 theSubsector(subsector), theTrigChamber(chamber) {
00057
00058
00059 static bool config_dumped = false;
00060
00061
00062
00063
00064
00065 edm::ParameterSet commonParams =
00066 conf.getParameter<edm::ParameterSet>("commonParam");
00067 isMTCC = commonParams.getParameter<bool>("isMTCC");
00068
00069
00070 isTMB07 = commonParams.getParameter<bool>("isTMB07");
00071
00072
00073
00074
00075
00076 edm::ParameterSet alctParams, clctParams;
00077 if (isTMB07) {
00078 alctParams = conf.getParameter<edm::ParameterSet>("alctParam07");
00079 clctParams = conf.getParameter<edm::ParameterSet>("clctParam07");
00080 }
00081 else if (isMTCC) {
00082 alctParams = conf.getParameter<edm::ParameterSet>("alctParamMTCC");
00083 clctParams = conf.getParameter<edm::ParameterSet>("clctParamMTCC");
00084 }
00085 else {
00086 alctParams = conf.getParameter<edm::ParameterSet>("alctParamOldMC");
00087 clctParams = conf.getParameter<edm::ParameterSet>("clctParamOldMC");
00088 }
00089 alct = new CSCAnodeLCTProcessor(endcap, station, sector, subsector,
00090 chamber, alctParams, commonParams);
00091 clct = new CSCCathodeLCTProcessor(endcap, station, sector, subsector,
00092 chamber, clctParams, commonParams);
00093
00094
00095 edm::ParameterSet tmbParams =
00096 conf.getParameter<edm::ParameterSet>("tmbParam");
00097 mpc_block_me1a = tmbParams.getParameter<unsigned int>("mpcBlockMe1a");
00098 alct_trig_enable = tmbParams.getParameter<unsigned int>("alctTrigEnable");
00099 clct_trig_enable = tmbParams.getParameter<unsigned int>("clctTrigEnable");
00100 match_trig_enable = tmbParams.getParameter<unsigned int>("matchTrigEnable");
00101 match_trig_window_size =
00102 tmbParams.getParameter<unsigned int>("matchTrigWindowSize");
00103 tmb_l1a_window_size =
00104 tmbParams.getParameter<unsigned int>("tmbL1aWindowSize");
00105
00106 infoV = tmbParams.getUntrackedParameter<int>("verbosity", 0);
00107
00108
00109 checkConfigParameters();
00110 if (infoV > 0 && !config_dumped) {
00111 dumpConfigParams();
00112 config_dumped = true;
00113 }
00114
00115
00116
00117
00118 }
00119
00120 CSCMotherboard::CSCMotherboard() :
00121 theEndcap(1), theStation(1), theSector(1),
00122 theSubsector(1), theTrigChamber(1) {
00123
00124 static bool config_dumped = false;
00125
00126 isMTCC = false;
00127 isTMB07 = true;
00128
00129 alct = new CSCAnodeLCTProcessor();
00130 clct = new CSCCathodeLCTProcessor();
00131 mpc_block_me1a = def_mpc_block_me1a;
00132 alct_trig_enable = def_alct_trig_enable;
00133 clct_trig_enable = def_clct_trig_enable;
00134 match_trig_enable = def_match_trig_enable;
00135 match_trig_window_size = def_match_trig_window_size;
00136 tmb_l1a_window_size = def_tmb_l1a_window_size;
00137
00138 infoV = 2;
00139
00140
00141 checkConfigParameters();
00142 if (infoV > 0 && !config_dumped) {
00143 dumpConfigParams();
00144 config_dumped = true;
00145 }
00146 }
00147
00148 CSCMotherboard::~CSCMotherboard() {
00149 if (alct) delete alct;
00150 if (clct) delete clct;
00151 }
00152
00153 void CSCMotherboard::clear() {
00154 if (alct) alct->clear();
00155 if (clct) clct->clear();
00156 for (int bx = 0; bx < MAX_LCT_BINS; bx++) {
00157 firstLCT[bx].clear();
00158 secondLCT[bx].clear();
00159 }
00160 }
00161
00162
00163 void CSCMotherboard::setConfigParameters(const CSCDBL1TPParameters* conf) {
00164 static bool config_dumped = false;
00165
00166
00167 mpc_block_me1a = conf->tmbMpcBlockMe1a();
00168 alct_trig_enable = conf->tmbAlctTrigEnable();
00169 clct_trig_enable = conf->tmbClctTrigEnable();
00170 match_trig_enable = conf->tmbMatchTrigEnable();
00171 match_trig_window_size = conf->tmbMatchTrigWindowSize();
00172 tmb_l1a_window_size = conf->tmbTmbL1aWindowSize();
00173
00174
00175 alct->setConfigParameters(conf);
00176 clct->setConfigParameters(conf);
00177
00178
00179 checkConfigParameters();
00180 if (!config_dumped) {
00181 dumpConfigParams();
00182 config_dumped = true;
00183 }
00184 }
00185
00186 void CSCMotherboard::checkConfigParameters() {
00187
00188
00189
00190 static const unsigned int max_mpc_block_me1a = 1 << 1;
00191 static const unsigned int max_alct_trig_enable = 1 << 1;
00192 static const unsigned int max_clct_trig_enable = 1 << 1;
00193 static const unsigned int max_match_trig_enable = 1 << 1;
00194 static const unsigned int max_match_trig_window_size = 1 << 4;
00195 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
00196
00197
00198 if (mpc_block_me1a >= max_mpc_block_me1a) {
00199 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00200 << "+++ Value of mpc_block_me1a, " << mpc_block_me1a
00201 << ", exceeds max allowed, " << max_mpc_block_me1a-1 << " +++\n"
00202 << "+++ Try to proceed with the default value, mpc_block_me1a="
00203 << def_mpc_block_me1a << " +++\n";
00204 mpc_block_me1a = def_mpc_block_me1a;
00205 }
00206 if (alct_trig_enable >= max_alct_trig_enable) {
00207 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00208 << "+++ Value of alct_trig_enable, " << alct_trig_enable
00209 << ", exceeds max allowed, " << max_alct_trig_enable-1 << " +++\n"
00210 << "+++ Try to proceed with the default value, alct_trig_enable="
00211 << def_alct_trig_enable << " +++\n";
00212 alct_trig_enable = def_alct_trig_enable;
00213 }
00214 if (clct_trig_enable >= max_clct_trig_enable) {
00215 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00216 << "+++ Value of clct_trig_enable, " << clct_trig_enable
00217 << ", exceeds max allowed, " << max_clct_trig_enable-1 << " +++\n"
00218 << "+++ Try to proceed with the default value, clct_trig_enable="
00219 << def_clct_trig_enable << " +++\n";
00220 clct_trig_enable = def_clct_trig_enable;
00221 }
00222 if (match_trig_enable >= max_match_trig_enable) {
00223 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00224 << "+++ Value of match_trig_enable, " << match_trig_enable
00225 << ", exceeds max allowed, " << max_match_trig_enable-1 << " +++\n"
00226 << "+++ Try to proceed with the default value, match_trig_enable="
00227 << def_match_trig_enable << " +++\n";
00228 match_trig_enable = def_match_trig_enable;
00229 }
00230 if (match_trig_window_size >= max_match_trig_window_size) {
00231 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00232 << "+++ Value of match_trig_window_size, " << match_trig_window_size
00233 << ", exceeds max allowed, " << max_match_trig_window_size-1 << " +++\n"
00234 << "+++ Try to proceed with the default value, match_trig_window_size="
00235 << def_match_trig_window_size << " +++\n";
00236 match_trig_window_size = def_match_trig_window_size;
00237 }
00238 if (tmb_l1a_window_size >= max_tmb_l1a_window_size) {
00239 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorConfigError")
00240 << "+++ Value of tmb_l1a_window_size, " << tmb_l1a_window_size
00241 << ", exceeds max allowed, " << max_tmb_l1a_window_size-1 << " +++\n"
00242 << "+++ Try to proceed with the default value, tmb_l1a_window_size="
00243 << def_tmb_l1a_window_size << " +++\n";
00244 tmb_l1a_window_size = def_tmb_l1a_window_size;
00245 }
00246 }
00247
00248 void CSCMotherboard::run(
00249 const std::vector<int> w_times[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES],
00250 const std::vector<int> hs_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS],
00251 const std::vector<int> ds_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS]) {
00252
00253 clear();
00254 alct->run(w_times);
00255 clct->run(hs_times, ds_times);
00256
00257 int bx_alct_matched = 0;
00258 for (int bx_clct = 0; bx_clct < CSCCathodeLCTProcessor::MAX_CLCT_BINS;
00259 bx_clct++) {
00260 if (clct->bestCLCT[bx_clct].isValid()) {
00261 bool is_matched = false;
00262 int bx_alct_start = bx_clct - match_trig_window_size/2;
00263
00264
00265 int bx_alct_stop = bx_clct + match_trig_window_size/2 +
00266 match_trig_window_size%2;
00267 for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
00268 if (bx_alct < 0 || bx_alct >= CSCAnodeLCTProcessor::MAX_ALCT_BINS)
00269 continue;
00270 if (alct->bestALCT[bx_alct].isValid()) {
00271 correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
00272 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00273 is_matched = true;
00274 bx_alct_matched = bx_alct;
00275 break;
00276 }
00277 }
00278
00279
00280 if (!is_matched) {
00281 correlateLCTs(alct->bestALCT[bx_clct], alct->secondALCT[bx_clct],
00282 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00283 }
00284 }
00285
00286 else {
00287 int bx_alct = bx_clct - match_trig_window_size/2;
00288 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
00289 if (alct->bestALCT[bx_alct].isValid()) {
00290 correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
00291 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00292 }
00293 }
00294 }
00295 }
00296 }
00297
00298 std::vector<CSCCorrelatedLCTDigi>
00299 CSCMotherboard::run(const CSCWireDigiCollection* wiredc,
00300 const CSCComparatorDigiCollection* compdc) {
00301 clear();
00302 if (alct && clct) {
00303 {
00304 std::vector<CSCALCTDigi> alctV = alct->run(wiredc);
00305 }
00306 {
00307 std::vector<CSCCLCTDigi> clctV = clct->run(compdc);
00308 }
00309
00310 int bx_alct_matched = 0;
00311 for (int bx_clct = 0; bx_clct < CSCCathodeLCTProcessor::MAX_CLCT_BINS;
00312 bx_clct++) {
00313
00314
00315
00316
00317 if (clct->bestCLCT[bx_clct].isValid()) {
00318
00319
00320
00321
00322
00323
00324
00325
00326 bool is_matched = false;
00327 int bx_alct_start = bx_clct - match_trig_window_size/2;
00328
00329
00330 int bx_alct_stop = bx_clct + match_trig_window_size/2 +
00331 match_trig_window_size%2;
00332 for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
00333 if (bx_alct < 0 || bx_alct >= CSCAnodeLCTProcessor::MAX_ALCT_BINS)
00334 continue;
00335 if (alct->bestALCT[bx_alct].isValid()) {
00336 if (infoV > 1) LogTrace("CSCMotherboard")
00337 << "Successful ALCT-CLCT match: bx_clct = " << bx_clct
00338 << "; match window: [" << bx_alct_start << "; " << bx_alct_stop
00339 << "]; bx_alct = " << bx_alct;
00340 correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
00341 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00342 is_matched = true;
00343 bx_alct_matched = bx_alct;
00344 break;
00345 }
00346 }
00347
00348
00349 if (!is_matched) {
00350 if (infoV > 1) LogTrace("CSCMotherboard")
00351 << "Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = "
00352 << bx_clct << "; match window: [" << bx_alct_start
00353 << "; " << bx_alct_stop << "]";
00354 correlateLCTs(alct->bestALCT[bx_clct], alct->secondALCT[bx_clct],
00355 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00356 }
00357 }
00358
00359
00360
00361
00362 else {
00363 int bx_alct = bx_clct - match_trig_window_size/2;
00364 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
00365 if (alct->bestALCT[bx_alct].isValid()) {
00366 if (infoV > 1) LogTrace("CSCMotherboard")
00367 << "Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = "
00368 << bx_alct;
00369 correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
00370 clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct]);
00371 }
00372 }
00373 }
00374 }
00375
00376 if (infoV > 0) {
00377 for (int bx = 0; bx < MAX_LCT_BINS; bx++) {
00378 if (firstLCT[bx].isValid())
00379 LogDebug("CSCMotherboard") << firstLCT[bx];
00380 if (secondLCT[bx].isValid())
00381 LogDebug("CSCMotherboard") << secondLCT[bx];
00382 }
00383 }
00384 }
00385 else {
00386 if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
00387 << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
00388 }
00389
00390 std::vector<CSCCorrelatedLCTDigi> tmpV = readoutLCTs();
00391 return tmpV;
00392 }
00393
00394
00395
00396
00397 std::vector<CSCCorrelatedLCTDigi> CSCMotherboard::readoutLCTs() {
00398 std::vector<CSCCorrelatedLCTDigi> tmpV;
00399
00400
00401
00402
00403
00404 static int early_tbins = 4;
00405
00406
00407
00408
00409
00410
00411 static int lct_bins = tmb_l1a_window_size;
00412 static int late_tbins = early_tbins + lct_bins;
00413
00414 static int ifois = 0;
00415 if (ifois == 0) {
00416 if (infoV >= 0 && early_tbins < 0) {
00417 edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
00418 << "+++ early_tbins = " << early_tbins
00419 << "; in-time LCTs are not getting read-out!!! +++" << "\n";
00420 }
00421
00422 if (late_tbins > MAX_LCT_BINS-1) {
00423 if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
00424 << "+++ Allowed range of time bins, [0-" << late_tbins
00425 << "] exceeds max allowed, " << MAX_LCT_BINS-1 << " +++\n"
00426 << "+++ Set late_tbins to max allowed +++\n";
00427 late_tbins = MAX_LCT_BINS-1;
00428 }
00429 ifois = 1;
00430 }
00431
00432
00433
00434 int bx_readout = -1;
00435 std::vector<CSCCorrelatedLCTDigi> all_lcts = getLCTs();
00436 for (std::vector <CSCCorrelatedLCTDigi>::const_iterator plct =
00437 all_lcts.begin(); plct != all_lcts.end(); plct++) {
00438 if (!plct->isValid()) continue;
00439
00440 int bx = (*plct).getBX();
00441
00442 if (bx <= early_tbins) {
00443 if (infoV > 1) LogDebug("CSCMotherboard")
00444 << " Do not report correlated LCT on key halfstrip "
00445 << plct->getStrip() << " and key wire " << plct->getKeyWG()
00446 << ": found at bx " << bx << ", whereas the earliest allowed bx is "
00447 << early_tbins+1;
00448 continue;
00449 }
00450
00451
00452 if (bx > late_tbins) {
00453 if (infoV > 1) LogDebug("CSCMotherboard")
00454 << " Do not report correlated LCT on key halfstrip "
00455 << plct->getStrip() << " and key wire " << plct->getKeyWG()
00456 << ": found at bx " << bx << ", whereas the latest allowed bx is "
00457 << late_tbins;
00458 continue;
00459 }
00460
00461
00462
00463
00464 if (bx_readout == -1 || bx == bx_readout) {
00465 tmpV.push_back(*plct);
00466 if (bx_readout == -1) bx_readout = bx;
00467 }
00468 }
00469 return tmpV;
00470 }
00471
00472
00473 std::vector<CSCCorrelatedLCTDigi> CSCMotherboard::getLCTs() {
00474 std::vector<CSCCorrelatedLCTDigi> tmpV;
00475
00476 bool me11 = (theStation == 1 &&
00477 CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00478 theTrigChamber)==1);
00479
00480
00481 for (int bx = 0; bx < MAX_LCT_BINS; bx++) {
00482 if (firstLCT[bx].isValid())
00483 if (!mpc_block_me1a || (!me11 || firstLCT[bx].getStrip() <= 127))
00484 tmpV.push_back(firstLCT[bx]);
00485 if (secondLCT[bx].isValid())
00486 if (!mpc_block_me1a || (!me11 || secondLCT[bx].getStrip() <= 127))
00487 tmpV.push_back(secondLCT[bx]);
00488 }
00489 return tmpV;
00490 }
00491
00492 void CSCMotherboard::correlateLCTs(CSCALCTDigi bestALCT,
00493 CSCALCTDigi secondALCT,
00494 CSCCLCTDigi bestCLCT,
00495 CSCCLCTDigi secondCLCT) {
00496
00497 bool anodeBestValid = bestALCT.isValid();
00498 bool anodeSecondValid = secondALCT.isValid();
00499 bool cathodeBestValid = bestCLCT.isValid();
00500 bool cathodeSecondValid = secondCLCT.isValid();
00501
00502 if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
00503 if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
00504 if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
00505 if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
00506
00507
00508
00509 if ((alct_trig_enable && bestALCT.isValid()) ||
00510 (clct_trig_enable && bestCLCT.isValid()) ||
00511 (match_trig_enable && bestALCT.isValid() && bestCLCT.isValid())) {
00512 CSCCorrelatedLCTDigi lct = constructLCTs(bestALCT, bestCLCT);
00513 int bx = lct.getBX();
00514 if (bx >= 0 && bx < MAX_LCT_BINS) {
00515 firstLCT[bx] = lct;
00516 firstLCT[bx].setTrknmb(1);
00517 }
00518 else {
00519 if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeLCT")
00520 << "+++ Bx of first LCT candidate, " << bx
00521 << ", is not within the allowed range, [0-" << MAX_LCT_BINS-1
00522 << "); skipping it... +++\n";
00523 }
00524 }
00525
00526 if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
00527 ((alct_trig_enable && secondALCT.isValid()) ||
00528 (clct_trig_enable && secondCLCT.isValid()) ||
00529 (match_trig_enable && secondALCT.isValid() && secondCLCT.isValid()))) {
00530 CSCCorrelatedLCTDigi lct = constructLCTs(secondALCT, secondCLCT);
00531 int bx = lct.getBX();
00532 if (bx >= 0 && bx < MAX_LCT_BINS) {
00533 secondLCT[bx] = lct;
00534 secondLCT[bx].setTrknmb(2);
00535 }
00536 else {
00537 if (infoV > 0) edm::LogWarning("L1CSCTPEmulatorOutOfTimeLCT")
00538 << "+++ Bx of second LCT candidate, " << bx
00539 << ", is not within the allowed range, [0-" << MAX_LCT_BINS-1
00540 << "); skipping it... +++\n";
00541 }
00542 }
00543 }
00544
00545
00546
00547 CSCCorrelatedLCTDigi CSCMotherboard::constructLCTs(const CSCALCTDigi& aLCT,
00548 const CSCCLCTDigi& cLCT) {
00549
00550 unsigned int pattern = encodePattern(cLCT.getPattern(), cLCT.getStripType());
00551
00552
00553 unsigned int quality = findQuality(aLCT, cLCT);
00554
00555
00556 int bx = aLCT.isValid() ? aLCT.getBX() : cLCT.getBX();
00557
00558
00559 int trknmb = 0;
00560 CSCCorrelatedLCTDigi thisLCT(trknmb, 1, quality, aLCT.getKeyWG(),
00561 cLCT.getKeyStrip(), pattern, cLCT.getBend(),
00562 bx, 0, 0, 0, theTrigChamber);
00563 return thisLCT;
00564 }
00565
00566
00567
00568 unsigned int CSCMotherboard::encodePattern(const int ptn,
00569 const int stripType) {
00570 const int kPatternBitWidth = 4;
00571 unsigned int pattern;
00572
00573 if (!isTMB07) {
00574
00575 pattern = (abs(ptn) & ((1<<(kPatternBitWidth-1))-1));
00576
00577
00578
00579 if (stripType) {
00580 pattern = pattern | (1<<(kPatternBitWidth-1));
00581 }
00582 }
00583 else {
00584
00585 pattern = (abs(ptn) & ((1<<kPatternBitWidth)-1));
00586 }
00587
00588 return pattern;
00589 }
00590
00591
00592
00593
00594 unsigned int CSCMotherboard::findQuality(const CSCALCTDigi& aLCT,
00595 const CSCCLCTDigi& cLCT) {
00596 unsigned int quality = 0;
00597
00598 if (!isTMB07) {
00599 bool isDistrip = (cLCT.getStripType() == 0);
00600
00601 if (aLCT.isValid() && !(cLCT.isValid())) {
00602 if (aLCT.getAccelerator()) {quality = 1;}
00603 else {quality = 3;}
00604 }
00605 else if (!(aLCT.isValid()) && cLCT.isValid()) {
00606 if (isDistrip) {quality = 4;}
00607 else {quality = 5;}
00608 }
00609 else if (aLCT.isValid() && cLCT.isValid()) {
00610 if (aLCT.getAccelerator()) {quality = 2;}
00611 else {
00612
00613
00614 int sumQual = aLCT.getQuality() + (cLCT.getQuality()-3);
00615 if (sumQual < 1 || sumQual > 6) {
00616 if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
00617 << "+++ findQuality: sumQual = " << sumQual << "+++ \n";
00618 }
00619 if (isDistrip) {
00620 if (sumQual == 2) {quality = 6;}
00621 else if (sumQual == 3) {quality = 7;}
00622 else if (sumQual == 4) {quality = 8;}
00623 else if (sumQual == 5) {quality = 9;}
00624 else if (sumQual == 6) {quality = 10;}
00625 }
00626 else {
00627 if (sumQual == 2) {quality = 11;}
00628 else if (sumQual == 3) {quality = 12;}
00629 else if (sumQual == 4) {quality = 13;}
00630 else if (sumQual == 5) {quality = 14;}
00631 else if (sumQual == 6) {quality = 15;}
00632 }
00633 }
00634 }
00635 }
00636 #ifdef OLD
00637 else {
00638
00639
00640
00641
00642 if (!(aLCT.isValid()) || !(cLCT.isValid())) {
00643 if (aLCT.isValid() && !(cLCT.isValid())) quality = 1;
00644 else if (!(aLCT.isValid()) && cLCT.isValid()) quality = 2;
00645 else quality = 0;
00646 }
00647 else {
00648
00649
00650
00651 int sumQual = aLCT.getQuality() + (cLCT.getQuality()-3);
00652 if (sumQual < 1 || sumQual > 6) {
00653 if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
00654 << "+++ findQuality: Unexpected sumQual = " << sumQual << "+++\n";
00655 }
00656
00657
00658
00659
00660 int offset = 0;
00661 if (cLCT.getPattern() <= 7) offset = 4;
00662 else offset = 9;
00663 quality = offset + sumQual;
00664 }
00665 }
00666 #endif
00667 else {
00668
00669 if (!(aLCT.isValid()) || !(cLCT.isValid())) {
00670 if (aLCT.isValid() && !(cLCT.isValid())) quality = 1;
00671 else if (!(aLCT.isValid()) && cLCT.isValid()) quality = 2;
00672 else quality = 0;
00673 }
00674 else {
00675 int pattern = cLCT.getPattern();
00676 if (pattern == 1) quality = 3;
00677 else {
00678
00679
00680 bool a4 = (aLCT.getQuality() >= 1);
00681 bool c4 = (cLCT.getQuality() >= 4);
00682
00683 if (!a4 && !c4) quality = 5;
00684 else if ( a4 && !c4) quality = 6;
00685 else if (!a4 && c4) quality = 7;
00686 else if ( a4 && c4) {
00687 if (aLCT.getAccelerator()) quality = 8;
00688 else {
00689
00690
00691 if (pattern == 2 || pattern == 3) quality = 11;
00692 else if (pattern == 4 || pattern == 5) quality = 12;
00693 else if (pattern == 6 || pattern == 7) quality = 13;
00694 else if (pattern == 8 || pattern == 9) quality = 14;
00695 else if (pattern == 10) quality = 15;
00696 else {
00697 if (infoV >= 0) edm::LogWarning("L1CSCTPEmulatorWrongValues")
00698 << "+++ findQuality: Unexpected CLCT pattern id = "
00699 << pattern << "+++\n";
00700 }
00701 }
00702 }
00703 }
00704 }
00705 }
00706 return quality;
00707 }
00708
00709 void CSCMotherboard::testLCT() {
00710 unsigned int lctPattern, lctQuality;
00711 for (int pattern = 0; pattern < 8; pattern++) {
00712 for (int bend = 0; bend < 2; bend++) {
00713 for (int cfeb = 0; cfeb < 5; cfeb++) {
00714 for (int strip = 0; strip < 32; strip++) {
00715 for (int bx = 0; bx < 7; bx++) {
00716 for (int stripType = 0; stripType < 2; stripType++) {
00717 for (int quality = 3; quality < 7; quality++) {
00718 CSCCLCTDigi cLCT(1, quality, pattern, stripType, bend,
00719 strip, cfeb, bx);
00720 lctPattern = encodePattern(cLCT.getPattern(),
00721 cLCT.getStripType());
00722 for (int aQuality = 0; aQuality < 4; aQuality++) {
00723 for (int wireGroup = 0; wireGroup < 120; wireGroup++) {
00724 for (int abx = 0; abx < 7; abx++) {
00725 CSCALCTDigi aLCT(1, aQuality, 0, 1, wireGroup, abx);
00726 lctQuality = findQuality(aLCT, cLCT);
00727 CSCCorrelatedLCTDigi
00728 thisLCT(0, 1, lctQuality, aLCT.getKeyWG(),
00729 cLCT.getKeyStrip(), lctPattern, cLCT.getBend(),
00730 aLCT.getBX());
00731 if (lctPattern != static_cast<unsigned int>(thisLCT.getPattern()) )
00732 LogTrace("CSCMotherboard")
00733 << "pattern mismatch: " << lctPattern
00734 << " " << thisLCT.getPattern();
00735 if (bend != thisLCT.getBend())
00736 LogTrace("CSCMotherboard")
00737 << "bend mismatch: " << bend
00738 << " " << thisLCT.getBend();
00739 int key_strip = 32*cfeb + strip;
00740 if (key_strip != thisLCT.getStrip())
00741 LogTrace("CSCMotherboard")
00742 << "strip mismatch: " << key_strip
00743 << " " << thisLCT.getStrip();
00744 if (wireGroup != thisLCT.getKeyWG())
00745 LogTrace("CSCMotherboard")
00746 << "wire group mismatch: " << wireGroup
00747 << " " << thisLCT.getKeyWG();
00748 if (abx != thisLCT.getBX())
00749 LogTrace("CSCMotherboard")
00750 << "bx mismatch: " << abx << " " << thisLCT.getBX();
00751 if (lctQuality != static_cast<unsigned int>(thisLCT.getQuality()))
00752 LogTrace("CSCMotherboard")
00753 << "quality mismatch: " << lctQuality
00754 << " " << thisLCT.getQuality();
00755 }
00756 }
00757 }
00758 }
00759 }
00760 }
00761 }
00762 }
00763 }
00764 }
00765 }
00766
00767 void CSCMotherboard::dumpConfigParams() const {
00768 std::ostringstream strm;
00769 strm << "\n";
00770 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
00771 strm << "+ TMB configuration parameters: +\n";
00772 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
00773 strm << " mpc_block_me1a [block/not block triggers which come from ME1/A] = "
00774 << mpc_block_me1a << "\n";
00775 strm << " alct_trig_enable [allow ALCT-only triggers] = "
00776 << alct_trig_enable << "\n";
00777 strm << " clct_trig_enable [allow CLCT-only triggers] = "
00778 << clct_trig_enable << "\n";
00779 strm << " match_trig_enable [allow matched ALCT-CLCT triggers] = "
00780 << match_trig_enable << "\n";
00781 strm << " match_trig_window_size [ALCT-CLCT match window width, in 25 ns] = "
00782 << match_trig_window_size << "\n";
00783 strm << " tmb_l1a_window_size [L1Accept window width, in 25 ns bins] = "
00784 << tmb_l1a_window_size << "\n";
00785 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
00786 LogDebug("CSCMotherboard") << strm.str();
00787 }