51 unsigned sector,
unsigned subsector,
54 theEndcap(endcap), theStation(station), theSector(sector),
55 theSubsector(subsector), theTrigChamber(chamber) {
61 static std::atomic<bool> config_dumped{
false};
102 const bool runME11ILT(commonParams.
existsAs<
bool>(
"runME11ILT")?commonParams.
getParameter<
bool>(
"runME11ILT"):
false);
103 const bool runME21ILT(commonParams.
existsAs<
bool>(
"runME21ILT")?commonParams.
getParameter<
bool>(
"runME21ILT"):
false);
112 tmbParams = me11tmbGemParams;
116 tmbParams = me21tmbGemParams;
122 mpc_block_me1a = tmbParams.getParameter<
unsigned int>(
"mpcBlockMe1a");
127 tmbParams.getParameter<
unsigned int>(
"matchTrigWindowSize");
129 tmbParams.getParameter<
unsigned int>(
"tmbL1aWindowSize");
134 early_tbins = tmbParams.getParameter<
int>(
"tmbEarlyTbins");
142 infoV = tmbParams.getParameter<
int>(
"verbosity");
151 if (infoV > 0 && !config_dumped) {
153 config_dumped =
true;
165 static std::atomic<bool> config_dumped{
false};
185 if (
infoV > 0 && !config_dumped) {
187 config_dumped =
true;
202 static std::atomic<bool> config_dumped{
false};
213 alct->setConfigParameters(conf);
214 clct->setConfigParameters(conf);
218 if (!config_dumped) {
220 config_dumped =
true;
228 static const unsigned int max_mpc_block_me1a = 1 << 1;
229 static const unsigned int max_alct_trig_enable = 1 << 1;
230 static const unsigned int max_clct_trig_enable = 1 << 1;
231 static const unsigned int max_match_trig_enable = 1 << 1;
232 static const unsigned int max_match_trig_window_size = 1 << 4;
233 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
239 <<
", exceeds max allowed, " << max_mpc_block_me1a-1 <<
" +++\n" 240 <<
"+++ Try to proceed with the default value, mpc_block_me1a=" 247 <<
", exceeds max allowed, " << max_alct_trig_enable-1 <<
" +++\n" 248 <<
"+++ Try to proceed with the default value, alct_trig_enable=" 255 <<
", exceeds max allowed, " << max_clct_trig_enable-1 <<
" +++\n" 256 <<
"+++ Try to proceed with the default value, clct_trig_enable=" 263 <<
", exceeds max allowed, " << max_match_trig_enable-1 <<
" +++\n" 264 <<
"+++ Try to proceed with the default value, match_trig_enable=" 271 <<
", exceeds max allowed, " << max_match_trig_window_size-1 <<
" +++\n" 272 <<
"+++ Try to proceed with the default value, match_trig_window_size=" 279 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n" 280 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size=" 298 clct->run(hs_times, ds_times);
300 int bx_alct_matched = 0;
303 if (
clct->bestCLCT[bx_clct].isValid()) {
304 bool is_matched =
false;
310 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
313 if (
alct->bestALCT[bx_alct].isValid()) {
315 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
317 bx_alct_matched = bx_alct;
325 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
331 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
332 if (
alct->bestALCT[bx_alct].isValid()) {
334 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
352 std::vector<CSCALCTDigi> alctV =
alct->run(wiredc);
355 std::vector<CSCCLCTDigi> clctV =
clct->run(compdc);
358 int used_alct_mask[20];
359 for (
int a=0;
a<20;++
a) used_alct_mask[
a]=0;
361 int bx_alct_matched = 0;
368 if (
clct->bestCLCT[bx_clct].isValid()) {
377 bool is_matched =
false;
384 for (
int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++) {
389 if (
alct->bestALCT[bx_alct].isValid()) {
391 <<
"Successful ALCT-CLCT match: bx_clct = " << bx_clct
392 <<
"; match window: [" << bx_alct_start <<
"; " << bx_alct_stop
393 <<
"]; bx_alct = " << bx_alct;
395 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
396 used_alct_mask[bx_alct] += 1;
398 bx_alct_matched = bx_alct;
406 <<
"Unsuccessful ALCT-CLCT match (CLCT only): bx_clct = " 407 << bx_clct <<
"; match window: [" << bx_alct_start
408 <<
"; " << bx_alct_stop <<
"]";
410 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
419 if (bx_alct >= 0 && bx_alct > bx_alct_matched) {
420 if (
alct->bestALCT[bx_alct].isValid()) {
422 <<
"Unsuccessful ALCT-CLCT match (ALCT only): bx_alct = " 425 clct->bestCLCT[bx_clct],
clct->secondCLCT[bx_clct]);
442 <<
"+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
450 std::vector<CSCCorrelatedLCTDigi> tmpV;
467 <<
"; in-time LCTs are not getting read-out!!! +++" <<
"\n";
472 <<
"+++ Allowed range of time bins, [0-" << late_tbins
474 <<
"+++ Set late_tbins to max allowed +++\n";
475 late_tbins = CSCConstants::MAX_LCT_TBINS-1;
483 std::vector<CSCCorrelatedLCTDigi> all_lcts =
getLCTs();
484 for (std::vector <CSCCorrelatedLCTDigi>::const_iterator plct =
485 all_lcts.begin(); plct != all_lcts.end(); plct++) {
486 if (!plct->isValid())
continue;
488 int bx = (*plct).getBX();
492 <<
" Do not report correlated LCT on key halfstrip " 493 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
494 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is " 500 if (bx > late_tbins) {
502 <<
" Do not report correlated LCT on key halfstrip " 503 << plct->getStrip() <<
" and key wire " << plct->getKeyWG()
504 <<
": found at bx " << bx <<
", whereas the latest allowed bx is " 513 if (bx_readout == -1 || bx == bx_readout) {
514 tmpV.push_back(*plct);
515 if (bx_readout == -1) bx_readout = bx;
519 else tmpV.push_back(*plct);
526 std::vector<CSCCorrelatedLCTDigi> tmpV;
549 bool anodeBestValid = bestALCT.
isValid();
550 bool anodeSecondValid = secondALCT.
isValid();
551 bool cathodeBestValid = bestCLCT.
isValid();
552 bool cathodeSecondValid = secondCLCT.
isValid();
554 if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
555 if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
556 if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
557 if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
565 int bx = lct.
getBX();
572 <<
"+++ Bx of first LCT candidate, " << bx
574 <<
"); skipping it... +++\n";
578 if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
583 int bx = lct.
getBX();
590 <<
"+++ Bx of second LCT candidate, " << bx
592 <<
"); skipping it... +++\n";
617 thisLCT.setALCT(aLCT);
618 thisLCT.setCLCT(cLCT);
625 const int stripType)
const {
626 const int kPatternBitWidth = 4;
631 pattern = (
abs(ptn) & ((1<<(kPatternBitWidth-1))-1));
636 pattern = pattern | (1<<(kPatternBitWidth-1));
641 pattern = (
abs(ptn) & ((1<<kPatternBitWidth)-1));
662 if (isDistrip) {quality = 4;}
671 if (sumQual < 1 || sumQual > 6) {
673 <<
"+++ findQuality: sumQual = " << sumQual <<
"+++ \n";
676 if (sumQual == 2) {quality = 6;}
677 else if (sumQual == 3) {quality = 7;}
678 else if (sumQual == 4) {quality = 8;}
679 else if (sumQual == 5) {quality = 9;}
680 else if (sumQual == 6) {quality = 10;}
683 if (sumQual == 2) {quality = 11;}
684 else if (sumQual == 3) {quality = 12;}
685 else if (sumQual == 4) {quality = 13;}
686 else if (sumQual == 5) {quality = 14;}
687 else if (sumQual == 6) {quality = 15;}
708 if (sumQual < 1 || sumQual > 6) {
710 <<
"+++ findQuality: Unexpected sumQual = " << sumQual <<
"+++\n";
719 quality = offset + sumQual;
732 if (pattern == 1) quality = 3;
739 if (!a4 && !c4) quality = 5;
740 else if ( a4 && !c4) quality = 6;
741 else if (!a4 && c4) quality = 7;
742 else if ( a4 && c4) {
747 if (pattern == 2 || pattern == 3) quality = 11;
748 else if (pattern == 4 || pattern == 5) quality = 12;
749 else if (pattern == 6 || pattern == 7) quality = 13;
750 else if (pattern == 8 || pattern == 9) quality = 14;
751 else if (pattern == 10) quality = 15;
754 <<
"+++ findQuality: Unexpected CLCT pattern id = " 755 << pattern <<
"+++\n";
766 unsigned int lctPattern, lctQuality;
768 for (
int bend = 0; bend < 2; bend++) {
769 for (
int cfeb = 0; cfeb < 5; cfeb++) {
771 for (
int bx = 0; bx < 7; bx++) {
772 for (
int stripType = 0; stripType < 2; stripType++) {
778 for (
int aQuality = 0; aQuality < 4; aQuality++) {
779 for (
int wireGroup = 0; wireGroup < 120; wireGroup++) {
780 for (
int abx = 0; abx < 7; abx++) {
781 CSCALCTDigi aLCT(1, aQuality, 0, 1, wireGroup, abx);
784 thisLCT(0, 1, lctQuality, aLCT.
getKeyWG(),
787 if (lctPattern != static_cast<unsigned int>(thisLCT.getPattern()) )
789 <<
"pattern mismatch: " << lctPattern
790 <<
" " << thisLCT.getPattern();
791 if (bend != thisLCT.getBend())
793 <<
"bend mismatch: " << bend
794 <<
" " << thisLCT.getBend();
795 int key_strip = 32*cfeb +
strip;
796 if (key_strip != thisLCT.getStrip())
798 <<
"strip mismatch: " << key_strip
799 <<
" " << thisLCT.getStrip();
800 if (wireGroup != thisLCT.getKeyWG())
802 <<
"wire group mismatch: " << wireGroup
803 <<
" " << thisLCT.getKeyWG();
804 if (abx != thisLCT.getBX())
806 <<
"bx mismatch: " << abx <<
" " << thisLCT.getBX();
807 if (lctQuality != static_cast<unsigned int>(thisLCT.getQuality()))
809 <<
"quality mismatch: " << lctQuality
810 <<
" " << thisLCT.getQuality();
824 std::ostringstream strm;
826 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
827 strm <<
"+ TMB configuration parameters: +\n";
828 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
829 strm <<
" mpc_block_me1a [block/not block triggers which come from ME1/A] = " 831 strm <<
" alct_trig_enable [allow ALCT-only triggers] = " 833 strm <<
" clct_trig_enable [allow CLCT-only triggers] = " 835 strm <<
" match_trig_enable [allow matched ALCT-CLCT triggers] = " 837 strm <<
" match_trig_window_size [ALCT-CLCT match window width, in 25 ns] = " 839 strm <<
" tmb_l1a_window_size [L1Accept window width, in 25 ns bins] = " 841 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
842 LogDebug(
"CSCMotherboard") << strm.str();
int getQuality() const
return quality of a pattern (number of layers hit!)
T getParameter(std::string const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
unsigned int clct_trig_enable
std::vector< CSCCorrelatedLCTDigi > getLCTs()
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
unsigned int match_trig_window_size
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
CSCCorrelatedLCTDigi secondLCT[CSCConstants::MAX_LCT_TBINS]
static const unsigned int def_clct_trig_enable
const CSCGeometry * csc_g
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
const unsigned theStation
unsigned int tmbMatchTrigWindowSize() const
static const unsigned int def_tmb_l1a_window_size
const unsigned theSubsector
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_7CFEBS], const std::vector< int > ds_times[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
int getBX() const
return BX
unsigned int tmbAlctTrigEnable() const
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
int getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
unsigned int tmbMpcBlockMe1a() const
int getQuality() const
return quality of a pattern
int getAccelerator() const
unsigned int findQuality(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT) const
int getPattern() const
return pattern
static const unsigned int def_match_trig_window_size
unsigned int encodePattern(const int ptn, const int highPt) const
unsigned int alct_trig_enable
std::unique_ptr< CSCAnodeLCTProcessor > alct
void dumpConfigParams() const
std::unique_ptr< CSCCathodeLCTProcessor > clct
void setConfigParameters(const CSCDBL1TPParameters *conf)
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, int type) const
void correlateLCTs(CSCALCTDigi &bestALCT, CSCALCTDigi &secondALCT, CSCCLCTDigi &bestCLCT, CSCCLCTDigi &secondCLCT)
int getKeyWG() const
return key wire group
static const unsigned int def_match_trig_enable
unsigned int tmbMatchTrigEnable() const
CSCCorrelatedLCTDigi firstLCT[CSCConstants::MAX_LCT_TBINS]