69 { 999, 999, 999, 999, 999,
70 999, 999, 999, 999, 999,
71 999, 999, 999, 999, 999,
73 999, 999, 999, 999, 999,
74 999, 999, 999, 999, 999, 0},
76 { 999, 999, 999, 0, 999,
77 999, 999, 999, 1, 999,
81 999, 5, 999, 999, 999, 1},
83 { 999, 0, 999, 999, 999,
84 999, 1, 999, 999, 999,
88 999, 999, 999, 5, 999, 0},
90 { 999, 999, 0, 999, 999,
91 999, 999, 1, 999, 999,
92 999, 999, 2, 999, 999,
94 999, 4, 999, 999, 999,
95 999, 5, 999, 999, 999, 1},
97 { 999, 999, 0, 999, 999,
98 999, 999, 1, 999, 999,
99 999, 999, 2, 999, 999,
101 999, 999, 999, 4, 999,
102 999, 999, 999, 5, 999, 0},
104 { 999, 999, 999, 0, 999,
105 999, 999, 999, 1, 999,
108 999, 999, 4, 999, 999,
109 999, 999, 5, 999, 999, 1},
111 { 999, 0, 999, 999, 999,
112 999, 1, 999, 999, 999,
115 999, 999, 4, 999, 999,
116 999, 999, 5, 999, 999, 0},
118 { 999, 999, 0, 999, 999,
119 999, 999, 1, 999, 999,
120 999, 999, 2, 999, 999,
122 999, 999, 4, 999, 999,
123 999, 999, 5, 999, 999, 1}
132 { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
136 -4, -3, -2, -1, 0, 1, 2, 3, 4,
137 -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
140 { 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
141 999, 999, 999, 999, 999,
143 999, 999, 999, 999, 999,
144 999, 999, 999, 999, 999, 999, 999, 999, 999,
145 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -1, 0},
147 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 4, 4, 4, 4, 4, 4, 4, 4, 4,
152 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 11},
154 { 999, 999, 999, 999, 999, 999, 999, 999, 0, 0, 0,
158 4, 4, 4, 999, 999, 999, 999, 999, 999,
159 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 999, 0, 11},
161 { 0, 0, 0, 999, 999, 999, 999, 999, 999, 999, 999,
165 999, 999, 999, 999, 999, 999, 4, 4, 4,
166 999, 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 1, 11},
168 { 999, 999, 999, 999, 999, 999, 999, 0, 0, 0, 999,
172 4, 4, 4, 999, 999, 999, 999, 999, 999,
173 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 0, 9},
175 { 999, 0, 0, 0, 999, 999, 999, 999, 999, 999, 999,
179 999, 999, 999, 999, 999, 999, 4, 4, 4,
180 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 1, 9},
182 { 999, 999, 999, 999, 999, 999, 0, 0, 0, 999, 999,
186 999, 999, 4, 4, 999, 999, 999, 999, 999,
187 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 0, 7},
189 { 999, 999, 0, 0, 0, 999, 999, 999, 999, 999, 999,
193 999, 999, 999, 999, 999, 4, 4, 999, 999,
194 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 1, 7},
196 { 999, 999, 999, 999, 999, 0, 0, 0, 999, 999, 999,
200 999, 999, 4, 4, 4, 999, 999, 999, 999,
201 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 0, 5},
203 { 999, 999, 999, 0, 0, 0, 999, 999, 999, 999, 999,
207 999, 999, 999, 999, 4, 4, 4, 999, 999,
208 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 1, 5},
210 { 999, 999, 999, 999, 0, 0, 0, 999, 999, 999, 999,
211 999, 999, 1, 999, 999,
213 999, 999, 3, 999, 999,
214 999, 999, 999, 4, 4, 4, 999, 999, 999,
215 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 0, 3}
248 theEndcap(endcap), theStation(station), theSector(sector),
249 theSubsector(subsector), theTrigChamber(chamber) {
250 static std::atomic<bool> config_dumped{
false};
257 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
259 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
288 if (isSLHC && !smartME1aME1b)
edm::LogError(
"L1CSCTPEmulatorConfigError")
289 <<
"+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n" 290 <<
"Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
294 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
330 if ((infoV > 0 || isSLHC) && !config_dumped) {
333 config_dumped =
true;
339 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
371 static std::atomic<bool> config_dumped{
false};
391 if (!config_dumped) {
394 config_dumped =
true;
400 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
433 static std::atomic<bool> config_dumped{
false};
450 if (!config_dumped) {
453 config_dumped =
true;
461 static const unsigned int max_fifo_tbins = 1 << 5;
462 static const unsigned int max_fifo_pretrig = 1 << 5;
463 static const unsigned int max_hit_persist = 1 << 4;
464 static const unsigned int max_drift_delay = 1 << 2;
465 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
466 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
467 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
469 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
475 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n" 476 <<
"+++ Try to proceed with the default value, fifo_tbins=" 483 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n" 484 <<
"+++ Try to proceed with the default value, fifo_pretrig=" 491 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n" 492 <<
"+++ Try to proceed with the default value, hit_persist=" 499 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n" 500 <<
"+++ Try to proceed with the default value, drift_delay=" 507 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n" 508 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig=" 515 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n" 516 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern=" 525 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n" 526 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig=" 533 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n" 534 <<
"+++ Try to proceed with the default value, min_separation=" 543 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n" 544 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size=" 559 std::vector<CSCCLCTDigi>
567 static std::atomic<bool> config_dumped{
false};
571 config_dumped =
true;
604 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
610 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
628 (
chamber->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
633 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
637 <<
" is not defined in current geometry! +++\n" 638 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
645 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
649 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
650 std::vector<CSCCLCTDigi> emptyV;
676 unsigned int layersHit = 0;
680 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
690 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
699 for (
auto&
p : tmpV){
714 std::vector<CSCCLCTDigi> LCTlist;
723 LCTlist =
findLCTs(halfstrip, distrip);
726 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
727 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
729 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
730 LCTlist.push_back(halfStripLCTs[
i]);
731 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
732 LCTlist.push_back(diStripLCTs[i]);
736 if (LCTlist.size() > 1)
737 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
740 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
741 plct != LCTlist.end(); plct++) {
742 int bx = plct->getBX();
745 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, " 788 digiV[i_layer].clear();
811 <<
"found " <<
digiV[i_layer].size()
812 <<
" comparator digi(s) in layer " << i_layer <<
" of ME" 827 bool me1b = (
id.station() == 1) && (
id.
ring() == 1);
828 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
831 digiIt != rcompd.second; ++digiIt) {
832 unsigned int origStrip = digiIt->getStrip();
833 unsigned int maxStripsME1a =
gangedME1a ? 16 : 48;
838 digiIt->getComparator(),
839 digiIt->getTimeBinWord());
840 digiV[
id.layer()-1].push_back(digi_corr);
845 if (me1aProc && me1b && origStrip > 64){
848 digiIt->getComparator(),
849 digiIt->getTimeBinWord());
850 digiV[
id.layer()-1].push_back(digi_corr);
851 }
else if ((me1bProc && me1b && origStrip <= 64)
852 || ((me1aProc && me1a))
854 digiV[
id.layer()-1].push_back(*digiIt);
858 digiV[
id.layer()-1].push_back(*digiIt);
871 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
872 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
875 std::ostringstream strstrm;
876 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
877 <<
" strip #" << pld->getStrip()
879 std::vector<int> bx_times = pld->getTimeBinsOn();
880 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
881 strstrm <<
" " << bx_times[tbin];
882 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
887 int thisComparator = pld->getComparator();
888 if (thisComparator != 0 && thisComparator != 1) {
890 <<
"+++ Found comparator digi with wrong comparator value = " 891 << thisComparator <<
"; skipping it... +++\n";
896 int thisStrip = pld->getStrip() - 1;
897 if (thisStrip < 0 || thisStrip >=
numStrips) {
899 <<
"+++ Found comparator digi with wrong strip number = " 901 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
907 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
910 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
911 <<
"; skipping this digi... +++\n";
916 std::vector<int> bx_times = pld->getTimeBinsOn();
917 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
925 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
927 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
933 <<
"Comp digi: layer " << i_layer+1
934 <<
" digi #" << i_digi+1
935 <<
" strip " << thisStrip
936 <<
" halfstrip " << thisHalfstrip
937 <<
" distrip " << thisStrip/2 +
938 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
939 <<
" time " << bx_times[
i]
940 <<
" comparator " << thisComparator
941 <<
" stagger " << stagger[i_layer];
942 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
946 <<
" Skipping comparator digi: strip = " << thisStrip
947 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
948 <<
", bx of previous hit = " << bx_times[
i-1];
953 <<
"+++ Skipping comparator digi: strip = " << thisStrip
954 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
975 digiNum[
i][j] = -999;
980 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
981 for (
unsigned int j = 0; j < layerDigiV.size(); j++) {
987 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
988 <<
" strip #" << thisDigi.
getStrip()
994 if (thisComparator != 0 && thisComparator != 1) {
996 <<
"+++ Comparator digi with wrong comparator value: digi #" << j
997 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
1002 int thisStrip = thisDigi.
getStrip() - 1;
1003 if (thisStrip < 0 || thisStrip >=
numStrips) {
1005 <<
"+++ Comparator digi with wrong strip number: digi #" << j
1006 <<
", strip = " << thisStrip
1007 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
1016 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
1025 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
1026 digiNum[
i][thisStrip] = j;
1027 time[
i][thisStrip] = thisDigiBx;
1028 comp[
i][thisStrip] = thisComparator;
1030 <<
"Comp digi: layer " <<
i+1
1032 <<
" strip " << thisStrip
1033 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
1034 <<
" distrip " << thisStrip/2 +
1035 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
1036 <<
" time " << time[
i][thisStrip]
1037 <<
" comparator " << comp[
i][thisStrip]
1043 <<
"+++ Skipping comparator digi: strip = " << thisStrip
1044 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1055 if (time[
i][j] >= 0) {
1056 int i_halfstrip = 2*j + comp[
i][j] +
stagger[
i];
1062 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1063 <<
"; skipping this digi... +++\n";
1066 halfstrip[
i][i_halfstrip].push_back(time[
i][j]);
1075 static std::atomic<int> test_iteration{0};
1077 if (time[
i][j] >= 0) {
1078 int i_distrip = j/2;
1079 if (j%2 == 1 && comp[
i][j] == 1 &&
stagger[
i] == 1) {
1081 bool stagger_debug = (
infoV > 2);
1090 if (
infoV > 2 && test_iteration == 1) {
1096 <<
"+++ Found wrong distrip number = " << i_distrip
1097 <<
"; skipping this digi... +++\n";
1100 distrip[
i][i_distrip].push_back(time[
i][j]);
1108 int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1109 int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1110 int i_strip,
bool debug) {
1128 <<
"+++ Found wrong strip number = " << i_strip
1129 <<
"; cannot apply distrip staggering... +++\n";
1135 <<
" Enter distripStagger: i_strip = " << i_strip
1136 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1137 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1138 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1139 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1150 if (stag_time[i_strip+2] >= 0) {
1151 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1152 stag_time[i_strip+2] = stag_time[i_strip];
1153 stag_digi[i_strip+2] = stag_digi[i_strip];
1159 stag_time[i_strip+2] = stag_time[i_strip];
1160 stag_digi[i_strip+2] = stag_digi[i_strip];
1167 stag_time[i_strip] = -999;
1168 stag_triad[i_strip] = 4;
1169 stag_digi[i_strip] = -999;
1173 <<
" Exit distripStagger: i_strip = " << i_strip
1174 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1175 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1176 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1177 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1195 const int adjacent_strips = 2;
1198 int highest_quality = 0;
1203 std::vector <CSCCLCTDigi> lctList;
1206 if (stripType == 1) nStrips = 2*
numStrips + 1;
1207 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1219 final_lcts[j] = -999;
1225 final_lcts[0] = best_strip;
1227 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1229 if (
abs(best_strip - key_strip) > adjacent_strips){
1231 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1232 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1233 final_lcts[1] = key_strip;
1241 int keystrip = final_lcts[j];
1242 if (keystrip >= 0 &&
1243 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1251 int halfstrip_in_cfeb =
1260 keystrip_data[keystrip][
CLCT_BX]);
1265 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1268 <<
"Key Strip: " << std::setw(3)
1270 <<
" Pattern: " << std::setw(2)
1272 <<
" Bend: " << std::setw(1) << bend
1273 <<
" Quality: " << std::setw(1)
1275 <<
" stripType: " << std::setw(1) << stripType
1276 <<
" BX: " << std::setw(1)
1277 << keystrip_data[keystrip][
CLCT_BX];
1279 lctList.push_back(thisLCT);
1290 const int stripType,
const int nStrips,
1297 int i_layer, i_strip, this_layer, this_strip;
1298 int hits, layers_hit;
1301 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1308 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1314 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1319 hit_layer[i_layer] =
false;
1324 if (this_strip >= 0 && this_strip < nStrips) {
1326 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1329 if (hit_layer[this_layer] ==
false) {
1330 hit_layer[this_layer] =
true;
1335 if (layers_hit >= pre_trigger_layer_min) {
1353 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1355 int key_strip, this_layer, this_strip;
1358 int highest_quality = 0;
1361 for (key_strip = 0; key_strip < nStrips; key_strip++)
1363 keystrip_data[key_strip][
i] = 0;
1368 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1375 if ((this_strip >= 0 && this_strip < nStrips) &&
1376 !
strip[this_layer][this_strip].empty()) {
1377 if (nullPattern) nullPattern =
false;
1378 std::vector<int> bx_times =
strip[this_layer][this_strip];
1379 lct_pattern[pattern_strip] = bx_times[0];
1382 lct_pattern[pattern_strip] = -999;
1386 if (nullPattern)
continue;
1400 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1402 <<
"Key_strip " << key_strip <<
" quality of pattern_num " 1403 << pattern_num <<
": " <<
quality;
1404 if (quality > best_quality){
1407 keystrip_data[key_strip][
CLCT_BEND] = bend;
1408 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1409 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1412 if (quality > highest_quality){
1417 best_strip = key_strip;
1439 hit_layer[i_layer] =
false;
1443 if (
hitIsGood(strip_value[strip_num], bx_time)){
1447 if (i_layer ==
pattern[pattern_num][strip_num]){
1449 if (hit_layer[i_layer] ==
false){
1451 hit_layer[i_layer] =
true;
1459 quality = layers_hit;
1467 int dt = BX - hitTime;
1468 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1469 else {
return false;}
1487 std::vector <CSCCLCTDigi> lctList;
1488 int _bx[2] = {999, 999};
1507 bool pre_trig[2] = {
false,
false};
1511 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1512 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1516 if (pre_trig[0] || pre_trig[1]) {
1517 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1519 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1520 <<
"\n ..... waiting drift delay ..... ";
1559 <<
"...............................\n" 1560 <<
"Final halfstrip hits and keys (after drift delay) ...";
1563 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1564 <<
" hits " << h_nhits[icfeb];
1567 <<
"Final distrip hits and keys (after drift delay) ...";
1570 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1571 <<
" hits " << d_nhits[icfeb];
1574 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1577 for (
int ilct = 0; ilct < 2; ilct++) {
1579 <<
"found lcts: ilct " << ilct
1580 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1582 int halfstrip_in_cfeb = 0;
1584 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1587 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1596 keystrip_data[ilct][
CLCT_BX]);
1597 lctList.push_back(thisLCT);
1611 const int stripType,
const int nStrips,
1612 const int start_bx,
int& first_bx) {
1614 <<
"....................PreTrigger...........................";
1616 if (start_bx == 0) {
1621 bool pre_trig =
false;
1623 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1637 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1646 const int stripType,
const int nStrips,
1647 const unsigned int bx_time) {
1652 int key_strip, this_layer, this_strip, layers_hit;
1655 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1657 if (stripType != 0 && stripType != 1) {
1659 <<
"+++ preTrigLookUp: stripType = " << stripType
1660 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1666 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1668 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1671 hit_layer[ilayer] =
false;
1678 if (this_strip >= 0 && this_strip < nStrips) {
1680 if (((
pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1681 if (hit_layer[this_layer] ==
false) {
1682 hit_layer[this_layer] =
true;
1684 if (layers_hit >= pre_trigger_layer_min) {
1686 <<
"pretrigger at bx: " << bx_time
1687 <<
", cfeb " << icfeb <<
", returning";
1706 const int stripType,
const int nStrips,
const int bx_time) {
1709 int key_strip, this_layer, this_strip;
1710 int layers_hit, prev_hits;
1713 keyStrip[icfeb] = -1;
1717 if (stripType != 0 && stripType != 1) {
1719 <<
"+++ latchLCTs: stripType = " << stripType
1720 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1727 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1729 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1732 hit_layer[ilayer] =
false;
1739 if (this_strip >= 0 && this_strip < nStrips) {
1741 if (((
pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1742 if (hit_layer[this_layer] ==
false) {
1743 hit_layer[this_layer] =
true;
1750 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1751 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1752 <<
" n_hits: " << layers_hit;
1757 if (layers_hit > prev_hits) {
1758 prev_hits = layers_hit;
1759 keyStrip[icfeb] = key_strip;
1760 n_hits[icfeb] = layers_hit;
1770 const int d_keyStrip[CSCConstants::MAX_CFEBS],
const unsigned int d_nhits[CSCConstants::MAX_CFEBS],
1787 key_strip[icfeb] = -1;
1788 key_phits[icfeb] = -1;
1789 strip_type[icfeb] = -1;
1794 <<
".....................PriorityEncode.......................";
1795 std::ostringstream strstrm;
1796 strstrm <<
"hkeys:";
1798 strstrm << std::setw(4) << h_keyStrip[icfeb];
1800 strstrm <<
"\ndkeys:";
1802 strstrm << std::setw(4) << d_keyStrip[icfeb];
1804 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1810 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1811 if (h_nhits[icfeb] >= hs_thresh) {
1812 key_strip[icfeb] = h_keyStrip[icfeb];
1813 key_phits[icfeb] = h_nhits[icfeb] + 8;
1814 strip_type[icfeb]= 1;
1820 key_strip[icfeb] = d_keyStrip[icfeb];
1821 key_phits[icfeb] = d_nhits[icfeb];
1822 strip_type[icfeb]= 0;
1825 else if (h_keyStrip[icfeb] != -1) {
1826 if (h_nhits[icfeb] >= hs_thresh) {
1827 key_strip[icfeb] = h_keyStrip[icfeb];
1828 key_phits[icfeb] = h_nhits[icfeb] + 8;
1829 strip_type[icfeb]= 1;
1832 else if (d_keyStrip[icfeb] != -1) {
1834 key_strip[icfeb] = d_keyStrip[icfeb];
1835 key_phits[icfeb] = d_nhits[icfeb];
1836 strip_type[icfeb]= 0;
1839 if (
infoV > 1 && strip_type[icfeb] != -1) {
1840 if (strip_type[icfeb] == 0)
1842 <<
" taking distrip pattern on cfeb " << icfeb;
1843 else if (strip_type[icfeb] == 1)
1845 <<
" taking halfstrip pattern on cfeb " << icfeb;
1847 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1848 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1859 <<
"...... Remove Duplicates ......";
1861 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1862 else key[icfeb] = key_strip[icfeb];
1864 for (
int icfeb = 0; icfeb < CSCConstants::MAX_CFEBS-1; icfeb++) {
1865 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1869 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1870 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1871 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1873 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1874 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1876 <<
" deleting LCT on CFEB " << icfeb;
1877 key_strip[icfeb] = -1;
1878 key_phits[icfeb] = -1;
1882 <<
" deleting LCT on CFEB " << icfeb+1;
1883 key_strip[icfeb+1] = -1;
1884 key_phits[icfeb+1] = -1;
1893 <<
"\n...... Select best LCTs ......";
1895 if (key_phits[icfeb] > ihits[0]) {
1896 ihits[1] = ihits[0];
1897 cfebs[1] = cfebs[0];
1898 ihits[0] = key_phits[icfeb];
1901 std::ostringstream strstrm;
1903 strstrm << std::setw(4) << strip_type[icfeb];
1906 <<
"strip_type" << strstrm.str()
1907 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1908 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1909 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1910 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1913 else if (key_phits[icfeb] > ihits[1]) {
1914 ihits[1] = key_phits[icfeb];
1917 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1918 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1925 if (cfebs[ilct] != -1) {
1926 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1927 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1930 <<
"filling key: " << key_strip[cfebs[ilct]]
1931 <<
" type: " << strip_type[cfebs[ilct]];
1945 int this_layer, this_strip;
1946 unsigned int quality = 0, bend = 0;
1947 unsigned int best_quality, best_pattern;
1948 bool valid[2] = {
false,
false};
1958 <<
"...............getKeyStripData....................";
1960 for (
int ilct = 0; ilct < 2; ilct++) {
1962 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1966 <<
"no lct at ilct " << ilct;
1971 lct_pattern[pattern_strip] = -999;
1980 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1981 lct_pattern[pattern_strip] = 1;
1987 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1988 lct_pattern[pattern_strip] = 1;
1998 for (
unsigned int pattern_num = 0;
2000 getPattern(pattern_num, lct_pattern, quality, bend);
2002 <<
"pattern " << pattern_num <<
" quality " << quality
2003 <<
" bend " << bend;
2010 if ((quality == best_quality && pattern_num > best_pattern) ||
2011 (quality > best_quality)) {
2013 <<
"valid = true at quality " << quality
2018 keystrip_data[ilct][
CLCT_BX] = first_bx;
2022 best_pattern = pattern_num;
2030 <<
"lct " << ilct <<
" not over threshold: deleting";
2034 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n" 2035 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
2036 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
2038 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
2039 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
2049 unsigned int&
quality,
unsigned int& bend) {
2056 unsigned int layers_hit = 0;
2061 hit_layer[i_layer] =
false;
2065 if (strip_value[strip_num] == 1){
2069 if (i_layer ==
pattern[pattern_num][strip_num]){
2071 if (hit_layer[i_layer] ==
false){
2073 hit_layer[i_layer] =
true;
2081 quality = layers_hit;
2094 std::vector<CSCCLCTDigi> lctList;
2097 const int maxHalfStrips = 2*
numStrips + 1;
2113 while (start_bx < stop_bx) {
2117 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2124 <<
"..... pretrigger at bx = " << first_bx
2125 <<
"; waiting drift delay .....";
2129 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2133 hstrip < maxHalfStrips; hstrip++) {
2134 if (
nhits[hstrip] > 0) {
2136 <<
" bx = " << std::setw(2) << latch_bx <<
" --->" 2137 <<
" halfstrip = " << std::setw(3) << hstrip
2138 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2139 <<
" nhits = " <<
nhits[hstrip];
2146 start_bx = first_bx + 1;
2152 best_halfstrip[ilct] = -1;
2153 best_quality[ilct] = 0;
2160 hstrip < maxHalfStrips; hstrip++) {
2163 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2164 if (quality[hstrip] > best_quality[0]) {
2165 best_halfstrip[0] = hstrip;
2166 best_quality[0] = quality[hstrip];
2168 if (
infoV > 1 && quality[hstrip] > 0) {
2170 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2171 <<
" quality = " << std::setw(3) << quality[hstrip]
2172 <<
" nhits = " << std::setw(3) <<
nhits[hstrip]
2173 <<
" pid = " << std::setw(3) <<
best_pid[hstrip]
2174 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2175 <<
" best quality = " << std::setw(3) << best_quality[0];
2181 if (best_halfstrip[0] >= 0) {
2187 hstrip < maxHalfStrips; hstrip++) {
2188 if (quality[hstrip] > best_quality[1]) {
2189 best_halfstrip[1] = hstrip;
2190 best_quality[1] = quality[hstrip];
2192 if (
infoV > 1 && quality[hstrip] > 0) {
2194 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2195 <<
" quality = " << std::setw(3) << quality[hstrip]
2196 <<
" nhits = " << std::setw(3) <<
nhits[hstrip]
2197 <<
" pid = " << std::setw(3) <<
best_pid[hstrip]
2198 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2199 <<
" best quality = " << std::setw(3) << best_quality[1];
2204 bool ptn_trig =
false;
2206 int best_hs = best_halfstrip[ilct];
2215 keystrip_data[ilct][
CLCT_BX] = first_bx;
2220 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2224 <<
" Final selection: ilct " << ilct
2225 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2228 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2236 keystrip_data[ilct][
CLCT_BX]);
2237 lctList.push_back(thisLCT);
2252 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2253 bool return_to_idle =
true;
2254 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2257 hstrip < maxHalfStrips; hstrip++) {
2260 <<
" State machine busy at bx = " << bx;
2261 return_to_idle =
false;
2266 if (return_to_idle) {
2268 <<
" State machine returns to idle state at bx = " << bx;
2277 start_bx = first_bx + 1;
2291 static const unsigned int bits_in_pulse = 8*
sizeof(
pulse[0][0]);
2302 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2303 pulse[i_layer][i_strip] = 0;
2307 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2311 std::vector<int> bx_times =
time[i_layer][i_strip];
2312 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2314 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2316 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2317 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2318 <<
" is not within the range (0-" << bits_in_pulse
2319 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2323 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2324 pulse[i_layer][i_strip] =
pulse[i_layer][i_strip] | (1 << bx);
2336 const int start_bx,
int& first_bx) {
2338 <<
"....................PreTrigger...........................";
2343 int nPreTriggers = 0;
2345 bool pre_trig =
false;
2347 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2356 hstrip < nStrips; hstrip++) {
2358 if (
nhits[hstrip] > 0) {
2360 <<
" bx = " << std::setw(2) << bx_time <<
" --->" 2361 <<
" halfstrip = " << std::setw(3) << hstrip
2362 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2363 <<
" nhits = " <<
nhits[hstrip];
2376 1, bend, hstrip%32, hstrip/32, bx_time, nPreTriggers, 0));
2389 "no pretrigger, returning \n";
2398 const int nStrips,
const unsigned int bx_time)
2405 unsigned int layers_hit = 0;
2408 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2410 if (((
pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2419 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2422 nhits[key_hstrip] = 0;
2435 hit_layer[ilayer] =
false;
2437 double num_pattern_hits=0., times_sum=0.;
2438 std::multiset<int> mset_for_median;
2439 mset_for_median.clear();
2446 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2449 if (this_strip >= 0 && this_strip < nStrips) {
2451 <<
" In ptnFinding: key_strip = " << key_hstrip
2452 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2453 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2455 if (((
pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2457 if (hit_layer[this_layer] ==
false)
2459 hit_layer[this_layer] =
true;
2465 int first_bx_layer = bx_time;
2466 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2468 if (((
pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2473 times_sum += (double) first_bx_layer;
2474 num_pattern_hits += 1.;
2475 mset_for_median.insert(first_bx_layer);
2477 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2478 <<
" #pat. hits: " << num_pattern_hits;
2484 if (layers_hit >
nhits[key_hstrip])
2487 nhits[key_hstrip] = layers_hit;
2490 const int sz = mset_for_median.size();
2492 std::multiset<int>::iterator im = mset_for_median.begin();
2493 if (sz>1) std::advance(im,sz/2-1);
2498 #if defined(EDM_ML_DEBUG) 2501 auto lt =
LogTrace(
"CSCCathodeLCTProcessor")
2503 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++) {
2511 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2521 const int best_patid,
2530 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2531 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
2543 std::vector<CSCCLCTDigi>
2546 std::vector<CSCCLCTDigi> lctList;
2549 const int maxHalfStrips = 2 *
numStrips + 1;
2557 busyMap[
i][j] =
false;
2559 std::vector<CSCCLCTDigi> lctListBX;
2573 while (start_bx < stop_bx)
2579 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2586 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2590 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2597 if (
nhits[hstrip] > 0)
2599 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = " 2600 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2607 start_bx = first_bx + 1;
2617 best_halfstrip[ilct] = -1;
2618 best_quality[ilct] = 0;
2630 pretrig_zone[hstrip] =
false;
2639 if (max_hs > CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1)
2640 max_hs = CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1;
2641 for (
int hs = min_hs; hs <= max_hs; hs++)
2642 pretrig_zone[hs] =
true;
2644 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2651 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2655 if (quality[hstrip] > best_quality[0] &&
2656 pretrig_zone[hstrip] &&
2657 !busyMap[hstrip][first_bx] )
2659 best_halfstrip[0] = hstrip;
2660 best_quality[0] = quality[hstrip];
2663 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = " 2664 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2665 <<
" best quality = " << std::setw(3) << best_quality[0];
2672 if (best_halfstrip[0] >= 0)
2679 if (quality[hstrip] > best_quality[1] &&
2680 pretrig_zone[hstrip] &&
2681 !busyMap[hstrip][first_bx] )
2683 best_halfstrip[1] = hstrip;
2684 best_quality[1] = quality[hstrip];
2687 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = " 2688 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2689 <<
" best quality = " << std::setw(3) << best_quality[1];
2695 bool ptn_trig =
false;
2698 int best_hs = best_halfstrip[ilct];
2712 keystrip_data[ilct][
CLCT_BX] = bx;
2719 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip " 2727 lctList.push_back(thisLCT);
2728 lctListBX.push_back(thisLCT);
2741 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2749 int min_hstrip = key_hstrip - delta_hs;
2750 int max_hstrip = key_hstrip + delta_hs;
2754 if (max_hstrip > maxHalfStrips)
2755 max_hstrip = maxHalfStrips;
2758 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" [" 2759 << min_hstrip <<
"," << max_hstrip <<
"]";
2766 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2768 bool busy_bx =
false;
2769 if (bx <= (
size_t)latch_bx)
2773 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2777 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits=" 2778 <<
nhits[key_hstrip];
2781 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2783 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2784 busyMap[hstrip][bx] =
true;
2794 start_bx = first_bx + 1;
2807 std::ostringstream strm;
2809 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2810 strm <<
"+ CLCT configuration parameters: +\n";
2811 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2812 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = " 2814 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = " 2816 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = " 2818 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = " 2820 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = " 2822 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = " 2825 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = " 2827 strm <<
" min_separation [region of busy key strips] = " 2830 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2831 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2839 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2841 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2843 std::ostringstream strstrm;
2844 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2845 if (i_strip%10 == 0) {
2846 if (i_strip < 100) strstrm << i_strip/10;
2847 else strstrm << (i_strip-100)/10;
2849 else strstrm <<
" ";
2850 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2853 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2854 strstrm << i_strip%10;
2855 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2859 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2861 std::vector<int> bx_times =
strip[i_layer][i_strip];
2863 strstrm << std::hex << bx_times[0] <<
std::dec;
2868 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2871 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2877 std::vector<CSCCLCTDigi> tmpV;
2889 static std::atomic<int> lct_bins;
2891 static std::atomic<int> late_tbins;
2894 static std::atomic<int> ifois{0};
2899 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2904 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2906 <<
"+++ Set late_tbins to max allowed +++\n";
2907 late_tbins = CSCConstants::MAX_CLCT_TBINS-1;
2914 int bx_readout = -1;
2915 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2916 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2917 plct != all_lcts.end(); plct++) {
2918 if (!plct->isValid())
continue;
2920 int bx = (*plct).getBX();
2924 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2925 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is " 2931 if (bx > late_tbins) {
2933 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2934 <<
": found at bx " << bx <<
", whereas the latest allowed bx is " 2943 if (bx_readout == -1 || bx == bx_readout) {
2944 tmpV.push_back(*plct);
2945 if (bx_readout == -1) bx_readout = bx;
2948 else tmpV.push_back(*plct);
2955 std::vector<CSCCLCTDigi> tmpV;
2975 test_triad[distrip] = 3;
2976 test_triad[distrip+1] = 3;
2977 test_triad[distrip+2] = 3;
2978 test_triad[distrip+3] = 3;
2979 test_triad[distrip+4] = 3;
2980 test_triad[distrip+5] = 3;
2981 test_triad[distrip+6] = 3;
2982 test_triad[distrip+7] = 3;
2983 test_triad[distrip+8] = 3;
2984 test_triad[distrip+9] = 3;
2985 test_triad[distrip+10] = 2;
2987 test_time[distrip] = 4;
2988 test_time[distrip+1] = 10;
2989 test_time[distrip+2] = 2;
2990 test_time[distrip+3] = 0;
2991 test_time[distrip+4] = 6;
2992 test_time[distrip+5] = 8;
2993 test_time[distrip+6] = 10;
2994 test_time[distrip+7] = 1;
2995 test_time[distrip+8] = 8;
2996 test_time[distrip+9] = 5;
2997 test_time[distrip+10] = 6;
2999 std::cout <<
"\n ------------------------------------------------- \n";
3000 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
3001 std::cout <<
"Values before distripStagger routine:" << std::endl;
3002 for (
int i=distrip;
i<distrip+11;
i++){
3004 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
3005 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
3007 distripStagger(test_triad, test_time, test_digi, distrip, debug);
3008 std::cout <<
"Values after distripStagger routine:" << std::endl;
3009 for (
int i=distrip;
i<distrip+11;
i++){
3010 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
3011 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
3013 std::cout <<
"\n ------------------------------------------------- \n \n";
3018 for (
int ptn = 0; ptn < 8; ptn++) {
3019 for (
int bend = 0; bend < 2; bend++) {
3022 for (
int bx = 0; bx < 7; bx++) {
3023 for (
int stripType = 0; stripType < 2; stripType++) {
3026 key_strip, cfeb, bx);
3029 <<
"pattern mismatch: " << ptn <<
" " 3031 if (bend != thisLCT.
getBend())
3033 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
3034 if (cfeb != thisLCT.
getCFEB())
3036 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
3039 <<
"strip mismatch: " << key_strip <<
" " 3041 if (bx != thisLCT.
getBX())
3043 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
3046 <<
"Strip Type mismatch: " << stripType <<
" " 3050 <<
"quality mismatch: " <<
quality <<
" " 3063 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3066 std::cout<<
" Pattern "<<patternNum<<
" ";
3076 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3084 minStrip = 3*layer - 2;
3108 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3111 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3112 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3113 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3114 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3115 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3116 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3117 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3118 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3119 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3120 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3121 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3122 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3123 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3124 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3125 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3126 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3135 if (numLayersHit > 3 || !results.empty()) {
3136 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3142 if (!results.empty()) {
3143 int thePatternStrip =
strip - (results[0].getKeyStrip() - 2) + 3*layer;
3146 thePatternStrip -= 2;
3168 minStrip = 3*layer - 2;
3180 if (!stripsHit[layer][10].
empty()) {
3188 if (layer < static_cast<int>(results.size()) ) {
3203 if ((!stripsHit[layer][ 9].
empty()) ||
3204 (!stripsHit[layer][10].
empty()) ||
3205 (!stripsHit[layer][11].
empty()) ) number++;
int getQuality() const
return quality of a pattern (number of layers hit!)
static const unsigned int def_drift_delay
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][CSCConstants::MAX_STRIPS_IN_PATTERN+1]
T getParameter(std::string const &) const
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
void setDefaultConfigParameters()
std::vector< CSCCLCTDigi > readoutCLCTs()
bool use_dead_time_zoning
unsigned int nplanes_hit_pretrig
static const unsigned int def_fifo_tbins
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int i_distrip, bool debug=false)
int getStrip() const
Get the strip number. Counts from 1.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int min_separation
static const int cfeb_strips[2]
unsigned int clctHitPersist() const
const unsigned theTrigChamber
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
void dumpConfigParams() const
const unsigned theStation
static const int pattern2007_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
static const unsigned int def_min_separation
unsigned int clctMinSeparation() const
int getComparator() const
Get Comparator readings. Can be 0 or 1.
unsigned int clctNplanesHitPretrig() const
static const unsigned int def_nplanes_hit_pretrig
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
static int ringFromTriggerLabels(int station, int triggerCSCID)
const CSCGeometry * csc_g
int getStripType() const
return striptype
unsigned int clctDriftDelay() const
int getBend() const
return bend
static const unsigned int def_pid_thresh_pretrig
unsigned int fifo_pretrig
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, const unsigned int bx_time)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int clctPidThreshPretrig() const
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keyStrip[CSCConstants::MAX_CFEBS], unsigned int nhits[CSCConstants::MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips) const
int getCFEB() const
return Key CFEB ID
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
void testDistripStagger()
static const unsigned int def_tmb_l1a_window_size
int getBX() const
return BX
bool getDigis(const CSCComparatorDigiCollection *compdc)
static const unsigned int def_nplanes_hit_pattern
Abs< T >::type abs(const T &t)
unsigned int pretrig_trig_zone
unsigned int clctFifoPretrig() const
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, int &first_bx)
unsigned int clct_state_machine_zone
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
unsigned int nplanes_hit_pattern
void getPattern(int pattern_num, int strip_value[CSCConstants::MAX_STRIPS_IN_PATTERN], int bx_time, int &quality, int &bend)
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
void priorityEncode(const int h_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int h_nhits[CSCConstants::MAX_CFEBS], const int d_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int d_nhits[CSCConstants::MAX_CFEBS], int keystrip_data[2][7])
double pulse(double x, double y, double z, double t)
void checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
static const unsigned int def_hit_persist
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int stripType)
unsigned int alctClctOffset
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCComparatorDigi >::const_iterator const_iterator
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
bool hitIsGood(int hitTime, int BX)
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int tmb_l1a_window_size
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7], int nStrips, int first_bx, int &best_strip, int stripType)
static const int pre_hit_pattern[2][CSCConstants::MAX_STRIPS_IN_PATTERN]
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
unsigned int pid_thresh_pretrig
std::vector< CSCCLCTDigi > getCLCTs()
void setConfigParameters(const CSCDBL1TPParameters *conf)
bool dynamic_state_machine_zone
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.