69 { 999, 999, 999, 999, 999,
70 999, 999, 999, 999, 999,
71 999, 999, 999, 999, 999,
73 999, 999, 999, 999, 999,
74 999, 999, 999, 999, 999, 0},
76 { 999, 999, 999, 0, 999,
77 999, 999, 999, 1, 999,
81 999, 5, 999, 999, 999, 1},
83 { 999, 0, 999, 999, 999,
84 999, 1, 999, 999, 999,
88 999, 999, 999, 5, 999, 0},
90 { 999, 999, 0, 999, 999,
91 999, 999, 1, 999, 999,
92 999, 999, 2, 999, 999,
94 999, 4, 999, 999, 999,
95 999, 5, 999, 999, 999, 1},
97 { 999, 999, 0, 999, 999,
98 999, 999, 1, 999, 999,
99 999, 999, 2, 999, 999,
101 999, 999, 999, 4, 999,
102 999, 999, 999, 5, 999, 0},
104 { 999, 999, 999, 0, 999,
105 999, 999, 999, 1, 999,
108 999, 999, 4, 999, 999,
109 999, 999, 5, 999, 999, 1},
111 { 999, 0, 999, 999, 999,
112 999, 1, 999, 999, 999,
115 999, 999, 4, 999, 999,
116 999, 999, 5, 999, 999, 0},
118 { 999, 999, 0, 999, 999,
119 999, 999, 1, 999, 999,
120 999, 999, 2, 999, 999,
122 999, 999, 4, 999, 999,
123 999, 999, 5, 999, 999, 1}
132 { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
136 -4, -3, -2, -1, 0, 1, 2, 3, 4,
137 -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
140 { 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
141 999, 999, 999, 999, 999,
143 999, 999, 999, 999, 999,
144 999, 999, 999, 999, 999, 999, 999, 999, 999,
145 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -1, 0},
147 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 4, 4, 4, 4, 4, 4, 4, 4, 4,
152 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 11},
154 { 999, 999, 999, 999, 999, 999, 999, 999, 0, 0, 0,
158 4, 4, 4, 999, 999, 999, 999, 999, 999,
159 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 999, 0, 11},
161 { 0, 0, 0, 999, 999, 999, 999, 999, 999, 999, 999,
165 999, 999, 999, 999, 999, 999, 4, 4, 4,
166 999, 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 1, 11},
168 { 999, 999, 999, 999, 999, 999, 999, 0, 0, 0, 999,
172 4, 4, 4, 999, 999, 999, 999, 999, 999,
173 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 0, 9},
175 { 999, 0, 0, 0, 999, 999, 999, 999, 999, 999, 999,
179 999, 999, 999, 999, 999, 999, 4, 4, 4,
180 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 1, 9},
182 { 999, 999, 999, 999, 999, 999, 0, 0, 0, 999, 999,
186 999, 999, 4, 4, 999, 999, 999, 999, 999,
187 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 0, 7},
189 { 999, 999, 0, 0, 0, 999, 999, 999, 999, 999, 999,
193 999, 999, 999, 999, 999, 4, 4, 999, 999,
194 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 1, 7},
196 { 999, 999, 999, 999, 999, 0, 0, 0, 999, 999, 999,
200 999, 999, 4, 4, 4, 999, 999, 999, 999,
201 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 0, 5},
203 { 999, 999, 999, 0, 0, 0, 999, 999, 999, 999, 999,
207 999, 999, 999, 999, 4, 4, 4, 999, 999,
208 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 1, 5},
210 { 999, 999, 999, 999, 0, 0, 0, 999, 999, 999, 999,
211 999, 999, 1, 999, 999,
213 999, 999, 3, 999, 999,
214 999, 999, 999, 4, 4, 4, 999, 999, 999,
215 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 0, 3}
248 theEndcap(endcap), theStation(station), theSector(sector),
249 theSubsector(subsector), theTrigChamber(chamber) {
250 static std::atomic<bool> config_dumped{
false};
257 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
259 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
279 if (isSLHC && !smartME1aME1b)
edm::LogError(
"L1CSCTPEmulatorConfigError")
280 <<
"+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n" 281 <<
"Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
285 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
321 if ((infoV > 0 || isSLHC) && !config_dumped) {
324 config_dumped =
true;
330 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
362 static std::atomic<bool> config_dumped{
false};
382 if (!config_dumped) {
385 config_dumped =
true;
391 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
424 static std::atomic<bool> config_dumped{
false};
441 if (!config_dumped) {
444 config_dumped =
true;
452 static const unsigned int max_fifo_tbins = 1 << 5;
453 static const unsigned int max_fifo_pretrig = 1 << 5;
454 static const unsigned int max_hit_persist = 1 << 4;
455 static const unsigned int max_drift_delay = 1 << 2;
456 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
457 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
458 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
460 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
466 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n" 467 <<
"+++ Try to proceed with the default value, fifo_tbins=" 474 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n" 475 <<
"+++ Try to proceed with the default value, fifo_pretrig=" 482 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n" 483 <<
"+++ Try to proceed with the default value, hit_persist=" 490 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n" 491 <<
"+++ Try to proceed with the default value, drift_delay=" 498 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n" 499 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig=" 506 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n" 507 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern=" 516 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n" 517 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig=" 524 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n" 525 <<
"+++ Try to proceed with the default value, min_separation=" 534 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n" 535 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size=" 550 std::vector<CSCCLCTDigi>
558 static std::atomic<bool> config_dumped{
false};
562 config_dumped =
true;
595 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
601 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
619 (
chamber->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
624 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
628 <<
" is not defined in current geometry! +++\n" 629 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
636 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
640 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
641 std::vector<CSCCLCTDigi> emptyV;
667 unsigned int layersHit = 0;
671 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
681 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
693 std::vector<CSCCLCTDigi> LCTlist;
702 LCTlist =
findLCTs(halfstrip, distrip);
705 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
706 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
708 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
709 LCTlist.push_back(halfStripLCTs[
i]);
710 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
711 LCTlist.push_back(diStripLCTs[i]);
715 if (LCTlist.size() > 1)
716 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
719 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
720 plct != LCTlist.end(); plct++) {
721 int bx = plct->getBX();
724 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, " 767 digiV[i_layer].clear();
790 <<
"found " <<
digiV[i_layer].size()
791 <<
" comparator digi(s) in layer " << i_layer <<
" of ME" 806 bool me1b = (
id.station() == 1) && (
id.
ring() == 1);
807 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
810 digiIt != rcompd.second; ++digiIt) {
811 unsigned int origStrip = digiIt->getStrip();
812 unsigned int maxStripsME1a =
gangedME1a ? 16 : 48;
817 digiIt->getComparator(),
818 digiIt->getTimeBinWord());
819 digiV[
id.layer()-1].push_back(digi_corr);
824 if (me1aProc && me1b && origStrip > 64){
827 digiIt->getComparator(),
828 digiIt->getTimeBinWord());
829 digiV[
id.layer()-1].push_back(digi_corr);
830 }
else if ((me1bProc && me1b && origStrip <= 64)
831 || ((me1aProc && me1a))
833 digiV[
id.layer()-1].push_back(*digiIt);
837 digiV[
id.layer()-1].push_back(*digiIt);
850 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
851 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
854 std::ostringstream strstrm;
855 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
856 <<
" strip #" << pld->getStrip()
858 std::vector<int> bx_times = pld->getTimeBinsOn();
859 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
860 strstrm <<
" " << bx_times[tbin];
861 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
866 int thisComparator = pld->getComparator();
867 if (thisComparator != 0 && thisComparator != 1) {
869 <<
"+++ Found comparator digi with wrong comparator value = " 870 << thisComparator <<
"; skipping it... +++\n";
875 int thisStrip = pld->getStrip() - 1;
876 if (thisStrip < 0 || thisStrip >=
numStrips) {
878 <<
"+++ Found comparator digi with wrong strip number = " 880 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
886 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
889 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
890 <<
"; skipping this digi... +++\n";
895 std::vector<int> bx_times = pld->getTimeBinsOn();
896 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
904 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
906 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
912 <<
"Comp digi: layer " << i_layer+1
913 <<
" digi #" << i_digi+1
914 <<
" strip " << thisStrip
915 <<
" halfstrip " << thisHalfstrip
916 <<
" distrip " << thisStrip/2 +
917 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
918 <<
" time " << bx_times[
i]
919 <<
" comparator " << thisComparator
920 <<
" stagger " << stagger[i_layer];
921 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
925 <<
" Skipping comparator digi: strip = " << thisStrip
926 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
927 <<
", bx of previous hit = " << bx_times[
i-1];
932 <<
"+++ Skipping comparator digi: strip = " << thisStrip
933 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
954 digiNum[
i][j] = -999;
959 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
960 for (
unsigned int j = 0; j < layerDigiV.size(); j++) {
966 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
967 <<
" strip #" << thisDigi.
getStrip()
973 if (thisComparator != 0 && thisComparator != 1) {
975 <<
"+++ Comparator digi with wrong comparator value: digi #" << j
976 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
981 int thisStrip = thisDigi.
getStrip() - 1;
982 if (thisStrip < 0 || thisStrip >=
numStrips) {
984 <<
"+++ Comparator digi with wrong strip number: digi #" << j
985 <<
", strip = " << thisStrip
986 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
995 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
1004 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
1005 digiNum[
i][thisStrip] = j;
1006 time[
i][thisStrip] = thisDigiBx;
1007 comp[
i][thisStrip] = thisComparator;
1009 <<
"Comp digi: layer " <<
i+1
1011 <<
" strip " << thisStrip
1012 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
1013 <<
" distrip " << thisStrip/2 +
1014 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
1015 <<
" time " << time[
i][thisStrip]
1016 <<
" comparator " << comp[
i][thisStrip]
1022 <<
"+++ Skipping comparator digi: strip = " << thisStrip
1023 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1034 if (time[
i][j] >= 0) {
1035 int i_halfstrip = 2*j + comp[
i][j] +
stagger[
i];
1041 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1042 <<
"; skipping this digi... +++\n";
1045 halfstrip[
i][i_halfstrip].push_back(time[
i][j]);
1054 static std::atomic<int> test_iteration{0};
1056 if (time[
i][j] >= 0) {
1057 int i_distrip = j/2;
1058 if (j%2 == 1 && comp[
i][j] == 1 &&
stagger[
i] == 1) {
1060 bool stagger_debug = (
infoV > 2);
1069 if (
infoV > 2 && test_iteration == 1) {
1075 <<
"+++ Found wrong distrip number = " << i_distrip
1076 <<
"; skipping this digi... +++\n";
1079 distrip[
i][i_distrip].push_back(time[
i][j]);
1087 int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1088 int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1089 int i_strip,
bool debug) {
1107 <<
"+++ Found wrong strip number = " << i_strip
1108 <<
"; cannot apply distrip staggering... +++\n";
1114 <<
" Enter distripStagger: i_strip = " << i_strip
1115 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1116 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1117 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1118 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1129 if (stag_time[i_strip+2] >= 0) {
1130 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1131 stag_time[i_strip+2] = stag_time[i_strip];
1132 stag_digi[i_strip+2] = stag_digi[i_strip];
1138 stag_time[i_strip+2] = stag_time[i_strip];
1139 stag_digi[i_strip+2] = stag_digi[i_strip];
1146 stag_time[i_strip] = -999;
1147 stag_triad[i_strip] = 4;
1148 stag_digi[i_strip] = -999;
1152 <<
" Exit distripStagger: i_strip = " << i_strip
1153 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1154 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1155 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1156 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1174 const int adjacent_strips = 2;
1177 int highest_quality = 0;
1182 std::vector <CSCCLCTDigi> lctList;
1185 if (stripType == 1) nStrips = 2*
numStrips + 1;
1186 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1198 final_lcts[j] = -999;
1204 final_lcts[0] = best_strip;
1206 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1208 if (
abs(best_strip - key_strip) > adjacent_strips){
1210 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1211 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1212 final_lcts[1] = key_strip;
1220 int keystrip = final_lcts[j];
1221 if (keystrip >= 0 &&
1222 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1230 int halfstrip_in_cfeb =
1239 keystrip_data[keystrip][
CLCT_BX]);
1244 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1247 <<
"Key Strip: " << std::setw(3)
1249 <<
" Pattern: " << std::setw(2)
1251 <<
" Bend: " << std::setw(1) << bend
1252 <<
" Quality: " << std::setw(1)
1254 <<
" stripType: " << std::setw(1) << stripType
1255 <<
" BX: " << std::setw(1)
1256 << keystrip_data[keystrip][
CLCT_BX];
1258 lctList.push_back(thisLCT);
1269 const int stripType,
const int nStrips,
1276 int i_layer, i_strip, this_layer, this_strip;
1277 int hits, layers_hit;
1280 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1287 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1293 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1298 hit_layer[i_layer] =
false;
1303 if (this_strip >= 0 && this_strip < nStrips) {
1305 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1308 if (hit_layer[this_layer] ==
false) {
1309 hit_layer[this_layer] =
true;
1314 if (layers_hit >= pre_trigger_layer_min) {
1332 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1334 int key_strip, this_layer, this_strip;
1337 int highest_quality = 0;
1340 for (key_strip = 0; key_strip < nStrips; key_strip++)
1342 keystrip_data[key_strip][
i] = 0;
1347 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1354 if ((this_strip >= 0 && this_strip < nStrips) &&
1355 !
strip[this_layer][this_strip].empty()) {
1356 if (nullPattern) nullPattern =
false;
1357 std::vector<int> bx_times =
strip[this_layer][this_strip];
1358 lct_pattern[pattern_strip] = bx_times[0];
1361 lct_pattern[pattern_strip] = -999;
1365 if (nullPattern)
continue;
1379 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1381 <<
"Key_strip " << key_strip <<
" quality of pattern_num " 1382 << pattern_num <<
": " <<
quality;
1383 if (quality > best_quality){
1386 keystrip_data[key_strip][
CLCT_BEND] = bend;
1387 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1388 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1391 if (quality > highest_quality){
1396 best_strip = key_strip;
1418 hit_layer[i_layer] =
false;
1422 if (
hitIsGood(strip_value[strip_num], bx_time)){
1426 if (i_layer ==
pattern[pattern_num][strip_num]){
1428 if (hit_layer[i_layer] ==
false){
1430 hit_layer[i_layer] =
true;
1438 quality = layers_hit;
1446 int dt = BX - hitTime;
1447 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1448 else {
return false;}
1466 std::vector <CSCCLCTDigi> lctList;
1467 int _bx[2] = {999, 999};
1486 bool pre_trig[2] = {
false,
false};
1490 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1491 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1495 if (pre_trig[0] || pre_trig[1]) {
1496 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1498 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1499 <<
"\n ..... waiting drift delay ..... ";
1538 <<
"...............................\n" 1539 <<
"Final halfstrip hits and keys (after drift delay) ...";
1542 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1543 <<
" hits " << h_nhits[icfeb];
1546 <<
"Final distrip hits and keys (after drift delay) ...";
1549 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1550 <<
" hits " << d_nhits[icfeb];
1553 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1556 for (
int ilct = 0; ilct < 2; ilct++) {
1558 <<
"found lcts: ilct " << ilct
1559 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1561 int halfstrip_in_cfeb = 0;
1563 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1566 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1575 keystrip_data[ilct][
CLCT_BX]);
1576 lctList.push_back(thisLCT);
1590 const int stripType,
const int nStrips,
1591 const int start_bx,
int& first_bx) {
1593 <<
"....................PreTrigger...........................";
1595 if (start_bx == 0) {
1600 bool pre_trig =
false;
1602 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1608 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1616 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1625 const int stripType,
const int nStrips,
1626 const unsigned int bx_time) {
1631 int key_strip, this_layer, this_strip, layers_hit;
1634 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1636 if (stripType != 0 && stripType != 1) {
1638 <<
"+++ preTrigLookUp: stripType = " << stripType
1639 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1645 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1647 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1650 hit_layer[ilayer] =
false;
1657 if (this_strip >= 0 && this_strip < nStrips) {
1659 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1660 if (hit_layer[this_layer] ==
false) {
1661 hit_layer[this_layer] =
true;
1663 if (layers_hit >= pre_trigger_layer_min) {
1665 <<
"pretrigger at bx: " << bx_time
1666 <<
", cfeb " << icfeb <<
", returning";
1685 const int stripType,
const int nStrips,
const int bx_time) {
1688 int key_strip, this_layer, this_strip;
1689 int layers_hit, prev_hits;
1692 keyStrip[icfeb] = -1;
1696 if (stripType != 0 && stripType != 1) {
1698 <<
"+++ latchLCTs: stripType = " << stripType
1699 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1706 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1708 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1711 hit_layer[ilayer] =
false;
1718 if (this_strip >= 0 && this_strip < nStrips) {
1720 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1721 if (hit_layer[this_layer] ==
false) {
1722 hit_layer[this_layer] =
true;
1729 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1730 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1731 <<
" n_hits: " << layers_hit;
1736 if (layers_hit > prev_hits) {
1737 prev_hits = layers_hit;
1738 keyStrip[icfeb] = key_strip;
1739 n_hits[icfeb] = layers_hit;
1749 const int d_keyStrip[CSCConstants::MAX_CFEBS],
const unsigned int d_nhits[CSCConstants::MAX_CFEBS],
1766 key_strip[icfeb] = -1;
1767 key_phits[icfeb] = -1;
1768 strip_type[icfeb] = -1;
1773 <<
".....................PriorityEncode.......................";
1774 std::ostringstream strstrm;
1775 strstrm <<
"hkeys:";
1777 strstrm << std::setw(4) << h_keyStrip[icfeb];
1779 strstrm <<
"\ndkeys:";
1781 strstrm << std::setw(4) << d_keyStrip[icfeb];
1783 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1789 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1790 if (h_nhits[icfeb] >= hs_thresh) {
1791 key_strip[icfeb] = h_keyStrip[icfeb];
1792 key_phits[icfeb] = h_nhits[icfeb] + 8;
1793 strip_type[icfeb]= 1;
1799 key_strip[icfeb] = d_keyStrip[icfeb];
1800 key_phits[icfeb] = d_nhits[icfeb];
1801 strip_type[icfeb]= 0;
1804 else if (h_keyStrip[icfeb] != -1) {
1805 if (h_nhits[icfeb] >= hs_thresh) {
1806 key_strip[icfeb] = h_keyStrip[icfeb];
1807 key_phits[icfeb] = h_nhits[icfeb] + 8;
1808 strip_type[icfeb]= 1;
1811 else if (d_keyStrip[icfeb] != -1) {
1813 key_strip[icfeb] = d_keyStrip[icfeb];
1814 key_phits[icfeb] = d_nhits[icfeb];
1815 strip_type[icfeb]= 0;
1818 if (
infoV > 1 && strip_type[icfeb] != -1) {
1819 if (strip_type[icfeb] == 0)
1821 <<
" taking distrip pattern on cfeb " << icfeb;
1822 else if (strip_type[icfeb] == 1)
1824 <<
" taking halfstrip pattern on cfeb " << icfeb;
1826 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1827 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1838 <<
"...... Remove Duplicates ......";
1840 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1841 else key[icfeb] = key_strip[icfeb];
1843 for (
int icfeb = 0; icfeb < CSCConstants::MAX_CFEBS-1; icfeb++) {
1844 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1848 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1849 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1850 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1852 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1853 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1855 <<
" deleting LCT on CFEB " << icfeb;
1856 key_strip[icfeb] = -1;
1857 key_phits[icfeb] = -1;
1861 <<
" deleting LCT on CFEB " << icfeb+1;
1862 key_strip[icfeb+1] = -1;
1863 key_phits[icfeb+1] = -1;
1872 <<
"\n...... Select best LCTs ......";
1874 if (key_phits[icfeb] > ihits[0]) {
1875 ihits[1] = ihits[0];
1876 cfebs[1] = cfebs[0];
1877 ihits[0] = key_phits[icfeb];
1880 std::ostringstream strstrm;
1882 strstrm << std::setw(4) << strip_type[icfeb];
1885 <<
"strip_type" << strstrm.str()
1886 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1887 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1888 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1889 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1892 else if (key_phits[icfeb] > ihits[1]) {
1893 ihits[1] = key_phits[icfeb];
1896 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1897 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1904 if (cfebs[ilct] != -1) {
1905 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1906 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1909 <<
"filling key: " << key_strip[cfebs[ilct]]
1910 <<
" type: " << strip_type[cfebs[ilct]];
1924 int this_layer, this_strip;
1925 unsigned int quality = 0, bend = 0;
1926 unsigned int best_quality, best_pattern;
1927 bool valid[2] = {
false,
false};
1937 <<
"...............getKeyStripData....................";
1939 for (
int ilct = 0; ilct < 2; ilct++) {
1941 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1945 <<
"no lct at ilct " << ilct;
1950 lct_pattern[pattern_strip] = -999;
1959 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1960 lct_pattern[pattern_strip] = 1;
1966 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1967 lct_pattern[pattern_strip] = 1;
1977 for (
unsigned int pattern_num = 0;
1979 getPattern(pattern_num, lct_pattern, quality, bend);
1981 <<
"pattern " << pattern_num <<
" quality " << quality
1982 <<
" bend " << bend;
1989 if ((quality == best_quality && pattern_num > best_pattern) ||
1990 (quality > best_quality)) {
1992 <<
"valid = true at quality " << quality
1997 keystrip_data[ilct][
CLCT_BX] = first_bx;
2001 best_pattern = pattern_num;
2009 <<
"lct " << ilct <<
" not over threshold: deleting";
2013 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n" 2014 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
2015 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
2017 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
2018 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
2028 unsigned int&
quality,
unsigned int& bend) {
2035 unsigned int layers_hit = 0;
2040 hit_layer[i_layer] =
false;
2044 if (strip_value[strip_num] == 1){
2048 if (i_layer ==
pattern[pattern_num][strip_num]){
2050 if (hit_layer[i_layer] ==
false){
2052 hit_layer[i_layer] =
true;
2060 quality = layers_hit;
2073 std::vector<CSCCLCTDigi> lctList;
2076 const int maxHalfStrips = 2*
numStrips + 1;
2092 while (start_bx < stop_bx) {
2096 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2103 <<
"..... pretrigger at bx = " << first_bx
2104 <<
"; waiting drift delay .....";
2108 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2112 hstrip < maxHalfStrips; hstrip++) {
2113 if (
nhits[hstrip] > 0) {
2115 <<
" bx = " << std::setw(2) << latch_bx <<
" --->" 2116 <<
" halfstrip = " << std::setw(3) << hstrip
2117 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2118 <<
" nhits = " <<
nhits[hstrip];
2125 start_bx = first_bx + 1;
2131 best_halfstrip[ilct] = -1;
2132 best_quality[ilct] = 0;
2139 hstrip < maxHalfStrips; hstrip++) {
2142 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2143 if (quality[hstrip] > best_quality[0]) {
2144 best_halfstrip[0] = hstrip;
2145 best_quality[0] = quality[hstrip];
2147 if (
infoV > 1 && quality[hstrip] > 0) {
2149 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2150 <<
" quality = " << std::setw(3) << quality[hstrip]
2151 <<
" nhits = " << std::setw(3) <<
nhits[hstrip]
2152 <<
" pid = " << std::setw(3) <<
best_pid[hstrip]
2153 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2154 <<
" best quality = " << std::setw(3) << best_quality[0];
2160 if (best_halfstrip[0] >= 0) {
2166 hstrip < maxHalfStrips; hstrip++) {
2167 if (quality[hstrip] > best_quality[1]) {
2168 best_halfstrip[1] = hstrip;
2169 best_quality[1] = quality[hstrip];
2171 if (
infoV > 1 && quality[hstrip] > 0) {
2173 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2174 <<
" quality = " << std::setw(3) << quality[hstrip]
2175 <<
" nhits = " << std::setw(3) <<
nhits[hstrip]
2176 <<
" pid = " << std::setw(3) <<
best_pid[hstrip]
2177 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2178 <<
" best quality = " << std::setw(3) << best_quality[1];
2183 bool ptn_trig =
false;
2185 int best_hs = best_halfstrip[ilct];
2194 keystrip_data[ilct][
CLCT_BX] = first_bx;
2199 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2203 <<
" Final selection: ilct " << ilct
2204 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2207 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2215 keystrip_data[ilct][
CLCT_BX]);
2216 lctList.push_back(thisLCT);
2231 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2232 bool return_to_idle =
true;
2233 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2236 hstrip < maxHalfStrips; hstrip++) {
2239 <<
" State machine busy at bx = " << bx;
2240 return_to_idle =
false;
2245 if (return_to_idle) {
2247 <<
" State machine returns to idle state at bx = " << bx;
2256 start_bx = first_bx + 1;
2270 static const unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2281 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2282 pulse[i_layer][i_strip] = 0;
2286 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2290 std::vector<int> bx_times =
time[i_layer][i_strip];
2291 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2293 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2295 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2296 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2297 <<
" is not within the range (0-" << bits_in_pulse
2298 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2302 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2303 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2315 const int start_bx,
int& first_bx) {
2317 <<
"....................PreTrigger...........................";
2322 int nPreTriggers = 0;
2324 bool pre_trig =
false;
2326 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2332 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2335 hstrip < nStrips; hstrip++) {
2337 if (
nhits[hstrip] > 0) {
2339 <<
" bx = " << std::setw(2) << bx_time <<
" --->" 2340 <<
" halfstrip = " << std::setw(3) << hstrip
2341 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2342 <<
" nhits = " <<
nhits[hstrip];
2355 1, bend, hstrip%32, hstrip/32, bx_time, nPreTriggers, 0));
2368 "no pretrigger, returning \n";
2377 const int nStrips,
const unsigned int bx_time)
2384 unsigned int layers_hit = 0;
2387 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2389 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2398 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2401 nhits[key_hstrip] = 0;
2414 hit_layer[ilayer] =
false;
2416 double num_pattern_hits=0., times_sum=0.;
2417 std::multiset<int> mset_for_median;
2418 mset_for_median.clear();
2425 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2428 if (this_strip >= 0 && this_strip < nStrips) {
2430 <<
" In ptnFinding: key_strip = " << key_hstrip
2431 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2432 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2434 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2436 if (hit_layer[this_layer] ==
false)
2438 hit_layer[this_layer] =
true;
2444 int first_bx_layer = bx_time;
2445 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2447 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2452 times_sum += (double) first_bx_layer;
2453 num_pattern_hits += 1.;
2454 mset_for_median.insert(first_bx_layer);
2456 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2457 <<
" #pat. hits: " << num_pattern_hits;
2463 if (layers_hit >
nhits[key_hstrip])
2466 nhits[key_hstrip] = layers_hit;
2469 const int sz = mset_for_median.size();
2471 std::multiset<int>::iterator im = mset_for_median.begin();
2472 if (sz>1) std::advance(im,sz/2-1);
2479 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2480 sprintf(bxs,
"%s %d", bxs, *im);
2488 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2498 const int best_patid,
2507 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2508 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
2520 std::vector<CSCCLCTDigi>
2523 std::vector<CSCCLCTDigi> lctList;
2526 const int maxHalfStrips = 2 *
numStrips + 1;
2534 busyMap[
i][j] =
false;
2536 std::vector<CSCCLCTDigi> lctListBX;
2550 while (start_bx < stop_bx)
2556 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2563 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2567 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2574 if (
nhits[hstrip] > 0)
2576 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = " 2577 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2584 start_bx = first_bx + 1;
2594 best_halfstrip[ilct] = -1;
2595 best_quality[ilct] = 0;
2607 pretrig_zone[hstrip] =
false;
2616 if (max_hs > CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1)
2617 max_hs = CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1;
2618 for (
int hs = min_hs; hs <= max_hs; hs++)
2619 pretrig_zone[hs] =
true;
2621 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2628 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2632 if (quality[hstrip] > best_quality[0] &&
2633 pretrig_zone[hstrip] &&
2634 !busyMap[hstrip][first_bx] )
2636 best_halfstrip[0] = hstrip;
2637 best_quality[0] = quality[hstrip];
2640 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = " 2641 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2642 <<
" best quality = " << std::setw(3) << best_quality[0];
2649 if (best_halfstrip[0] >= 0)
2656 if (quality[hstrip] > best_quality[1] &&
2657 pretrig_zone[hstrip] &&
2658 !busyMap[hstrip][first_bx] )
2660 best_halfstrip[1] = hstrip;
2661 best_quality[1] = quality[hstrip];
2664 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = " 2665 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2666 <<
" best quality = " << std::setw(3) << best_quality[1];
2672 bool ptn_trig =
false;
2675 int best_hs = best_halfstrip[ilct];
2689 keystrip_data[ilct][
CLCT_BX] = bx;
2696 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip " 2704 lctList.push_back(thisLCT);
2705 lctListBX.push_back(thisLCT);
2718 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2726 int min_hstrip = key_hstrip - delta_hs;
2727 int max_hstrip = key_hstrip + delta_hs;
2731 if (max_hstrip > maxHalfStrips)
2732 max_hstrip = maxHalfStrips;
2735 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" [" 2736 << min_hstrip <<
"," << max_hstrip <<
"]";
2743 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2745 bool busy_bx =
false;
2746 if (bx <= (
size_t)latch_bx)
2750 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2754 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits=" 2755 <<
nhits[key_hstrip];
2758 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2760 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2761 busyMap[hstrip][bx] =
true;
2771 start_bx = first_bx + 1;
2784 std::ostringstream strm;
2786 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2787 strm <<
"+ CLCT configuration parameters: +\n";
2788 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2789 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = " 2791 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = " 2793 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = " 2795 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = " 2797 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = " 2799 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = " 2802 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = " 2804 strm <<
" min_separation [region of busy key strips] = " 2807 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2808 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2816 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2818 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2820 std::ostringstream strstrm;
2821 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2822 if (i_strip%10 == 0) {
2823 if (i_strip < 100) strstrm << i_strip/10;
2824 else strstrm << (i_strip-100)/10;
2826 else strstrm <<
" ";
2827 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2830 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2831 strstrm << i_strip%10;
2832 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2836 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2838 std::vector<int> bx_times =
strip[i_layer][i_strip];
2840 strstrm << std::hex << bx_times[0] <<
std::dec;
2845 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2848 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2854 std::vector<CSCCLCTDigi> tmpV;
2866 static std::atomic<int> lct_bins;
2868 static std::atomic<int> late_tbins;
2871 static std::atomic<int> ifois{0};
2876 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2881 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2883 <<
"+++ Set late_tbins to max allowed +++\n";
2884 late_tbins = CSCConstants::MAX_CLCT_TBINS-1;
2891 int bx_readout = -1;
2892 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2893 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2894 plct != all_lcts.end(); plct++) {
2895 if (!plct->isValid())
continue;
2897 int bx = (*plct).getBX();
2901 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2902 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is " 2908 if (bx > late_tbins) {
2910 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2911 <<
": found at bx " << bx <<
", whereas the latest allowed bx is " 2920 if (bx_readout == -1 || bx == bx_readout) {
2921 tmpV.push_back(*plct);
2922 if (bx_readout == -1) bx_readout = bx;
2925 else tmpV.push_back(*plct);
2932 std::vector<CSCCLCTDigi> tmpV;
2952 test_triad[distrip] = 3;
2953 test_triad[distrip+1] = 3;
2954 test_triad[distrip+2] = 3;
2955 test_triad[distrip+3] = 3;
2956 test_triad[distrip+4] = 3;
2957 test_triad[distrip+5] = 3;
2958 test_triad[distrip+6] = 3;
2959 test_triad[distrip+7] = 3;
2960 test_triad[distrip+8] = 3;
2961 test_triad[distrip+9] = 3;
2962 test_triad[distrip+10] = 2;
2964 test_time[distrip] = 4;
2965 test_time[distrip+1] = 10;
2966 test_time[distrip+2] = 2;
2967 test_time[distrip+3] = 0;
2968 test_time[distrip+4] = 6;
2969 test_time[distrip+5] = 8;
2970 test_time[distrip+6] = 10;
2971 test_time[distrip+7] = 1;
2972 test_time[distrip+8] = 8;
2973 test_time[distrip+9] = 5;
2974 test_time[distrip+10] = 6;
2976 std::cout <<
"\n ------------------------------------------------- \n";
2977 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2978 std::cout <<
"Values before distripStagger routine:" << std::endl;
2979 for (
int i=distrip;
i<distrip+11;
i++){
2981 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2982 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2984 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2985 std::cout <<
"Values after distripStagger routine:" << std::endl;
2986 for (
int i=distrip;
i<distrip+11;
i++){
2987 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2988 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2990 std::cout <<
"\n ------------------------------------------------- \n \n";
2995 for (
int ptn = 0; ptn < 8; ptn++) {
2996 for (
int bend = 0; bend < 2; bend++) {
2999 for (
int bx = 0; bx < 7; bx++) {
3000 for (
int stripType = 0; stripType < 2; stripType++) {
3003 key_strip, cfeb, bx);
3006 <<
"pattern mismatch: " << ptn <<
" " 3008 if (bend != thisLCT.
getBend())
3010 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
3011 if (cfeb != thisLCT.
getCFEB())
3013 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
3016 <<
"strip mismatch: " << key_strip <<
" " 3018 if (bx != thisLCT.
getBX())
3020 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
3023 <<
"Strip Type mismatch: " << stripType <<
" " 3027 <<
"quality mismatch: " <<
quality <<
" " 3040 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3043 std::cout<<
" Pattern "<<patternNum<<
" ";
3053 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3061 minStrip = 3*layer - 2;
3085 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3088 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3089 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3090 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3091 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3092 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3093 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3094 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3095 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3096 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3097 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3098 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3099 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3100 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3101 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3102 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3103 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3112 if (numLayersHit > 3 || !results.empty()) {
3113 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3119 if (!results.empty()) {
3120 int thePatternStrip =
strip - (results[0].getKeyStrip() - 2) + 3*layer;
3123 thePatternStrip -= 2;
3145 minStrip = 3*layer - 2;
3157 if (!stripsHit[layer][10].
empty()) {
3165 if (layer < static_cast<int>(results.size()) ) {
3180 if ((!stripsHit[layer][ 9].
empty()) ||
3181 (!stripsHit[layer][10].
empty()) ||
3182 (!stripsHit[layer][11].
empty()) ) number++;
int getQuality() const
return quality of a pattern (number of layers hit!)
static const unsigned int def_drift_delay
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][CSCConstants::MAX_STRIPS_IN_PATTERN+1]
T getParameter(std::string const &) const
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
void setDefaultConfigParameters()
std::vector< CSCCLCTDigi > readoutCLCTs()
bool use_dead_time_zoning
unsigned int nplanes_hit_pretrig
static const unsigned int def_fifo_tbins
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int i_distrip, bool debug=false)
int getStrip() const
Get the strip number. Counts from 1.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int min_separation
static const int cfeb_strips[2]
unsigned int clctHitPersist() const
const unsigned theTrigChamber
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
void dumpConfigParams() const
const unsigned theStation
static const int pattern2007_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
static const unsigned int def_min_separation
unsigned int clctMinSeparation() const
int getComparator() const
Get Comparator readings. Can be 0 or 1.
unsigned int clctNplanesHitPretrig() const
static const unsigned int def_nplanes_hit_pretrig
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
static int ringFromTriggerLabels(int station, int triggerCSCID)
const CSCGeometry * csc_g
int getStripType() const
return striptype
unsigned int clctDriftDelay() const
int getBend() const
return bend
static const unsigned int def_pid_thresh_pretrig
unsigned int fifo_pretrig
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, const unsigned int bx_time)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int clctPidThreshPretrig() const
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keyStrip[CSCConstants::MAX_CFEBS], unsigned int nhits[CSCConstants::MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips) const
int getCFEB() const
return Key CFEB ID
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
void testDistripStagger()
static const unsigned int def_tmb_l1a_window_size
int getBX() const
return BX
bool getDigis(const CSCComparatorDigiCollection *compdc)
static const unsigned int def_nplanes_hit_pattern
Abs< T >::type abs(const T &t)
unsigned int pretrig_trig_zone
unsigned int clctFifoPretrig() const
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, int &first_bx)
unsigned int clct_state_machine_zone
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
unsigned int nplanes_hit_pattern
void getPattern(int pattern_num, int strip_value[CSCConstants::MAX_STRIPS_IN_PATTERN], int bx_time, int &quality, int &bend)
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
void priorityEncode(const int h_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int h_nhits[CSCConstants::MAX_CFEBS], const int d_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int d_nhits[CSCConstants::MAX_CFEBS], int keystrip_data[2][7])
void checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
static const unsigned int def_hit_persist
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int stripType)
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCComparatorDigi >::const_iterator const_iterator
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
bool hitIsGood(int hitTime, int BX)
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int tmb_l1a_window_size
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7], int nStrips, int first_bx, int &best_strip, int stripType)
static const int pre_hit_pattern[2][CSCConstants::MAX_STRIPS_IN_PATTERN]
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
unsigned int pid_thresh_pretrig
std::vector< CSCCLCTDigi > getCLCTs()
void setConfigParameters(const CSCDBL1TPParameters *conf)
bool dynamic_state_machine_zone
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.