68 { 999, 999, 999, 999, 999,
69 999, 999, 999, 999, 999,
70 999, 999, 999, 999, 999,
72 999, 999, 999, 999, 999,
73 999, 999, 999, 999, 999, 0},
75 { 999, 999, 999, 0, 999,
76 999, 999, 999, 1, 999,
80 999, 5, 999, 999, 999, 1},
82 { 999, 0, 999, 999, 999,
83 999, 1, 999, 999, 999,
87 999, 999, 999, 5, 999, 0},
89 { 999, 999, 0, 999, 999,
90 999, 999, 1, 999, 999,
91 999, 999, 2, 999, 999,
93 999, 4, 999, 999, 999,
94 999, 5, 999, 999, 999, 1},
96 { 999, 999, 0, 999, 999,
97 999, 999, 1, 999, 999,
98 999, 999, 2, 999, 999,
100 999, 999, 999, 4, 999,
101 999, 999, 999, 5, 999, 0},
103 { 999, 999, 999, 0, 999,
104 999, 999, 999, 1, 999,
107 999, 999, 4, 999, 999,
108 999, 999, 5, 999, 999, 1},
110 { 999, 0, 999, 999, 999,
111 999, 1, 999, 999, 999,
114 999, 999, 4, 999, 999,
115 999, 999, 5, 999, 999, 0},
117 { 999, 999, 0, 999, 999,
118 999, 999, 1, 999, 999,
119 999, 999, 2, 999, 999,
121 999, 999, 4, 999, 999,
122 999, 999, 5, 999, 999, 1}
131 { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
135 -4, -3, -2, -1, 0, 1, 2, 3, 4,
136 -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
139 { 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
140 999, 999, 999, 999, 999,
142 999, 999, 999, 999, 999,
143 999, 999, 999, 999, 999, 999, 999, 999, 999,
144 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -1, 0},
146 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150 4, 4, 4, 4, 4, 4, 4, 4, 4,
151 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 11},
153 { 999, 999, 999, 999, 999, 999, 999, 999, 0, 0, 0,
157 4, 4, 4, 999, 999, 999, 999, 999, 999,
158 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 999, 0, 11},
160 { 0, 0, 0, 999, 999, 999, 999, 999, 999, 999, 999,
164 999, 999, 999, 999, 999, 999, 4, 4, 4,
165 999, 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 1, 11},
167 { 999, 999, 999, 999, 999, 999, 999, 0, 0, 0, 999,
171 4, 4, 4, 999, 999, 999, 999, 999, 999,
172 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 0, 9},
174 { 999, 0, 0, 0, 999, 999, 999, 999, 999, 999, 999,
178 999, 999, 999, 999, 999, 999, 4, 4, 4,
179 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 1, 9},
181 { 999, 999, 999, 999, 999, 999, 0, 0, 0, 999, 999,
185 999, 999, 4, 4, 999, 999, 999, 999, 999,
186 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 0, 7},
188 { 999, 999, 0, 0, 0, 999, 999, 999, 999, 999, 999,
192 999, 999, 999, 999, 999, 4, 4, 999, 999,
193 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 1, 7},
195 { 999, 999, 999, 999, 999, 0, 0, 0, 999, 999, 999,
199 999, 999, 4, 4, 4, 999, 999, 999, 999,
200 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 0, 5},
202 { 999, 999, 999, 0, 0, 0, 999, 999, 999, 999, 999,
206 999, 999, 999, 999, 4, 4, 4, 999, 999,
207 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 1, 5},
209 { 999, 999, 999, 999, 0, 0, 0, 999, 999, 999, 999,
210 999, 999, 1, 999, 999,
212 999, 999, 3, 999, 999,
213 999, 999, 999, 4, 4, 4, 999, 999, 999,
214 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 0, 3}
244 theEndcap(endcap), theStation(station), theSector(sector),
245 theSubsector(subsector), theTrigChamber(chamber) {
246 static std::atomic<bool> config_dumped{
false};
253 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
255 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
275 if (isSLHC && !smartME1aME1b)
edm::LogError(
"L1CSCTPEmulatorConfigError")
276 <<
"+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n"
277 <<
"Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
281 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
311 static int fpga_latency = 3;
312 if (early_tbins<0) early_tbins = fifo_pretrig - fpga_latency;
322 if ((infoV > 0 || isSLHC) && !config_dumped) {
325 config_dumped =
true;
331 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
359 theEndcap(1), theStation(1), theSector(1),
360 theSubsector(1), theTrigChamber(1) {
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;
422 static std::atomic<bool> config_dumped{
false};
439 if (!config_dumped) {
442 config_dumped =
true;
450 static const unsigned int max_fifo_tbins = 1 << 5;
451 static const unsigned int max_fifo_pretrig = 1 << 5;
452 static const unsigned int max_hit_persist = 1 << 4;
453 static const unsigned int max_drift_delay = 1 << 2;
454 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
455 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
456 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
458 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
464 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n"
465 <<
"+++ Try to proceed with the default value, fifo_tbins="
472 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n"
473 <<
"+++ Try to proceed with the default value, fifo_pretrig="
480 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n"
481 <<
"+++ Try to proceed with the default value, hit_persist="
488 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n"
489 <<
"+++ Try to proceed with the default value, drift_delay="
496 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n"
497 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig="
504 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n"
505 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern="
514 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n"
515 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig="
522 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n"
523 <<
"+++ Try to proceed with the default value, min_separation="
532 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
533 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
547 std::vector<CSCCLCTDigi>
555 static std::atomic<bool> config_dumped{
false};
559 config_dumped =
true;
589 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
595 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
618 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
622 <<
" is not defined in current geometry! +++\n"
623 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
630 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
634 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
635 std::vector<CSCCLCTDigi> emptyV;
661 unsigned int layersHit = 0;
665 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
675 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
687 std::vector<CSCCLCTDigi> LCTlist;
696 LCTlist =
findLCTs(halfstrip, distrip);
699 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
700 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
702 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
703 LCTlist.push_back(halfStripLCTs[
i]);
704 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
705 LCTlist.push_back(diStripLCTs[i]);
709 if (LCTlist.size() > 1)
710 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
713 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
714 plct != LCTlist.end(); plct++) {
715 int bx = plct->getBX();
718 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, "
761 digiV[i_layer].clear();
776 <<
"found " <<
digiV[i_layer].size()
777 <<
" comparator digi(s) in layer " << i_layer <<
" of ME"
790 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
793 digiIt != rcompd.second; ++digiIt) {
798 digiIt->getComparator(),
799 digiIt->getTimeBinWord());
800 digiV[
id.layer()-1].push_back(digi_corr);
803 digiV[
id.layer()-1].push_back(*digiIt);
816 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
817 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
820 std::ostringstream strstrm;
821 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
822 <<
" strip #" << pld->getStrip()
824 std::vector<int> bx_times = pld->getTimeBinsOn();
825 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
826 strstrm <<
" " << bx_times[tbin];
827 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
832 int thisComparator = pld->getComparator();
833 if (thisComparator != 0 && thisComparator != 1) {
835 <<
"+++ Found comparator digi with wrong comparator value = "
836 << thisComparator <<
"; skipping it... +++\n";
841 int thisStrip = pld->getStrip() - 1;
842 if (thisStrip < 0 || thisStrip >=
numStrips) {
844 <<
"+++ Found comparator digi with wrong strip number = "
846 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
852 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
855 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
856 <<
"; skipping this digi... +++\n";
861 std::vector<int> bx_times = pld->getTimeBinsOn();
862 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
870 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
872 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
878 <<
"Comp digi: layer " << i_layer+1
879 <<
" digi #" << i_digi+1
880 <<
" strip " << thisStrip
881 <<
" halfstrip " << thisHalfstrip
882 <<
" distrip " << thisStrip/2 +
883 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
884 <<
" time " << bx_times[
i]
885 <<
" comparator " << thisComparator
886 <<
" stagger " << stagger[i_layer];
887 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
891 <<
" Skipping comparator digi: strip = " << thisStrip
892 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
893 <<
", bx of previous hit = " << bx_times[
i-1];
898 <<
"+++ Skipping comparator digi: strip = " << thisStrip
899 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
920 digiNum[
i][
j] = -999;
925 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
926 for (
unsigned int j = 0;
j < layerDigiV.size();
j++) {
932 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
933 <<
" strip #" << thisDigi.
getStrip()
939 if (thisComparator != 0 && thisComparator != 1) {
941 <<
"+++ Comparator digi with wrong comparator value: digi #" <<
j
942 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
947 int thisStrip = thisDigi.
getStrip() - 1;
948 if (thisStrip < 0 || thisStrip >=
numStrips) {
950 <<
"+++ Comparator digi with wrong strip number: digi #" <<
j
951 <<
", strip = " << thisStrip
952 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
961 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
970 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
971 digiNum[
i][thisStrip] =
j;
972 time[
i][thisStrip] = thisDigiBx;
973 comp[
i][thisStrip] = thisComparator;
975 <<
"Comp digi: layer " <<
i+1
977 <<
" strip " << thisStrip
978 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
979 <<
" distrip " << thisStrip/2 +
980 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
981 <<
" time " << time[
i][thisStrip]
982 <<
" comparator " << comp[
i][thisStrip]
988 <<
"+++ Skipping comparator digi: strip = " << thisStrip
989 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1000 if (time[
i][
j] >= 0) {
1007 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1008 <<
"; skipping this digi... +++\n";
1011 halfstrip[
i][i_halfstrip].push_back(time[
i][
j]);
1020 static std::atomic<int> test_iteration{0};
1022 if (time[
i][
j] >= 0) {
1023 int i_distrip =
j/2;
1024 if (
j%2 == 1 && comp[
i][
j] == 1 &&
stagger[
i] == 1) {
1026 bool stagger_debug = (
infoV > 2);
1035 if (
infoV > 2 && test_iteration == 1) {
1041 <<
"+++ Found wrong distrip number = " << i_distrip
1042 <<
"; skipping this digi... +++\n";
1045 distrip[
i][i_distrip].push_back(time[
i][
j]);
1053 int stag_time[CSCConstants::MAX_NUM_STRIPS],
1054 int stag_digi[CSCConstants::MAX_NUM_STRIPS],
1055 int i_strip,
bool debug) {
1071 if (i_strip >= CSCConstants::MAX_NUM_STRIPS) {
1073 <<
"+++ Found wrong strip number = " << i_strip
1074 <<
"; cannot apply distrip staggering... +++\n";
1080 <<
" Enter distripStagger: i_strip = " << i_strip
1081 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1082 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1083 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1084 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1088 if (i_strip+2 < CSCConstants::MAX_NUM_STRIPS && stag_triad[i_strip+2] == 1)
1095 if (stag_time[i_strip+2] >= 0) {
1096 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1097 stag_time[i_strip+2] = stag_time[i_strip];
1098 stag_digi[i_strip+2] = stag_digi[i_strip];
1104 stag_time[i_strip+2] = stag_time[i_strip];
1105 stag_digi[i_strip+2] = stag_digi[i_strip];
1112 stag_time[i_strip] = -999;
1113 stag_triad[i_strip] = 4;
1114 stag_digi[i_strip] = -999;
1118 <<
" Exit distripStagger: i_strip = " << i_strip
1119 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1120 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1121 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1122 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1140 const int max_lct_num = 2;
1141 const int adjacent_strips = 2;
1144 int highest_quality = 0;
1147 int final_lcts[max_lct_num];
1149 std::vector <CSCCLCTDigi> lctList;
1152 if (stripType == 1) nStrips = 2*
numStrips + 1;
1153 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1160 if (
preTrigger(strip, stripType, nStrips, first_bx)){
1161 getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);
1164 for (j = 0; j < max_lct_num; j++)
1165 final_lcts[j] = -999;
1171 final_lcts[0] = best_strip;
1173 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1175 if (
abs(best_strip - key_strip) > adjacent_strips){
1177 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1178 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1179 final_lcts[1] = key_strip;
1184 for (j = 0; j < max_lct_num; j++){
1187 int keystrip = final_lcts[
j];
1188 if (keystrip >= 0 &&
1189 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1196 keystrip_data[keystrip][
CLCT_CFEB] = theHalfStrip/32;
1197 int halfstrip_in_cfeb =
1198 theHalfStrip - 32*keystrip_data[keystrip][
CLCT_CFEB];
1206 keystrip_data[keystrip][
CLCT_BX]);
1211 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1214 <<
"Key Strip: " << std::setw(3)
1216 <<
" Pattern: " << std::setw(2)
1218 <<
" Bend: " << std::setw(1) << bend
1219 <<
" Quality: " << std::setw(1)
1221 <<
" stripType: " << std::setw(1) << stripType
1222 <<
" BX: " << std::setw(1)
1223 << keystrip_data[keystrip][
CLCT_BX];
1225 lctList.push_back(thisLCT);
1236 const int stripType,
const int nStrips,
1243 int i_layer, i_strip, this_layer, this_strip;
1244 int hits, layers_hit;
1247 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1254 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1260 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1265 hit_layer[i_layer] =
false;
1270 if (this_strip >= 0 && this_strip < nStrips) {
1272 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1275 if (hit_layer[this_layer] ==
false) {
1276 hit_layer[this_layer] =
true;
1281 if (layers_hit >= pre_trigger_layer_min) {
1298 int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7],
1299 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1301 int key_strip, this_layer, this_strip;
1302 int quality, best_quality;
1304 int highest_quality = 0;
1307 for (key_strip = 0; key_strip < nStrips; key_strip++)
1308 for (
int i = 0;
i < 7;
i++)
1309 keystrip_data[key_strip][
i] = 0;
1314 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1321 if ((this_strip >= 0 && this_strip < nStrips) &&
1322 !strip[this_layer][this_strip].empty()) {
1323 if (nullPattern) nullPattern =
false;
1324 std::vector<int> bx_times = strip[this_layer][this_strip];
1325 lct_pattern[pattern_strip] = bx_times[0];
1328 lct_pattern[pattern_strip] = -999;
1332 if (nullPattern)
continue;
1346 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1348 <<
"Key_strip " << key_strip <<
" quality of pattern_num "
1349 << pattern_num <<
": " << quality;
1350 if (quality > best_quality){
1353 keystrip_data[key_strip][
CLCT_BEND] = bend;
1354 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1355 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1358 if (quality > highest_quality){
1363 best_strip = key_strip;
1364 highest_quality = quality;
1366 best_quality = quality;
1375 int strip_value[NUM_PATTERN_STRIPS],
int bx_time,
1376 int& quality,
int& bend){
1385 hit_layer[i_layer] =
false;
1389 if (
hitIsGood(strip_value[strip_num], bx_time)){
1393 if (i_layer ==
pattern[pattern_num][strip_num]){
1395 if (hit_layer[i_layer] ==
false){
1397 hit_layer[i_layer] =
true;
1405 quality = layers_hit;
1413 int dt = BX - hitTime;
1414 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1415 else {
return false;}
1433 std::vector <CSCCLCTDigi> lctList;
1434 int _bx[2] = {999, 999};
1450 int keystrip_data[2][7];
1453 bool pre_trig[2] = {
false,
false};
1457 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1458 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1462 if (pre_trig[0] || pre_trig[1]) {
1463 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1465 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1466 <<
"\n ..... waiting drift delay ..... ";
1498 latchLCTs(h_pulse, h_keyStrip, h_nhits, 1, CSCConstants::NUM_HALF_STRIPS,
1505 <<
"...............................\n"
1506 <<
"Final halfstrip hits and keys (after drift delay) ...";
1507 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1509 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1510 <<
" hits " << h_nhits[icfeb];
1513 <<
"Final distrip hits and keys (after drift delay) ...";
1514 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1516 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1517 <<
" hits " << d_nhits[icfeb];
1520 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1523 for (
int ilct = 0; ilct < 2; ilct++) {
1525 <<
"found lcts: ilct " << ilct
1526 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1528 int halfstrip_in_cfeb = 0;
1530 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1533 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1542 keystrip_data[ilct][
CLCT_BX]);
1543 lctList.push_back(thisLCT);
1557 const int stripType,
const int nStrips,
1558 const int start_bx,
int& first_bx) {
1560 <<
"....................PreTrigger...........................";
1562 if (start_bx == 0) {
1567 bool pre_trig =
false;
1569 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1575 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1583 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1592 const int stripType,
const int nStrips,
1593 const unsigned int bx_time) {
1598 int key_strip, this_layer, this_strip, layers_hit;
1601 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1603 if (stripType != 0 && stripType != 1) {
1605 <<
"+++ preTrigLookUp: stripType = " << stripType
1606 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1610 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1612 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1614 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1617 hit_layer[ilayer] =
false;
1624 if (this_strip >= 0 && this_strip < nStrips) {
1626 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1627 if (hit_layer[this_layer] ==
false) {
1628 hit_layer[this_layer] =
true;
1630 if (layers_hit >= pre_trigger_layer_min) {
1632 <<
"pretrigger at bx: " << bx_time
1633 <<
", cfeb " << icfeb <<
", returning";
1651 int keyStrip[MAX_CFEBS],
unsigned int n_hits[MAX_CFEBS],
1652 const int stripType,
const int nStrips,
const int bx_time) {
1655 int key_strip, this_layer, this_strip;
1656 int layers_hit, prev_hits;
1658 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1659 keyStrip[icfeb] = -1;
1663 if (stripType != 0 && stripType != 1) {
1665 <<
"+++ latchLCTs: stripType = " << stripType
1666 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1670 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1673 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1675 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1678 hit_layer[ilayer] =
false;
1685 if (this_strip >= 0 && this_strip < nStrips) {
1687 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1688 if (hit_layer[this_layer] ==
false) {
1689 hit_layer[this_layer] =
true;
1696 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1697 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1698 <<
" n_hits: " << layers_hit;
1703 if (layers_hit > prev_hits) {
1704 prev_hits = layers_hit;
1705 keyStrip[icfeb] = key_strip;
1706 n_hits[icfeb] = layers_hit;
1715 const int h_keyStrip[MAX_CFEBS],
const unsigned int h_nhits[MAX_CFEBS],
1716 const int d_keyStrip[MAX_CFEBS],
const unsigned int d_nhits[MAX_CFEBS],
1717 int keystrip_data[2][7]) {
1723 const int nlcts = 2;
1727 for (
int ilct = 0; ilct < nlcts; ilct++) {
1728 for (
int j = 0;
j < 7;
j++) keystrip_data[ilct][
j] = -1;
1732 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1733 key_strip[icfeb] = -1;
1734 key_phits[icfeb] = -1;
1735 strip_type[icfeb] = -1;
1740 <<
".....................PriorityEncode.......................";
1741 std::ostringstream strstrm;
1742 strstrm <<
"hkeys:";
1743 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1744 strstrm << std::setw(4) << h_keyStrip[icfeb];
1746 strstrm <<
"\ndkeys:";
1747 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1748 strstrm << std::setw(4) << d_keyStrip[icfeb];
1750 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1755 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1756 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1757 if (h_nhits[icfeb] >= hs_thresh) {
1758 key_strip[icfeb] = h_keyStrip[icfeb];
1759 key_phits[icfeb] = h_nhits[icfeb] + 8;
1760 strip_type[icfeb]= 1;
1766 key_strip[icfeb] = d_keyStrip[icfeb];
1767 key_phits[icfeb] = d_nhits[icfeb];
1768 strip_type[icfeb]= 0;
1771 else if (h_keyStrip[icfeb] != -1) {
1772 if (h_nhits[icfeb] >= hs_thresh) {
1773 key_strip[icfeb] = h_keyStrip[icfeb];
1774 key_phits[icfeb] = h_nhits[icfeb] + 8;
1775 strip_type[icfeb]= 1;
1778 else if (d_keyStrip[icfeb] != -1) {
1780 key_strip[icfeb] = d_keyStrip[icfeb];
1781 key_phits[icfeb] = d_nhits[icfeb];
1782 strip_type[icfeb]= 0;
1785 if (
infoV > 1 && strip_type[icfeb] != -1) {
1786 if (strip_type[icfeb] == 0)
1788 <<
" taking distrip pattern on cfeb " << icfeb;
1789 else if (strip_type[icfeb] == 1)
1791 <<
" taking halfstrip pattern on cfeb " << icfeb;
1793 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1794 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1805 <<
"...... Remove Duplicates ......";
1806 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1807 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1808 else key[icfeb] = key_strip[icfeb];
1810 for (
int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1811 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1815 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1816 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1817 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1819 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1820 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1822 <<
" deleting LCT on CFEB " << icfeb;
1823 key_strip[icfeb] = -1;
1824 key_phits[icfeb] = -1;
1828 <<
" deleting LCT on CFEB " << icfeb+1;
1829 key_strip[icfeb+1] = -1;
1830 key_phits[icfeb+1] = -1;
1839 <<
"\n...... Select best LCTs ......";
1840 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1841 if (key_phits[icfeb] > ihits[0]) {
1842 ihits[1] = ihits[0];
1843 cfebs[1] = cfebs[0];
1844 ihits[0] = key_phits[icfeb];
1847 std::ostringstream strstrm;
1848 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1849 strstrm << std::setw(4) << strip_type[icfeb];
1852 <<
"strip_type" << strstrm.str()
1853 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1854 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1855 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1856 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1859 else if (key_phits[icfeb] > ihits[1]) {
1860 ihits[1] = key_phits[icfeb];
1863 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1864 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1870 for (
int ilct = 0; ilct < nlcts; ilct++) {
1871 if (cfebs[ilct] != -1) {
1872 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1873 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1876 <<
"filling key: " << key_strip[cfebs[ilct]]
1877 <<
" type: " << strip_type[cfebs[ilct]];
1888 int keystrip_data[2][7],
const int first_bx) {
1891 int this_layer, this_strip;
1892 unsigned int quality = 0, bend = 0;
1893 unsigned int best_quality, best_pattern;
1894 bool valid[2] = {
false,
false};
1904 <<
"...............getKeyStripData....................";
1906 for (
int ilct = 0; ilct < 2; ilct++) {
1908 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1912 <<
"no lct at ilct " << ilct;
1917 lct_pattern[pattern_strip] = -999;
1924 if (this_strip >= 0 && this_strip < CSCConstants::NUM_HALF_STRIPS) {
1926 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1927 lct_pattern[pattern_strip] = 1;
1933 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1934 lct_pattern[pattern_strip] = 1;
1944 for (
unsigned int pattern_num = 0;
1946 getPattern(pattern_num, lct_pattern, quality, bend);
1948 <<
"pattern " << pattern_num <<
" quality " << quality
1949 <<
" bend " << bend;
1956 if ((quality == best_quality && pattern_num > best_pattern) ||
1957 (quality > best_quality)) {
1959 <<
"valid = true at quality " << quality
1964 keystrip_data[ilct][
CLCT_BX] = first_bx;
1967 best_quality = quality;
1968 best_pattern = pattern_num;
1976 <<
"lct " << ilct <<
" not over threshold: deleting";
1980 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n"
1981 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
1982 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
1984 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
1985 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
1994 const int strip_value[NUM_PATTERN_STRIPS],
1995 unsigned int& quality,
unsigned int& bend) {
2002 unsigned int layers_hit = 0;
2007 hit_layer[i_layer] =
false;
2011 if (strip_value[strip_num] == 1){
2015 if (i_layer ==
pattern[pattern_num][strip_num]){
2017 if (hit_layer[i_layer] ==
false){
2019 hit_layer[i_layer] =
true;
2027 quality = layers_hit;
2040 std::vector<CSCCLCTDigi> lctList;
2043 const int maxHalfStrips = 2*
numStrips + 1;
2048 enum {max_lcts = 2};
2050 int keystrip_data[max_lcts][7] = {{0}};
2061 while (start_bx < stop_bx) {
2065 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2072 <<
"..... pretrigger at bx = " << first_bx
2073 <<
"; waiting drift delay .....";
2077 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2081 hstrip < maxHalfStrips; hstrip++) {
2082 if (
nhits[hstrip] > 0) {
2084 <<
" bx = " << std::setw(2) << latch_bx <<
" --->"
2085 <<
" halfstrip = " << std::setw(3) << hstrip
2086 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2087 <<
" nhits = " <<
nhits[hstrip];
2094 start_bx = first_bx + 1;
2098 int best_halfstrip[max_lcts], best_quality[max_lcts];
2099 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2100 best_halfstrip[ilct] = -1;
2101 best_quality[ilct] = 0;
2108 hstrip < maxHalfStrips; hstrip++) {
2111 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2112 if (quality[hstrip] > best_quality[0]) {
2113 best_halfstrip[0] = hstrip;
2114 best_quality[0] = quality[hstrip];
2116 if (
infoV > 1 && quality[hstrip] > 0) {
2118 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2119 <<
" quality = " << std::setw(3) << quality[hstrip]
2120 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2121 <<
" best quality = " << std::setw(3) << best_quality[0];
2127 if (best_halfstrip[0] >= 0) {
2133 hstrip < maxHalfStrips; hstrip++) {
2134 if (quality[hstrip] > best_quality[1]) {
2135 best_halfstrip[1] = hstrip;
2136 best_quality[1] = quality[hstrip];
2138 if (
infoV > 1 && quality[hstrip] > 0) {
2140 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2141 <<
" quality = " << std::setw(3) << quality[hstrip]
2142 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2143 <<
" best quality = " << std::setw(3) << best_quality[1];
2148 bool ptn_trig =
false;
2149 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2150 int best_hs = best_halfstrip[ilct];
2159 keystrip_data[ilct][
CLCT_BX] = first_bx;
2164 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2168 <<
" Final selection: ilct " << ilct
2169 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2172 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2180 keystrip_data[ilct][
CLCT_BX]);
2181 lctList.push_back(thisLCT);
2196 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2197 bool return_to_idle =
true;
2198 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2201 hstrip < maxHalfStrips; hstrip++) {
2204 <<
" State machine busy at bx = " << bx;
2205 return_to_idle =
false;
2210 if (return_to_idle) {
2212 <<
" State machine returns to idle state at bx = " << bx;
2221 start_bx = first_bx + 1;
2235 static const unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2246 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2247 pulse[i_layer][i_strip] = 0;
2251 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2254 if (
time[i_layer][i_strip].
size() > 0) {
2255 std::vector<int> bx_times =
time[i_layer][i_strip];
2256 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2258 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2260 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2261 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2262 <<
" is not within the range (0-" << bits_in_pulse
2263 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2267 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2268 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2280 const int start_bx,
int& first_bx) {
2282 <<
"....................PreTrigger...........................";
2287 bool pre_trig =
false;
2289 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2295 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2298 hstrip < nStrips; hstrip++) {
2300 if (
nhits[hstrip] > 0) {
2302 <<
" bx = " << std::setw(2) << bx_time <<
" --->"
2303 <<
" halfstrip = " << std::setw(3) << hstrip
2304 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2305 <<
" nhits = " <<
nhits[hstrip];
2324 "no pretrigger, returning \n";
2333 const int nStrips,
const unsigned int bx_time)
2340 unsigned int layers_hit = 0;
2343 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2345 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2354 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2357 nhits[key_hstrip] = 0;
2370 hit_layer[ilayer] =
false;
2372 double num_pattern_hits=0., times_sum=0.;
2373 std::multiset<int> mset_for_median;
2374 mset_for_median.clear();
2381 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2384 if (this_strip >= 0 && this_strip < nStrips) {
2386 <<
" In ptnFinding: key_strip = " << key_hstrip
2387 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2388 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2390 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2392 if (hit_layer[this_layer] ==
false)
2394 hit_layer[this_layer] =
true;
2400 int first_bx_layer = bx_time;
2401 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2403 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2408 times_sum += (double) first_bx_layer;
2409 num_pattern_hits += 1.;
2410 mset_for_median.insert(first_bx_layer);
2412 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2413 <<
" #pat. hits: " << num_pattern_hits;
2419 if (layers_hit >
nhits[key_hstrip])
2422 nhits[key_hstrip] = layers_hit;
2425 const int sz = mset_for_median.size();
2427 std::multiset<int>::iterator im = mset_for_median.begin();
2428 if (sz>1) std::advance(im,sz/2-1);
2435 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2436 sprintf(bxs,
"%s %d", bxs, *im);
2444 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2454 const int best_patid,
2463 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2464 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS) {
2465 quality[hstrip] = 0;
2476 std::vector<CSCCLCTDigi>
2479 std::vector<CSCCLCTDigi> lctList;
2482 const int maxHalfStrips = 2 *
numStrips + 1;
2486 enum { max_lcts = 2 };
2492 busyMap[
i][
j] =
false;
2494 std::vector<CSCCLCTDigi> lctListBX;
2508 while (start_bx < stop_bx)
2514 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2521 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2525 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2532 if (
nhits[hstrip] > 0)
2534 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = "
2535 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2542 start_bx = first_bx + 1;
2545 int keystrip_data[max_lcts][7] = {{0}};
2549 int best_halfstrip[max_lcts], best_quality[max_lcts];
2550 for (
int ilct = 0; ilct < max_lcts; ilct++)
2552 best_halfstrip[ilct] = -1;
2553 best_quality[ilct] = 0;
2565 pretrig_zone[hstrip] = 0;
2574 if (max_hs > CSCConstants::NUM_HALF_STRIPS - 1)
2575 max_hs = CSCConstants::NUM_HALF_STRIPS - 1;
2576 for (
int hs = min_hs; hs <= max_hs; hs++)
2577 pretrig_zone[hs] = 1;
2579 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2586 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2590 if (quality[hstrip] > best_quality[0] &&
2591 pretrig_zone[hstrip] &&
2592 !busyMap[hstrip][first_bx] )
2594 best_halfstrip[0] = hstrip;
2595 best_quality[0] = quality[hstrip];
2598 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2599 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2600 <<
" best quality = " << std::setw(3) << best_quality[0];
2607 if (best_halfstrip[0] >= 0)
2614 if (quality[hstrip] > best_quality[1] &&
2615 pretrig_zone[hstrip] &&
2616 !busyMap[hstrip][first_bx] )
2618 best_halfstrip[1] = hstrip;
2619 best_quality[1] = quality[hstrip];
2622 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2623 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2624 <<
" best quality = " << std::setw(3) << best_quality[1];
2630 bool ptn_trig =
false;
2631 for (
int ilct = 0; ilct < max_lcts; ilct++)
2633 int best_hs = best_halfstrip[ilct];
2647 keystrip_data[ilct][
CLCT_BX] = bx;
2654 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip "
2662 lctList.push_back(thisLCT);
2663 lctListBX.push_back(thisLCT);
2676 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2684 int min_hstrip = key_hstrip - delta_hs;
2685 int max_hstrip = key_hstrip + delta_hs;
2689 if (max_hstrip > maxHalfStrips)
2690 max_hstrip = maxHalfStrips;
2693 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" ["
2694 << min_hstrip <<
"," << max_hstrip <<
"]";
2701 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2703 bool busy_bx =
false;
2704 if (bx <= (
size_t)latch_bx)
2708 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2712 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits="
2713 <<
nhits[key_hstrip];
2716 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2718 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2719 busyMap[hstrip][bx] =
true;
2729 start_bx = first_bx + 1;
2742 std::ostringstream strm;
2744 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2745 strm <<
"+ CLCT configuration parameters: +\n";
2746 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2747 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = "
2749 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2751 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = "
2753 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = "
2755 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2757 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = "
2760 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = "
2762 strm <<
" min_separation [region of busy key strips] = "
2765 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2766 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2774 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2776 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2778 std::ostringstream strstrm;
2779 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2780 if (i_strip%10 == 0) {
2781 if (i_strip < 100) strstrm << i_strip/10;
2782 else strstrm << (i_strip-100)/10;
2784 else strstrm <<
" ";
2785 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2788 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2789 strstrm << i_strip%10;
2790 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2794 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2795 if (!strip[i_layer][i_strip].
empty()) {
2796 std::vector<int> bx_times = strip[i_layer][i_strip];
2798 strstrm << std::hex << bx_times[0] << std::dec;
2803 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2806 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2812 std::vector<CSCCLCTDigi> tmpV;
2827 static std::atomic<int> lct_bins;
2829 static std::atomic<int> late_tbins;
2832 static std::atomic<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
Abs< T >::type abs(const T &t)
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< CSCComparatorDigi >::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.