52 unsigned sector,
unsigned subsector,
55 theEndcap(endcap), theStation(station), theSector(sector),
56 theSubsector(subsector), theTrigChamber(chamber) {
59 static bool config_dumped =
false;
90 chamber, alctParams, commonParams);
92 chamber, clctParams, commonParams);
102 tmbParams.
getParameter<
unsigned int>(
"matchTrigWindowSize");
104 tmbParams.
getParameter<
unsigned int>(
"tmbL1aWindowSize");
110 if (infoV > 0 && !config_dumped) {
112 config_dumped =
true;
121 theEndcap(1), theStation(1), theSector(1),
122 theSubsector(1), theTrigChamber(1) {
124 static bool config_dumped =
false;
142 if (
infoV > 0 && !config_dumped) {
144 config_dumped =
true;
164 static bool config_dumped =
false;
180 if (!config_dumped) {
182 config_dumped =
true;
190 static const unsigned int max_mpc_block_me1a = 1 << 1;
191 static const unsigned int max_alct_trig_enable = 1 << 1;
192 static const unsigned int max_clct_trig_enable = 1 << 1;
193 static const unsigned int max_match_trig_enable = 1 << 1;
194 static const unsigned int max_match_trig_window_size = 1 << 4;
195 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
201 <<
", exceeds max allowed, " << max_mpc_block_me1a-1 <<
" +++\n"
202 <<
"+++ Try to proceed with the default value, mpc_block_me1a="
209 <<
", exceeds max allowed, " << max_alct_trig_enable-1 <<
" +++\n"
210 <<
"+++ Try to proceed with the default value, alct_trig_enable="
217 <<
", exceeds max allowed, " << max_clct_trig_enable-1 <<
" +++\n"
218 <<
"+++ Try to proceed with the default value, clct_trig_enable="
225 <<
", exceeds max allowed, " << max_match_trig_enable-1 <<
" +++\n"
226 <<
"+++ Try to proceed with the default value, match_trig_enable="
233 <<
", exceeds max allowed, " << max_match_trig_window_size-1 <<
" +++\n"
234 <<
"+++ Try to proceed with the default value, match_trig_window_size="
241 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
242 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
257 int bx_alct_matched = 0;
261 bool is_matched =
false;
267 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
274 bx_alct_matched = bx_alct;
288 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
298 std::vector<CSCCorrelatedLCTDigi>
304 std::vector<CSCALCTDigi> alctV =
alct->
run(wiredc);
307 std::vector<CSCCLCTDigi> clctV =
clct->
run(compdc);
310 int bx_alct_matched = 0;
326 bool is_matched =
false;
332 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
337 <<
"Successful ALCT-CLCT match: bx_clct = " << bx_clct
338 <<
"; match window: [" << bx_alct_start <<
"; " << bx_alct_stop
339 <<
"]; bx_alct = " << bx_alct;
343 bx_alct_matched = bx_alct;
351 <<
"Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = "
352 << bx_clct <<
"; match window: [" << bx_alct_start
353 <<
"; " << bx_alct_stop <<
"]";
364 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
367 <<
"Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = "
387 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
390 std::vector<CSCCorrelatedLCTDigi> tmpV =
readoutLCTs();
398 std::vector<CSCCorrelatedLCTDigi> tmpV;
404 static int early_tbins = 4;
412 static int late_tbins = early_tbins + lct_bins;
414 static int ifois = 0;
416 if (
infoV >= 0 && early_tbins < 0) {
418 <<
"+++ early_tbins = " << early_tbins
419 <<
"; in-time LCTs are not getting read-out!!! +++" <<
"\n";
424 <<
"+++ Allowed range of time bins, [0-" << late_tbins
425 <<
"] exceeds max allowed, " <<
MAX_LCT_BINS-1 <<
" +++\n"
426 <<
"+++ Set late_tbins to max allowed +++\n";
427 late_tbins = MAX_LCT_BINS-1;
435 std::vector<CSCCorrelatedLCTDigi> all_lcts =
getLCTs();
436 for (std::vector <CSCCorrelatedLCTDigi>::const_iterator plct =
437 all_lcts.begin(); plct != all_lcts.end(); plct++) {
438 if (!plct->isValid())
continue;
440 int bx = (*plct).getBX();
442 if (bx <= early_tbins) {
444 <<
" Do not report correlated LCT on key halfstrip "
445 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
446 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
452 if (bx > late_tbins) {
454 <<
" Do not report correlated LCT on key halfstrip "
455 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
456 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
464 if (bx_readout == -1 || bx == bx_readout) {
465 tmpV.push_back(*plct);
466 if (bx_readout == -1) bx_readout = bx;
474 std::vector<CSCCorrelatedLCTDigi> tmpV;
497 bool anodeBestValid = bestALCT.
isValid();
498 bool anodeSecondValid = secondALCT.
isValid();
499 bool cathodeBestValid = bestCLCT.
isValid();
500 bool cathodeSecondValid = secondCLCT.
isValid();
502 if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
503 if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
504 if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
505 if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
513 int bx = lct.
getBX();
520 <<
"+++ Bx of first LCT candidate, " << bx
521 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
522 <<
"); skipping it... +++\n";
526 if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
531 int bx = lct.
getBX();
538 <<
"+++ Bx of second LCT candidate, " << bx
539 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
540 <<
"); skipping it... +++\n";
569 const int stripType) {
570 const int kPatternBitWidth = 4;
575 pattern = (
abs(ptn) & ((1<<(kPatternBitWidth-1))-1));
580 pattern = pattern | (1<<(kPatternBitWidth-1));
585 pattern = (
abs(ptn) & ((1<<kPatternBitWidth)-1));
596 unsigned int quality = 0;
606 if (isDistrip) {quality = 4;}
615 if (sumQual < 1 || sumQual > 6) {
617 <<
"+++ findQuality: sumQual = " << sumQual <<
"+++ \n";
620 if (sumQual == 2) {quality = 6;}
621 else if (sumQual == 3) {quality = 7;}
622 else if (sumQual == 4) {quality = 8;}
623 else if (sumQual == 5) {quality = 9;}
624 else if (sumQual == 6) {quality = 10;}
627 if (sumQual == 2) {quality = 11;}
628 else if (sumQual == 3) {quality = 12;}
629 else if (sumQual == 4) {quality = 13;}
630 else if (sumQual == 5) {quality = 14;}
631 else if (sumQual == 6) {quality = 15;}
652 if (sumQual < 1 || sumQual > 6) {
654 <<
"+++ findQuality: Unexpected sumQual = " << sumQual <<
"+++\n";
663 quality = offset + sumQual;
676 if (pattern == 1) quality = 3;
683 if (!a4 && !c4) quality = 5;
684 else if ( a4 && !c4) quality = 6;
685 else if (!a4 && c4) quality = 7;
686 else if ( a4 && c4) {
691 if (pattern == 2 || pattern == 3) quality = 11;
692 else if (pattern == 4 || pattern == 5) quality = 12;
693 else if (pattern == 6 || pattern == 7) quality = 13;
694 else if (pattern == 8 || pattern == 9) quality = 14;
695 else if (pattern == 10) quality = 15;
698 <<
"+++ findQuality: Unexpected CLCT pattern id = "
699 << pattern <<
"+++\n";
710 unsigned int lctPattern, lctQuality;
712 for (
int bend = 0; bend < 2; bend++) {
713 for (
int cfeb = 0; cfeb < 5; cfeb++) {
715 for (
int bx = 0; bx < 7; bx++) {
716 for (
int stripType = 0; stripType < 2; stripType++) {
717 for (
int quality = 3; quality < 7; quality++) {
722 for (
int aQuality = 0; aQuality < 4; aQuality++) {
723 for (
int wireGroup = 0; wireGroup < 120; wireGroup++) {
724 for (
int abx = 0; abx < 7; abx++) {
725 CSCALCTDigi aLCT(1, aQuality, 0, 1, wireGroup, abx);
728 thisLCT(0, 1, lctQuality, aLCT.
getKeyWG(),
731 if (lctPattern != static_cast<unsigned int>(thisLCT.getPattern()) )
733 <<
"pattern mismatch: " << lctPattern
734 <<
" " << thisLCT.getPattern();
735 if (bend != thisLCT.getBend())
737 <<
"bend mismatch: " << bend
738 <<
" " << thisLCT.getBend();
739 int key_strip = 32*cfeb +
strip;
740 if (key_strip != thisLCT.getStrip())
742 <<
"strip mismatch: " << key_strip
743 <<
" " << thisLCT.getStrip();
744 if (wireGroup != thisLCT.getKeyWG())
746 <<
"wire group mismatch: " << wireGroup
747 <<
" " << thisLCT.getKeyWG();
748 if (abx != thisLCT.getBX())
750 <<
"bx mismatch: " << abx <<
" " << thisLCT.getBX();
751 if (lctQuality != static_cast<unsigned int>(thisLCT.getQuality()))
753 <<
"quality mismatch: " << lctQuality
754 <<
" " << thisLCT.getQuality();
768 std::ostringstream strm;
770 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
771 strm <<
"+ TMB configuration parameters: +\n";
772 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
773 strm <<
" mpc_block_me1a [block/not block triggers which come from ME1/A] = "
775 strm <<
" alct_trig_enable [allow ALCT-only triggers] = "
777 strm <<
" clct_trig_enable [allow CLCT-only triggers] = "
779 strm <<
" match_trig_enable [allow matched ALCT-CLCT triggers] = "
781 strm <<
" match_trig_window_size [ALCT-CLCT match window width, in 25 ns] = "
783 strm <<
" tmb_l1a_window_size [L1Accept window width, in 25 ns bins] = "
785 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
786 LogDebug(
"CSCMotherboard") << strm.str();
int getQuality() const
return quality of a pattern (number of layers hit!)
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT)
void run(const std::vector< int > w_time[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_WIRES], const std::vector< int > hs_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const std::vector< int > ds_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
unsigned int clct_trig_enable
std::vector< CSCCorrelatedLCTDigi > getLCTs()
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
CSCALCTDigi bestALCT[MAX_ALCT_BINS]
unsigned int match_trig_window_size
CSCALCTDigi secondALCT[MAX_ALCT_BINS]
const unsigned theTrigChamber
static const unsigned int def_alct_trig_enable
bool isValid() const
check ALCT validity (1 - valid ALCT)
static const unsigned int def_mpc_block_me1a
unsigned int tmbClctTrigEnable() const
unsigned int findQuality(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT)
static const unsigned int def_clct_trig_enable
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
void setConfigParameters(const CSCDBL1TPParameters *conf)
static int ringFromTriggerLabels(int station, int triggerCSCID)
int getStripType() const
return striptype
int getBend() const
return bend
unsigned int mpc_block_me1a
unsigned int tmbTmbL1aWindowSize() const
void correlateLCTs(CSCALCTDigi bestALCT, CSCALCTDigi secondALCT, CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT)
const unsigned theStation
unsigned int tmbMatchTrigWindowSize() const
CSCCorrelatedLCTDigi secondLCT[MAX_LCT_BINS]
static const unsigned int def_tmb_l1a_window_size
int getBX() const
return BX
unsigned int tmbAlctTrigEnable() const
unsigned int encodePattern(const int ptn, const int highPt)
unsigned int tmb_l1a_window_size
void checkConfigParameters()
bool isValid() const
check CLCT validity (1 - valid CLCT)
unsigned int match_trig_enable
unsigned int offset(bool)
CSCAnodeLCTProcessor * alct
int getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
CSCCorrelatedLCTDigi firstLCT[MAX_LCT_BINS]
unsigned int tmbMpcBlockMe1a() const
int getQuality() const
return quality of a pattern
int getAccelerator() const
int getPattern() const
return pattern
static const unsigned int def_match_trig_window_size
unsigned int alct_trig_enable
CSCCathodeLCTProcessor * clct
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
void dumpConfigParams() const
void setConfigParameters(const CSCDBL1TPParameters *conf)
std::vector< CSCALCTDigi > run(const CSCWireDigiCollection *wiredc)
int getKeyWG() const
return key wire group
static const unsigned int def_match_trig_enable
void setConfigParameters(const CSCDBL1TPParameters *conf)
unsigned int tmbMatchTrigEnable() const