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 #include <L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h>
00031 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h>
00032 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00033
00034 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00035 #include <FWCore/Utilities/interface/Exception.h>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 const int CSCAnodeLCTProcessor::pattern_envelope[CSCConstants::NUM_ALCT_PATTERNS][NUM_PATTERN_WIRES] = {
00046
00047 { 0, 0, 0,
00048 1, 1,
00049 2,
00050 3, 3,
00051 4, 4, 4,
00052 5, 5, 5},
00053
00054
00055 {-2, -1, 0,
00056 -1, 0,
00057 0,
00058 0, 1,
00059 0, 1, 2,
00060 0, 1, 2},
00061
00062
00063 {2, 1, 0,
00064 1, 0,
00065 0,
00066 0, -1,
00067 0, -1, -2,
00068 0, -1, -2}
00069 };
00070
00071
00072
00073 const int CSCAnodeLCTProcessor::pattern_mask_default[CSCConstants::NUM_ALCT_PATTERNS][NUM_PATTERN_WIRES] = {
00074
00075 {0, 0, 1,
00076 0, 1,
00077 1,
00078 1, 0,
00079 1, 0, 0,
00080 1, 0, 0},
00081
00082
00083 {0, 1, 0,
00084 1, 1,
00085 1,
00086 1, 0,
00087 0, 1, 0,
00088 0, 1, 0},
00089
00090
00091 {1, 1, 0,
00092 1, 1,
00093 1,
00094 1, 1,
00095 0, 1, 1,
00096 0, 0, 1}
00097 };
00098
00099
00100
00101 const int CSCAnodeLCTProcessor::pattern_mask_MTCC[CSCConstants::NUM_ALCT_PATTERNS][NUM_PATTERN_WIRES] = {
00102
00103 {0, 0, 1,
00104 0, 1,
00105 1,
00106 1, 0,
00107 1, 0, 0,
00108 1, 0, 0},
00109
00110
00111 {1, 1, 1,
00112 1, 1,
00113 1,
00114 1, 1,
00115 1, 1, 1,
00116 1, 1, 1},
00117
00118
00119 {1, 1, 1,
00120 1, 1,
00121 1,
00122 1, 1,
00123 1, 1, 1,
00124 1, 1, 1}
00125 };
00126
00127
00128 const unsigned int CSCAnodeLCTProcessor::def_fifo_tbins = 16;
00129 const unsigned int CSCAnodeLCTProcessor::def_fifo_pretrig = 10;
00130 const unsigned int CSCAnodeLCTProcessor::def_drift_delay = 2;
00131 const unsigned int CSCAnodeLCTProcessor::def_nplanes_hit_pretrig = 2;
00132 const unsigned int CSCAnodeLCTProcessor::def_nplanes_hit_pattern = 4;
00133 const unsigned int CSCAnodeLCTProcessor::def_nplanes_hit_accel_pretrig = 2;
00134 const unsigned int CSCAnodeLCTProcessor::def_nplanes_hit_accel_pattern = 4;
00135 const unsigned int CSCAnodeLCTProcessor::def_trig_mode = 2;
00136 const unsigned int CSCAnodeLCTProcessor::def_accel_mode = 0;
00137 const unsigned int CSCAnodeLCTProcessor::def_l1a_window_width = 7;
00138
00139
00140
00141
00142
00143 CSCAnodeLCTProcessor::CSCAnodeLCTProcessor(unsigned endcap, unsigned station,
00144 unsigned sector, unsigned subsector,
00145 unsigned chamber,
00146 const edm::ParameterSet& conf,
00147 const edm::ParameterSet& comm) :
00148 theEndcap(endcap), theStation(station), theSector(sector),
00149 theSubsector(subsector), theTrigChamber(chamber) {
00150 static bool config_dumped = false;
00151
00152
00153 fifo_tbins = conf.getParameter<unsigned int>("alctFifoTbins");
00154 fifo_pretrig = conf.getParameter<unsigned int>("alctFifoPretrig");
00155 drift_delay = conf.getParameter<unsigned int>("alctDriftDelay");
00156 nplanes_hit_pretrig =
00157 conf.getParameter<unsigned int>("alctNplanesHitPretrig");
00158 nplanes_hit_pattern =
00159 conf.getParameter<unsigned int>("alctNplanesHitPattern");
00160 nplanes_hit_accel_pretrig =
00161 conf.getParameter<unsigned int>("alctNplanesHitAccelPretrig");
00162 nplanes_hit_accel_pattern =
00163 conf.getParameter<unsigned int>("alctNplanesHitAccelPattern");
00164 trig_mode = conf.getParameter<unsigned int>("alctTrigMode");
00165 accel_mode = conf.getParameter<unsigned int>("alctAccelMode");
00166 l1a_window_width = conf.getParameter<unsigned int>("alctL1aWindowWidth");
00167
00168
00169 infoV = conf.getUntrackedParameter<int>("verbosity", 0);
00170
00171
00172 isMTCC = comm.getParameter<bool>("isMTCC");
00173
00174 isTMB07 = comm.getParameter<bool>("isTMB07");
00175
00176
00177 checkConfigParameters();
00178 if (infoV > 0 && !config_dumped) {
00179 dumpConfigParams();
00180 config_dumped = true;
00181 }
00182
00183 numWireGroups = 0;
00184 MESelection = (theStation < 3) ? 0 : 1;
00185
00186
00187 for (int i_patt = 0; i_patt < CSCConstants::NUM_ALCT_PATTERNS; i_patt++) {
00188 for (int i_wire = 0; i_wire < NUM_PATTERN_WIRES; i_wire++) {
00189 if (isMTCC || isTMB07) {
00190 pattern_mask[i_patt][i_wire] = pattern_mask_MTCC[i_patt][i_wire];
00191 }
00192 else {
00193 pattern_mask[i_patt][i_wire] = pattern_mask_default[i_patt][i_wire];
00194 }
00195 }
00196 }
00197 }
00198
00199 CSCAnodeLCTProcessor::CSCAnodeLCTProcessor() :
00200 theEndcap(1), theStation(1), theSector(1),
00201 theSubsector(1), theTrigChamber(1) {
00202
00203 static bool config_dumped = false;
00204
00205
00206 setDefaultConfigParameters();
00207 infoV = 2;
00208 isMTCC = true;
00209 isTMB07 = true;
00210
00211
00212 checkConfigParameters();
00213 if (!config_dumped) {
00214 dumpConfigParams();
00215 config_dumped = true;
00216 }
00217
00218 numWireGroups = CSCConstants::MAX_NUM_WIRES;
00219 MESelection = (theStation < 3) ? 0 : 1;
00220 }
00221
00222 void CSCAnodeLCTProcessor::setDefaultConfigParameters() {
00223
00224 fifo_tbins = def_fifo_tbins;
00225 fifo_pretrig = def_fifo_pretrig;
00226 drift_delay = def_drift_delay;
00227 nplanes_hit_pretrig = def_nplanes_hit_pretrig;
00228 nplanes_hit_pattern = def_nplanes_hit_pattern;
00229 nplanes_hit_accel_pretrig = def_nplanes_hit_accel_pretrig;
00230 nplanes_hit_accel_pattern = def_nplanes_hit_accel_pattern;
00231 trig_mode = def_trig_mode;
00232 accel_mode = def_accel_mode;
00233 l1a_window_width = def_l1a_window_width;
00234 }
00235
00236
00237 void CSCAnodeLCTProcessor::setConfigParameters(const CSCL1TPParameters* conf) {
00238 static bool config_dumped = false;
00239
00240 fifo_tbins = conf->alctFifoTbins();
00241 fifo_pretrig = conf->alctFifoPretrig();
00242 drift_delay = conf->alctDriftDelay();
00243 nplanes_hit_pretrig = conf->alctNplanesHitPretrig();
00244 nplanes_hit_pattern = conf->alctNplanesHitPattern();
00245 nplanes_hit_accel_pretrig = conf->alctNplanesHitAccelPretrig();
00246 nplanes_hit_accel_pattern = conf->alctNplanesHitAccelPattern();
00247 trig_mode = conf->alctTrigMode();
00248 accel_mode = conf->alctAccelMode();
00249 l1a_window_width = conf->alctL1aWindowWidth();
00250
00251
00252 checkConfigParameters();
00253 if (!config_dumped) {
00254 dumpConfigParams();
00255 config_dumped = true;
00256 }
00257 }
00258
00259 void CSCAnodeLCTProcessor::checkConfigParameters() {
00260
00261
00262
00263 static const unsigned int max_fifo_tbins = 1 << 5;
00264 static const unsigned int max_fifo_pretrig = 1 << 5;
00265 static const unsigned int max_drift_delay = 1 << 2;
00266 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
00267 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
00268 static const unsigned int max_nplanes_hit_accel_pretrig = 1 << 3;
00269 static const unsigned int max_nplanes_hit_accel_pattern = 1 << 3;
00270 static const unsigned int max_trig_mode = 1 << 2;
00271 static const unsigned int max_accel_mode = 1 << 2;
00272 static const unsigned int max_l1a_window_width = MAX_ALCT_BINS;
00273
00274
00275 if (fifo_tbins >= max_fifo_tbins) {
00276 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00277 << "+++ Value of fifo_tbins, " << fifo_tbins
00278 << ", exceeds max allowed, " << max_fifo_tbins-1 << " +++\n"
00279 << "+++ Try to proceed with the default value, fifo_tbins="
00280 << def_fifo_tbins << " +++\n";
00281 fifo_tbins = def_fifo_tbins;
00282 }
00283 if (fifo_pretrig >= max_fifo_pretrig) {
00284 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00285 << "+++ Value of fifo_pretrig, " << fifo_pretrig
00286 << ", exceeds max allowed, " << max_fifo_pretrig-1 << " +++\n"
00287 << "+++ Try to proceed with the default value, fifo_pretrig="
00288 << def_fifo_pretrig << " +++\n";
00289 fifo_pretrig = def_fifo_pretrig;
00290 }
00291 if (drift_delay >= max_drift_delay) {
00292 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00293 << "+++ Value of drift_delay, " << drift_delay
00294 << ", exceeds max allowed, " << max_drift_delay-1 << " +++\n"
00295 << "+++ Try to proceed with the default value, drift_delay="
00296 << def_drift_delay << " +++\n";
00297 drift_delay = def_drift_delay;
00298 }
00299 if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) {
00300 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00301 << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig
00302 << ", exceeds max allowed, " << max_nplanes_hit_pretrig-1 << " +++\n"
00303 << "+++ Try to proceed with the default value, nplanes_hit_pretrig="
00304 << nplanes_hit_pretrig << " +++\n";
00305 nplanes_hit_pretrig = def_nplanes_hit_pretrig;
00306 }
00307 if (nplanes_hit_pattern >= max_nplanes_hit_pattern) {
00308 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00309 << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern
00310 << ", exceeds max allowed, " << max_nplanes_hit_pattern-1 << " +++\n"
00311 << "+++ Try to proceed with the default value, nplanes_hit_pattern="
00312 << nplanes_hit_pattern << " +++\n";
00313 nplanes_hit_pattern = def_nplanes_hit_pattern;
00314 }
00315 if (nplanes_hit_accel_pretrig >= max_nplanes_hit_accel_pretrig) {
00316 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00317 << "+++ Value of nplanes_hit_accel_pretrig, "
00318 << nplanes_hit_accel_pretrig << ", exceeds max allowed, "
00319 << max_nplanes_hit_accel_pretrig-1 << " +++\n"
00320 << "+++ Try to proceed with the default value, "
00321 << "nplanes_hit_accel_pretrig=" << nplanes_hit_accel_pretrig << " +++\n";
00322 nplanes_hit_accel_pretrig = def_nplanes_hit_accel_pretrig;
00323 }
00324 if (nplanes_hit_accel_pattern >= max_nplanes_hit_accel_pattern) {
00325 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00326 << "+++ Value of nplanes_hit_accel_pattern, "
00327 << nplanes_hit_accel_pattern << ", exceeds max allowed, "
00328 << max_nplanes_hit_accel_pattern-1 << " +++\n"
00329 << "+++ Try to proceed with the default value, "
00330 << "nplanes_hit_accel_pattern=" << nplanes_hit_accel_pattern << " +++\n";
00331 nplanes_hit_accel_pattern = def_nplanes_hit_accel_pattern;
00332 }
00333 if (trig_mode >= max_trig_mode) {
00334 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00335 << "+++ Value of trig_mode, " << trig_mode
00336 << ", exceeds max allowed, " << max_trig_mode-1 << " +++\n"
00337 << "+++ Try to proceed with the default value, trig_mode="
00338 << trig_mode << " +++\n";
00339 trig_mode = def_trig_mode;
00340 }
00341 if (accel_mode >= max_accel_mode) {
00342 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00343 << "+++ Value of accel_mode, " << accel_mode
00344 << ", exceeds max allowed, " << max_accel_mode-1 << " +++\n"
00345 << "+++ Try to proceed with the default value, accel_mode="
00346 << accel_mode << " +++\n";
00347 accel_mode = def_accel_mode;
00348 }
00349 if (l1a_window_width >= max_l1a_window_width) {
00350 if (infoV > 0) edm::LogError("CSCAnodeLCTProcessor")
00351 << "+++ Value of l1a_window_width, " << l1a_window_width
00352 << ", exceeds max allowed, " << max_l1a_window_width-1 << " +++\n"
00353 << "+++ Try to proceed with the default value, l1a_window_width="
00354 << l1a_window_width << " +++\n";
00355 l1a_window_width = def_l1a_window_width;
00356 }
00357 }
00358
00359 void CSCAnodeLCTProcessor::clear() {
00360 for (int bx = 0; bx < MAX_ALCT_BINS; bx++) {
00361 bestALCT[bx].clear();
00362 secondALCT[bx].clear();
00363 }
00364 }
00365
00366 void CSCAnodeLCTProcessor::clear(const int wire, const int pattern) {
00367
00368 if (pattern == 0) quality[wire][0] = -999;
00369 else {
00370 quality[wire][1] = -999;
00371 quality[wire][2] = -999;
00372 }
00373 }
00374
00375 std::vector<CSCALCTDigi>
00376 CSCAnodeLCTProcessor::run(const CSCWireDigiCollection* wiredc) {
00377
00378
00379
00380
00381
00382
00383
00384 if (numWireGroups == 0) {
00385 CSCTriggerGeomManager* theGeom = CSCTriggerGeometry::get();
00386 CSCChamber* theChamber = theGeom->chamber(theEndcap, theStation, theSector,
00387 theSubsector, theTrigChamber);
00388 if (theChamber) {
00389 numWireGroups = theChamber->layer(1)->geometry()->numberOfWireGroups();
00390 if (numWireGroups > CSCConstants::MAX_NUM_WIRES) {
00391 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00392 << "+++ Number of wire groups, " << numWireGroups
00393 << " found in ME" << ((theEndcap == 1) ? "+" : "-")
00394 << theStation << "/"
00395 << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00396 theTrigChamber) << "/"
00397 << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
00398 theSubsector, theStation, theTrigChamber)
00399 << " (sector " << theSector << " subsector " << theSubsector
00400 << " trig id. " << theTrigChamber << ")"
00401 << " exceeds max expected, " << CSCConstants::MAX_NUM_WIRES
00402 << " +++\n"
00403 << "+++ CSC geometry looks garbled; no emulation possible +++\n";
00404 numWireGroups = -1;
00405 }
00406 }
00407 else {
00408 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00409 << "+++ ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
00410 << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00411 theTrigChamber) << "/"
00412 << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
00413 theSubsector, theStation, theTrigChamber)
00414 << " (sector " << theSector << " subsector " << theSubsector
00415 << " trig id. " << theTrigChamber << ")"
00416 << " is not defined in current geometry! +++\n"
00417 << "+++ CSC geometry looks garbled; no emulation possible +++\n";
00418 numWireGroups = -1;
00419 }
00420 }
00421
00422 if (numWireGroups < 0) {
00423 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00424 << "+++ ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
00425 << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00426 theTrigChamber) << "/"
00427 << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
00428 theSubsector, theStation, theTrigChamber)
00429 << " (sector " << theSector << " subsector " << theSubsector
00430 << " trig id. " << theTrigChamber << "):"
00431 << " numWireGroups = " << numWireGroups
00432 << "; ALCT emulation skipped! +++";
00433 std::vector<CSCALCTDigi> emptyV;
00434 return emptyV;
00435 }
00436
00437
00438 bool noDigis = getDigis(wiredc);
00439
00440 if (!noDigis) {
00441
00442 std::vector<int>
00443 wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES];
00444 readWireDigis(wire);
00445
00446
00447
00448 run(wire);
00449 }
00450
00451
00452 std::vector<CSCALCTDigi> tmpV = getALCTs();
00453 return tmpV;
00454 }
00455
00456 void CSCAnodeLCTProcessor::run(const std::vector<int> wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES]) {
00457
00458
00459
00460
00461
00462 bool trigger = false;
00463
00464
00465 bool chamber_empty = pulseExtension(wire);
00466
00467
00468 if (!chamber_empty) {
00469 for (int i_wire = 0; i_wire < numWireGroups; i_wire++) {
00470 unsigned int start_bx = 0;
00471
00472 while (start_bx < fifo_tbins) {
00473 if (preTrigger(i_wire, start_bx)) {
00474 if (infoV > 2) showPatterns(i_wire);
00475 if (patternDetection(i_wire)) {
00476 trigger = true;
00477 break;
00478 }
00479 else {
00480
00481
00482
00483 start_bx = first_bx[i_wire] + drift_delay + 4;
00484 }
00485 }
00486 else {
00487 break;
00488 }
00489 }
00490 }
00491 }
00492
00493
00494 if (trigger) {
00495 ghostCancellationLogic();
00496 lctSearch();
00497 }
00498 }
00499
00500 bool CSCAnodeLCTProcessor::getDigis(const CSCWireDigiCollection* wiredc) {
00501
00502 bool noDigis = true;
00503 int theRing = CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00504 theTrigChamber);
00505 int theChamber = CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
00506 theSubsector, theStation, theTrigChamber);
00507
00508
00509 for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
00510 CSCDetId detid(theEndcap, theStation, theRing, theChamber, i_layer+1);
00511
00512 const CSCWireDigiCollection::Range rwired = wiredc->get(detid);
00513
00514
00515 if (rwired.second == rwired.first) continue;
00516
00517
00518
00519 if (noDigis) {
00520 for (int lay = 0; lay < CSCConstants::NUM_LAYERS; lay++) {
00521 digiV[lay].clear();
00522 }
00523 noDigis = false;
00524 }
00525
00526 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
00527 << "found " << rwired.second - rwired.first
00528 << " wire digi(s) in layer " << i_layer << " of ME"
00529 << ((theEndcap == 1) ? "+" : "-") << theStation << "/" << theRing
00530 << "/" << theChamber << " (trig. sector " << theSector
00531 << " subsector " << theSubsector << " id " << theTrigChamber << ")";
00532
00533 for (CSCWireDigiCollection::const_iterator digiIt = rwired.first;
00534 digiIt != rwired.second; ++digiIt) {
00535 digiV[i_layer].push_back(*digiIt);
00536 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor") << " " << (*digiIt);
00537 }
00538 }
00539
00540 return noDigis;
00541 }
00542
00543 void CSCAnodeLCTProcessor::readWireDigis(std::vector<int> wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES]) {
00544
00545
00546
00547 for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
00548
00549
00550 for (std::vector<CSCWireDigi>::iterator pld = digiV[i_layer].begin();
00551 pld != digiV[i_layer].end(); pld++) {
00552 int i_wire = pld->getWireGroup()-1;
00553 std::vector<int> bx_times = pld->getTimeBinsOn();
00554
00555
00556 if (i_wire < 0 || i_wire >= numWireGroups) {
00557 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00558 << "+++ Found wire digi with wrong wire number = " << i_wire
00559 << "( max wires = " << numWireGroups << "); skipping it... +++\n";
00560 continue;
00561 }
00562
00563
00564
00565
00566
00567
00568
00569
00570 for (unsigned int i = 0; i < bx_times.size(); i++) {
00571
00572 if (bx_times[i] > 0 && bx_times[i] < static_cast<int>(fifo_tbins)) {
00573 if (infoV > 2) LogTrace("CSCAnodeLCTProcessor")
00574 << "Digi on layer " << i_layer << " wire " << i_wire
00575 << " at time " << bx_times[i];
00576
00577
00578
00579
00580
00581 wire[i_layer][i_wire].push_back(bx_times[i]);
00582 break;
00583
00584
00585 }
00586 else {
00587 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
00588 << "+++ Skipping wire digi: wire = " << i_wire
00589 << " layer = " << i_layer << ", bx = " << bx_times[i] << " +++";
00590 }
00591 }
00592 }
00593 }
00594 }
00595
00596 bool CSCAnodeLCTProcessor::pulseExtension(const std::vector<int> wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES]){
00597
00598
00599
00600
00601
00602
00603 bool chamber_empty = true;
00604 int i_wire, i_layer, digi_num;
00605 static unsigned int hit_persist = 6;
00606 static unsigned int bits_in_pulse = 8*sizeof(pulse[0][0]);
00607
00608 for (i_wire = 0; i_wire < numWireGroups; i_wire++) {
00609 for (i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
00610 pulse[i_layer][i_wire] = 0;
00611 }
00612 first_bx[i_wire] = -999;
00613 for (int j = 0; j < 3; j++) quality[i_wire][j] = -999;
00614 }
00615
00616 for (i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++){
00617 digi_num = 0;
00618 for (i_wire = 0; i_wire < numWireGroups; i_wire++) {
00619 if (wire[i_layer][i_wire].size() > 0) {
00620 std::vector<int> bx_times = wire[i_layer][i_wire];
00621 for (unsigned int i = 0; i < bx_times.size(); i++) {
00622
00623 if (bx_times[i] < 0 || bx_times[i] + hit_persist >= bits_in_pulse) {
00624 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00625 << "+++ BX time of wire digi (wire = " << i_wire
00626 << " layer = " << i_layer << ") bx = " << bx_times[i]
00627 << " is not within the range (0-" << bits_in_pulse
00628 << "] allowed for pulse extension. Skip this digi! +++\n";
00629 continue;
00630 }
00631
00632
00633 if (chamber_empty) chamber_empty = false;
00634
00635
00636 for (unsigned int bx = bx_times[i];
00637 bx < (bx_times[i] + hit_persist); bx++)
00638 pulse[i_layer][i_wire] = pulse[i_layer][i_wire] | (1 << bx);
00639
00640
00641 if (infoV > 1) {
00642 LogTrace("CSCAnodeLCTProcessor")
00643 << "Wire digi: layer " << i_layer
00644 << " digi #" << ++digi_num << " wire group " << i_wire
00645 << " time " << bx_times[i];
00646 if (infoV > 2) {
00647 std::ostringstream strstrm;
00648 for (int i = 1; i <= 32; i++) {
00649 strstrm << ((pulse[i_layer][i_wire]>>(32-i)) & 1);
00650 }
00651 LogTrace("CSCAnodeLCTProcessor") << " Pulse: " << strstrm.str();
00652 }
00653 }
00654 }
00655 }
00656 }
00657 }
00658
00659 if (infoV > 1 && !chamber_empty) {
00660 dumpDigis(wire);
00661 }
00662
00663 return chamber_empty;
00664 }
00665
00666 bool CSCAnodeLCTProcessor::preTrigger(const int key_wire, const int start_bx) {
00667
00668
00669
00670
00671 unsigned int layers_hit;
00672 bool hit_layer[CSCConstants::NUM_LAYERS];
00673 int this_layer, this_wire;
00674 const unsigned int pretrig_thresh[CSCConstants::NUM_ALCT_PATTERNS] = {
00675 nplanes_hit_accel_pretrig, nplanes_hit_pretrig, nplanes_hit_pretrig
00676 };
00677
00678
00679
00680 for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
00681 for (int i_pattern = 0; i_pattern < CSCConstants::NUM_ALCT_PATTERNS; i_pattern++) {
00682 for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
00683 hit_layer[i_layer] = false;
00684 layers_hit = 0;
00685
00686 for (int i_wire = 0; i_wire < NUM_PATTERN_WIRES; i_wire++){
00687 if (pattern_mask[i_pattern][i_wire] != 0){
00688 this_layer = pattern_envelope[0][i_wire];
00689 this_wire = pattern_envelope[1+MESelection][i_wire]+key_wire;
00690 if ((this_wire >= 0) && (this_wire < numWireGroups)){
00691
00692 if (((pulse[this_layer][this_wire] >> bx_time) & 1) == 1) {
00693
00694 if (hit_layer[this_layer] == false){
00695 hit_layer[this_layer] = true;
00696 layers_hit++;
00697 }
00698
00699
00700
00701 if (layers_hit >= pretrig_thresh[i_pattern]) {
00702 first_bx[key_wire] = bx_time;
00703 if (infoV > 1) {
00704 LogTrace("CSCAnodeLCTProcessor")
00705 << "Pretrigger was satisfied for wire: " << key_wire
00706 << " pattern: " << i_pattern
00707 << " bx_time: " << bx_time;
00708 }
00709 return true;
00710 }
00711 }
00712 }
00713 }
00714 }
00715 }
00716 }
00717
00718 return false;
00719 }
00720
00721 bool CSCAnodeLCTProcessor::patternDetection(const int key_wire) {
00722
00723
00724
00725
00726 bool trigger = false;
00727 bool hit_layer[CSCConstants::NUM_LAYERS];
00728 unsigned int temp_quality;
00729 int this_layer, this_wire;
00730 const unsigned int pattern_thresh[CSCConstants::NUM_ALCT_PATTERNS] = {
00731 nplanes_hit_accel_pattern, nplanes_hit_pattern, nplanes_hit_pattern
00732 };
00733 const std::string ptn_label[] = {"Accelerator", "CollisionA", "CollisionB"};
00734
00735 for (int i_pattern = 0; i_pattern < CSCConstants::NUM_ALCT_PATTERNS; i_pattern++){
00736 temp_quality = 0;
00737 for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
00738 hit_layer[i_layer] = false;
00739
00740 for (int i_wire = 0; i_wire < NUM_PATTERN_WIRES; i_wire++){
00741 if (pattern_mask[i_pattern][i_wire] != 0){
00742 this_layer = pattern_envelope[0][i_wire];
00743 this_wire = pattern_envelope[1+MESelection][i_wire]+key_wire;
00744 if ((this_wire >= 0) && (this_wire < numWireGroups)){
00745
00746
00747
00748 if ((pulse[this_layer][this_wire] >>
00749 (first_bx[key_wire] + drift_delay)) & 1 == 1) {
00750
00751
00752
00753 if (hit_layer[this_layer] == false){
00754 temp_quality++;
00755
00756 hit_layer[this_layer] = true;
00757 if (infoV > 1)
00758 LogTrace("CSCAnodeLCTProcessor")
00759 << "bx_time: " << first_bx[key_wire]
00760 << " pattern: " << i_pattern << " keywire: " << key_wire
00761 << " layer: " << this_layer
00762 << " quality: " << temp_quality;
00763 }
00764 }
00765 }
00766 }
00767 }
00768 if (temp_quality >= pattern_thresh[i_pattern]) {
00769 trigger = true;
00770
00771 if (!isTMB07) {
00772
00773
00774 temp_quality -= (pattern_thresh[i_pattern]-1);
00775 }
00776 else {
00777
00778
00779 if (temp_quality > 3) temp_quality -= 3;
00780 else temp_quality = 0;
00781 }
00782
00783 if (i_pattern == 0) {
00784
00785 quality[key_wire][0] = temp_quality;
00786 }
00787 else {
00788
00789 if (static_cast<int>(temp_quality) > quality[key_wire][1]) {
00790 quality[key_wire][1] = temp_quality;
00791 quality[key_wire][2] = i_pattern-1;
00792 }
00793 }
00794 if (infoV > 1) {
00795 LogTrace("CSCAnodeLCTProcessor")
00796 << "Pattern found; keywire: " << key_wire
00797 << " type: " << ptn_label[i_pattern]
00798 << " quality: " << temp_quality << "\n";
00799 }
00800 }
00801 }
00802 if (infoV > 1 && quality[key_wire][1] > 0) {
00803 if (quality[key_wire][2] == 0)
00804 LogTrace("CSCAnodeLCTProcessor")
00805 << "Collision Pattern A is chosen" << "\n";
00806 else if (quality[key_wire][2] == 1)
00807 LogTrace("CSCAnodeLCTProcessor")
00808 << "Collision Pattern B is chosen" << "\n";
00809 }
00810 return trigger;
00811 }
00812
00813 void CSCAnodeLCTProcessor::ghostCancellationLogic() {
00814
00815
00816
00817
00818
00819
00820
00821 int ghost_cleared[CSCConstants::MAX_NUM_WIRES][2];
00822
00823 for (int key_wire = 0; key_wire < numWireGroups; key_wire++) {
00824 for (int i_pattern = 0; i_pattern < 2; i_pattern++) {
00825 ghost_cleared[key_wire][i_pattern] = 0;
00826
00827
00828 int qual_this = quality[key_wire][i_pattern];
00829 if (qual_this > 0) {
00830
00831
00832 int qual_prev = (key_wire > 0) ? quality[key_wire-1][i_pattern] : 0;
00833 if (qual_prev > 0) {
00834 int dt = first_bx[key_wire] - first_bx[key_wire-1];
00835
00836
00837
00838
00839
00840
00841 if (dt == 0) {
00842 if (qual_prev >= qual_this) ghost_cleared[key_wire][i_pattern] = 1;
00843 }
00844 else if (dt > 0 && dt <= 4) {
00845
00846
00847
00848
00850 ghost_cleared[key_wire][i_pattern] = 1;
00851 }
00852 }
00853
00854
00855
00856 if (ghost_cleared[key_wire][i_pattern] == 1) {
00857 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
00858 << ((i_pattern == 0) ? "Accelerator" : "Collision")
00859 << " pattern ghost cancelled on key_wire " << key_wire
00860 << " by wire " << key_wire-1;
00861 continue;
00862 }
00863
00864 int qual_next =
00865 (key_wire < numWireGroups-1) ? quality[key_wire+1][i_pattern] : 0;
00866 if (qual_next > 0) {
00867 int dt = first_bx[key_wire] - first_bx[key_wire+1];
00868
00869 if (dt == 0) {
00870 if (qual_next > qual_this) ghost_cleared[key_wire][i_pattern] = 1;
00871 }
00872 else if (dt > 0 && dt <= 4) {
00873
00874
00875
00876
00878 ghost_cleared[key_wire][i_pattern] = 1;
00879 }
00880 }
00881 if (ghost_cleared[key_wire][i_pattern] == 1) {
00882 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
00883 << ((i_pattern == 0) ? "Accelerator" : "Collision")
00884 << " pattern ghost cancelled on key_wire " << key_wire
00885 << " by wire " << key_wire+1;
00886 continue;
00887 }
00888 }
00889 }
00890 }
00891
00892
00893
00894 for (int key_wire = 0; key_wire < numWireGroups; key_wire++) {
00895 for (int i_pattern = 0; i_pattern < 2; i_pattern++) {
00896 if (ghost_cleared[key_wire][i_pattern] > 0) {
00897 clear(key_wire, i_pattern);
00898 }
00899 }
00900 }
00901 }
00902
00903 void CSCAnodeLCTProcessor::lctSearch() {
00904
00905
00906 std::vector<CSCALCTDigi> lct_list;
00907
00908 for (int i_wire = 0; i_wire < numWireGroups; i_wire++) {
00909
00910
00911 if (quality[i_wire][0] > 0 || quality[i_wire][1] > 0) {
00912 trigMode(i_wire);
00913
00914
00915 if (quality[i_wire][0] > 0) {
00916 int qual = (quality[i_wire][0] & 0x03);
00917 CSCALCTDigi lct_info(1, qual, 1, 0, i_wire, first_bx[i_wire]);
00918 lct_list.push_back(lct_info);
00919 }
00920
00921
00922 if (quality[i_wire][1] > 0) {
00923 int qual = (quality[i_wire][1] & 0x03);
00924 CSCALCTDigi lct_info(1, qual, 0, quality[i_wire][2], i_wire,
00925 first_bx[i_wire]);
00926 lct_list.push_back(lct_info);
00927 }
00928
00929
00930 accelMode(i_wire);
00931 }
00932 }
00933
00934
00935
00936 std::vector<CSCALCTDigi> fourBest = bestTrackSelector(lct_list);
00937
00938
00939
00940 for (std::vector<CSCALCTDigi>::const_iterator plct = fourBest.begin();
00941 plct != fourBest.end(); plct++) {
00942
00943 int bx = plct->getBX();
00944 if (bx >= MAX_ALCT_BINS) {
00945 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
00946 << "+++ Bx of ALCT candidate, " << bx << ", exceeds max allowed, "
00947 << MAX_ALCT_BINS-1 << "; skipping it... +++\n";
00948 continue;
00949 }
00950
00951 if (isBetterALCT(*plct, bestALCT[bx])) {
00952 if (isBetterALCT(bestALCT[bx], secondALCT[bx])) {
00953 secondALCT[bx] = bestALCT[bx];
00954 }
00955 bestALCT[bx] = *plct;
00956 }
00957 else if (isBetterALCT(*plct, secondALCT[bx])) {
00958 secondALCT[bx] = *plct;
00959 }
00960 }
00961
00962 if (!isTMB07) {
00963
00964 int first_bx = MAX_ALCT_BINS;
00965 for (int bx = 0; bx < MAX_ALCT_BINS; bx++) {
00966 if (bestALCT[bx].isValid()) {
00967 first_bx = bx;
00968 break;
00969 }
00970 }
00971 if (first_bx < MAX_ALCT_BINS) {
00972 for (int bx = first_bx + 1; bx < MAX_ALCT_BINS; bx++) {
00973 if (bestALCT[bx].isValid()) bestALCT[bx].clear();
00974 if (secondALCT[bx].isValid()) secondALCT[bx].clear();
00975 }
00976 }
00977 }
00978
00979 for (int bx = 0; bx < MAX_ALCT_BINS; bx++) {
00980 if (bestALCT[bx].isValid()) {
00981 bestALCT[bx].setTrknmb(1);
00982 if (infoV > 0) {
00983 LogDebug("CSCAnodeLCTProcessor")
00984 << "\n" << bestALCT[bx] << " found in ME"
00985 << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
00986 << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
00987 theTrigChamber) << "/"
00988 << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
00989 theSubsector, theStation, theTrigChamber)
00990 << " (sector " << theSector << " subsector " << theSubsector
00991 << " trig id. " << theTrigChamber << ")" << "\n";
00992 }
00993 if (secondALCT[bx].isValid()) {
00994 secondALCT[bx].setTrknmb(2);
00995 if (infoV > 0) {
00996 LogDebug("CSCAnodeLCTProcessor")
00997 << secondALCT[bx] << " found in ME"
00998 << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
00999 << CSCTriggerNumbering::ringFromTriggerLabels(theStation,
01000 theTrigChamber) <<"/"
01001 << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
01002 theSubsector, theStation, theTrigChamber)
01003 << " (sector " << theSector << " subsector " << theSubsector
01004 << " trig id. " << theTrigChamber << ")" << "\n";
01005 }
01006 }
01007 }
01008 }
01009 }
01010
01011 std::vector<CSCALCTDigi> CSCAnodeLCTProcessor::bestTrackSelector(
01012 const std::vector<CSCALCTDigi>& all_alcts) {
01013
01014
01015 CSCALCTDigi bestALCTs[MAX_ALCT_BINS][2], secondALCTs[MAX_ALCT_BINS][2];
01016
01017 static int fpga_latency = 6;
01018 static int early_tbins = fifo_pretrig - fpga_latency;
01019
01020
01021 static int lct_bins =
01022 (l1a_window_width%2 == 0) ? l1a_window_width : l1a_window_width-1;
01023 static int late_tbins = early_tbins + lct_bins;
01024
01025 static int ifois = 0;
01026 if (ifois == 0) {
01027 if (infoV > 0 && early_tbins < 0) {
01028 edm::LogWarning("CSCAnodeLCTProcessor")
01029 << "+++ fifo_pretrig = " << fifo_pretrig
01030 << "; you are loosing in-time ALCT hits!!! +++" << "\n";
01031 }
01032
01033 if (late_tbins > MAX_ALCT_BINS-1) {
01034 if (infoV > 0) edm::LogWarning("CSCAnodeLCTProcessor")
01035 << "+++ Allowed range of time bins, [0-" << late_tbins
01036 << "] exceeds max allowed, " << MAX_ALCT_BINS-1 << " +++\n"
01037 << "+++ Set late_tbins to max allowed +++\n";
01038 late_tbins = MAX_ALCT_BINS-1;
01039 }
01040 ifois = 1;
01041 }
01042
01043 if (infoV > 1) {
01044 LogTrace("CSCAnodeLCTProcessor") << all_alcts.size() <<
01045 " ALCTs at the input of best-track selector: ";
01046 for (std::vector <CSCALCTDigi>::const_iterator plct = all_alcts.begin();
01047 plct != all_alcts.end(); plct++) {
01048 if (!plct->isValid()) continue;
01049 LogTrace("CSCAnodeLCTProcessor") << (*plct);
01050 }
01051 }
01052
01053 CSCALCTDigi tA[MAX_ALCT_BINS][2], tB[MAX_ALCT_BINS][2];
01054 for (std::vector <CSCALCTDigi>::const_iterator plct = all_alcts.begin();
01055 plct != all_alcts.end(); plct++) {
01056 if (!plct->isValid()) continue;
01057
01058 int bx = (*plct).getBX();
01059
01060 if (bx <= early_tbins) {
01061 if (infoV > 1) LogDebug("CSCAnodeLCTProcessor")
01062 << " Do not report ALCT on keywire " << plct->getKeyWG()
01063 << ": found at bx " << bx << ", whereas the earliest allowed bx is "
01064 << early_tbins+1;
01065 continue;
01066 }
01067
01068
01069 if (bx > late_tbins) {
01070 if (infoV > 1) LogDebug("CSCAnodeLCTProcessor")
01071 << " Do not report ALCT on keywire " << plct->getKeyWG()
01072 << ": found at bx " << bx << ", whereas the latest allowed bx is "
01073 << late_tbins;
01074 continue;
01075 }
01076
01077
01078
01079
01080
01081
01082
01083
01084 int accel = (*plct).getAccelerator();
01085 int qual = (*plct).getQuality();
01086 int wire = (*plct).getKeyWG();
01087 bool vA = tA[bx][accel].isValid();
01088 bool vB = tB[bx][accel].isValid();
01089 int qA = tA[bx][accel].getQuality();
01090 int qB = tB[bx][accel].getQuality();
01091 int wA = tA[bx][accel].getKeyWG();
01092 int wB = tB[bx][accel].getKeyWG();
01093 if (!vA || qual > qA || (qual == qA && wire > wA)) {
01094 tA[bx][accel] = *plct;
01095 }
01096 if (!vB || qual > qB || (qual == qB && wire < wB)) {
01097 tB[bx][accel] = *plct;
01098 }
01099 }
01100
01101 for (int bx = early_tbins+1; bx <= late_tbins; bx++) {
01102 for (int accel = 0; accel <= 1; accel++) {
01103
01104 if (tA[bx][accel].isValid()) {
01105 if (infoV > 2) {
01106 LogTrace("CSCAnodeLCTProcessor") << "tA: " << tA[bx][accel];
01107 LogTrace("CSCAnodeLCTProcessor") << "tB: " << tB[bx][accel];
01108 }
01109 bestALCTs[bx][accel] = tA[bx][accel];
01110
01111
01112 if (tA[bx][accel] != tB[bx][accel] &&
01113 tA[bx][accel].getQuality() == tB[bx][accel].getQuality()) {
01114 secondALCTs[bx][accel] = tB[bx][accel];
01115 }
01116 else {
01117
01118
01119
01120
01121 for (std::vector <CSCALCTDigi>::const_iterator plct =
01122 all_alcts.begin(); plct != all_alcts.end(); plct++) {
01123 if ((*plct).isValid() &&
01124 (*plct).getAccelerator() == accel && (*plct).getBX() == bx &&
01125 (*plct).getQuality() < bestALCTs[bx][accel].getQuality() &&
01126 (*plct).getQuality() >= secondALCTs[bx][accel].getQuality() &&
01127 (*plct).getKeyWG() >= secondALCTs[bx][accel].getKeyWG()) {
01128 secondALCTs[bx][accel] = *plct;
01129 }
01130 }
01131 }
01132 }
01133 }
01134 }
01135
01136
01137 std::vector<CSCALCTDigi> fourBest;
01138 for (int bx = 0; bx <= late_tbins; bx++) {
01139 for (int i = 0; i < 2; i++) {
01140 if (bestALCTs[bx][i].isValid()) fourBest.push_back(bestALCTs[bx][i]);
01141 }
01142 for (int i = 0; i < 2; i++) {
01143 if (secondALCTs[bx][i].isValid()) fourBest.push_back(secondALCTs[bx][i]);
01144 }
01145 }
01146
01147 if (infoV > 1) {
01148 LogTrace("CSCAnodeLCTProcessor") << fourBest.size() << " ALCTs selected: ";
01149 for (std::vector<CSCALCTDigi>::const_iterator plct = fourBest.begin();
01150 plct != fourBest.end(); plct++) {
01151 LogTrace("CSCAnodeLCTProcessor") << (*plct);
01152 }
01153 }
01154
01155 return fourBest;
01156 }
01157
01158 bool CSCAnodeLCTProcessor::isBetterALCT(const CSCALCTDigi& lhsALCT,
01159 const CSCALCTDigi& rhsALCT) {
01160
01161
01162
01163 bool returnValue = false;
01164
01165 if (lhsALCT.isValid() && !rhsALCT.isValid()) {return true;}
01166
01167
01168
01169 if (lhsALCT.getBX() < rhsALCT.getBX()) {returnValue = true;}
01170 if (lhsALCT.getBX() != rhsALCT.getBX()) {return returnValue;}
01171
01172
01173 int qual1 = lhsALCT.getQuality();
01174 int qual2 = rhsALCT.getQuality();
01175 if (qual1 > qual2) {returnValue = true;}
01176
01177
01178
01179 else if (qual1 == qual2 &&
01180 lhsALCT.getAccelerator() != rhsALCT.getAccelerator() &&
01181 quality[lhsALCT.getKeyWG()][1-lhsALCT.getAccelerator()] >
01182 quality[rhsALCT.getKeyWG()][1-rhsALCT.getAccelerator()])
01183 {returnValue = true;}
01184
01185 return returnValue;
01186 }
01187
01188 void CSCAnodeLCTProcessor::trigMode(const int key_wire) {
01189
01190
01191
01192 switch(trig_mode) {
01193 default:
01194 case 0:
01195
01196 break;
01197 case 1:
01198
01199 if (quality[key_wire][1] > 0) {
01200 quality[key_wire][1] = 0;
01201 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01202 << "trigMode(): collision track " << key_wire << " disabled" << "\n";
01203 }
01204 break;
01205 case 2:
01206
01207 if (quality[key_wire][0] > 0) {
01208 quality[key_wire][0] = 0;
01209 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01210 << "trigMode(): accelerator track " << key_wire << " disabled" << "\n";
01211 }
01212 break;
01213 case 3:
01214
01215
01216 if (quality[key_wire][0] > 0 && quality[key_wire][1] > 0) {
01217 quality[key_wire][1] = 0;
01218 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01219 << "trigMode(): collision track " << key_wire << " disabled" << "\n";
01220 }
01221 break;
01222 }
01223 }
01224
01225 void CSCAnodeLCTProcessor::accelMode(const int key_wire) {
01226
01227
01228
01229 int promotionBit = 1 << 2;
01230
01231 switch(accel_mode) {
01232 default:
01233 case 0:
01234
01235 if (quality[key_wire][0] > 0) {
01236 quality[key_wire][0] = 0;
01237 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01238 << "alctMode(): accelerator track " << key_wire << " ignored" << "\n";
01239 }
01240 break;
01241 case 1:
01242
01243 if (quality[key_wire][1] > 0) {
01244 quality[key_wire][1] += promotionBit;
01245 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01246 << "alctMode(): collision track " << key_wire << " promoted" << "\n";
01247 }
01248 break;
01249 case 2:
01250
01251 if (quality[key_wire][0] > 0) {
01252 quality[key_wire][0] += promotionBit;
01253 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01254 << "alctMode(): accelerator track " << key_wire << " promoted"<< "\n";
01255 }
01256 break;
01257 case 3:
01258
01259 if (quality[key_wire][1] > 0) {
01260 quality[key_wire][1] = 0;
01261 if (infoV > 1) LogTrace("CSCAnodeLCTProcessor")
01262 << "alctMode(): collision track " << key_wire << " ignored" << "\n";
01263 }
01264 break;
01265 }
01266 }
01267
01268
01269 void CSCAnodeLCTProcessor::dumpConfigParams() const {
01270 std::ostringstream strm;
01271 strm << "\n";
01272 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
01273 strm << "+ ALCT configuration parameters: +\n";
01274 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
01275 strm << " fifo_tbins [total number of time bins in DAQ readout] = "
01276 << fifo_tbins << "\n";
01277 strm << " fifo_pretrig [start time of anode raw hits in DAQ readout] = "
01278 << fifo_pretrig << "\n";
01279 strm << " drift_delay [drift delay after pre-trigger, in 25 ns bins] = "
01280 << drift_delay << "\n";
01281 strm << " nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
01282 << nplanes_hit_pretrig << "\n";
01283 strm << " nplanes_hit_pattern [min. number of layers hit for trigger] = "
01284 << nplanes_hit_pattern << "\n";
01285 strm << " nplanes_hit_accel_pretrig [min. number of layers hit for accel."
01286 << " pre-trig.] = " << nplanes_hit_accel_pretrig << "\n";
01287 strm << " nplanes_hit_accel_pattern [min. number of layers hit for accel."
01288 << " trigger] = " << nplanes_hit_accel_pattern << "\n";
01289 strm << " trig_mode [enabling/disabling collision/accelerator tracks] = "
01290 << trig_mode << "\n";
01291 strm << " accel_mode [preference to collision/accelerator tracks] = "
01292 << accel_mode << "\n";
01293 strm << " l1a_window_width [L1Accept window width, in 25 ns bins] = "
01294 << l1a_window_width << "\n";
01295 strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
01296 LogDebug("CSCAnodeLCTProcessor") << strm.str();
01297 }
01298
01299
01300 void CSCAnodeLCTProcessor::dumpDigis(const std::vector<int> wire[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES]) const {
01301 LogDebug("CSCAnodeLCTProcessor")
01302 << "ME" << ((theEndcap == 1) ? "+" : "-") << theStation << "/"
01303 << CSCTriggerNumbering::ringFromTriggerLabels(theStation, theTrigChamber)
01304 << "/" << CSCTriggerNumbering::chamberFromTriggerLabels(theSector,
01305 theSubsector, theStation, theTrigChamber)
01306 << " nWiregroups " << numWireGroups;
01307
01308 std::ostringstream strstrm;
01309 for (int i_wire = 0; i_wire < numWireGroups; i_wire++) {
01310 if (i_wire%10 == 0) {
01311 if (i_wire < 100) strstrm << i_wire/10;
01312 else strstrm << (i_wire-100)/10;
01313 }
01314 else strstrm << " ";
01315 }
01316 strstrm << "\n";
01317 for (int i_wire = 0; i_wire < numWireGroups; i_wire++) {
01318 strstrm << i_wire%10;
01319 }
01320 for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
01321 strstrm << "\n";
01322 for (int i_wire = 0; i_wire < numWireGroups; i_wire++) {
01323 if (wire[i_layer][i_wire].size() > 0) {
01324 std::vector<int> bx_times = wire[i_layer][i_wire];
01325 strstrm << std::hex << bx_times[0] << std::dec;
01326 }
01327 else {
01328 strstrm << ".";
01329 }
01330 }
01331 }
01332 LogTrace("CSCAnodeLCTProcessor") << strstrm.str();
01333 }
01334
01335
01336 std::vector<CSCALCTDigi> CSCAnodeLCTProcessor::getALCTs() {
01337 std::vector<CSCALCTDigi> tmpV;
01338 for (int bx = 0; bx < MAX_ALCT_BINS; bx++) {
01339 if (bestALCT[bx].isValid()) tmpV.push_back(bestALCT[bx]);
01340 if (secondALCT[bx].isValid()) tmpV.push_back(secondALCT[bx]);
01341 }
01342 return tmpV;
01343 }
01344
01347
01348 void CSCAnodeLCTProcessor::showPatterns(const int key_wire) {
01349
01350 for (int i_pattern = 0; i_pattern < CSCConstants::NUM_ALCT_PATTERNS;
01351 i_pattern++) {
01352 std::ostringstream strstrm_header;
01353 LogTrace("CSCAnodeLCTProcessor")
01354 << "\n" << "Pattern: " << i_pattern << " Key wire: " << key_wire;
01355 for (int i = 1; i <= 32; i++) {
01356 strstrm_header << ((32-i)%10);
01357 }
01358 LogTrace("CSCAnodeLCTProcessor") << strstrm_header.str();
01359 for (int i_wire = 0; i_wire < NUM_PATTERN_WIRES; i_wire++) {
01360 if (pattern_mask[i_pattern][i_wire] != 0) {
01361 std::ostringstream strstrm_pulse;
01362 int this_layer = pattern_envelope[0][i_wire];
01363 int this_wire = pattern_envelope[1+MESelection][i_wire]+key_wire;
01364 for (int i = 1; i <= 32; i++) {
01365 strstrm_pulse << ((pulse[this_layer][this_wire]>>(32-i)) & 1);
01366 }
01367 LogTrace("CSCAnodeLCTProcessor")
01368 << strstrm_pulse.str() << " on layer " << this_layer;
01369 }
01370 }
01371 LogTrace("CSCAnodeLCTProcessor")
01372 << "-------------------------------------------";
01373 }
01374 }