51 unsigned sector,
unsigned subsector,
54 theEndcap(endcap), theStation(station), theSector(sector),
55 theSubsector(subsector), theTrigChamber(chamber) {
58 static bool config_dumped =
false;
107 tmbParams.
getParameter<
unsigned int>(
"matchTrigWindowSize");
109 tmbParams.
getParameter<
unsigned int>(
"tmbL1aWindowSize");
129 if (infoV > 0 && !config_dumped) {
131 config_dumped =
true;
140 theEndcap(1), theStation(1), theSector(1),
141 theSubsector(1), theTrigChamber(1) {
143 static bool config_dumped =
false;
163 if (
infoV > 0 && !config_dumped) {
165 config_dumped =
true;
185 static bool config_dumped =
false;
201 if (!config_dumped) {
203 config_dumped =
true;
211 static const unsigned int max_mpc_block_me1a = 1 << 1;
212 static const unsigned int max_alct_trig_enable = 1 << 1;
213 static const unsigned int max_clct_trig_enable = 1 << 1;
214 static const unsigned int max_match_trig_enable = 1 << 1;
215 static const unsigned int max_match_trig_window_size = 1 << 4;
216 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
222 <<
", exceeds max allowed, " << max_mpc_block_me1a-1 <<
" +++\n"
223 <<
"+++ Try to proceed with the default value, mpc_block_me1a="
230 <<
", exceeds max allowed, " << max_alct_trig_enable-1 <<
" +++\n"
231 <<
"+++ Try to proceed with the default value, alct_trig_enable="
238 <<
", exceeds max allowed, " << max_clct_trig_enable-1 <<
" +++\n"
239 <<
"+++ Try to proceed with the default value, clct_trig_enable="
246 <<
", exceeds max allowed, " << max_match_trig_enable-1 <<
" +++\n"
247 <<
"+++ Try to proceed with the default value, match_trig_enable="
254 <<
", exceeds max allowed, " << max_match_trig_window_size-1 <<
" +++\n"
255 <<
"+++ Try to proceed with the default value, match_trig_window_size="
262 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
263 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
278 int bx_alct_matched = 0;
282 bool is_matched =
false;
288 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
295 bx_alct_matched = bx_alct;
309 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
325 std::vector<CSCALCTDigi> alctV =
alct->
run(wiredc);
328 std::vector<CSCCLCTDigi> clctV =
clct->
run(compdc);
331 int used_alct_mask[20];
332 for (
int a=0;
a<20;++
a) used_alct_mask[
a]=0;
334 int bx_alct_matched = 0;
350 bool is_matched =
false;
357 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
364 <<
"Successful ALCT-CLCT match: bx_clct = " << bx_clct
365 <<
"; match window: [" << bx_alct_start <<
"; " << bx_alct_stop
366 <<
"]; bx_alct = " << bx_alct;
369 used_alct_mask[bx_alct] += 1;
371 bx_alct_matched = bx_alct;
379 <<
"Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = "
380 << bx_clct <<
"; match window: [" << bx_alct_start
381 <<
"; " << bx_alct_stop <<
"]";
392 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
395 <<
"Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = "
415 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
423 std::vector<CSCCorrelatedLCTDigi> tmpV;
435 static int ifois = 0;
440 <<
"; in-time LCTs are not getting read-out!!! +++" <<
"\n";
445 <<
"+++ Allowed range of time bins, [0-" << late_tbins
446 <<
"] exceeds max allowed, " <<
MAX_LCT_BINS-1 <<
" +++\n"
447 <<
"+++ Set late_tbins to max allowed +++\n";
448 late_tbins = MAX_LCT_BINS-1;
456 std::vector<CSCCorrelatedLCTDigi> all_lcts =
getLCTs();
457 for (std::vector <CSCCorrelatedLCTDigi>::const_iterator plct =
458 all_lcts.begin(); plct != all_lcts.end(); plct++) {
459 if (!plct->isValid())
continue;
461 int bx = (*plct).getBX();
465 <<
" Do not report correlated LCT on key halfstrip "
466 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
467 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
473 if (bx > late_tbins) {
475 <<
" Do not report correlated LCT on key halfstrip "
476 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
477 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
486 if (bx_readout == -1 || bx == bx_readout) {
487 tmpV.push_back(*plct);
488 if (bx_readout == -1) bx_readout = bx;
492 else tmpV.push_back(*plct);
499 std::vector<CSCCorrelatedLCTDigi> tmpV;
522 bool anodeBestValid = bestALCT.
isValid();
523 bool anodeSecondValid = secondALCT.
isValid();
524 bool cathodeBestValid = bestCLCT.
isValid();
525 bool cathodeSecondValid = secondCLCT.
isValid();
527 if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
528 if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
529 if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
530 if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
538 int bx = lct.
getBX();
545 <<
"+++ Bx of first LCT candidate, " << bx
546 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
547 <<
"); skipping it... +++\n";
551 if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
556 int bx = lct.
getBX();
563 <<
"+++ Bx of second LCT candidate, " << bx
564 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
565 <<
"); skipping it... +++\n";
594 const int stripType) {
595 const int kPatternBitWidth = 4;
600 pattern = (
abs(ptn) & ((1<<(kPatternBitWidth-1))-1));
605 pattern = pattern | (1<<(kPatternBitWidth-1));
610 pattern = (
abs(ptn) & ((1<<kPatternBitWidth)-1));
621 unsigned int quality = 0;
631 if (isDistrip) {quality = 4;}
640 if (sumQual < 1 || sumQual > 6) {
642 <<
"+++ findQuality: sumQual = " << sumQual <<
"+++ \n";
645 if (sumQual == 2) {quality = 6;}
646 else if (sumQual == 3) {quality = 7;}
647 else if (sumQual == 4) {quality = 8;}
648 else if (sumQual == 5) {quality = 9;}
649 else if (sumQual == 6) {quality = 10;}
652 if (sumQual == 2) {quality = 11;}
653 else if (sumQual == 3) {quality = 12;}
654 else if (sumQual == 4) {quality = 13;}
655 else if (sumQual == 5) {quality = 14;}
656 else if (sumQual == 6) {quality = 15;}
677 if (sumQual < 1 || sumQual > 6) {
679 <<
"+++ findQuality: Unexpected sumQual = " << sumQual <<
"+++\n";
688 quality = offset + sumQual;
701 if (pattern == 1) quality = 3;
708 if (!a4 && !c4) quality = 5;
709 else if ( a4 && !c4) quality = 6;
710 else if (!a4 && c4) quality = 7;
711 else if ( a4 && c4) {
716 if (pattern == 2 || pattern == 3) quality = 11;
717 else if (pattern == 4 || pattern == 5) quality = 12;
718 else if (pattern == 6 || pattern == 7) quality = 13;
719 else if (pattern == 8 || pattern == 9) quality = 14;
720 else if (pattern == 10) quality = 15;
723 <<
"+++ findQuality: Unexpected CLCT pattern id = "
724 << pattern <<
"+++\n";
735 unsigned int lctPattern, lctQuality;
737 for (
int bend = 0; bend < 2; bend++) {
738 for (
int cfeb = 0; cfeb < 5; cfeb++) {
739 for (
int strip = 0; strip < 32; strip++) {
740 for (
int bx = 0; bx < 7; bx++) {
741 for (
int stripType = 0; stripType < 2; stripType++) {
742 for (
int quality = 3; quality < 7; quality++) {
747 for (
int aQuality = 0; aQuality < 4; aQuality++) {
748 for (
int wireGroup = 0; wireGroup < 120; wireGroup++) {
749 for (
int abx = 0; abx < 7; abx++) {
750 CSCALCTDigi aLCT(1, aQuality, 0, 1, wireGroup, abx);
753 thisLCT(0, 1, lctQuality, aLCT.
getKeyWG(),
756 if (lctPattern != static_cast<unsigned int>(thisLCT.getPattern()) )
758 <<
"pattern mismatch: " << lctPattern
759 <<
" " << thisLCT.getPattern();
760 if (bend != thisLCT.getBend())
762 <<
"bend mismatch: " << bend
763 <<
" " << thisLCT.getBend();
764 int key_strip = 32*cfeb + strip;
765 if (key_strip != thisLCT.getStrip())
767 <<
"strip mismatch: " << key_strip
768 <<
" " << thisLCT.getStrip();
769 if (wireGroup != thisLCT.getKeyWG())
771 <<
"wire group mismatch: " << wireGroup
772 <<
" " << thisLCT.getKeyWG();
773 if (abx != thisLCT.getBX())
775 <<
"bx mismatch: " << abx <<
" " << thisLCT.getBX();
776 if (lctQuality != static_cast<unsigned int>(thisLCT.getQuality()))
778 <<
"quality mismatch: " << lctQuality
779 <<
" " << thisLCT.getQuality();
793 std::ostringstream strm;
795 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
796 strm <<
"+ TMB configuration parameters: +\n";
797 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
798 strm <<
" mpc_block_me1a [block/not block triggers which come from ME1/A] = "
800 strm <<
" alct_trig_enable [allow ALCT-only triggers] = "
802 strm <<
" clct_trig_enable [allow CLCT-only triggers] = "
804 strm <<
" match_trig_enable [allow matched ALCT-CLCT triggers] = "
806 strm <<
" match_trig_window_size [ALCT-CLCT match window width, in 25 ns] = "
808 strm <<
" tmb_l1a_window_size [L1Accept window width, in 25 ns bins] = "
810 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
811 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