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");
307 static int fpga_latency = 3;
308 if (early_tbins<0) early_tbins = fifo_pretrig - fpga_latency;
318 if ((infoV > 0 || isSLHC) && !config_dumped) {
321 config_dumped =
true;
327 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
355 theEndcap(1), theStation(1), theSector(1),
356 theSubsector(1), theTrigChamber(1) {
358 static std::atomic<bool> config_dumped{
false};
378 if (!config_dumped) {
381 config_dumped =
true;
387 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
418 static std::atomic<bool> config_dumped{
false};
435 if (!config_dumped) {
438 config_dumped =
true;
446 static const unsigned int max_fifo_tbins = 1 << 5;
447 static const unsigned int max_fifo_pretrig = 1 << 5;
448 static const unsigned int max_hit_persist = 1 << 4;
449 static const unsigned int max_drift_delay = 1 << 2;
450 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
451 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
452 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
454 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
460 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n"
461 <<
"+++ Try to proceed with the default value, fifo_tbins="
468 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n"
469 <<
"+++ Try to proceed with the default value, fifo_pretrig="
476 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n"
477 <<
"+++ Try to proceed with the default value, hit_persist="
484 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n"
485 <<
"+++ Try to proceed with the default value, drift_delay="
492 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n"
493 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig="
500 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n"
501 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern="
510 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n"
511 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig="
518 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n"
519 <<
"+++ Try to proceed with the default value, min_separation="
528 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n"
529 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size="
543 std::vector<CSCCLCTDigi>
551 static std::atomic<bool> config_dumped{
false};
555 config_dumped =
true;
586 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
592 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
615 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
619 <<
" is not defined in current geometry! +++\n"
620 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
627 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
631 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
632 std::vector<CSCCLCTDigi> emptyV;
658 unsigned int layersHit = 0;
662 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
672 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
684 std::vector<CSCCLCTDigi> LCTlist;
693 LCTlist =
findLCTs(halfstrip, distrip);
696 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
697 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
699 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
700 LCTlist.push_back(halfStripLCTs[
i]);
701 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
702 LCTlist.push_back(diStripLCTs[i]);
706 if (LCTlist.size() > 1)
707 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
710 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
711 plct != LCTlist.end(); plct++) {
712 int bx = plct->getBX();
715 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, "
758 digiV[i_layer].clear();
781 <<
"found " <<
digiV[i_layer].size()
782 <<
" comparator digi(s) in layer " << i_layer <<
" of ME"
797 bool me1b = (
id.station() == 1) && (
id.
ring() == 1);
798 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
801 digiIt != rcompd.second; ++digiIt) {
802 unsigned int origStrip = digiIt->getStrip();
803 unsigned int maxStripsME1a =
gangedME1a ? 16 : 48;
808 digiIt->getComparator(),
809 digiIt->getTimeBinWord());
810 digiV[
id.layer()-1].push_back(digi_corr);
815 if (me1aProc && me1b && origStrip > 64){
818 digiIt->getComparator(),
819 digiIt->getTimeBinWord());
820 digiV[
id.layer()-1].push_back(digi_corr);
821 }
else if ((me1bProc && me1b && origStrip <= 64)
822 || ((me1aProc && me1a))
824 digiV[
id.layer()-1].push_back(*digiIt);
828 digiV[
id.layer()-1].push_back(*digiIt);
841 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
842 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
845 std::ostringstream strstrm;
846 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
847 <<
" strip #" << pld->getStrip()
849 std::vector<int> bx_times = pld->getTimeBinsOn();
850 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
851 strstrm <<
" " << bx_times[tbin];
852 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
857 int thisComparator = pld->getComparator();
858 if (thisComparator != 0 && thisComparator != 1) {
860 <<
"+++ Found comparator digi with wrong comparator value = "
861 << thisComparator <<
"; skipping it... +++\n";
866 int thisStrip = pld->getStrip() - 1;
867 if (thisStrip < 0 || thisStrip >=
numStrips) {
869 <<
"+++ Found comparator digi with wrong strip number = "
871 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
877 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
880 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
881 <<
"; skipping this digi... +++\n";
886 std::vector<int> bx_times = pld->getTimeBinsOn();
887 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
895 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
897 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
903 <<
"Comp digi: layer " << i_layer+1
904 <<
" digi #" << i_digi+1
905 <<
" strip " << thisStrip
906 <<
" halfstrip " << thisHalfstrip
907 <<
" distrip " << thisStrip/2 +
908 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
909 <<
" time " << bx_times[
i]
910 <<
" comparator " << thisComparator
911 <<
" stagger " << stagger[i_layer];
912 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
916 <<
" Skipping comparator digi: strip = " << thisStrip
917 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
918 <<
", bx of previous hit = " << bx_times[
i-1];
923 <<
"+++ Skipping comparator digi: strip = " << thisStrip
924 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
945 digiNum[
i][
j] = -999;
950 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
951 for (
unsigned int j = 0;
j < layerDigiV.size();
j++) {
957 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
958 <<
" strip #" << thisDigi.
getStrip()
964 if (thisComparator != 0 && thisComparator != 1) {
966 <<
"+++ Comparator digi with wrong comparator value: digi #" <<
j
967 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
972 int thisStrip = thisDigi.
getStrip() - 1;
973 if (thisStrip < 0 || thisStrip >=
numStrips) {
975 <<
"+++ Comparator digi with wrong strip number: digi #" <<
j
976 <<
", strip = " << thisStrip
977 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
986 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
995 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
996 digiNum[
i][thisStrip] =
j;
997 time[
i][thisStrip] = thisDigiBx;
998 comp[
i][thisStrip] = thisComparator;
1000 <<
"Comp digi: layer " <<
i+1
1002 <<
" strip " << thisStrip
1003 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
1004 <<
" distrip " << thisStrip/2 +
1005 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
1006 <<
" time " << time[
i][thisStrip]
1007 <<
" comparator " << comp[
i][thisStrip]
1013 <<
"+++ Skipping comparator digi: strip = " << thisStrip
1014 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1025 if (time[
i][
j] >= 0) {
1032 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1033 <<
"; skipping this digi... +++\n";
1036 halfstrip[
i][i_halfstrip].push_back(time[
i][
j]);
1045 static std::atomic<int> test_iteration{0};
1047 if (time[
i][
j] >= 0) {
1048 int i_distrip =
j/2;
1049 if (
j%2 == 1 && comp[
i][
j] == 1 &&
stagger[
i] == 1) {
1051 bool stagger_debug = (
infoV > 2);
1060 if (
infoV > 2 && test_iteration == 1) {
1066 <<
"+++ Found wrong distrip number = " << i_distrip
1067 <<
"; skipping this digi... +++\n";
1070 distrip[
i][i_distrip].push_back(time[
i][
j]);
1078 int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1079 int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1080 int i_strip,
bool debug) {
1098 <<
"+++ Found wrong strip number = " << i_strip
1099 <<
"; cannot apply distrip staggering... +++\n";
1105 <<
" Enter distripStagger: i_strip = " << i_strip
1106 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1107 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1108 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1109 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1120 if (stag_time[i_strip+2] >= 0) {
1121 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1122 stag_time[i_strip+2] = stag_time[i_strip];
1123 stag_digi[i_strip+2] = stag_digi[i_strip];
1129 stag_time[i_strip+2] = stag_time[i_strip];
1130 stag_digi[i_strip+2] = stag_digi[i_strip];
1137 stag_time[i_strip] = -999;
1138 stag_triad[i_strip] = 4;
1139 stag_digi[i_strip] = -999;
1143 <<
" Exit distripStagger: i_strip = " << i_strip
1144 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1145 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1146 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1147 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1165 const int max_lct_num = 2;
1166 const int adjacent_strips = 2;
1169 int highest_quality = 0;
1172 int final_lcts[max_lct_num];
1174 std::vector <CSCCLCTDigi> lctList;
1177 if (stripType == 1) nStrips = 2*
numStrips + 1;
1178 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1185 if (
preTrigger(strip, stripType, nStrips, first_bx)){
1186 getKeyStripData(strip, keystrip_data, nStrips, first_bx, best_strip, stripType);
1189 for (j = 0; j < max_lct_num; j++)
1190 final_lcts[j] = -999;
1196 final_lcts[0] = best_strip;
1198 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1200 if (
abs(best_strip - key_strip) > adjacent_strips){
1202 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1203 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1204 final_lcts[1] = key_strip;
1209 for (j = 0; j < max_lct_num; j++){
1212 int keystrip = final_lcts[
j];
1213 if (keystrip >= 0 &&
1214 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1221 keystrip_data[keystrip][
CLCT_CFEB] = theHalfStrip/32;
1222 int halfstrip_in_cfeb =
1223 theHalfStrip - 32*keystrip_data[keystrip][
CLCT_CFEB];
1231 keystrip_data[keystrip][
CLCT_BX]);
1236 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1239 <<
"Key Strip: " << std::setw(3)
1241 <<
" Pattern: " << std::setw(2)
1243 <<
" Bend: " << std::setw(1) << bend
1244 <<
" Quality: " << std::setw(1)
1246 <<
" stripType: " << std::setw(1) << stripType
1247 <<
" BX: " << std::setw(1)
1248 << keystrip_data[keystrip][
CLCT_BX];
1250 lctList.push_back(thisLCT);
1261 const int stripType,
const int nStrips,
1268 int i_layer, i_strip, this_layer, this_strip;
1269 int hits, layers_hit;
1272 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1279 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1285 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1290 hit_layer[i_layer] =
false;
1295 if (this_strip >= 0 && this_strip < nStrips) {
1297 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1300 if (hit_layer[this_layer] ==
false) {
1301 hit_layer[this_layer] =
true;
1306 if (layers_hit >= pre_trigger_layer_min) {
1323 int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7],
1324 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1326 int key_strip, this_layer, this_strip;
1329 int highest_quality = 0;
1332 for (key_strip = 0; key_strip < nStrips; key_strip++)
1333 for (
int i = 0;
i < 7;
i++)
1334 keystrip_data[key_strip][
i] = 0;
1339 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1346 if ((this_strip >= 0 && this_strip < nStrips) &&
1347 !strip[this_layer][this_strip].empty()) {
1348 if (nullPattern) nullPattern =
false;
1349 std::vector<int> bx_times = strip[this_layer][this_strip];
1350 lct_pattern[pattern_strip] = bx_times[0];
1353 lct_pattern[pattern_strip] = -999;
1357 if (nullPattern)
continue;
1371 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1373 <<
"Key_strip " << key_strip <<
" quality of pattern_num "
1374 << pattern_num <<
": " <<
quality;
1375 if (quality > best_quality){
1378 keystrip_data[key_strip][
CLCT_BEND] = bend;
1379 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1380 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1383 if (quality > highest_quality){
1388 best_strip = key_strip;
1400 int strip_value[NUM_PATTERN_STRIPS],
int bx_time,
1410 hit_layer[i_layer] =
false;
1414 if (
hitIsGood(strip_value[strip_num], bx_time)){
1418 if (i_layer ==
pattern[pattern_num][strip_num]){
1420 if (hit_layer[i_layer] ==
false){
1422 hit_layer[i_layer] =
true;
1430 quality = layers_hit;
1438 int dt = BX - hitTime;
1439 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1440 else {
return false;}
1458 std::vector <CSCCLCTDigi> lctList;
1459 int _bx[2] = {999, 999};
1475 int keystrip_data[2][7];
1478 bool pre_trig[2] = {
false,
false};
1482 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1483 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1487 if (pre_trig[0] || pre_trig[1]) {
1488 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1490 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1491 <<
"\n ..... waiting drift delay ..... ";
1530 <<
"...............................\n"
1531 <<
"Final halfstrip hits and keys (after drift delay) ...";
1532 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1534 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1535 <<
" hits " << h_nhits[icfeb];
1538 <<
"Final distrip hits and keys (after drift delay) ...";
1539 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1541 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1542 <<
" hits " << d_nhits[icfeb];
1545 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1548 for (
int ilct = 0; ilct < 2; ilct++) {
1550 <<
"found lcts: ilct " << ilct
1551 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1553 int halfstrip_in_cfeb = 0;
1555 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1558 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1567 keystrip_data[ilct][
CLCT_BX]);
1568 lctList.push_back(thisLCT);
1582 const int stripType,
const int nStrips,
1583 const int start_bx,
int& first_bx) {
1585 <<
"....................PreTrigger...........................";
1587 if (start_bx == 0) {
1592 bool pre_trig =
false;
1594 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1600 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1608 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1617 const int stripType,
const int nStrips,
1618 const unsigned int bx_time) {
1623 int key_strip, this_layer, this_strip, layers_hit;
1626 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1628 if (stripType != 0 && stripType != 1) {
1630 <<
"+++ preTrigLookUp: stripType = " << stripType
1631 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1635 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1637 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1639 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1642 hit_layer[ilayer] =
false;
1649 if (this_strip >= 0 && this_strip < nStrips) {
1651 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1652 if (hit_layer[this_layer] ==
false) {
1653 hit_layer[this_layer] =
true;
1655 if (layers_hit >= pre_trigger_layer_min) {
1657 <<
"pretrigger at bx: " << bx_time
1658 <<
", cfeb " << icfeb <<
", returning";
1676 int keyStrip[MAX_CFEBS],
unsigned int n_hits[MAX_CFEBS],
1677 const int stripType,
const int nStrips,
const int bx_time) {
1680 int key_strip, this_layer, this_strip;
1681 int layers_hit, prev_hits;
1683 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1684 keyStrip[icfeb] = -1;
1688 if (stripType != 0 && stripType != 1) {
1690 <<
"+++ latchLCTs: stripType = " << stripType
1691 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1695 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1698 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1700 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1703 hit_layer[ilayer] =
false;
1710 if (this_strip >= 0 && this_strip < nStrips) {
1712 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1713 if (hit_layer[this_layer] ==
false) {
1714 hit_layer[this_layer] =
true;
1721 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1722 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1723 <<
" n_hits: " << layers_hit;
1728 if (layers_hit > prev_hits) {
1729 prev_hits = layers_hit;
1730 keyStrip[icfeb] = key_strip;
1731 n_hits[icfeb] = layers_hit;
1740 const int h_keyStrip[MAX_CFEBS],
const unsigned int h_nhits[MAX_CFEBS],
1741 const int d_keyStrip[MAX_CFEBS],
const unsigned int d_nhits[MAX_CFEBS],
1742 int keystrip_data[2][7]) {
1748 const int nlcts = 2;
1752 for (
int ilct = 0; ilct < nlcts; ilct++) {
1753 for (
int j = 0;
j < 7;
j++) keystrip_data[ilct][
j] = -1;
1757 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1758 key_strip[icfeb] = -1;
1759 key_phits[icfeb] = -1;
1760 strip_type[icfeb] = -1;
1765 <<
".....................PriorityEncode.......................";
1766 std::ostringstream strstrm;
1767 strstrm <<
"hkeys:";
1768 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1769 strstrm << std::setw(4) << h_keyStrip[icfeb];
1771 strstrm <<
"\ndkeys:";
1772 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1773 strstrm << std::setw(4) << d_keyStrip[icfeb];
1775 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1780 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1781 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1782 if (h_nhits[icfeb] >= hs_thresh) {
1783 key_strip[icfeb] = h_keyStrip[icfeb];
1784 key_phits[icfeb] = h_nhits[icfeb] + 8;
1785 strip_type[icfeb]= 1;
1791 key_strip[icfeb] = d_keyStrip[icfeb];
1792 key_phits[icfeb] = d_nhits[icfeb];
1793 strip_type[icfeb]= 0;
1796 else if (h_keyStrip[icfeb] != -1) {
1797 if (h_nhits[icfeb] >= hs_thresh) {
1798 key_strip[icfeb] = h_keyStrip[icfeb];
1799 key_phits[icfeb] = h_nhits[icfeb] + 8;
1800 strip_type[icfeb]= 1;
1803 else if (d_keyStrip[icfeb] != -1) {
1805 key_strip[icfeb] = d_keyStrip[icfeb];
1806 key_phits[icfeb] = d_nhits[icfeb];
1807 strip_type[icfeb]= 0;
1810 if (
infoV > 1 && strip_type[icfeb] != -1) {
1811 if (strip_type[icfeb] == 0)
1813 <<
" taking distrip pattern on cfeb " << icfeb;
1814 else if (strip_type[icfeb] == 1)
1816 <<
" taking halfstrip pattern on cfeb " << icfeb;
1818 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1819 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1830 <<
"...... Remove Duplicates ......";
1831 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1832 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1833 else key[icfeb] = key_strip[icfeb];
1835 for (
int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1836 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1840 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1841 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1842 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1844 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1845 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1847 <<
" deleting LCT on CFEB " << icfeb;
1848 key_strip[icfeb] = -1;
1849 key_phits[icfeb] = -1;
1853 <<
" deleting LCT on CFEB " << icfeb+1;
1854 key_strip[icfeb+1] = -1;
1855 key_phits[icfeb+1] = -1;
1864 <<
"\n...... Select best LCTs ......";
1865 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1866 if (key_phits[icfeb] > ihits[0]) {
1867 ihits[1] = ihits[0];
1868 cfebs[1] = cfebs[0];
1869 ihits[0] = key_phits[icfeb];
1872 std::ostringstream strstrm;
1873 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1874 strstrm << std::setw(4) << strip_type[icfeb];
1877 <<
"strip_type" << strstrm.str()
1878 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1879 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1880 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1881 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1884 else if (key_phits[icfeb] > ihits[1]) {
1885 ihits[1] = key_phits[icfeb];
1888 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1889 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1895 for (
int ilct = 0; ilct < nlcts; ilct++) {
1896 if (cfebs[ilct] != -1) {
1897 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1898 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1901 <<
"filling key: " << key_strip[cfebs[ilct]]
1902 <<
" type: " << strip_type[cfebs[ilct]];
1913 int keystrip_data[2][7],
const int first_bx) {
1916 int this_layer, this_strip;
1917 unsigned int quality = 0, bend = 0;
1918 unsigned int best_quality, best_pattern;
1919 bool valid[2] = {
false,
false};
1929 <<
"...............getKeyStripData....................";
1931 for (
int ilct = 0; ilct < 2; ilct++) {
1933 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1937 <<
"no lct at ilct " << ilct;
1942 lct_pattern[pattern_strip] = -999;
1951 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1952 lct_pattern[pattern_strip] = 1;
1958 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1959 lct_pattern[pattern_strip] = 1;
1969 for (
unsigned int pattern_num = 0;
1971 getPattern(pattern_num, lct_pattern, quality, bend);
1973 <<
"pattern " << pattern_num <<
" quality " << quality
1974 <<
" bend " << bend;
1981 if ((quality == best_quality && pattern_num > best_pattern) ||
1982 (quality > best_quality)) {
1984 <<
"valid = true at quality " << quality
1989 keystrip_data[ilct][
CLCT_BX] = first_bx;
1993 best_pattern = pattern_num;
2001 <<
"lct " << ilct <<
" not over threshold: deleting";
2005 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n"
2006 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
2007 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
2009 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
2010 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
2019 const int strip_value[NUM_PATTERN_STRIPS],
2020 unsigned int&
quality,
unsigned int& bend) {
2027 unsigned int layers_hit = 0;
2032 hit_layer[i_layer] =
false;
2036 if (strip_value[strip_num] == 1){
2040 if (i_layer ==
pattern[pattern_num][strip_num]){
2042 if (hit_layer[i_layer] ==
false){
2044 hit_layer[i_layer] =
true;
2052 quality = layers_hit;
2065 std::vector<CSCCLCTDigi> lctList;
2068 const int maxHalfStrips = 2*
numStrips + 1;
2073 enum {max_lcts = 2};
2075 int keystrip_data[max_lcts][7] = {{0}};
2086 while (start_bx < stop_bx) {
2090 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2097 <<
"..... pretrigger at bx = " << first_bx
2098 <<
"; waiting drift delay .....";
2102 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2106 hstrip < maxHalfStrips; hstrip++) {
2107 if (
nhits[hstrip] > 0) {
2109 <<
" bx = " << std::setw(2) << latch_bx <<
" --->"
2110 <<
" halfstrip = " << std::setw(3) << hstrip
2111 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2112 <<
" nhits = " <<
nhits[hstrip];
2119 start_bx = first_bx + 1;
2123 int best_halfstrip[max_lcts], best_quality[max_lcts];
2124 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2125 best_halfstrip[ilct] = -1;
2126 best_quality[ilct] = 0;
2133 hstrip < maxHalfStrips; hstrip++) {
2136 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2137 if (quality[hstrip] > best_quality[0]) {
2138 best_halfstrip[0] = hstrip;
2139 best_quality[0] = quality[hstrip];
2141 if (
infoV > 1 && quality[hstrip] > 0) {
2143 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2144 <<
" quality = " << std::setw(3) << quality[hstrip]
2145 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2146 <<
" best quality = " << std::setw(3) << best_quality[0];
2152 if (best_halfstrip[0] >= 0) {
2158 hstrip < maxHalfStrips; hstrip++) {
2159 if (quality[hstrip] > best_quality[1]) {
2160 best_halfstrip[1] = hstrip;
2161 best_quality[1] = quality[hstrip];
2163 if (
infoV > 1 && quality[hstrip] > 0) {
2165 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2166 <<
" quality = " << std::setw(3) << quality[hstrip]
2167 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2168 <<
" best quality = " << std::setw(3) << best_quality[1];
2173 bool ptn_trig =
false;
2174 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2175 int best_hs = best_halfstrip[ilct];
2184 keystrip_data[ilct][
CLCT_BX] = first_bx;
2189 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2193 <<
" Final selection: ilct " << ilct
2194 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2197 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2205 keystrip_data[ilct][
CLCT_BX]);
2206 lctList.push_back(thisLCT);
2221 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2222 bool return_to_idle =
true;
2223 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2226 hstrip < maxHalfStrips; hstrip++) {
2229 <<
" State machine busy at bx = " << bx;
2230 return_to_idle =
false;
2235 if (return_to_idle) {
2237 <<
" State machine returns to idle state at bx = " << bx;
2246 start_bx = first_bx + 1;
2260 static const unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2271 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2272 pulse[i_layer][i_strip] = 0;
2276 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2279 if (time[i_layer][i_strip].
size() > 0) {
2280 std::vector<int> bx_times = time[i_layer][i_strip];
2281 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2283 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2285 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2286 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2287 <<
" is not within the range (0-" << bits_in_pulse
2288 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2292 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2293 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2305 const int start_bx,
int& first_bx) {
2307 <<
"....................PreTrigger...........................";
2312 bool pre_trig =
false;
2314 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2320 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2323 hstrip < nStrips; hstrip++) {
2325 if (
nhits[hstrip] > 0) {
2327 <<
" bx = " << std::setw(2) << bx_time <<
" --->"
2328 <<
" halfstrip = " << std::setw(3) << hstrip
2329 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2330 <<
" nhits = " <<
nhits[hstrip];
2349 "no pretrigger, returning \n";
2358 const int nStrips,
const unsigned int bx_time)
2365 unsigned int layers_hit = 0;
2368 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2370 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2379 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2382 nhits[key_hstrip] = 0;
2395 hit_layer[ilayer] =
false;
2397 double num_pattern_hits=0., times_sum=0.;
2398 std::multiset<int> mset_for_median;
2399 mset_for_median.clear();
2406 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2409 if (this_strip >= 0 && this_strip < nStrips) {
2411 <<
" In ptnFinding: key_strip = " << key_hstrip
2412 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2413 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2415 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2417 if (hit_layer[this_layer] ==
false)
2419 hit_layer[this_layer] =
true;
2425 int first_bx_layer = bx_time;
2426 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2428 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2433 times_sum += (double) first_bx_layer;
2434 num_pattern_hits += 1.;
2435 mset_for_median.insert(first_bx_layer);
2437 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2438 <<
" #pat. hits: " << num_pattern_hits;
2444 if (layers_hit >
nhits[key_hstrip])
2447 nhits[key_hstrip] = layers_hit;
2450 const int sz = mset_for_median.size();
2452 std::multiset<int>::iterator im = mset_for_median.begin();
2453 if (sz>1) std::advance(im,sz/2-1);
2460 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2461 sprintf(bxs,
"%s %d", bxs, *im);
2469 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2479 const int best_patid,
2488 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2489 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
2501 std::vector<CSCCLCTDigi>
2504 std::vector<CSCCLCTDigi> lctList;
2507 const int maxHalfStrips = 2 *
numStrips + 1;
2511 enum { max_lcts = 2 };
2517 busyMap[
i][
j] =
false;
2519 std::vector<CSCCLCTDigi> lctListBX;
2533 while (start_bx < stop_bx)
2539 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2546 LogTrace(
"CSCCathodeLCTProcessor") <<
"..... pretrigger at bx = " << first_bx <<
"; waiting drift delay .....";
2550 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2557 if (
nhits[hstrip] > 0)
2559 LogTrace(
"CSCCathodeLCTProcessor") <<
" bx = " << std::setw(2) << latch_bx <<
" --->" <<
" halfstrip = "
2560 << std::setw(3) << hstrip <<
" best pid = " << std::setw(2) <<
best_pid[hstrip] <<
" nhits = " <<
nhits[hstrip];
2567 start_bx = first_bx + 1;
2570 int keystrip_data[max_lcts][7] = {{0}};
2574 int best_halfstrip[max_lcts], best_quality[max_lcts];
2575 for (
int ilct = 0; ilct < max_lcts; ilct++)
2577 best_halfstrip[ilct] = -1;
2578 best_quality[ilct] = 0;
2590 pretrig_zone[hstrip] = 0;
2599 if (max_hs > CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1)
2600 max_hs = CSCConstants::NUM_HALF_STRIPS_7CFEBS - 1;
2601 for (
int hs = min_hs; hs <= max_hs; hs++)
2602 pretrig_zone[hs] = 1;
2604 LogTrace(
"CSCCathodeLCTProcessor") <<
" marked pretrigger halfstrip zone [" << min_hs <<
"," << max_hs <<
"]";
2611 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2615 if (quality[hstrip] > best_quality[0] &&
2616 pretrig_zone[hstrip] &&
2617 !busyMap[hstrip][first_bx] )
2619 best_halfstrip[0] = hstrip;
2620 best_quality[0] = quality[hstrip];
2623 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2624 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2625 <<
" best quality = " << std::setw(3) << best_quality[0];
2632 if (best_halfstrip[0] >= 0)
2639 if (quality[hstrip] > best_quality[1] &&
2640 pretrig_zone[hstrip] &&
2641 !busyMap[hstrip][first_bx] )
2643 best_halfstrip[1] = hstrip;
2644 best_quality[1] = quality[hstrip];
2647 LogTrace(
"CSCCathodeLCTProcessor") <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip <<
" quality = "
2648 << std::setw(3) << quality[hstrip] <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2649 <<
" best quality = " << std::setw(3) << best_quality[1];
2655 bool ptn_trig =
false;
2656 for (
int ilct = 0; ilct < max_lcts; ilct++)
2658 int best_hs = best_halfstrip[ilct];
2672 keystrip_data[ilct][
CLCT_BX] = bx;
2679 LogTrace(
"CSCCathodeLCTProcessor") <<
" Final selection: ilct " << ilct <<
" key halfstrip "
2687 lctList.push_back(thisLCT);
2688 lctListBX.push_back(thisLCT);
2701 for (
unsigned int ilct = 0; ilct < lctListBX.size(); ilct++)
2709 int min_hstrip = key_hstrip - delta_hs;
2710 int max_hstrip = key_hstrip + delta_hs;
2714 if (max_hstrip > maxHalfStrips)
2715 max_hstrip = maxHalfStrips;
2718 LogTrace(
"CSCCathodeLCTProcessor") <<
" marking post-trigger zone after bx=" << lctListBX[ilct].getBX() <<
" ["
2719 << min_hstrip <<
"," << max_hstrip <<
"]";
2726 for (
size_t bx = first_bx + 1; bx <
fifo_tbins; bx++)
2728 bool busy_bx =
false;
2729 if (bx <= (
size_t)latch_bx)
2733 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2737 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" hits_in_time=" << hits_in_time <<
" nhits="
2738 <<
nhits[key_hstrip];
2741 LogTrace(
"CSCCathodeLCTProcessor") <<
" at bx=" << bx <<
" busy=" << busy_bx;
2743 for (
int hstrip = min_hstrip; hstrip <= max_hstrip; hstrip++)
2744 busyMap[hstrip][bx] =
true;
2754 start_bx = first_bx + 1;
2767 std::ostringstream strm;
2769 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2770 strm <<
"+ CLCT configuration parameters: +\n";
2771 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2772 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = "
2774 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2776 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = "
2778 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = "
2780 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2782 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = "
2785 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = "
2787 strm <<
" min_separation [region of busy key strips] = "
2790 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2791 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2799 <<
"ME" << ((
theEndcap == 1) ?
"+" :
"-")
2801 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2803 std::ostringstream strstrm;
2804 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2805 if (i_strip%10 == 0) {
2806 if (i_strip < 100) strstrm << i_strip/10;
2807 else strstrm << (i_strip-100)/10;
2809 else strstrm <<
" ";
2810 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2813 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2814 strstrm << i_strip%10;
2815 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2819 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2820 if (!strip[i_layer][i_strip].
empty()) {
2821 std::vector<int> bx_times = strip[i_layer][i_strip];
2823 strstrm << std::hex << bx_times[0] <<
std::dec;
2828 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2831 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2837 std::vector<CSCCLCTDigi> tmpV;
2852 static std::atomic<int> lct_bins;
2854 static std::atomic<int> late_tbins;
2857 static std::atomic<int> ifois{0};
2862 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2867 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2869 <<
"+++ Set late_tbins to max allowed +++\n";
2870 late_tbins = MAX_CLCT_BINS-1;
2877 int bx_readout = -1;
2878 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2879 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2880 plct != all_lcts.end(); plct++) {
2881 if (!plct->isValid())
continue;
2883 int bx = (*plct).getBX();
2887 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2888 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
2894 if (bx > late_tbins) {
2896 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2897 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
2906 if (bx_readout == -1 || bx == bx_readout) {
2907 tmpV.push_back(*plct);
2908 if (bx_readout == -1) bx_readout = bx;
2911 else tmpV.push_back(*plct);
2918 std::vector<CSCCLCTDigi> tmpV;
2938 test_triad[distrip] = 3;
2939 test_triad[distrip+1] = 3;
2940 test_triad[distrip+2] = 3;
2941 test_triad[distrip+3] = 3;
2942 test_triad[distrip+4] = 3;
2943 test_triad[distrip+5] = 3;
2944 test_triad[distrip+6] = 3;
2945 test_triad[distrip+7] = 3;
2946 test_triad[distrip+8] = 3;
2947 test_triad[distrip+9] = 3;
2948 test_triad[distrip+10] = 2;
2950 test_time[distrip] = 4;
2951 test_time[distrip+1] = 10;
2952 test_time[distrip+2] = 2;
2953 test_time[distrip+3] = 0;
2954 test_time[distrip+4] = 6;
2955 test_time[distrip+5] = 8;
2956 test_time[distrip+6] = 10;
2957 test_time[distrip+7] = 1;
2958 test_time[distrip+8] = 8;
2959 test_time[distrip+9] = 5;
2960 test_time[distrip+10] = 6;
2962 std::cout <<
"\n ------------------------------------------------- \n";
2963 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2964 std::cout <<
"Values before distripStagger routine:" << std::endl;
2965 for (
int i=distrip;
i<distrip+11;
i++){
2967 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2968 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2970 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2971 std::cout <<
"Values after distripStagger routine:" << std::endl;
2972 for (
int i=distrip;
i<distrip+11;
i++){
2973 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2974 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2976 std::cout <<
"\n ------------------------------------------------- \n \n";
2981 for (
int ptn = 0; ptn < 8; ptn++) {
2982 for (
int bend = 0; bend < 2; bend++) {
2983 for (
int cfeb = 0; cfeb <
MAX_CFEBS; cfeb++) {
2984 for (
int key_strip = 0; key_strip < 32; key_strip++) {
2985 for (
int bx = 0; bx < 7; bx++) {
2986 for (
int stripType = 0; stripType < 2; stripType++) {
2989 key_strip, cfeb, bx);
2992 <<
"pattern mismatch: " << ptn <<
" "
2994 if (bend != thisLCT.
getBend())
2996 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
2997 if (cfeb != thisLCT.
getCFEB())
2999 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
3002 <<
"strip mismatch: " << key_strip <<
" "
3004 if (bx != thisLCT.
getBX())
3006 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
3009 <<
"Strip Type mismatch: " << stripType <<
" "
3013 <<
"quality mismatch: " <<
quality <<
" "
3026 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3029 std::cout<<
" Pattern "<<patternNum<<
" ";
3039 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3047 minStrip = 3*layer - 2;
3049 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3050 if (layer ==
pattern[patternNum][strip]) {
3071 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3074 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3075 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3076 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3077 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3078 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3079 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3080 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3081 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3082 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3083 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3084 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3085 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3086 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3087 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3088 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3089 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3098 if (numLayersHit > 3 || results.size() > 0) {
3099 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3103 for (
int strip = 9; strip < 12; strip++) {
3104 if (!stripsHit[layer][strip].
empty()) {
3105 if (results.size() > 0) {
3106 int thePatternStrip = strip - (results[0].getKeyStrip() - 2) + 3*layer;
3109 thePatternStrip -= 2;
3131 minStrip = 3*layer - 2;
3133 for (
int strip = minStrip; strip < minStrip + 3; strip++) {
3143 if (!stripsHit[layer][10].
empty()) {
3151 if (layer < static_cast<int>(results.size()) ) {
3166 if ((!stripsHit[layer][ 9].
empty()) ||
3167 (!stripsHit[layer][10].
empty()) ||
3168 (!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
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.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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.