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;
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();
785 <<
"found " <<
digiV[i_layer].size()
786 <<
" comparator digi(s) in layer " << i_layer <<
" of ME"
801 bool me1b = (
id.station() == 1) && (
id.
ring() == 1);
802 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
805 digiIt != rcompd.second; ++digiIt) {
806 unsigned int origStrip = digiIt->getStrip();
807 unsigned int maxStripsME1a =
gangedME1a ? 16 : 48;
812 digiIt->getComparator(),
813 digiIt->getTimeBinWord());
814 digiV[
id.layer()-1].push_back(digi_corr);
819 if (me1aProc && me1b && origStrip > 64){
822 digiIt->getComparator(),
823 digiIt->getTimeBinWord());
824 digiV[
id.layer()-1].push_back(digi_corr);
825 }
else if ((me1bProc && me1b && origStrip <= 64)
826 || ((me1aProc && me1a))
828 digiV[
id.layer()-1].push_back(*digiIt);
832 digiV[
id.layer()-1].push_back(*digiIt);
845 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
846 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
849 std::ostringstream strstrm;
850 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
851 <<
" strip #" << pld->getStrip()
853 std::vector<int> bx_times = pld->getTimeBinsOn();
854 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
855 strstrm <<
" " << bx_times[tbin];
856 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
861 int thisComparator = pld->getComparator();
862 if (thisComparator != 0 && thisComparator != 1) {
864 <<
"+++ Found comparator digi with wrong comparator value = "
865 << thisComparator <<
"; skipping it... +++\n";
870 int thisStrip = pld->getStrip() - 1;
871 if (thisStrip < 0 || thisStrip >=
numStrips) {
873 <<
"+++ Found comparator digi with wrong strip number = "
875 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
881 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
884 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
885 <<
"; skipping this digi... +++\n";
890 std::vector<int> bx_times = pld->getTimeBinsOn();
891 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
899 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
901 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
907 <<
"Comp digi: layer " << i_layer+1
908 <<
" digi #" << i_digi+1
909 <<
" strip " << thisStrip
910 <<
" halfstrip " << thisHalfstrip
911 <<
" distrip " << thisStrip/2 +
912 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
913 <<
" time " << bx_times[
i]
914 <<
" comparator " << thisComparator
915 <<
" stagger " << stagger[i_layer];
916 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
920 <<
" Skipping comparator digi: strip = " << thisStrip
921 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
922 <<
", bx of previous hit = " << bx_times[
i-1];
927 <<
"+++ Skipping comparator digi: strip = " << thisStrip
928 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
949 digiNum[
i][
j] = -999;
954 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
955 for (
unsigned int j = 0;
j < layerDigiV.size();
j++) {
961 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
962 <<
" strip #" << thisDigi.
getStrip()
968 if (thisComparator != 0 && thisComparator != 1) {
970 <<
"+++ Comparator digi with wrong comparator value: digi #" <<
j
971 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
976 int thisStrip = thisDigi.
getStrip() - 1;
977 if (thisStrip < 0 || thisStrip >=
numStrips) {
979 <<
"+++ Comparator digi with wrong strip number: digi #" <<
j
980 <<
", strip = " << thisStrip
981 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
990 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
999 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
1000 digiNum[
i][thisStrip] =
j;
1001 time[
i][thisStrip] = thisDigiBx;
1002 comp[
i][thisStrip] = thisComparator;
1004 <<
"Comp digi: layer " <<
i+1
1006 <<
" strip " << thisStrip
1007 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
1008 <<
" distrip " << thisStrip/2 +
1009 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
1010 <<
" time " << time[
i][thisStrip]
1011 <<
" comparator " << comp[
i][thisStrip]
1017 <<
"+++ Skipping comparator digi: strip = " << thisStrip
1018 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1029 if (time[
i][
j] >= 0) {
1036 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1037 <<
"; skipping this digi... +++\n";
1040 halfstrip[
i][i_halfstrip].push_back(time[
i][
j]);
1049 static std::atomic<int> test_iteration{0};
1051 if (time[
i][
j] >= 0) {
1052 int i_distrip =
j/2;
1053 if (
j%2 == 1 && comp[
i][
j] == 1 &&
stagger[
i] == 1) {
1055 bool stagger_debug = (
infoV > 2);
1064 if (
infoV > 2 && test_iteration == 1) {
1070 <<
"+++ Found wrong distrip number = " << i_distrip
1071 <<
"; skipping this digi... +++\n";
1074 distrip[
i][i_distrip].push_back(time[
i][
j]);
1082 int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1083 int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1084 int i_strip,
bool debug) {
1102 <<
"+++ Found wrong strip number = " << i_strip
1103 <<
"; cannot apply distrip staggering... +++\n";
1109 <<
" Enter distripStagger: i_strip = " << i_strip
1110 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1111 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1112 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1113 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1124 if (stag_time[i_strip+2] >= 0) {
1125 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1126 stag_time[i_strip+2] = stag_time[i_strip];
1127 stag_digi[i_strip+2] = stag_digi[i_strip];
1133 stag_time[i_strip+2] = stag_time[i_strip];
1134 stag_digi[i_strip+2] = stag_digi[i_strip];
1141 stag_time[i_strip] = -999;
1142 stag_triad[i_strip] = 4;
1143 stag_digi[i_strip] = -999;
1147 <<
" Exit distripStagger: i_strip = " << i_strip
1148 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1149 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1150 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1151 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1169 const int max_lct_num = 2;
1170 const int adjacent_strips = 2;
1173 int highest_quality = 0;
1176 int final_lcts[max_lct_num];
1178 std::vector <CSCCLCTDigi> lctList;
1181 if (stripType == 1) nStrips = 2*
numStrips + 1;
1182 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1189 if (
preTrigger(strip, stripType, nStrips, first_bx)){
1190 getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);
1193 for (j = 0; j < max_lct_num; j++)
1194 final_lcts[j] = -999;
1200 final_lcts[0] = best_strip;
1202 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1204 if (
abs(best_strip - key_strip) > adjacent_strips){
1206 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1207 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1208 final_lcts[1] = key_strip;
1213 for (j = 0; j < max_lct_num; j++){
1216 int keystrip = final_lcts[
j];
1217 if (keystrip >= 0 &&
1218 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1225 keystrip_data[keystrip][
CLCT_CFEB] = theHalfStrip/32;
1226 int halfstrip_in_cfeb =
1227 theHalfStrip - 32*keystrip_data[keystrip][
CLCT_CFEB];
1235 keystrip_data[keystrip][
CLCT_BX]);
1240 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1243 <<
"Key Strip: " << std::setw(3)
1245 <<
" Pattern: " << std::setw(2)
1247 <<
" Bend: " << std::setw(1) << bend
1248 <<
" Quality: " << std::setw(1)
1250 <<
" stripType: " << std::setw(1) << stripType
1251 <<
" BX: " << std::setw(1)
1252 << keystrip_data[keystrip][
CLCT_BX];
1254 lctList.push_back(thisLCT);
1265 const int stripType,
const int nStrips,
1272 int i_layer, i_strip, this_layer, this_strip;
1273 int hits, layers_hit;
1276 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1283 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1289 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1294 hit_layer[i_layer] =
false;
1299 if (this_strip >= 0 && this_strip < nStrips) {
1301 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1304 if (hit_layer[this_layer] ==
false) {
1305 hit_layer[this_layer] =
true;
1310 if (layers_hit >= pre_trigger_layer_min) {
1327 int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7],
1328 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1330 int key_strip, this_layer, this_strip;
1333 int highest_quality = 0;
1336 for (key_strip = 0; key_strip < nStrips; key_strip++)
1337 for (
int i = 0;
i < 7;
i++)
1338 keystrip_data[key_strip][
i] = 0;
1343 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1350 if ((this_strip >= 0 && this_strip < nStrips) &&
1351 !strip[this_layer][this_strip].empty()) {
1352 if (nullPattern) nullPattern =
false;
1353 std::vector<int> bx_times = strip[this_layer][this_strip];
1354 lct_pattern[pattern_strip] = bx_times[0];
1357 lct_pattern[pattern_strip] = -999;
1361 if (nullPattern)
continue;
1375 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1377 <<
"Key_strip " << key_strip <<
" quality of pattern_num "
1378 << pattern_num <<
": " <<
quality;
1379 if (quality > best_quality){
1382 keystrip_data[key_strip][
CLCT_BEND] = bend;
1383 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1384 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1387 if (quality > highest_quality){
1392 best_strip = key_strip;
1404 int strip_value[NUM_PATTERN_STRIPS],
int bx_time,
1414 hit_layer[i_layer] =
false;
1418 if (
hitIsGood(strip_value[strip_num], bx_time)){
1422 if (i_layer ==
pattern[pattern_num][strip_num]){
1424 if (hit_layer[i_layer] ==
false){
1426 hit_layer[i_layer] =
true;
1434 quality = layers_hit;
1442 int dt = BX - hitTime;
1443 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1444 else {
return false;}
1462 std::vector <CSCCLCTDigi> lctList;
1463 int _bx[2] = {999, 999};
1479 int keystrip_data[2][7];
1482 bool pre_trig[2] = {
false,
false};
1486 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1487 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1491 if (pre_trig[0] || pre_trig[1]) {
1492 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1494 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1495 <<
"\n ..... waiting drift delay ..... ";
1534 <<
"...............................\n"
1535 <<
"Final halfstrip hits and keys (after drift delay) ...";
1536 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1538 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1539 <<
" hits " << h_nhits[icfeb];
1542 <<
"Final distrip hits and keys (after drift delay) ...";
1543 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1545 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1546 <<
" hits " << d_nhits[icfeb];
1549 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1552 for (
int ilct = 0; ilct < 2; ilct++) {
1554 <<
"found lcts: ilct " << ilct
1555 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1557 int halfstrip_in_cfeb = 0;
1559 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1562 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1571 keystrip_data[ilct][
CLCT_BX]);
1572 lctList.push_back(thisLCT);
1586 const int stripType,
const int nStrips,
1587 const int start_bx,
int& first_bx) {
1589 <<
"....................PreTrigger...........................";
1591 if (start_bx == 0) {
1596 bool pre_trig =
false;
1598 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1604 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1612 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1621 const int stripType,
const int nStrips,
1622 const unsigned int bx_time) {
1627 int key_strip, this_layer, this_strip, layers_hit;
1630 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1632 if (stripType != 0 && stripType != 1) {
1634 <<
"+++ preTrigLookUp: stripType = " << stripType
1635 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1639 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1641 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1643 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1646 hit_layer[ilayer] =
false;
1653 if (this_strip >= 0 && this_strip < nStrips) {
1655 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1656 if (hit_layer[this_layer] ==
false) {
1657 hit_layer[this_layer] =
true;
1659 if (layers_hit >= pre_trigger_layer_min) {
1661 <<
"pretrigger at bx: " << bx_time
1662 <<
", cfeb " << icfeb <<
", returning";
1680 int keyStrip[MAX_CFEBS],
unsigned int n_hits[MAX_CFEBS],
1681 const int stripType,
const int nStrips,
const int bx_time) {
1684 int key_strip, this_layer, this_strip;
1685 int layers_hit, prev_hits;
1687 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1688 keyStrip[icfeb] = -1;
1692 if (stripType != 0 && stripType != 1) {
1694 <<
"+++ latchLCTs: stripType = " << stripType
1695 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1699 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1702 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1704 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1707 hit_layer[ilayer] =
false;
1714 if (this_strip >= 0 && this_strip < nStrips) {
1716 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1717 if (hit_layer[this_layer] ==
false) {
1718 hit_layer[this_layer] =
true;
1725 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1726 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1727 <<
" n_hits: " << layers_hit;
1732 if (layers_hit > prev_hits) {
1733 prev_hits = layers_hit;
1734 keyStrip[icfeb] = key_strip;
1735 n_hits[icfeb] = layers_hit;
1744 const int h_keyStrip[MAX_CFEBS],
const unsigned int h_nhits[MAX_CFEBS],
1745 const int d_keyStrip[MAX_CFEBS],
const unsigned int d_nhits[MAX_CFEBS],
1746 int keystrip_data[2][7]) {
1752 const int nlcts = 2;
1756 for (
int ilct = 0; ilct < nlcts; ilct++) {
1757 for (
int j = 0;
j < 7;
j++) keystrip_data[ilct][
j] = -1;
1761 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1762 key_strip[icfeb] = -1;
1763 key_phits[icfeb] = -1;
1764 strip_type[icfeb] = -1;
1769 <<
".....................PriorityEncode.......................";
1770 std::ostringstream strstrm;
1771 strstrm <<
"hkeys:";
1772 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1773 strstrm << std::setw(4) << h_keyStrip[icfeb];
1775 strstrm <<
"\ndkeys:";
1776 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1777 strstrm << std::setw(4) << d_keyStrip[icfeb];
1779 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1784 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1785 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1786 if (h_nhits[icfeb] >= hs_thresh) {
1787 key_strip[icfeb] = h_keyStrip[icfeb];
1788 key_phits[icfeb] = h_nhits[icfeb] + 8;
1789 strip_type[icfeb]= 1;
1795 key_strip[icfeb] = d_keyStrip[icfeb];
1796 key_phits[icfeb] = d_nhits[icfeb];
1797 strip_type[icfeb]= 0;
1800 else if (h_keyStrip[icfeb] != -1) {
1801 if (h_nhits[icfeb] >= hs_thresh) {
1802 key_strip[icfeb] = h_keyStrip[icfeb];
1803 key_phits[icfeb] = h_nhits[icfeb] + 8;
1804 strip_type[icfeb]= 1;
1807 else if (d_keyStrip[icfeb] != -1) {
1809 key_strip[icfeb] = d_keyStrip[icfeb];
1810 key_phits[icfeb] = d_nhits[icfeb];
1811 strip_type[icfeb]= 0;
1814 if (
infoV > 1 && strip_type[icfeb] != -1) {
1815 if (strip_type[icfeb] == 0)
1817 <<
" taking distrip pattern on cfeb " << icfeb;
1818 else if (strip_type[icfeb] == 1)
1820 <<
" taking halfstrip pattern on cfeb " << icfeb;
1822 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1823 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1834 <<
"...... Remove Duplicates ......";
1835 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1836 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1837 else key[icfeb] = key_strip[icfeb];
1839 for (
int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1840 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1844 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1845 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1846 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1848 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1849 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1851 <<
" deleting LCT on CFEB " << icfeb;
1852 key_strip[icfeb] = -1;
1853 key_phits[icfeb] = -1;
1857 <<
" deleting LCT on CFEB " << icfeb+1;
1858 key_strip[icfeb+1] = -1;
1859 key_phits[icfeb+1] = -1;
1868 <<
"\n...... Select best LCTs ......";
1869 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1870 if (key_phits[icfeb] > ihits[0]) {
1871 ihits[1] = ihits[0];
1872 cfebs[1] = cfebs[0];
1873 ihits[0] = key_phits[icfeb];
1876 std::ostringstream strstrm;
1877 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1878 strstrm << std::setw(4) << strip_type[icfeb];
1881 <<
"strip_type" << strstrm.str()
1882 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1883 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1884 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1885 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1888 else if (key_phits[icfeb] > ihits[1]) {
1889 ihits[1] = key_phits[icfeb];
1892 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1893 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1899 for (
int ilct = 0; ilct < nlcts; ilct++) {
1900 if (cfebs[ilct] != -1) {
1901 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1902 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1905 <<
"filling key: " << key_strip[cfebs[ilct]]
1906 <<
" type: " << strip_type[cfebs[ilct]];
1917 int keystrip_data[2][7],
const int first_bx) {
1920 int this_layer, this_strip;
1921 unsigned int quality = 0, bend = 0;
1922 unsigned int best_quality, best_pattern;
1923 bool valid[2] = {
false,
false};
1933 <<
"...............getKeyStripData....................";
1935 for (
int ilct = 0; ilct < 2; ilct++) {
1937 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1941 <<
"no lct at ilct " << ilct;
1946 lct_pattern[pattern_strip] = -999;
1955 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1956 lct_pattern[pattern_strip] = 1;
1962 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1963 lct_pattern[pattern_strip] = 1;
1973 for (
unsigned int pattern_num = 0;
1975 getPattern(pattern_num, lct_pattern, quality, bend);
1977 <<
"pattern " << pattern_num <<
" quality " << quality
1978 <<
" bend " << bend;
1985 if ((quality == best_quality && pattern_num > best_pattern) ||
1986 (quality > best_quality)) {
1988 <<
"valid = true at quality " << quality
1993 keystrip_data[ilct][
CLCT_BX] = first_bx;
1997 best_pattern = pattern_num;
2005 <<
"lct " << ilct <<
" not over threshold: deleting";
2009 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n"
2010 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
2011 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
2013 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
2014 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
2023 const int strip_value[NUM_PATTERN_STRIPS],
2024 unsigned int&
quality,
unsigned int& bend) {
2031 unsigned int layers_hit = 0;
2036 hit_layer[i_layer] =
false;
2040 if (strip_value[strip_num] == 1){
2044 if (i_layer ==
pattern[pattern_num][strip_num]){
2046 if (hit_layer[i_layer] ==
false){
2048 hit_layer[i_layer] =
true;
2056 quality = layers_hit;
2069 std::vector<CSCCLCTDigi> lctList;
2072 const int maxHalfStrips = 2*
numStrips + 1;
2077 enum {max_lcts = 2};
2079 int keystrip_data[max_lcts][7] = {{0}};
2090 while (start_bx < stop_bx) {
2094 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2101 <<
"..... pretrigger at bx = " << first_bx
2102 <<
"; waiting drift delay .....";
2106 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2110 hstrip < maxHalfStrips; hstrip++) {
2111 if (
nhits[hstrip] > 0) {
2113 <<
" bx = " << std::setw(2) << latch_bx <<
" --->"
2114 <<
" halfstrip = " << std::setw(3) << hstrip
2115 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2116 <<
" nhits = " <<
nhits[hstrip];
2123 start_bx = first_bx + 1;
2127 int best_halfstrip[max_lcts], best_quality[max_lcts];
2128 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2129 best_halfstrip[ilct] = -1;
2130 best_quality[ilct] = 0;
2137 hstrip < maxHalfStrips; hstrip++) {
2140 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2141 if (quality[hstrip] > best_quality[0]) {
2142 best_halfstrip[0] = hstrip;
2143 best_quality[0] = quality[hstrip];
2145 if (
infoV > 1 && quality[hstrip] > 0) {
2147 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2148 <<
" quality = " << std::setw(3) << quality[hstrip]
2149 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2150 <<
" best quality = " << std::setw(3) << best_quality[0];
2156 if (best_halfstrip[0] >= 0) {
2162 hstrip < maxHalfStrips; hstrip++) {
2163 if (quality[hstrip] > best_quality[1]) {
2164 best_halfstrip[1] = hstrip;
2165 best_quality[1] = quality[hstrip];
2167 if (
infoV > 1 && quality[hstrip] > 0) {
2169 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2170 <<
" quality = " << std::setw(3) << quality[hstrip]
2171 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2172 <<
" best quality = " << std::setw(3) << best_quality[1];
2177 bool ptn_trig =
false;
2178 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2179 int best_hs = best_halfstrip[ilct];
2188 keystrip_data[ilct][
CLCT_BX] = first_bx;
2193 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2197 <<
" Final selection: ilct " << ilct
2198 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2201 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2209 keystrip_data[ilct][
CLCT_BX]);
2210 lctList.push_back(thisLCT);
2225 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2226 bool return_to_idle =
true;
2227 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2230 hstrip < maxHalfStrips; hstrip++) {
2233 <<
" State machine busy at bx = " << bx;
2234 return_to_idle =
false;
2239 if (return_to_idle) {
2241 <<
" State machine returns to idle state at bx = " << bx;
2250 start_bx = first_bx + 1;
2264 static const unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2275 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2276 pulse[i_layer][i_strip] = 0;
2280 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2283 if (
time[i_layer][i_strip].
size() > 0) {
2284 std::vector<int> bx_times =
time[i_layer][i_strip];
2285 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2287 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2289 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2290 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2291 <<
" is not within the range (0-" << bits_in_pulse
2292 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2296 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2297 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2309 const int start_bx,
int& first_bx) {
2311 <<
"....................PreTrigger...........................";
2316 bool pre_trig =
false;
2318 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2324 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2327 hstrip < nStrips; hstrip++) {
2329 if (
nhits[hstrip] > 0) {
2331 <<
" bx = " << std::setw(2) << bx_time <<
" --->"
2332 <<
" halfstrip = " << std::setw(3) << hstrip
2333 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2334 <<
" nhits = " <<
nhits[hstrip];
2353 "no pretrigger, returning \n";
2362 const int nStrips,
const unsigned int bx_time)
2369 unsigned int layers_hit = 0;
2372 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2374 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2383 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2386 nhits[key_hstrip] = 0;
2399 hit_layer[ilayer] =
false;
2401 double num_pattern_hits=0., times_sum=0.;
2402 std::multiset<int> mset_for_median;
2403 mset_for_median.clear();
2410 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2413 if (this_strip >= 0 && this_strip < nStrips) {
2415 <<
" In ptnFinding: key_strip = " << key_hstrip
2416 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2417 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2419 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2421 if (hit_layer[this_layer] ==
false)
2423 hit_layer[this_layer] =
true;
2429 int first_bx_layer = bx_time;
2430 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2432 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2437 times_sum += (double) first_bx_layer;
2438 num_pattern_hits += 1.;
2439 mset_for_median.insert(first_bx_layer);
2441 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2442 <<
" #pat. hits: " << num_pattern_hits;
2448 if (layers_hit >
nhits[key_hstrip])
2451 nhits[key_hstrip] = layers_hit;
2454 const int sz = mset_for_median.size();
2456 std::multiset<int>::iterator im = mset_for_median.begin();
2457 if (sz>1) std::advance(im,sz/2-1);
2464 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2465 sprintf(bxs,
"%s %d", bxs, *im);
2473 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2483 const int best_patid,
2492 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2493 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
2505 std::vector<CSCCLCTDigi>
2508 std::vector<CSCCLCTDigi> lctList;
2511 const int maxHalfStrips = 2 *
numStrips + 1;
2515 enum { max_lcts = 2 };
2521 busyMap[
i][
j] =
false;
2523 std::vector<CSCCLCTDigi> lctListBX;
2537 while (start_bx < stop_bx)
2543 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2550 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2554 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2561 if (
nhits[hstrip] > 0)
2563 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = "
2564 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2571 start_bx = first_bx + 1;
2574 int keystrip_data[max_lcts][7] = {{0}};
2578 int best_halfstrip[max_lcts], best_quality[max_lcts];
2579 for (
int ilct = 0; ilct < max_lcts; ilct++)
2581 best_halfstrip[ilct] = -1;
2582 best_quality[ilct] = 0;
2594 pretrig_zone[hstrip] = 0;
2603 if (max_hs > CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1)
2604 max_hs = CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1;
2605 for (
int hs = min_hs; hs <= max_hs; hs++)
2606 pretrig_zone[hs] = 1;
2608 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2615 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2619 if (quality[hstrip] > best_quality[0] &&
2620 pretrig_zone[hstrip] &&
2621 !busyMap[hstrip][first_bx] )
2623 best_halfstrip[0] = hstrip;
2624 best_quality[0] = quality[hstrip];
2627 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2628 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2629 <<
" best quality = " << std::setw(3) << best_quality[0];
2636 if (best_halfstrip[0] >= 0)
2643 if (quality[hstrip] > best_quality[1] &&
2644 pretrig_zone[hstrip] &&
2645 !busyMap[hstrip][first_bx] )
2647 best_halfstrip[1] = hstrip;
2648 best_quality[1] = quality[hstrip];
2651 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2652 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2653 <<
" best quality = " << std::setw(3) << best_quality[1];
2659 bool ptn_trig =
false;
2660 for (
int ilct = 0; ilct < max_lcts; ilct++)
2662 int best_hs = best_halfstrip[ilct];
2676 keystrip_data[ilct][
CLCT_BX] = bx;
2683 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip "
2691 lctList.push_back(thisLCT);
2692 lctListBX.push_back(thisLCT);
2705 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2713 int min_hstrip = key_hstrip - delta_hs;
2714 int max_hstrip = key_hstrip + delta_hs;
2718 if (max_hstrip > maxHalfStrips)
2719 max_hstrip = maxHalfStrips;
2722 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" ["
2723 << min_hstrip <<
"," << max_hstrip <<
"]";
2730 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2732 bool busy_bx =
false;
2733 if (bx <= (
size_t)latch_bx)
2737 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2741 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits="
2742 <<
nhits[key_hstrip];
2745 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2747 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2748 busyMap[hstrip][bx] =
true;
2758 start_bx = first_bx + 1;
2771 std::ostringstream strm;
2773 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2774 strm <<
"+ CLCT configuration parameters: +\n";
2775 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2776 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = "
2778 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2780 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = "
2782 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = "
2784 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2786 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = "
2789 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = "
2791 strm <<
" min_separation [region of busy key strips] = "
2794 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2795 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2803 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2805 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2807 std::ostringstream strstrm;
2808 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2809 if (i_strip%10 == 0) {
2810 if (i_strip < 100) strstrm << i_strip/10;
2811 else strstrm << (i_strip-100)/10;
2813 else strstrm <<
" ";
2814 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2817 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2818 strstrm << i_strip%10;
2819 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2823 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2824 if (!strip[i_layer][i_strip].
empty()) {
2825 std::vector<int> bx_times = strip[i_layer][i_strip];
2827 strstrm << std::hex << bx_times[0] <<
std::dec;
2832 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2835 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2841 std::vector<CSCCLCTDigi> tmpV;
2856 static std::atomic<int> lct_bins;
2858 static std::atomic<int> late_tbins;
2861 static std::atomic<int> ifois{0};
2866 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2871 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2873 <<
"+++ Set late_tbins to max allowed +++\n";
2874 late_tbins = MAX_CLCT_BINS-1;
2881 int bx_readout = -1;
2882 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2883 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2884 plct != all_lcts.end(); plct++) {
2885 if (!plct->isValid())
continue;
2887 int bx = (*plct).getBX();
2891 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2892 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
2898 if (bx > late_tbins) {
2900 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2901 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
2910 if (bx_readout == -1 || bx == bx_readout) {
2911 tmpV.push_back(*plct);
2912 if (bx_readout == -1) bx_readout = bx;
2915 else tmpV.push_back(*plct);
2922 std::vector<CSCCLCTDigi> tmpV;
2942 test_triad[distrip] = 3;
2943 test_triad[distrip+1] = 3;
2944 test_triad[distrip+2] = 3;
2945 test_triad[distrip+3] = 3;
2946 test_triad[distrip+4] = 3;
2947 test_triad[distrip+5] = 3;
2948 test_triad[distrip+6] = 3;
2949 test_triad[distrip+7] = 3;
2950 test_triad[distrip+8] = 3;
2951 test_triad[distrip+9] = 3;
2952 test_triad[distrip+10] = 2;
2954 test_time[distrip] = 4;
2955 test_time[distrip+1] = 10;
2956 test_time[distrip+2] = 2;
2957 test_time[distrip+3] = 0;
2958 test_time[distrip+4] = 6;
2959 test_time[distrip+5] = 8;
2960 test_time[distrip+6] = 10;
2961 test_time[distrip+7] = 1;
2962 test_time[distrip+8] = 8;
2963 test_time[distrip+9] = 5;
2964 test_time[distrip+10] = 6;
2966 std::cout <<
"\n ------------------------------------------------- \n";
2967 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2968 std::cout <<
"Values before distripStagger routine:" << std::endl;
2969 for (
int i=distrip;
i<distrip+11;
i++){
2971 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2972 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2974 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2975 std::cout <<
"Values after distripStagger routine:" << std::endl;
2976 for (
int i=distrip;
i<distrip+11;
i++){
2977 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2978 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2980 std::cout <<
"\n ------------------------------------------------- \n \n";
2985 for (
int ptn = 0; ptn < 8; ptn++) {
2986 for (
int bend = 0; bend < 2; bend++) {
2987 for (
int cfeb = 0; cfeb <
MAX_CFEBS; cfeb++) {
2988 for (
int key_strip = 0; key_strip < 32; key_strip++) {
2989 for (
int bx = 0; bx < 7; bx++) {
2990 for (
int stripType = 0; stripType < 2; stripType++) {
2993 key_strip, cfeb, bx);
2996 <<
"pattern mismatch: " << ptn <<
" "
2998 if (bend != thisLCT.
getBend())
3000 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
3001 if (cfeb != thisLCT.
getCFEB())
3003 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
3006 <<
"strip mismatch: " << key_strip <<
" "
3008 if (bx != thisLCT.
getBX())
3010 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
3013 <<
"Strip Type mismatch: " << stripType <<
" "
3017 <<
"quality mismatch: " <<
quality <<
" "
3030 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3033 std::cout<<
" Pattern "<<patternNum<<
" ";
3043 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3051 minStrip = 3*layer - 2;
3053 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3054 if (layer ==
pattern[patternNum][strip]) {
3075 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3078 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3079 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3080 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3081 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3082 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3083 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3084 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3085 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3086 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3087 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3088 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3089 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3090 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3091 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3092 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3093 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3102 if (numLayersHit > 3 || results.size() > 0) {
3103 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3107 for (
int strip = 9; strip < 12; strip++) {
3108 if (!stripsHit[layer][strip].
empty()) {
3109 if (results.size() > 0) {
3110 int thePatternStrip = strip - (results[0].getKeyStrip() - 2) + 3*layer;
3113 thePatternStrip -= 2;
3135 minStrip = 3*layer - 2;
3137 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3147 if (!stripsHit[layer][10].
empty()) {
3155 if (layer < static_cast<int>(results.size()) ) {
3170 if ((!stripsHit[layer][ 9].
empty()) ||
3171 (!stripsHit[layer][10].
empty()) ||
3172 (!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
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int i_distrip, bool debug=false)
int getStrip() const
Get the strip number.
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...
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int min_separation
static const int cfeb_strips[2]
unsigned int clctHitPersist() const
const unsigned theTrigChamber
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
void dumpConfigParams() const
const unsigned theStation
static const unsigned int def_min_separation
int numberOfStrips() const
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
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, const unsigned int bx_time)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keyStrip[MAX_CFEBS], unsigned int nhits[MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
static CSCTriggerGeomManager * get()
unsigned int clctPidThreshPretrig() const
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips) const
int getCFEB() const
return Key CFEB ID
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
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, int &first_bx)
unsigned int clct_state_machine_zone
unsigned int nplanes_hit_pattern
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
void priorityEncode(const int h_keyStrip[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 checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
static const unsigned int def_hit_persist
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int stripType)
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCComparatorDigi >::const_iterator const_iterator
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
static const int pattern2007_offset[NUM_PATTERN_HALFSTRIPS]
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
bool hitIsGood(int hitTime, int BX)
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
unsigned int tmb_l1a_window_size
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7], int nStrips, int first_bx, int &best_strip, int stripType)
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
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 dynamic_state_machine_zone
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.