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}
245 theEndcap(endcap), theStation(station), theSector(sector),
246 theSubsector(subsector), theTrigChamber(chamber) {
247 static bool config_dumped =
false;
254 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
256 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
276 if (isSLHC && !smartME1aME1b)
edm::LogError(
"L1CSCTPEmulatorConfigError")
277 <<
"+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n"
278 <<
"Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
282 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
312 static int fpga_latency = 3;
313 if (early_tbins<0) early_tbins = fifo_pretrig - fpga_latency;
323 if ((infoV > 0 || isSLHC) && !config_dumped) {
326 config_dumped =
true;
332 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
360 theEndcap(1), theStation(1), theSector(1),
361 theSubsector(1), theTrigChamber(1) {
363 static bool config_dumped =
false;
383 if (!config_dumped) {
386 config_dumped =
true;
392 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
423 static bool config_dumped =
false;
440 if (!config_dumped) {
443 config_dumped =
true;
451 static const unsigned int max_fifo_tbins = 1 << 5;
452 static const unsigned int max_fifo_pretrig = 1 << 5;
453 static const unsigned int max_hit_persist = 1 << 4;
454 static const unsigned int max_drift_delay = 1 << 2;
455 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
456 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
457 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
459 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
465 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n"
466 <<
"+++ Try to proceed with the default value, fifo_tbins="
473 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n"
474 <<
"+++ Try to proceed with the default value, fifo_pretrig="
481 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n"
482 <<
"+++ Try to proceed with the default value, hit_persist="
489 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n"
490 <<
"+++ Try to proceed with the default value, drift_delay="
497 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n"
498 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig="
505 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n"
506 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern="
515 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n"
516 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig="
523 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n"
524 <<
"+++ Try to proceed with the default value, min_separation="
533 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
534 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
548 std::vector<CSCCLCTDigi>
556 static bool config_dumped =
false;
560 config_dumped =
true;
590 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
596 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
619 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
623 <<
" is not defined in current geometry! +++\n"
624 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
631 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
635 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
636 std::vector<CSCCLCTDigi> emptyV;
662 unsigned int layersHit = 0;
666 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
676 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
688 std::vector<CSCCLCTDigi> LCTlist;
697 LCTlist =
findLCTs(halfstrip, distrip);
700 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
701 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
703 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
704 LCTlist.push_back(halfStripLCTs[
i]);
705 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
706 LCTlist.push_back(diStripLCTs[i]);
710 if (LCTlist.size() > 1)
711 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
714 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
715 plct != LCTlist.end(); plct++) {
716 int bx = plct->getBX();
719 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, "
762 digiV[i_layer].clear();
777 <<
"found " <<
digiV[i_layer].size()
778 <<
" comparator digi(s) in layer " << i_layer <<
" of ME"
791 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
794 digiIt != rcompd.second; ++digiIt) {
799 digiIt->getComparator(),
800 digiIt->getTimeBinWord());
801 digiV[
id.layer()-1].push_back(digi_corr);
804 digiV[
id.layer()-1].push_back(*digiIt);
817 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
818 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
821 std::ostringstream strstrm;
822 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
823 <<
" strip #" << pld->getStrip()
825 std::vector<int> bx_times = pld->getTimeBinsOn();
826 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
827 strstrm <<
" " << bx_times[tbin];
828 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
833 int thisComparator = pld->getComparator();
834 if (thisComparator != 0 && thisComparator != 1) {
836 <<
"+++ Found comparator digi with wrong comparator value = "
837 << thisComparator <<
"; skipping it... +++\n";
842 int thisStrip = pld->getStrip() - 1;
843 if (thisStrip < 0 || thisStrip >=
numStrips) {
845 <<
"+++ Found comparator digi with wrong strip number = "
847 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
853 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
856 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
857 <<
"; skipping this digi... +++\n";
862 std::vector<int> bx_times = pld->getTimeBinsOn();
863 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
871 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
873 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
879 <<
"Comp digi: layer " << i_layer+1
880 <<
" digi #" << i_digi+1
881 <<
" strip " << thisStrip
882 <<
" halfstrip " << thisHalfstrip
883 <<
" distrip " << thisStrip/2 +
884 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
885 <<
" time " << bx_times[
i]
886 <<
" comparator " << thisComparator
887 <<
" stagger " << stagger[i_layer];
888 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
892 <<
" Skipping comparator digi: strip = " << thisStrip
893 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
894 <<
", bx of previous hit = " << bx_times[
i-1];
899 <<
"+++ Skipping comparator digi: strip = " << thisStrip
900 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
921 digiNum[
i][
j] = -999;
926 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
927 for (
unsigned int j = 0;
j < layerDigiV.size();
j++) {
933 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
934 <<
" strip #" << thisDigi.
getStrip()
940 if (thisComparator != 0 && thisComparator != 1) {
942 <<
"+++ Comparator digi with wrong comparator value: digi #" <<
j
943 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
948 int thisStrip = thisDigi.
getStrip() - 1;
949 if (thisStrip < 0 || thisStrip >=
numStrips) {
951 <<
"+++ Comparator digi with wrong strip number: digi #" <<
j
952 <<
", strip = " << thisStrip
953 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
962 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
971 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
972 digiNum[
i][thisStrip] =
j;
973 time[
i][thisStrip] = thisDigiBx;
974 comp[
i][thisStrip] = thisComparator;
976 <<
"Comp digi: layer " <<
i+1
978 <<
" strip " << thisStrip
979 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
980 <<
" distrip " << thisStrip/2 +
981 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
982 <<
" time " << time[
i][thisStrip]
983 <<
" comparator " << comp[
i][thisStrip]
989 <<
"+++ Skipping comparator digi: strip = " << thisStrip
990 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1001 if (time[
i][
j] >= 0) {
1008 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1009 <<
"; skipping this digi... +++\n";
1012 halfstrip[
i][i_halfstrip].push_back(time[
i][
j]);
1021 static int test_iteration = 0;
1023 if (time[
i][
j] >= 0) {
1024 int i_distrip =
j/2;
1025 if (
j%2 == 1 && comp[
i][
j] == 1 &&
stagger[
i] == 1) {
1027 bool stagger_debug = (
infoV > 2);
1036 if (
infoV > 2 && test_iteration == 1) {
1042 <<
"+++ Found wrong distrip number = " << i_distrip
1043 <<
"; skipping this digi... +++\n";
1046 distrip[
i][i_distrip].push_back(time[
i][
j]);
1054 int stag_time[CSCConstants::MAX_NUM_STRIPS],
1055 int stag_digi[CSCConstants::MAX_NUM_STRIPS],
1056 int i_strip,
bool debug) {
1072 if (i_strip >= CSCConstants::MAX_NUM_STRIPS) {
1074 <<
"+++ Found wrong strip number = " << i_strip
1075 <<
"; cannot apply distrip staggering... +++\n";
1081 <<
" Enter distripStagger: i_strip = " << i_strip
1082 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1083 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1084 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1085 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1089 if (i_strip+2 < CSCConstants::MAX_NUM_STRIPS && stag_triad[i_strip+2] == 1)
1096 if (stag_time[i_strip+2] >= 0) {
1097 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1098 stag_time[i_strip+2] = stag_time[i_strip];
1099 stag_digi[i_strip+2] = stag_digi[i_strip];
1105 stag_time[i_strip+2] = stag_time[i_strip];
1106 stag_digi[i_strip+2] = stag_digi[i_strip];
1113 stag_time[i_strip] = -999;
1114 stag_triad[i_strip] = 4;
1115 stag_digi[i_strip] = -999;
1119 <<
" Exit distripStagger: i_strip = " << i_strip
1120 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1121 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1122 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1123 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1141 const int max_lct_num = 2;
1142 const int adjacent_strips = 2;
1145 int highest_quality = 0;
1148 int final_lcts[max_lct_num];
1150 std::vector <CSCCLCTDigi> lctList;
1153 if (stripType == 1) nStrips = 2*
numStrips + 1;
1154 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1161 if (
preTrigger(strip, stripType, nStrips, first_bx)){
1162 getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);
1165 for (j = 0; j < max_lct_num; j++)
1166 final_lcts[j] = -999;
1172 final_lcts[0] = best_strip;
1174 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1176 if (
abs(best_strip - key_strip) > adjacent_strips){
1178 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1179 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1180 final_lcts[1] = key_strip;
1185 for (j = 0; j < max_lct_num; j++){
1188 int keystrip = final_lcts[
j];
1189 if (keystrip >= 0 &&
1190 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1197 keystrip_data[keystrip][
CLCT_CFEB] = theHalfStrip/32;
1198 int halfstrip_in_cfeb =
1199 theHalfStrip - 32*keystrip_data[keystrip][
CLCT_CFEB];
1207 keystrip_data[keystrip][
CLCT_BX]);
1212 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1215 <<
"Key Strip: " << std::setw(3)
1217 <<
" Pattern: " << std::setw(2)
1219 <<
" Bend: " << std::setw(1) << bend
1220 <<
" Quality: " << std::setw(1)
1222 <<
" stripType: " << std::setw(1) << stripType
1223 <<
" BX: " << std::setw(1)
1224 << keystrip_data[keystrip][
CLCT_BX];
1226 lctList.push_back(thisLCT);
1237 const int stripType,
const int nStrips,
1244 int i_layer, i_strip, this_layer, this_strip;
1245 int hits, layers_hit;
1248 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1255 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1261 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1266 hit_layer[i_layer] =
false;
1271 if (this_strip >= 0 && this_strip < nStrips) {
1273 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1276 if (hit_layer[this_layer] ==
false) {
1277 hit_layer[this_layer] =
true;
1282 if (layers_hit >= pre_trigger_layer_min) {
1299 int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7],
1300 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1302 int key_strip, this_layer, this_strip;
1303 int quality, best_quality;
1305 int highest_quality = 0;
1308 for (key_strip = 0; key_strip < nStrips; key_strip++)
1309 for (
int i = 0;
i < 7;
i++)
1310 keystrip_data[key_strip][
i] = 0;
1315 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1322 if ((this_strip >= 0 && this_strip < nStrips) &&
1323 !strip[this_layer][this_strip].empty()) {
1324 if (nullPattern) nullPattern =
false;
1325 std::vector<int> bx_times = strip[this_layer][this_strip];
1326 lct_pattern[pattern_strip] = bx_times[0];
1329 lct_pattern[pattern_strip] = -999;
1333 if (nullPattern)
continue;
1347 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1349 <<
"Key_strip " << key_strip <<
" quality of pattern_num "
1350 << pattern_num <<
": " << quality;
1351 if (quality > best_quality){
1354 keystrip_data[key_strip][
CLCT_BEND] = bend;
1355 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1356 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1359 if (quality > highest_quality){
1364 best_strip = key_strip;
1365 highest_quality = quality;
1367 best_quality = quality;
1376 int strip_value[NUM_PATTERN_STRIPS],
int bx_time,
1377 int& quality,
int& bend){
1386 hit_layer[i_layer] =
false;
1390 if (
hitIsGood(strip_value[strip_num], bx_time)){
1394 if (i_layer ==
pattern[pattern_num][strip_num]){
1396 if (hit_layer[i_layer] ==
false){
1398 hit_layer[i_layer] =
true;
1406 quality = layers_hit;
1414 int dt = BX - hitTime;
1415 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1416 else {
return false;}
1434 std::vector <CSCCLCTDigi> lctList;
1435 int _bx[2] = {999, 999};
1451 int keystrip_data[2][7];
1454 bool pre_trig[2] = {
false,
false};
1458 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1459 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1463 if (pre_trig[0] || pre_trig[1]) {
1464 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1466 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1467 <<
"\n ..... waiting drift delay ..... ";
1499 latchLCTs(h_pulse, h_keyStrip, h_nhits, 1, CSCConstants::NUM_HALF_STRIPS,
1506 <<
"...............................\n"
1507 <<
"Final halfstrip hits and keys (after drift delay) ...";
1508 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1510 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1511 <<
" hits " << h_nhits[icfeb];
1514 <<
"Final distrip hits and keys (after drift delay) ...";
1515 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1517 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1518 <<
" hits " << d_nhits[icfeb];
1521 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1524 for (
int ilct = 0; ilct < 2; ilct++) {
1526 <<
"found lcts: ilct " << ilct
1527 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1529 int halfstrip_in_cfeb = 0;
1531 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1534 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1543 keystrip_data[ilct][
CLCT_BX]);
1544 lctList.push_back(thisLCT);
1558 const int stripType,
const int nStrips,
1559 const int start_bx,
int& first_bx) {
1561 <<
"....................PreTrigger...........................";
1563 if (start_bx == 0) {
1568 bool pre_trig =
false;
1570 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1576 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1584 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1593 const int stripType,
const int nStrips,
1594 const unsigned int bx_time) {
1599 int key_strip, this_layer, this_strip, layers_hit;
1602 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1604 if (stripType != 0 && stripType != 1) {
1606 <<
"+++ preTrigLookUp: stripType = " << stripType
1607 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1611 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1613 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1615 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1618 hit_layer[ilayer] =
false;
1625 if (this_strip >= 0 && this_strip < nStrips) {
1627 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1628 if (hit_layer[this_layer] ==
false) {
1629 hit_layer[this_layer] =
true;
1631 if (layers_hit >= pre_trigger_layer_min) {
1633 <<
"pretrigger at bx: " << bx_time
1634 <<
", cfeb " << icfeb <<
", returning";
1652 int keyStrip[MAX_CFEBS],
unsigned int n_hits[MAX_CFEBS],
1653 const int stripType,
const int nStrips,
const int bx_time) {
1656 int key_strip, this_layer, this_strip;
1657 int layers_hit, prev_hits;
1659 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1660 keyStrip[icfeb] = -1;
1664 if (stripType != 0 && stripType != 1) {
1666 <<
"+++ latchLCTs: stripType = " << stripType
1667 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1671 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1674 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1676 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1679 hit_layer[ilayer] =
false;
1686 if (this_strip >= 0 && this_strip < nStrips) {
1688 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1689 if (hit_layer[this_layer] ==
false) {
1690 hit_layer[this_layer] =
true;
1697 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1698 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1699 <<
" n_hits: " << layers_hit;
1704 if (layers_hit > prev_hits) {
1705 prev_hits = layers_hit;
1706 keyStrip[icfeb] = key_strip;
1707 n_hits[icfeb] = layers_hit;
1716 const int h_keyStrip[MAX_CFEBS],
const unsigned int h_nhits[MAX_CFEBS],
1717 const int d_keyStrip[MAX_CFEBS],
const unsigned int d_nhits[MAX_CFEBS],
1718 int keystrip_data[2][7]) {
1724 const int nlcts = 2;
1728 for (
int ilct = 0; ilct < nlcts; ilct++) {
1729 for (
int j = 0;
j < 7;
j++) keystrip_data[ilct][
j] = -1;
1733 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1734 key_strip[icfeb] = -1;
1735 key_phits[icfeb] = -1;
1736 strip_type[icfeb] = -1;
1741 <<
".....................PriorityEncode.......................";
1742 std::ostringstream strstrm;
1743 strstrm <<
"hkeys:";
1744 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1745 strstrm << std::setw(4) << h_keyStrip[icfeb];
1747 strstrm <<
"\ndkeys:";
1748 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1749 strstrm << std::setw(4) << d_keyStrip[icfeb];
1751 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1756 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1757 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1758 if (h_nhits[icfeb] >= hs_thresh) {
1759 key_strip[icfeb] = h_keyStrip[icfeb];
1760 key_phits[icfeb] = h_nhits[icfeb] + 8;
1761 strip_type[icfeb]= 1;
1767 key_strip[icfeb] = d_keyStrip[icfeb];
1768 key_phits[icfeb] = d_nhits[icfeb];
1769 strip_type[icfeb]= 0;
1772 else if (h_keyStrip[icfeb] != -1) {
1773 if (h_nhits[icfeb] >= hs_thresh) {
1774 key_strip[icfeb] = h_keyStrip[icfeb];
1775 key_phits[icfeb] = h_nhits[icfeb] + 8;
1776 strip_type[icfeb]= 1;
1779 else if (d_keyStrip[icfeb] != -1) {
1781 key_strip[icfeb] = d_keyStrip[icfeb];
1782 key_phits[icfeb] = d_nhits[icfeb];
1783 strip_type[icfeb]= 0;
1786 if (
infoV > 1 && strip_type[icfeb] != -1) {
1787 if (strip_type[icfeb] == 0)
1789 <<
" taking distrip pattern on cfeb " << icfeb;
1790 else if (strip_type[icfeb] == 1)
1792 <<
" taking halfstrip pattern on cfeb " << icfeb;
1794 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1795 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1806 <<
"...... Remove Duplicates ......";
1807 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1808 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1809 else key[icfeb] = key_strip[icfeb];
1811 for (
int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1812 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1816 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1817 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1818 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1820 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1821 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1823 <<
" deleting LCT on CFEB " << icfeb;
1824 key_strip[icfeb] = -1;
1825 key_phits[icfeb] = -1;
1829 <<
" deleting LCT on CFEB " << icfeb+1;
1830 key_strip[icfeb+1] = -1;
1831 key_phits[icfeb+1] = -1;
1840 <<
"\n...... Select best LCTs ......";
1841 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1842 if (key_phits[icfeb] > ihits[0]) {
1843 ihits[1] = ihits[0];
1844 cfebs[1] = cfebs[0];
1845 ihits[0] = key_phits[icfeb];
1848 std::ostringstream strstrm;
1849 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1850 strstrm << std::setw(4) << strip_type[icfeb];
1853 <<
"strip_type" << strstrm.str()
1854 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1855 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1856 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1857 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1860 else if (key_phits[icfeb] > ihits[1]) {
1861 ihits[1] = key_phits[icfeb];
1864 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1865 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1871 for (
int ilct = 0; ilct < nlcts; ilct++) {
1872 if (cfebs[ilct] != -1) {
1873 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1874 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1877 <<
"filling key: " << key_strip[cfebs[ilct]]
1878 <<
" type: " << strip_type[cfebs[ilct]];
1889 int keystrip_data[2][7],
const int first_bx) {
1892 int this_layer, this_strip;
1893 unsigned int quality = 0, bend = 0;
1894 unsigned int best_quality, best_pattern;
1895 bool valid[2] = {
false,
false};
1905 <<
"...............getKeyStripData....................";
1907 for (
int ilct = 0; ilct < 2; ilct++) {
1909 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1913 <<
"no lct at ilct " << ilct;
1918 lct_pattern[pattern_strip] = -999;
1925 if (this_strip >= 0 && this_strip < CSCConstants::NUM_HALF_STRIPS) {
1927 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1928 lct_pattern[pattern_strip] = 1;
1934 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1935 lct_pattern[pattern_strip] = 1;
1945 for (
unsigned int pattern_num = 0;
1947 getPattern(pattern_num, lct_pattern, quality, bend);
1949 <<
"pattern " << pattern_num <<
" quality " << quality
1950 <<
" bend " << bend;
1957 if ((quality == best_quality && pattern_num > best_pattern) ||
1958 (quality > best_quality)) {
1960 <<
"valid = true at quality " << quality
1965 keystrip_data[ilct][
CLCT_BX] = first_bx;
1968 best_quality = quality;
1969 best_pattern = pattern_num;
1977 <<
"lct " << ilct <<
" not over threshold: deleting";
1981 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n"
1982 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
1983 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
1985 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
1986 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
1995 const int strip_value[NUM_PATTERN_STRIPS],
1996 unsigned int& quality,
unsigned int& bend) {
2003 unsigned int layers_hit = 0;
2008 hit_layer[i_layer] =
false;
2012 if (strip_value[strip_num] == 1){
2016 if (i_layer ==
pattern[pattern_num][strip_num]){
2018 if (hit_layer[i_layer] ==
false){
2020 hit_layer[i_layer] =
true;
2028 quality = layers_hit;
2041 std::vector<CSCCLCTDigi> lctList;
2044 const int maxHalfStrips = 2*
numStrips + 1;
2049 enum {max_lcts = 2};
2051 int keystrip_data[max_lcts][7] = {{0}};
2062 while (start_bx < stop_bx) {
2066 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2073 <<
"..... pretrigger at bx = " << first_bx
2074 <<
"; waiting drift delay .....";
2078 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2082 hstrip < maxHalfStrips; hstrip++) {
2083 if (
nhits[hstrip] > 0) {
2085 <<
" bx = " << std::setw(2) << latch_bx <<
" --->"
2086 <<
" halfstrip = " << std::setw(3) << hstrip
2087 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2088 <<
" nhits = " <<
nhits[hstrip];
2095 start_bx = first_bx + 1;
2099 int best_halfstrip[max_lcts], best_quality[max_lcts];
2100 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2101 best_halfstrip[ilct] = -1;
2102 best_quality[ilct] = 0;
2109 hstrip < maxHalfStrips; hstrip++) {
2112 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2113 if (quality[hstrip] > best_quality[0]) {
2114 best_halfstrip[0] = hstrip;
2115 best_quality[0] = quality[hstrip];
2117 if (
infoV > 1 && quality[hstrip] > 0) {
2119 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2120 <<
" quality = " << std::setw(3) << quality[hstrip]
2121 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2122 <<
" best quality = " << std::setw(3) << best_quality[0];
2128 if (best_halfstrip[0] >= 0) {
2134 hstrip < maxHalfStrips; hstrip++) {
2135 if (quality[hstrip] > best_quality[1]) {
2136 best_halfstrip[1] = hstrip;
2137 best_quality[1] = quality[hstrip];
2139 if (
infoV > 1 && quality[hstrip] > 0) {
2141 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2142 <<
" quality = " << std::setw(3) << quality[hstrip]
2143 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2144 <<
" best quality = " << std::setw(3) << best_quality[1];
2149 bool ptn_trig =
false;
2150 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2151 int best_hs = best_halfstrip[ilct];
2160 keystrip_data[ilct][
CLCT_BX] = first_bx;
2165 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2169 <<
" Final selection: ilct " << ilct
2170 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2173 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2181 keystrip_data[ilct][
CLCT_BX]);
2182 lctList.push_back(thisLCT);
2197 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2198 bool return_to_idle =
true;
2199 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2202 hstrip < maxHalfStrips; hstrip++) {
2205 <<
" State machine busy at bx = " << bx;
2206 return_to_idle =
false;
2211 if (return_to_idle) {
2213 <<
" State machine returns to idle state at bx = " << bx;
2222 start_bx = first_bx + 1;
2236 static unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2247 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2248 pulse[i_layer][i_strip] = 0;
2252 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2255 if (
time[i_layer][i_strip].
size() > 0) {
2256 std::vector<int> bx_times =
time[i_layer][i_strip];
2257 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2259 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2261 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2262 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2263 <<
" is not within the range (0-" << bits_in_pulse
2264 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2268 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2269 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2281 const int start_bx,
int& first_bx) {
2283 <<
"....................PreTrigger...........................";
2288 bool pre_trig =
false;
2290 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2296 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2299 hstrip < nStrips; hstrip++) {
2301 if (
nhits[hstrip] > 0) {
2303 <<
" bx = " << std::setw(2) << bx_time <<
" --->"
2304 <<
" halfstrip = " << std::setw(3) << hstrip
2305 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2306 <<
" nhits = " <<
nhits[hstrip];
2325 "no pretrigger, returning \n";
2334 const int nStrips,
const unsigned int bx_time)
2341 unsigned int layers_hit = 0;
2344 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2346 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2355 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2358 nhits[key_hstrip] = 0;
2371 hit_layer[ilayer] =
false;
2373 double num_pattern_hits=0., times_sum=0.;
2374 std::multiset<int> mset_for_median;
2375 mset_for_median.clear();
2382 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2385 if (this_strip >= 0 && this_strip < nStrips) {
2387 <<
" In ptnFinding: key_strip = " << key_hstrip
2388 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2389 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2391 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2393 if (hit_layer[this_layer] ==
false)
2395 hit_layer[this_layer] =
true;
2401 int first_bx_layer = bx_time;
2402 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2404 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2409 times_sum += (double) first_bx_layer;
2410 num_pattern_hits += 1.;
2411 mset_for_median.insert(first_bx_layer);
2413 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2414 <<
" #pat. hits: " << num_pattern_hits;
2420 if (layers_hit >
nhits[key_hstrip])
2423 nhits[key_hstrip] = layers_hit;
2426 const int sz = mset_for_median.size();
2428 std::multiset<int>::iterator im = mset_for_median.begin();
2429 if (sz>1) std::advance(im,sz/2-1);
2436 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2437 sprintf(bxs,
"%s %d", bxs, *im);
2445 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2455 const int best_patid,
2464 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2465 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS) {
2466 quality[hstrip] = 0;
2477 std::vector<CSCCLCTDigi>
2480 std::vector<CSCCLCTDigi> lctList;
2483 const int maxHalfStrips = 2 *
numStrips + 1;
2487 enum { max_lcts = 2 };
2493 busyMap[
i][
j] =
false;
2495 std::vector<CSCCLCTDigi> lctListBX;
2509 while (start_bx < stop_bx)
2515 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2522 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2526 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2533 if (
nhits[hstrip] > 0)
2535 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = "
2536 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2543 start_bx = first_bx + 1;
2546 int keystrip_data[max_lcts][7] = {{0}};
2550 int best_halfstrip[max_lcts], best_quality[max_lcts];
2551 for (
int ilct = 0; ilct < max_lcts; ilct++)
2553 best_halfstrip[ilct] = -1;
2554 best_quality[ilct] = 0;
2566 pretrig_zone[hstrip] = 0;
2575 if (max_hs > CSCConstants::NUM_HALF_STRIPS - 1)
2576 max_hs = CSCConstants::NUM_HALF_STRIPS - 1;
2577 for (
int hs = min_hs; hs <= max_hs; hs++)
2578 pretrig_zone[hs] = 1;
2580 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2587 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2591 if (quality[hstrip] > best_quality[0] &&
2592 pretrig_zone[hstrip] &&
2593 !busyMap[hstrip][first_bx] )
2595 best_halfstrip[0] = hstrip;
2596 best_quality[0] = quality[hstrip];
2599 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2600 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2601 <<
" best quality = " << std::setw(3) << best_quality[0];
2608 if (best_halfstrip[0] >= 0)
2615 if (quality[hstrip] > best_quality[1] &&
2616 pretrig_zone[hstrip] &&
2617 !busyMap[hstrip][first_bx] )
2619 best_halfstrip[1] = hstrip;
2620 best_quality[1] = quality[hstrip];
2623 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2624 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2625 <<
" best quality = " << std::setw(3) << best_quality[1];
2631 bool ptn_trig =
false;
2632 for (
int ilct = 0; ilct < max_lcts; ilct++)
2634 int best_hs = best_halfstrip[ilct];
2648 keystrip_data[ilct][
CLCT_BX] = bx;
2655 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip "
2663 lctList.push_back(thisLCT);
2664 lctListBX.push_back(thisLCT);
2677 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2685 int min_hstrip = key_hstrip - delta_hs;
2686 int max_hstrip = key_hstrip + delta_hs;
2690 if (max_hstrip > maxHalfStrips)
2691 max_hstrip = maxHalfStrips;
2694 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" ["
2695 << min_hstrip <<
"," << max_hstrip <<
"]";
2702 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2704 bool busy_bx =
false;
2705 if (bx <= (
size_t)latch_bx)
2709 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2713 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits="
2714 <<
nhits[key_hstrip];
2717 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2719 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2720 busyMap[hstrip][bx] =
true;
2730 start_bx = first_bx + 1;
2743 std::ostringstream strm;
2745 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2746 strm <<
"+ CLCT configuration parameters: +\n";
2747 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2748 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = "
2750 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2752 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = "
2754 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = "
2756 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2758 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = "
2761 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = "
2763 strm <<
" min_separation [region of busy key strips] = "
2766 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2767 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2775 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2777 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2779 std::ostringstream strstrm;
2780 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2781 if (i_strip%10 == 0) {
2782 if (i_strip < 100) strstrm << i_strip/10;
2783 else strstrm << (i_strip-100)/10;
2785 else strstrm <<
" ";
2786 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2789 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2790 strstrm << i_strip%10;
2791 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2795 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2796 if (!strip[i_layer][i_strip].
empty()) {
2797 std::vector<int> bx_times = strip[i_layer][i_strip];
2799 strstrm << std::hex << bx_times[0] << std::dec;
2804 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2807 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2813 std::vector<CSCCLCTDigi> tmpV;
2828 static int lct_bins =
2832 static int ifois = 0;
2837 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2842 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2844 <<
"+++ Set late_tbins to max allowed +++\n";
2845 late_tbins = MAX_CLCT_BINS-1;
2852 int bx_readout = -1;
2853 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2854 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2855 plct != all_lcts.end(); plct++) {
2856 if (!plct->isValid())
continue;
2858 int bx = (*plct).getBX();
2862 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2863 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
2869 if (bx > late_tbins) {
2871 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2872 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
2881 if (bx_readout == -1 || bx == bx_readout) {
2882 tmpV.push_back(*plct);
2883 if (bx_readout == -1) bx_readout = bx;
2886 else tmpV.push_back(*plct);
2893 std::vector<CSCCLCTDigi> tmpV;
2913 test_triad[distrip] = 3;
2914 test_triad[distrip+1] = 3;
2915 test_triad[distrip+2] = 3;
2916 test_triad[distrip+3] = 3;
2917 test_triad[distrip+4] = 3;
2918 test_triad[distrip+5] = 3;
2919 test_triad[distrip+6] = 3;
2920 test_triad[distrip+7] = 3;
2921 test_triad[distrip+8] = 3;
2922 test_triad[distrip+9] = 3;
2923 test_triad[distrip+10] = 2;
2925 test_time[distrip] = 4;
2926 test_time[distrip+1] = 10;
2927 test_time[distrip+2] = 2;
2928 test_time[distrip+3] = 0;
2929 test_time[distrip+4] = 6;
2930 test_time[distrip+5] = 8;
2931 test_time[distrip+6] = 10;
2932 test_time[distrip+7] = 1;
2933 test_time[distrip+8] = 8;
2934 test_time[distrip+9] = 5;
2935 test_time[distrip+10] = 6;
2937 std::cout <<
"\n ------------------------------------------------- \n";
2938 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2939 std::cout <<
"Values before distripStagger routine:" << std::endl;
2940 for (
int i=distrip;
i<distrip+11;
i++){
2942 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2943 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2945 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2946 std::cout <<
"Values after distripStagger routine:" << std::endl;
2947 for (
int i=distrip;
i<distrip+11;
i++){
2948 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2949 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2951 std::cout <<
"\n ------------------------------------------------- \n \n";
2956 for (
int ptn = 0; ptn < 8; ptn++) {
2957 for (
int bend = 0; bend < 2; bend++) {
2958 for (
int cfeb = 0; cfeb <
MAX_CFEBS; cfeb++) {
2959 for (
int key_strip = 0; key_strip < 32; key_strip++) {
2960 for (
int bx = 0; bx < 7; bx++) {
2961 for (
int stripType = 0; stripType < 2; stripType++) {
2962 for (
int quality = 3; quality < 6; quality++) {
2963 CSCCLCTDigi thisLCT(1, quality, ptn, stripType, bend,
2964 key_strip, cfeb, bx);
2967 <<
"pattern mismatch: " << ptn <<
" "
2969 if (bend != thisLCT.
getBend())
2971 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
2972 if (cfeb != thisLCT.
getCFEB())
2974 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
2977 <<
"strip mismatch: " << key_strip <<
" "
2979 if (bx != thisLCT.
getBX())
2981 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
2984 <<
"Strip Type mismatch: " << stripType <<
" "
2988 <<
"quality mismatch: " << quality <<
" "
3001 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3004 std::cout<<
" Pattern "<<patternNum<<
" ";
3014 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3022 minStrip = 3*layer - 2;
3024 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3025 if (layer ==
pattern[patternNum][strip]) {
3046 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3049 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3050 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3051 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3052 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3053 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3054 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3055 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3056 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3057 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3058 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3059 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3060 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3061 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3062 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3063 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3064 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3073 if (numLayersHit > 3 || results.size() > 0) {
3074 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3078 for (
int strip = 9; strip < 12; strip++) {
3079 if (!stripsHit[layer][strip].
empty()) {
3080 if (results.size() > 0) {
3081 int thePatternStrip = strip - (results[0].getKeyStrip() - 2) + 3*layer;
3084 thePatternStrip -= 2;
3106 minStrip = 3*layer - 2;
3108 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3118 if (!stripsHit[layer][10].
empty()) {
3126 if (layer < static_cast<int>(results.size()) ) {
3141 if ((!stripsHit[layer][ 9].
empty()) ||
3142 (!stripsHit[layer][10].
empty()) ||
3143 (!stripsHit[layer][11].
empty()) ) number++;
int getQuality() const
return quality of a pattern (number of layers hit!)
void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
static const unsigned int def_drift_delay
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setDefaultConfigParameters()
std::vector< CSCCLCTDigi > readoutCLCTs()
bool use_dead_time_zoning
unsigned int nplanes_hit_pretrig
static const unsigned int def_fifo_tbins
int getStrip() const
Get the strip number.
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int stripType)
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
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]
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7], int nStrips, int first_bx, int &best_strip, int stripType)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS])
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void dumpConfigParams() const
const unsigned theStation
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keyStrip[MAX_CFEBS], unsigned int nhits[MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
static const unsigned int def_min_separation
int numberOfStrips() const
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
unsigned int clctMinSeparation() const
int getComparator() const
Get Comparator readings.
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)
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
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS], int stag_time[CSCConstants::MAX_NUM_STRIPS], int stag_digi[CSCConstants::MAX_NUM_STRIPS], int i_distrip, bool debug=false)
static CSCTriggerGeomManager * get()
unsigned int clctPidThreshPretrig() const
int getCFEB() const
return Key CFEB ID
void testDistripStagger()
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+2]
static const unsigned int def_tmb_l1a_window_size
int getBX() const
return BX
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
bool getDigis(const CSCComparatorDigiCollection *compdc)
static const unsigned int def_nplanes_hit_pattern
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
unsigned int pretrig_trig_zone
unsigned int clctFifoPretrig() const
unsigned int clct_state_machine_zone
unsigned int nplanes_hit_pattern
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
void priorityEncode(const int h_keyStrip[MAX_CFEBS], const unsigned int h_nhits[MAX_CFEBS], const int d_keyStrip[MAX_CFEBS], const unsigned int d_nhits[MAX_CFEBS], int keystrip_data[2][7])
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
static const unsigned int def_hit_persist
int stagger[CSCConstants::NUM_LAYERS]
std::vector< DigiType >::const_iterator const_iterator
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
static const int pattern2007_offset[NUM_PATTERN_HALFSTRIPS]
bool hitIsGood(int hitTime, int BX)
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
unsigned int tmb_l1a_window_size
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
const CSCLayerGeometry * geometry() const
tuple size
Write out results.
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 ispretrig[CSCConstants::NUM_HALF_STRIPS]
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, const unsigned int bx_time)
bool dynamic_state_machine_zone
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.