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}
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},
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},
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},
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},
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},
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},
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},
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},
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},
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},
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}
242 theEndcap(endcap), theStation(station), theSector(sector),
243 theSubsector(subsector), theTrigChamber(chamber) {
244 static bool config_dumped =
false;
251 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
253 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
266 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
276 if (
infoV > 0 && !config_dumped) {
278 config_dumped =
true;
284 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
304 theEndcap(1), theStation(1), theSector(1),
305 theSubsector(1), theTrigChamber(1) {
307 static bool config_dumped =
false;
317 if (!config_dumped) {
319 config_dumped =
true;
325 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
351 static bool config_dumped =
false;
368 if (!config_dumped) {
370 config_dumped =
true;
378 static const unsigned int max_fifo_tbins = 1 << 5;
379 static const unsigned int max_fifo_pretrig = 1 << 5;
380 static const unsigned int max_hit_persist = 1 << 4;
381 static const unsigned int max_drift_delay = 1 << 2;
382 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
383 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
384 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
391 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n"
392 <<
"+++ Try to proceed with the default value, fifo_tbins="
399 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n"
400 <<
"+++ Try to proceed with the default value, fifo_pretrig="
407 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n"
408 <<
"+++ Try to proceed with the default value, hit_persist="
415 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n"
416 <<
"+++ Try to proceed with the default value, drift_delay="
423 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n"
424 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig="
431 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n"
432 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern="
441 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n"
442 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig="
449 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n"
450 <<
"+++ Try to proceed with the default value, min_separation="
465 std::vector<CSCCLCTDigi>
495 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
505 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
535 <<
" is not defined in current geometry! +++\n"
536 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
550 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
551 std::vector<CSCCLCTDigi> emptyV;
577 unsigned int layersHit = 0;
581 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
588 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
600 std::vector<CSCCLCTDigi> LCTlist;
606 LCTlist =
findLCTs(halfstrip, distrip);
609 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
610 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
612 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
613 LCTlist.push_back(halfStripLCTs[
i]);
614 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
615 LCTlist.push_back(diStripLCTs[i]);
619 if (LCTlist.size() > 1)
620 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
623 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
624 plct != LCTlist.end(); plct++) {
625 int bx = plct->getBX();
628 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, "
683 digiV[i_layer].clear();
698 <<
"found " <<
digiV[i_layer].size()
699 <<
" comparator digi(s) in layer " << i_layer <<
" of ME"
701 <<
"/" << theChamber <<
" (trig. sector " <<
theSector
712 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
715 digiIt != rcompd.second; ++digiIt) {
716 if (me1a && digiIt->getStrip() <= 16) {
720 digiIt->getComparator(),
721 digiIt->getTimeBinWord());
722 digiV[
id.layer()-1].push_back(digi_corr);
725 digiV[
id.layer()-1].push_back(*digiIt);
738 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
739 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
742 std::ostringstream strstrm;
743 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
744 <<
" strip #" << pld->getStrip()
746 std::vector<int> bx_times = pld->getTimeBinsOn();
747 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
748 strstrm <<
" " << bx_times[tbin];
749 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
754 int thisComparator = pld->getComparator();
755 if (thisComparator != 0 && thisComparator != 1) {
757 <<
"+++ Found comparator digi with wrong comparator value = "
758 << thisComparator <<
"; skipping it... +++\n";
763 int thisStrip = pld->getStrip() - 1;
764 if (thisStrip < 0 || thisStrip >=
numStrips) {
766 <<
"+++ Found comparator digi with wrong strip number = "
768 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
774 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
777 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
778 <<
"; skipping this digi... +++\n";
783 std::vector<int> bx_times = pld->getTimeBinsOn();
784 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
792 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
794 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
800 <<
"Comp digi: layer " << i_layer+1
801 <<
" digi #" << i_digi+1
802 <<
" strip " << thisStrip
803 <<
" halfstrip " << thisHalfstrip
804 <<
" distrip " << thisStrip/2 +
805 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
806 <<
" time " << bx_times[
i]
807 <<
" comparator " << thisComparator
808 <<
" stagger " << stagger[i_layer];
809 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
813 <<
" Skipping comparator digi: strip = " << thisStrip
814 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
815 <<
", bx of previous hit = " << bx_times[
i-1];
820 <<
"+++ Skipping comparator digi: strip = " << thisStrip
821 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
842 digiNum[
i][
j] = -999;
847 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
848 for (
unsigned int j = 0;
j < layerDigiV.size();
j++) {
854 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
855 <<
" strip #" << thisDigi.
getStrip()
861 if (thisComparator != 0 && thisComparator != 1) {
863 <<
"+++ Comparator digi with wrong comparator value: digi #" <<
j
864 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
869 int thisStrip = thisDigi.
getStrip() - 1;
870 if (thisStrip < 0 || thisStrip >=
numStrips) {
872 <<
"+++ Comparator digi with wrong strip number: digi #" <<
j
873 <<
", strip = " << thisStrip
874 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
883 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
892 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
893 digiNum[
i][thisStrip] =
j;
894 time[
i][thisStrip] = thisDigiBx;
895 comp[
i][thisStrip] = thisComparator;
897 <<
"Comp digi: layer " <<
i+1
899 <<
" strip " << thisStrip
900 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
901 <<
" distrip " << thisStrip/2 +
902 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
903 <<
" time " << time[
i][thisStrip]
904 <<
" comparator " << comp[
i][thisStrip]
910 <<
"+++ Skipping comparator digi: strip = " << thisStrip
911 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
922 if (time[
i][
j] >= 0) {
929 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
930 <<
"; skipping this digi... +++\n";
933 halfstrip[
i][i_halfstrip].push_back(time[
i][
j]);
942 static int test_iteration = 0;
944 if (time[
i][
j] >= 0) {
946 if (
j%2 == 1 && comp[
i][
j] == 1 &&
stagger[
i] == 1) {
948 bool stagger_debug = (
infoV > 2);
957 if (
infoV > 2 && test_iteration == 1) {
963 <<
"+++ Found wrong distrip number = " << i_distrip
964 <<
"; skipping this digi... +++\n";
967 distrip[
i][i_distrip].push_back(time[
i][
j]);
975 int stag_time[CSCConstants::MAX_NUM_STRIPS],
976 int stag_digi[CSCConstants::MAX_NUM_STRIPS],
977 int i_strip,
bool debug) {
993 if (i_strip >= CSCConstants::MAX_NUM_STRIPS) {
995 <<
"+++ Found wrong strip number = " << i_strip
996 <<
"; cannot apply distrip staggering... +++\n";
1002 <<
" Enter distripStagger: i_strip = " << i_strip
1003 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1004 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1005 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1006 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1010 if (i_strip+2 < CSCConstants::MAX_NUM_STRIPS && stag_triad[i_strip+2] == 1)
1017 if (stag_time[i_strip+2] >= 0) {
1018 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1019 stag_time[i_strip+2] = stag_time[i_strip];
1020 stag_digi[i_strip+2] = stag_digi[i_strip];
1026 stag_time[i_strip+2] = stag_time[i_strip];
1027 stag_digi[i_strip+2] = stag_digi[i_strip];
1034 stag_time[i_strip] = -999;
1035 stag_triad[i_strip] = 4;
1036 stag_digi[i_strip] = -999;
1040 <<
" Exit distripStagger: i_strip = " << i_strip
1041 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1042 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1043 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1044 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1062 const int max_lct_num = 2;
1063 const int adjacent_strips = 2;
1066 int highest_quality = 0;
1069 int final_lcts[max_lct_num];
1071 std::vector <CSCCLCTDigi> lctList;
1074 if (stripType == 1) nStrips = 2*
numStrips + 1;
1075 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1086 for (j = 0; j < max_lct_num; j++)
1087 final_lcts[j] = -999;
1093 final_lcts[0] = best_strip;
1095 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1097 if (
abs(best_strip - key_strip) > adjacent_strips){
1099 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1100 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1101 final_lcts[1] = key_strip;
1106 for (j = 0; j < max_lct_num; j++){
1109 int keystrip = final_lcts[
j];
1110 if (keystrip >= 0 &&
1111 keystrip_data[keystrip][
CLCT_QUALITY] >= ptrn_thrsh[stripType]) {
1118 keystrip_data[keystrip][
CLCT_CFEB] = theHalfStrip/32;
1119 int halfstrip_in_cfeb =
1120 theHalfStrip - 32*keystrip_data[keystrip][
CLCT_CFEB];
1128 keystrip_data[keystrip][
CLCT_BX]);
1133 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1136 <<
"Key Strip: " << std::setw(3)
1138 <<
" Pattern: " << std::setw(2)
1140 <<
" Bend: " << std::setw(1) << bend
1141 <<
" Quality: " << std::setw(1)
1143 <<
" stripType: " << std::setw(1) << stripType
1144 <<
" BX: " << std::setw(1)
1145 << keystrip_data[keystrip][
CLCT_BX];
1147 lctList.push_back(thisLCT);
1158 const int stripType,
const int nStrips,
1165 int i_layer, i_strip, this_layer, this_strip;
1166 int hits, layers_hit;
1169 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1176 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1182 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1187 hit_layer[i_layer] =
false;
1192 if (this_strip >= 0 && this_strip < nStrips) {
1194 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1197 if (hit_layer[this_layer] ==
false) {
1198 hit_layer[this_layer] =
true;
1203 if (layers_hit >= pre_trigger_layer_min) {
1220 int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7],
1221 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1223 int key_strip, this_layer, this_strip;
1224 int quality, best_quality;
1226 int highest_quality = 0;
1229 for (key_strip = 0; key_strip < nStrips; key_strip++)
1230 for (
int i = 0;
i < 7;
i++)
1231 keystrip_data[key_strip][
i] = 0;
1236 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1243 if ((this_strip >= 0 && this_strip < nStrips) &&
1244 !
strip[this_layer][this_strip].empty()) {
1245 if (nullPattern) nullPattern =
false;
1246 std::vector<int> bx_times =
strip[this_layer][this_strip];
1247 lct_pattern[pattern_strip] = bx_times[0];
1250 lct_pattern[pattern_strip] = -999;
1254 if (nullPattern)
continue;
1268 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1270 <<
"Key_strip " << key_strip <<
" quality of pattern_num "
1271 << pattern_num <<
": " << quality;
1272 if (quality > best_quality){
1275 keystrip_data[key_strip][
CLCT_BEND] = bend;
1276 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1277 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1280 if (quality > highest_quality){
1285 best_strip = key_strip;
1286 highest_quality = quality;
1288 best_quality = quality;
1297 int strip_value[NUM_PATTERN_STRIPS],
int bx_time,
1298 int& quality,
int& bend){
1307 hit_layer[i_layer] =
false;
1311 if (
hitIsGood(strip_value[strip_num], bx_time)){
1315 if (i_layer ==
pattern[pattern_num][strip_num]){
1317 if (hit_layer[i_layer] ==
false){
1319 hit_layer[i_layer] =
true;
1327 quality = layers_hit;
1335 int dt = BX - hitTime;
1336 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1337 else {
return false;}
1355 std::vector <CSCCLCTDigi> lctList;
1356 int _bx[2] = {999, 999};
1372 int keystrip_data[2][7];
1375 bool pre_trig[2] = {
false,
false};
1379 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1380 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1384 if (pre_trig[0] || pre_trig[1]) {
1385 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1387 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1388 <<
"\n ..... waiting drift delay ..... ";
1420 latchLCTs(h_pulse, h_keyStrip, h_nhits, 1, CSCConstants::NUM_HALF_STRIPS,
1427 <<
"...............................\n"
1428 <<
"Final halfstrip hits and keys (after drift delay) ...";
1429 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1431 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1432 <<
" hits " << h_nhits[icfeb];
1435 <<
"Final distrip hits and keys (after drift delay) ...";
1436 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1438 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1439 <<
" hits " << d_nhits[icfeb];
1442 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1445 for (
int ilct = 0; ilct < 2; ilct++) {
1447 <<
"found lcts: ilct " << ilct
1448 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1450 int halfstrip_in_cfeb = 0;
1452 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1455 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1464 keystrip_data[ilct][
CLCT_BX]);
1465 lctList.push_back(thisLCT);
1479 const int stripType,
const int nStrips,
1480 const int start_bx,
int& first_bx) {
1482 <<
"....................PreTrigger...........................";
1484 if (start_bx == 0) {
1489 bool pre_trig =
false;
1491 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1497 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1505 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1514 const int stripType,
const int nStrips,
1515 const unsigned int bx_time) {
1520 int key_strip, this_layer, this_strip, layers_hit;
1523 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1525 if (stripType != 0 && stripType != 1) {
1527 <<
"+++ preTrigLookUp: stripType = " << stripType
1528 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1532 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1534 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1536 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1539 hit_layer[ilayer] =
false;
1546 if (this_strip >= 0 && this_strip < nStrips) {
1548 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1549 if (hit_layer[this_layer] ==
false) {
1550 hit_layer[this_layer] =
true;
1552 if (layers_hit >= pre_trigger_layer_min) {
1554 <<
"pretrigger at bx: " << bx_time
1555 <<
", cfeb " << icfeb <<
", returning";
1573 int keyStrip[MAX_CFEBS],
unsigned int n_hits[MAX_CFEBS],
1574 const int stripType,
const int nStrips,
const int bx_time) {
1577 int key_strip, this_layer, this_strip;
1578 int layers_hit, prev_hits;
1580 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1581 keyStrip[icfeb] = -1;
1585 if (stripType != 0 && stripType != 1) {
1587 <<
"+++ latchLCTs: stripType = " << stripType
1588 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1592 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1595 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1597 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1600 hit_layer[ilayer] =
false;
1607 if (this_strip >= 0 && this_strip < nStrips) {
1609 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1610 if (hit_layer[this_layer] ==
false) {
1611 hit_layer[this_layer] =
true;
1618 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1619 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1620 <<
" n_hits: " << layers_hit;
1625 if (layers_hit > prev_hits) {
1626 prev_hits = layers_hit;
1627 keyStrip[icfeb] = key_strip;
1628 n_hits[icfeb] = layers_hit;
1637 const int h_keyStrip[MAX_CFEBS],
const unsigned int h_nhits[MAX_CFEBS],
1638 const int d_keyStrip[MAX_CFEBS],
const unsigned int d_nhits[MAX_CFEBS],
1639 int keystrip_data[2][7]) {
1645 const int nlcts = 2;
1649 for (
int ilct = 0; ilct < nlcts; ilct++) {
1650 for (
int j = 0;
j < 7;
j++) keystrip_data[ilct][
j] = -1;
1654 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1655 key_strip[icfeb] = -1;
1656 key_phits[icfeb] = -1;
1657 strip_type[icfeb] = -1;
1662 <<
".....................PriorityEncode.......................";
1663 std::ostringstream strstrm;
1664 strstrm <<
"hkeys:";
1665 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1666 strstrm << std::setw(4) << h_keyStrip[icfeb];
1668 strstrm <<
"\ndkeys:";
1669 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1670 strstrm << std::setw(4) << d_keyStrip[icfeb];
1672 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1677 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1678 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1679 if (h_nhits[icfeb] >= hs_thresh) {
1680 key_strip[icfeb] = h_keyStrip[icfeb];
1681 key_phits[icfeb] = h_nhits[icfeb] + 8;
1682 strip_type[icfeb]= 1;
1688 key_strip[icfeb] = d_keyStrip[icfeb];
1689 key_phits[icfeb] = d_nhits[icfeb];
1690 strip_type[icfeb]= 0;
1693 else if (h_keyStrip[icfeb] != -1) {
1694 if (h_nhits[icfeb] >= hs_thresh) {
1695 key_strip[icfeb] = h_keyStrip[icfeb];
1696 key_phits[icfeb] = h_nhits[icfeb] + 8;
1697 strip_type[icfeb]= 1;
1700 else if (d_keyStrip[icfeb] != -1) {
1702 key_strip[icfeb] = d_keyStrip[icfeb];
1703 key_phits[icfeb] = d_nhits[icfeb];
1704 strip_type[icfeb]= 0;
1707 if (
infoV > 1 && strip_type[icfeb] != -1) {
1708 if (strip_type[icfeb] == 0)
1710 <<
" taking distrip pattern on cfeb " << icfeb;
1711 else if (strip_type[icfeb] == 1)
1713 <<
" taking halfstrip pattern on cfeb " << icfeb;
1715 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1716 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1727 <<
"...... Remove Duplicates ......";
1728 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1729 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1730 else key[icfeb] = key_strip[icfeb];
1732 for (
int icfeb = 0; icfeb < MAX_CFEBS-1; icfeb++) {
1733 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1737 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1738 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1739 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1741 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1742 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1744 <<
" deleting LCT on CFEB " << icfeb;
1745 key_strip[icfeb] = -1;
1746 key_phits[icfeb] = -1;
1750 <<
" deleting LCT on CFEB " << icfeb+1;
1751 key_strip[icfeb+1] = -1;
1752 key_phits[icfeb+1] = -1;
1761 <<
"\n...... Select best LCTs ......";
1762 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1763 if (key_phits[icfeb] > ihits[0]) {
1764 ihits[1] = ihits[0];
1765 cfebs[1] = cfebs[0];
1766 ihits[0] = key_phits[icfeb];
1769 std::ostringstream strstrm;
1770 for (
int icfeb = 0; icfeb <
MAX_CFEBS; icfeb++) {
1771 strstrm << std::setw(4) << strip_type[icfeb];
1774 <<
"strip_type" << strstrm.str()
1775 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1776 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1777 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1778 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1781 else if (key_phits[icfeb] > ihits[1]) {
1782 ihits[1] = key_phits[icfeb];
1785 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1786 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1792 for (
int ilct = 0; ilct < nlcts; ilct++) {
1793 if (cfebs[ilct] != -1) {
1794 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1795 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1798 <<
"filling key: " << key_strip[cfebs[ilct]]
1799 <<
" type: " << strip_type[cfebs[ilct]];
1810 int keystrip_data[2][7],
const int first_bx) {
1813 int this_layer, this_strip;
1814 unsigned int quality = 0, bend = 0;
1815 unsigned int best_quality, best_pattern;
1816 bool valid[2] = {
false,
false};
1826 <<
"...............getKeyStripData....................";
1828 for (
int ilct = 0; ilct < 2; ilct++) {
1830 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1834 <<
"no lct at ilct " << ilct;
1839 lct_pattern[pattern_strip] = -999;
1846 if (this_strip >= 0 && this_strip < CSCConstants::NUM_HALF_STRIPS) {
1848 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1849 lct_pattern[pattern_strip] = 1;
1855 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1856 lct_pattern[pattern_strip] = 1;
1866 for (
unsigned int pattern_num = 0;
1868 getPattern(pattern_num, lct_pattern, quality, bend);
1870 <<
"pattern " << pattern_num <<
" quality " << quality
1871 <<
" bend " << bend;
1878 if ((quality == best_quality && pattern_num > best_pattern) ||
1879 (quality > best_quality)) {
1881 <<
"valid = true at quality " << quality
1886 keystrip_data[ilct][
CLCT_BX] = first_bx;
1889 best_quality = quality;
1890 best_pattern = pattern_num;
1898 <<
"lct " << ilct <<
" not over threshold: deleting";
1902 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n"
1903 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
1904 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
1906 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
1907 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
1916 const int strip_value[NUM_PATTERN_STRIPS],
1917 unsigned int& quality,
unsigned int& bend) {
1924 unsigned int layers_hit = 0;
1929 hit_layer[i_layer] =
false;
1933 if (strip_value[strip_num] == 1){
1937 if (i_layer ==
pattern[pattern_num][strip_num]){
1939 if (hit_layer[i_layer] ==
false){
1941 hit_layer[i_layer] =
true;
1949 quality = layers_hit;
1962 std::vector<CSCCLCTDigi> lctList;
1965 const int maxHalfStrips = 2*
numStrips + 1;
1970 enum {max_lcts = 2};
1972 int keystrip_data[max_lcts][7] = {{0}};
1978 unsigned int start_bx = 0;
1983 while (start_bx < stop_bx) {
1987 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
1994 <<
"..... pretrigger at bx = " << first_bx
1995 <<
"; waiting drift delay .....";
1999 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2003 hstrip < maxHalfStrips; hstrip++) {
2004 if (
nhits[hstrip] > 0) {
2006 <<
" bx = " << std::setw(2) << latch_bx <<
" --->"
2007 <<
" halfstrip = " << std::setw(3) << hstrip
2008 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2009 <<
" nhits = " <<
nhits[hstrip];
2016 start_bx = first_bx + 1;
2020 int best_halfstrip[max_lcts], best_quality[max_lcts];
2021 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2022 best_halfstrip[ilct] = -1;
2023 best_quality[ilct] = 0;
2030 hstrip < maxHalfStrips; hstrip++) {
2033 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2034 if (quality[hstrip] > best_quality[0]) {
2035 best_halfstrip[0] = hstrip;
2036 best_quality[0] = quality[hstrip];
2038 if (
infoV > 1 && quality[hstrip] > 0) {
2040 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2041 <<
" quality = " << std::setw(3) << quality[hstrip]
2042 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2043 <<
" best quality = " << std::setw(3) << best_quality[0];
2049 if (best_halfstrip[0] >= 0) {
2055 hstrip < maxHalfStrips; hstrip++) {
2056 if (quality[hstrip] > best_quality[1]) {
2057 best_halfstrip[1] = hstrip;
2058 best_quality[1] = quality[hstrip];
2060 if (
infoV > 1 && quality[hstrip] > 0) {
2062 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2063 <<
" quality = " << std::setw(3) << quality[hstrip]
2064 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2065 <<
" best quality = " << std::setw(3) << best_quality[1];
2070 bool ptn_trig =
false;
2071 for (
int ilct = 0; ilct < max_lcts; ilct++) {
2072 int best_hs = best_halfstrip[ilct];
2081 keystrip_data[ilct][
CLCT_BX] = first_bx;
2086 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2090 <<
" Final selection: ilct " << ilct
2091 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2094 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2102 keystrip_data[ilct][
CLCT_BX]);
2103 lctList.push_back(thisLCT);
2118 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2119 bool return_to_idle =
true;
2120 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2123 hstrip < maxHalfStrips; hstrip++) {
2126 <<
" State machine busy at bx = " << bx;
2127 return_to_idle =
false;
2132 if (return_to_idle) {
2134 <<
" State machine returns to idle state at bx = " << bx;
2143 start_bx = first_bx + 1;
2157 static unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2168 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2169 pulse[i_layer][i_strip] = 0;
2173 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2176 if (
time[i_layer][i_strip].
size() > 0) {
2177 std::vector<int> bx_times =
time[i_layer][i_strip];
2178 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2180 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2182 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2183 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2184 <<
" is not within the range (0-" << bits_in_pulse
2185 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2188 for (
unsigned int bx = bx_times[
i];
2190 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2201 const int start_bx,
int& first_bx) {
2203 <<
"....................PreTrigger...........................";
2208 bool pre_trig =
false;
2210 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2216 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2219 hstrip < nStrips; hstrip++) {
2221 if (
nhits[hstrip] > 0) {
2223 <<
" bx = " << std::setw(2) << bx_time <<
" --->"
2224 <<
" halfstrip = " << std::setw(3) << hstrip
2225 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2226 <<
" nhits = " <<
nhits[hstrip];
2243 "no pretrigger, returning \n";
2252 const int nStrips,
const unsigned int bx_time) {
2258 unsigned int layers_hit = 0;
2260 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++) {
2261 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1) {
2269 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++) {
2271 nhits[key_hstrip] = 0;
2277 key_hstrip < nStrips; key_hstrip++) {
2283 hit_layer[ilayer] =
false;
2290 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS) {
2292 if (this_strip >= 0 && this_strip < nStrips) {
2294 <<
" In ptnFinding: key_strip = " << key_hstrip
2295 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2296 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2298 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
2299 if (hit_layer[this_layer] ==
false) {
2300 hit_layer[this_layer] =
true;
2308 if (layers_hit >
nhits[key_hstrip]) {
2310 nhits[key_hstrip] = layers_hit;
2313 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2323 const int best_patid,
2328 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2329 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS) {
2330 quality[hstrip] = 0;
2340 std::ostringstream strm;
2342 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2343 strm <<
"+ CLCT configuration parameters: +\n";
2344 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2345 strm <<
" fifo_tbins [total number of time bins in DAQ readout] = "
2347 strm <<
" fifo_pretrig [start time of cathode raw hits in DAQ readout] = "
2349 strm <<
" hit_persist [duration of signal pulse, in 25 ns bins] = "
2351 strm <<
" drift_delay [time after pre-trigger before TMB latches LCTs] = "
2353 strm <<
" nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = "
2355 strm <<
" nplanes_hit_pattern [min. number of layers hit for trigger] = "
2358 strm <<
" pid_thresh_pretrig [lower threshold on pattern id] = "
2360 strm <<
" min_separation [region of busy key strips] = "
2363 strm <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
2364 LogDebug(
"CSCCathodeLCTProcessor") << strm.str();
2375 <<
" strip type " << stripType <<
" nStrips " << nStrips;
2377 std::ostringstream strstrm;
2378 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2379 if (i_strip%10 == 0) {
2380 if (i_strip < 100) strstrm << i_strip/10;
2381 else strstrm << (i_strip-100)/10;
2383 else strstrm <<
" ";
2384 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2387 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2388 strstrm << i_strip%10;
2389 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2393 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2395 std::vector<int> bx_times =
strip[i_layer][i_strip];
2397 strstrm << std::hex << bx_times[0] << std::dec;
2402 if ((i_strip+1)%
cfeb_strips[stripType] == 0) strstrm <<
" ";
2405 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
2411 std::vector<CSCCLCTDigi> tmpV;
2420 static int early_tbins = 4;
2426 static int tmb_l1a_window_size = 7;
2427 static int lct_bins =
2428 (tmb_l1a_window_size%2 == 0) ? tmb_l1a_window_size : tmb_l1a_window_size-1;
2429 static int late_tbins = early_tbins + lct_bins;
2431 static int ifois = 0;
2433 if (
infoV >= 0 && early_tbins < 0) {
2435 <<
"+++ early_tbins = " << early_tbins
2436 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2441 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2443 <<
"+++ Set late_tbins to max allowed +++\n";
2444 late_tbins = MAX_CLCT_BINS-1;
2451 int bx_readout = -1;
2452 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2453 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2454 plct != all_lcts.end(); plct++) {
2455 if (!plct->isValid())
continue;
2457 int bx = (*plct).getBX();
2459 if (bx <= early_tbins) {
2461 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2462 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is "
2468 if (bx > late_tbins) {
2470 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2471 <<
": found at bx " << bx <<
", whereas the latest allowed bx is "
2479 if (bx_readout == -1 || bx == bx_readout) {
2480 tmpV.push_back(*plct);
2481 if (bx_readout == -1) bx_readout = bx;
2489 std::vector<CSCCLCTDigi> tmpV;
2509 test_triad[distrip] = 3;
2510 test_triad[distrip+1] = 3;
2511 test_triad[distrip+2] = 3;
2512 test_triad[distrip+3] = 3;
2513 test_triad[distrip+4] = 3;
2514 test_triad[distrip+5] = 3;
2515 test_triad[distrip+6] = 3;
2516 test_triad[distrip+7] = 3;
2517 test_triad[distrip+8] = 3;
2518 test_triad[distrip+9] = 3;
2519 test_triad[distrip+10] = 2;
2521 test_time[distrip] = 4;
2522 test_time[distrip+1] = 10;
2523 test_time[distrip+2] = 2;
2524 test_time[distrip+3] = 0;
2525 test_time[distrip+4] = 6;
2526 test_time[distrip+5] = 8;
2527 test_time[distrip+6] = 10;
2528 test_time[distrip+7] = 1;
2529 test_time[distrip+8] = 8;
2530 test_time[distrip+9] = 5;
2531 test_time[distrip+10] = 6;
2533 std::cout <<
"\n ------------------------------------------------- \n";
2534 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2535 std::cout <<
"Values before distripStagger routine:" << std::endl;
2536 for (
int i=distrip;
i<distrip+11;
i++){
2538 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2539 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2541 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2542 std::cout <<
"Values after distripStagger routine:" << std::endl;
2543 for (
int i=distrip;
i<distrip+11;
i++){
2544 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2545 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2547 std::cout <<
"\n ------------------------------------------------- \n \n";
2552 for (
int ptn = 0; ptn < 8; ptn++) {
2553 for (
int bend = 0; bend < 2; bend++) {
2554 for (
int cfeb = 0; cfeb <
MAX_CFEBS; cfeb++) {
2555 for (
int key_strip = 0; key_strip < 32; key_strip++) {
2556 for (
int bx = 0; bx < 7; bx++) {
2557 for (
int stripType = 0; stripType < 2; stripType++) {
2558 for (
int quality = 3; quality < 6; quality++) {
2559 CSCCLCTDigi thisLCT(1, quality, ptn, stripType, bend,
2560 key_strip, cfeb, bx);
2563 <<
"pattern mismatch: " << ptn <<
" "
2565 if (bend != thisLCT.
getBend())
2567 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
2568 if (cfeb != thisLCT.
getCFEB())
2570 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
2573 <<
"strip mismatch: " << key_strip <<
" "
2575 if (bx != thisLCT.
getBX())
2577 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
2580 <<
"Strip Type mismatch: " << stripType <<
" "
2584 <<
"quality mismatch: " << quality <<
" "
2597 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
2600 std::cout<<
" Pattern "<<patternNum<<
" ";
2610 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
2618 minStrip = 3*layer - 2;
2642 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
2645 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
2646 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
2647 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
2648 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
2649 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
2650 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
2651 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
2652 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
2653 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
2654 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
2655 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
2656 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
2657 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
2658 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
2659 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
2660 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
2669 if (numLayersHit > 3 || results.size() > 0) {
2670 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
2676 if (results.size() > 0) {
2677 int thePatternStrip =
strip - (results[0].getKeyStrip() - 2) + 3*layer;
2680 thePatternStrip -= 2;
2702 minStrip = 3*layer - 2;
2714 if (!stripsHit[layer][10].
empty()) {
2722 if (layer < static_cast<int>(results.size()) ) {
2737 if ((!stripsHit[layer][ 9].
empty()) ||
2738 (!stripsHit[layer][10].
empty()) ||
2739 (!stripsHit[layer][11].
empty()) ) number++;
int getQuality() const
return quality of a pattern (number of layers hit!)
void getPattern(int pattern_num, int strip_value[NUM_PATTERN_STRIPS], int bx_time, int &quality, int &bend)
static const unsigned int def_drift_delay
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][NUM_PATTERN_HALFSTRIPS+1]
void setDefaultConfigParameters()
std::vector< CSCCLCTDigi > readoutCLCTs()
unsigned int nplanes_hit_pretrig
static const unsigned int def_fifo_tbins
int getStrip() const
Get the strip number.
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int stripType)
CSCChamber * chamber(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned tcscid) const
Return the CSCChamber for a corresponding endcap/station/sector/subsector/trigger cscid...
unsigned int min_separation
static const int cfeb_strips[2]
unsigned int clctHitPersist() const
const unsigned theTrigChamber
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS][7], int nStrips, int first_bx, int &best_strip, int stripType)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS])
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void dumpConfigParams() const
const unsigned theStation
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], int keyStrip[MAX_CFEBS], unsigned int nhits[MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
static const unsigned int def_min_separation
int numberOfStrips() const
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
unsigned int clctMinSeparation() const
int getComparator() const
Get Comparator readings.
unsigned int clctNplanesHitPretrig() const
static const unsigned int def_nplanes_hit_pretrig
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
static int ringFromTriggerLabels(int station, int triggerCSCID)
int getStripType() const
return striptype
unsigned int clctDriftDelay() const
int getBend() const
return bend
static const unsigned int def_pid_thresh_pretrig
unsigned int fifo_pretrig
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS], int stag_time[CSCConstants::MAX_NUM_STRIPS], int stag_digi[CSCConstants::MAX_NUM_STRIPS], int i_distrip, bool debug=false)
static CSCTriggerGeomManager * get()
unsigned int clctPidThreshPretrig() const
int getCFEB() const
return Key CFEB ID
void testDistripStagger()
int getBX() const
return BX
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][NUM_PATTERN_STRIPS+1]
bool getDigis(const CSCComparatorDigiCollection *compdc)
static const unsigned int def_nplanes_hit_pattern
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
unsigned int clctFifoPretrig() const
unsigned int nplanes_hit_pattern
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips) const
void priorityEncode(const int h_keyStrip[MAX_CFEBS], const unsigned int h_nhits[MAX_CFEBS], const int d_keyStrip[MAX_CFEBS], const unsigned int d_nhits[MAX_CFEBS], int keystrip_data[2][7])
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS])
void checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
static const unsigned int def_hit_persist
int stagger[CSCConstants::NUM_LAYERS]
std::vector< DigiType >::const_iterator const_iterator
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
static const int pattern2007_offset[NUM_PATTERN_HALFSTRIPS]
bool hitIsGood(int hitTime, int BX)
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS]
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
static const int pre_hit_pattern[2][NUM_PATTERN_STRIPS]
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int nStrips, const unsigned int bx_time)
const CSCLayerGeometry * geometry() const
tuple size
Write out results.
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
unsigned int pid_thresh_pretrig
std::vector< CSCCLCTDigi > getCLCTs()
void setConfigParameters(const CSCDBL1TPParameters *conf)
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, int &first_bx)
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS], const int stripType, const int nStrips, const unsigned int bx_time)
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.