50 unsigned sector,
unsigned subsector,
53 theEndcap(endcap), theStation(station), theSector(sector),
54 theSubsector(subsector), theTrigChamber(chamber) {
57 static bool config_dumped =
false;
106 tmbParams.
getParameter<
unsigned int>(
"matchTrigWindowSize");
108 tmbParams.
getParameter<
unsigned int>(
"tmbL1aWindowSize");
128 if (infoV > 0 && !config_dumped) {
130 config_dumped =
true;
139 theEndcap(1), theStation(1), theSector(1),
140 theSubsector(1), theTrigChamber(1) {
142 static bool config_dumped =
false;
162 if (
infoV > 0 && !config_dumped) {
164 config_dumped =
true;
184 static bool config_dumped =
false;
200 if (!config_dumped) {
202 config_dumped =
true;
210 static const unsigned int max_mpc_block_me1a = 1 << 1;
211 static const unsigned int max_alct_trig_enable = 1 << 1;
212 static const unsigned int max_clct_trig_enable = 1 << 1;
213 static const unsigned int max_match_trig_enable = 1 << 1;
214 static const unsigned int max_match_trig_window_size = 1 << 4;
215 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
221 <<
", exceeds max allowed, " << max_mpc_block_me1a-1 <<
" +++\n"
222 <<
"+++ Try to proceed with the default value, mpc_block_me1a="
229 <<
", exceeds max allowed, " << max_alct_trig_enable-1 <<
" +++\n"
230 <<
"+++ Try to proceed with the default value, alct_trig_enable="
237 <<
", exceeds max allowed, " << max_clct_trig_enable-1 <<
" +++\n"
238 <<
"+++ Try to proceed with the default value, clct_trig_enable="
245 <<
", exceeds max allowed, " << max_match_trig_enable-1 <<
" +++\n"
246 <<
"+++ Try to proceed with the default value, match_trig_enable="
253 <<
", exceeds max allowed, " << max_match_trig_window_size-1 <<
" +++\n"
254 <<
"+++ Try to proceed with the default value, match_trig_window_size="
261 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
262 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
277 int bx_alct_matched = 0;
281 bool is_matched =
false;
287 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
294 bx_alct_matched = bx_alct;
308 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
324 std::vector<CSCALCTDigi> alctV =
alct->
run(wiredc);
327 std::vector<CSCCLCTDigi> clctV =
clct->
run(compdc);
330 int used_alct_mask[20];
331 for (
int a=0;
a<20;++
a) used_alct_mask[
a]=0;
333 int bx_alct_matched = 0;
349 bool is_matched =
false;
356 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
363 <<
"Successful ALCT-CLCT match: bx_clct = " << bx_clct
364 <<
"; match window: [" << bx_alct_start <<
"; " << bx_alct_stop
365 <<
"]; bx_alct = " << bx_alct;
368 used_alct_mask[bx_alct] += 1;
370 bx_alct_matched = bx_alct;
378 <<
"Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = "
379 << bx_clct <<
"; match window: [" << bx_alct_start
380 <<
"; " << bx_alct_stop <<
"]";
391 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
394 <<
"Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = "
414 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
422 std::vector<CSCCorrelatedLCTDigi> tmpV;
434 static int ifois = 0;
439 <<
"; in-time LCTs are not getting read-out!!! +++" <<
"\n";
444 <<
"+++ Allowed range of time bins, [0-" << late_tbins
445 <<
"] exceeds max allowed, " <<
MAX_LCT_BINS-1 <<
" +++\n"
446 <<
"+++ Set late_tbins to max allowed +++\n";
447 late_tbins = MAX_LCT_BINS-1;
455 std::vector<CSCCorrelatedLCTDigi> all_lcts =
getLCTs();
456 for (std::vector <CSCCorrelatedLCTDigi>::const_iterator plct =
457 all_lcts.begin(); plct != all_lcts.end(); plct++) {
458 if (!plct->isValid())
continue;
460 int bx = (*plct).getBX();
464 <<
" Do not report correlated LCT on key halfstrip "
465 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
466 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
472 if (bx > late_tbins) {
474 <<
" Do not report correlated LCT on key halfstrip "
475 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
476 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
485 if (bx_readout == -1 || bx == bx_readout) {
486 tmpV.push_back(*plct);
487 if (bx_readout == -1) bx_readout = bx;
491 else tmpV.push_back(*plct);
498 std::vector<CSCCorrelatedLCTDigi> tmpV;
521 bool anodeBestValid = bestALCT.
isValid();
522 bool anodeSecondValid = secondALCT.
isValid();
523 bool cathodeBestValid = bestCLCT.
isValid();
524 bool cathodeSecondValid = secondCLCT.
isValid();
526 if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
527 if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
528 if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
529 if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
537 int bx = lct.
getBX();
544 <<
"+++ Bx of first LCT candidate, " << bx
545 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
546 <<
"); skipping it... +++\n";
550 if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
555 int bx = lct.
getBX();
562 <<
"+++ Bx of second LCT candidate, " << bx
563 <<
", is not within the allowed range, [0-" <<
MAX_LCT_BINS-1
564 <<
"); skipping it... +++\n";
593 const int stripType) {
594 const int kPatternBitWidth = 4;
599 pattern = (
abs(ptn) & ((1<<(kPatternBitWidth-1))-1));
604 pattern = pattern | (1<<(kPatternBitWidth-1));
609 pattern = (
abs(ptn) & ((1<<kPatternBitWidth)-1));
630 if (isDistrip) {quality = 4;}
639 if (sumQual < 1 || sumQual > 6) {
641 <<
"+++ findQuality: sumQual = " << sumQual <<
"+++ \n";
644 if (sumQual == 2) {quality = 6;}
645 else if (sumQual == 3) {quality = 7;}
646 else if (sumQual == 4) {quality = 8;}
647 else if (sumQual == 5) {quality = 9;}
648 else if (sumQual == 6) {quality = 10;}
651 if (sumQual == 2) {quality = 11;}
652 else if (sumQual == 3) {quality = 12;}
653 else if (sumQual == 4) {quality = 13;}
654 else if (sumQual == 5) {quality = 14;}
655 else if (sumQual == 6) {quality = 15;}
676 if (sumQual < 1 || sumQual > 6) {
678 <<
"+++ findQuality: Unexpected sumQual = " << sumQual <<
"+++\n";
687 quality = offset + sumQual;
700 if (pattern == 1) quality = 3;
707 if (!a4 && !c4) quality = 5;
708 else if ( a4 && !c4) quality = 6;
709 else if (!a4 && c4) quality = 7;
710 else if ( a4 && c4) {
715 if (pattern == 2 || pattern == 3) quality = 11;
716 else if (pattern == 4 || pattern == 5) quality = 12;
717 else if (pattern == 6 || pattern == 7) quality = 13;
718 else if (pattern == 8 || pattern == 9) quality = 14;
719 else if (pattern == 10) quality = 15;
722 <<
"+++ findQuality: Unexpected CLCT pattern id = "
723 << pattern <<
"+++\n";
734 unsigned int lctPattern, lctQuality;
736 for (
int bend = 0; bend < 2; bend++) {
737 for (
int cfeb = 0; cfeb < 5; cfeb++) {
738 for (
int strip = 0; strip < 32; strip++) {
739 for (
int bx = 0; bx < 7; bx++) {
740 for (
int stripType = 0; stripType < 2; stripType++) {
746 for (
int aQuality = 0; aQuality < 4; aQuality++) {
747 for (
int wireGroup = 0; wireGroup < 120; wireGroup++) {
748 for (
int abx = 0; abx < 7; abx++) {
749 CSCALCTDigi aLCT(1, aQuality, 0, 1, wireGroup, abx);
752 thisLCT(0, 1, lctQuality, aLCT.
getKeyWG(),
755 if (lctPattern != static_cast<unsigned int>(thisLCT.getPattern()) )
757 <<
"pattern mismatch: " << lctPattern
758 <<
" " << thisLCT.getPattern();
759 if (bend != thisLCT.getBend())
761 <<
"bend mismatch: " << bend
762 <<
" " << thisLCT.getBend();
763 int key_strip = 32*cfeb + strip;
764 if (key_strip != thisLCT.getStrip())
766 <<
"strip mismatch: " << key_strip
767 <<
" " << thisLCT.getStrip();
768 if (wireGroup != thisLCT.getKeyWG())
770 <<
"wire group mismatch: " << wireGroup
771 <<
" " << thisLCT.getKeyWG();
772 if (abx != thisLCT.getBX())
774 <<
"bx mismatch: " << abx <<
" " << thisLCT.getBX();
775 if (lctQuality != static_cast<unsigned int>(thisLCT.getQuality()))
777 <<
"quality mismatch: " << lctQuality
778 <<
" " << thisLCT.getQuality();
792 std::ostringstream strm;
794 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
795 strm <<
"+ TMB configuration parameters: +\n";
796 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
797 strm <<
" mpc_block_me1a [block/not block triggers which come from ME1/A] = "
799 strm <<
" alct_trig_enable [allow ALCT-only triggers] = "
801 strm <<
" clct_trig_enable [allow CLCT-only triggers] = "
803 strm <<
" match_trig_enable [allow matched ALCT-CLCT triggers] = "
805 strm <<
" match_trig_window_size [ALCT-CLCT match window width, in 25 ns] = "
807 strm <<
" tmb_l1a_window_size [L1Accept window width, in 25 ns bins] = "
809 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
810 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)
Abs< T >::type abs(const T &t)
unsigned int tmb_l1a_window_size
void checkConfigParameters()
bool isValid() const
check CLCT validity (1 - valid CLCT)
unsigned int match_trig_enable
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