69 { 999, 999, 999, 999, 999,
70 999, 999, 999, 999, 999,
71 999, 999, 999, 999, 999,
73 999, 999, 999, 999, 999,
74 999, 999, 999, 999, 999, 0},
76 { 999, 999, 999, 0, 999,
77 999, 999, 999, 1, 999,
81 999, 5, 999, 999, 999, 1},
83 { 999, 0, 999, 999, 999,
84 999, 1, 999, 999, 999,
88 999, 999, 999, 5, 999, 0},
90 { 999, 999, 0, 999, 999,
91 999, 999, 1, 999, 999,
92 999, 999, 2, 999, 999,
94 999, 4, 999, 999, 999,
95 999, 5, 999, 999, 999, 1},
97 { 999, 999, 0, 999, 999,
98 999, 999, 1, 999, 999,
99 999, 999, 2, 999, 999,
101 999, 999, 999, 4, 999,
102 999, 999, 999, 5, 999, 0},
104 { 999, 999, 999, 0, 999,
105 999, 999, 999, 1, 999,
108 999, 999, 4, 999, 999,
109 999, 999, 5, 999, 999, 1},
111 { 999, 0, 999, 999, 999,
112 999, 1, 999, 999, 999,
115 999, 999, 4, 999, 999,
116 999, 999, 5, 999, 999, 0},
118 { 999, 999, 0, 999, 999,
119 999, 999, 1, 999, 999,
120 999, 999, 2, 999, 999,
122 999, 999, 4, 999, 999,
123 999, 999, 5, 999, 999, 1}
132 { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
136 -4, -3, -2, -1, 0, 1, 2, 3, 4,
137 -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
140 { 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
141 999, 999, 999, 999, 999,
143 999, 999, 999, 999, 999,
144 999, 999, 999, 999, 999, 999, 999, 999, 999,
145 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -1, 0},
147 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 4, 4, 4, 4, 4, 4, 4, 4, 4,
152 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, 11},
154 { 999, 999, 999, 999, 999, 999, 999, 999, 0, 0, 0,
158 4, 4, 4, 999, 999, 999, 999, 999, 999,
159 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 999, 0, 11},
161 { 0, 0, 0, 999, 999, 999, 999, 999, 999, 999, 999,
165 999, 999, 999, 999, 999, 999, 4, 4, 4,
166 999, 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 1, 11},
168 { 999, 999, 999, 999, 999, 999, 999, 0, 0, 0, 999,
172 4, 4, 4, 999, 999, 999, 999, 999, 999,
173 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 999, 0, 9},
175 { 999, 0, 0, 0, 999, 999, 999, 999, 999, 999, 999,
179 999, 999, 999, 999, 999, 999, 4, 4, 4,
180 999, 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 1, 9},
182 { 999, 999, 999, 999, 999, 999, 0, 0, 0, 999, 999,
186 999, 999, 4, 4, 999, 999, 999, 999, 999,
187 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 999, 0, 7},
189 { 999, 999, 0, 0, 0, 999, 999, 999, 999, 999, 999,
193 999, 999, 999, 999, 999, 4, 4, 999, 999,
194 999, 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 1, 7},
196 { 999, 999, 999, 999, 999, 0, 0, 0, 999, 999, 999,
200 999, 999, 4, 4, 4, 999, 999, 999, 999,
201 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 999, 0, 5},
203 { 999, 999, 999, 0, 0, 0, 999, 999, 999, 999, 999,
207 999, 999, 999, 999, 4, 4, 4, 999, 999,
208 999, 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 1, 5},
210 { 999, 999, 999, 999, 0, 0, 0, 999, 999, 999, 999,
211 999, 999, 1, 999, 999,
213 999, 999, 3, 999, 999,
214 999, 999, 999, 4, 4, 4, 999, 999, 999,
215 999, 999, 999, 999, 5, 5, 5, 999, 999, 999, 999, 0, 3}
248 theEndcap(endcap), theStation(station), theSector(sector),
249 theSubsector(subsector), theTrigChamber(chamber) {
250 static std::atomic<bool> config_dumped{
false};
257 conf.
getParameter<
unsigned int>(
"clctNplanesHitPretrig");
259 conf.
getParameter<
unsigned int>(
"clctNplanesHitPattern");
279 if (isSLHC && !smartME1aME1b)
edm::LogError(
"L1CSCTPEmulatorConfigError")
280 <<
"+++ SLHC upgrade configuration is used (isSLHC=True) but smartME1aME1b=False!\n" 281 <<
"Only smartME1aME1b algorithm is so far supported for upgrade! +++\n";
285 conf.
getParameter<
unsigned int>(
"clctPidThreshPretrig");
321 if ((infoV > 0 || isSLHC) && !config_dumped) {
324 config_dumped =
true;
330 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
361 static std::atomic<bool> config_dumped{
false};
381 if (!config_dumped) {
384 config_dumped =
true;
390 if ((i_layer+1)%2 == 0)
stagger[i_layer] = 0;
421 static std::atomic<bool> config_dumped{
false};
438 if (!config_dumped) {
441 config_dumped =
true;
449 static const unsigned int max_fifo_tbins = 1 << 5;
450 static const unsigned int max_fifo_pretrig = 1 << 5;
451 static const unsigned int max_hit_persist = 1 << 4;
452 static const unsigned int max_drift_delay = 1 << 2;
453 static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
454 static const unsigned int max_nplanes_hit_pattern = 1 << 3;
455 static const unsigned int max_pid_thresh_pretrig = 1 << 4;
457 static const unsigned int max_tmb_l1a_window_size = 1 << 4;
463 <<
", exceeds max allowed, " << max_fifo_tbins-1 <<
" +++\n" 464 <<
"+++ Try to proceed with the default value, fifo_tbins=" 471 <<
", exceeds max allowed, " << max_fifo_pretrig-1 <<
" +++\n" 472 <<
"+++ Try to proceed with the default value, fifo_pretrig=" 479 <<
", exceeds max allowed, " << max_hit_persist-1 <<
" +++\n" 480 <<
"+++ Try to proceed with the default value, hit_persist=" 487 <<
", exceeds max allowed, " << max_drift_delay-1 <<
" +++\n" 488 <<
"+++ Try to proceed with the default value, drift_delay=" 495 <<
", exceeds max allowed, " << max_nplanes_hit_pretrig-1 <<
" +++\n" 496 <<
"+++ Try to proceed with the default value, nplanes_hit_pretrig=" 503 <<
", exceeds max allowed, " << max_nplanes_hit_pattern-1 <<
" +++\n" 504 <<
"+++ Try to proceed with the default value, nplanes_hit_pattern=" 513 <<
", exceeds max allowed, " << max_pid_thresh_pretrig-1 <<
" +++\n" 514 <<
"+++ Try to proceed with the default value, pid_thresh_pretrig=" 521 <<
", exceeds max allowed, " << max_min_separation-1 <<
" +++\n" 522 <<
"+++ Try to proceed with the default value, min_separation=" 531 <<
", exceeds max allowed, " << max_tmb_l1a_window_size-1 <<
" +++\n" 532 <<
"+++ Try to proceed with the default value, tmb_l1a_window_size=" 546 std::vector<CSCCLCTDigi>
554 static std::atomic<bool> config_dumped{
false};
558 config_dumped =
true;
591 <<
" found in ME" << ((
theEndcap == 1) ?
"+" :
"-")
597 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
615 (
chamber->layer(i_layer+1)->geometry()->stagger() + 1) / 2;
620 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
624 <<
" is not defined in current geometry! +++\n" 625 <<
"+++ CSC geometry looks garbled; no emulation possible +++\n";
632 <<
" ME" << ((
theEndcap == 1) ?
"+" :
"-")
636 <<
" numStrips = " <<
numStrips <<
"; CLCT emulation skipped! +++";
637 std::vector<CSCCLCTDigi> emptyV;
663 unsigned int layersHit = 0;
667 if (!halfstrip[i_layer][i_hstrip].
empty()) {layersHit++;
break;}
677 std::vector<CSCCLCTDigi> tmpV =
getCLCTs();
689 std::vector<CSCCLCTDigi> LCTlist;
698 LCTlist =
findLCTs(halfstrip, distrip);
701 std::vector<CSCCLCTDigi> halfStripLCTs =
findLCTs(halfstrip, 1);
702 std::vector<CSCCLCTDigi> diStripLCTs =
findLCTs(distrip, 0);
704 for (
unsigned int i = 0;
i < halfStripLCTs.size();
i++)
705 LCTlist.push_back(halfStripLCTs[
i]);
706 for (
unsigned int i = 0; i < diStripLCTs.size(); i++)
707 LCTlist.push_back(diStripLCTs[i]);
711 if (LCTlist.size() > 1)
712 sort(LCTlist.begin(), LCTlist.end(), std::greater<CSCCLCTDigi>());
715 for (std::vector<CSCCLCTDigi>::const_iterator plct = LCTlist.begin();
716 plct != LCTlist.end(); plct++) {
717 int bx = plct->getBX();
720 <<
"+++ Bx of CLCT candidate, " << bx <<
", exceeds max allowed, " 763 digiV[i_layer].clear();
786 <<
"found " <<
digiV[i_layer].size()
787 <<
" comparator digi(s) in layer " << i_layer <<
" of ME" 802 bool me1b = (
id.station() == 1) && (
id.
ring() == 1);
803 bool me1a = (
id.station() == 1) && (
id.
ring() == 4);
806 digiIt != rcompd.second; ++digiIt) {
807 unsigned int origStrip = digiIt->getStrip();
808 unsigned int maxStripsME1a =
gangedME1a ? 16 : 48;
813 digiIt->getComparator(),
814 digiIt->getTimeBinWord());
815 digiV[
id.layer()-1].push_back(digi_corr);
820 if (me1aProc && me1b && origStrip > 64){
823 digiIt->getComparator(),
824 digiIt->getTimeBinWord());
825 digiV[
id.layer()-1].push_back(digi_corr);
826 }
else if ((me1bProc && me1b && origStrip <= 64)
827 || ((me1aProc && me1a))
829 digiV[
id.layer()-1].push_back(*digiIt);
833 digiV[
id.layer()-1].push_back(*digiIt);
846 for (std::vector<CSCComparatorDigi>::iterator pld =
digiV[i_layer].
begin();
847 pld !=
digiV[i_layer].end(); pld++, i_digi++) {
850 std::ostringstream strstrm;
851 strstrm <<
"Comparator digi: comparator = " << pld->getComparator()
852 <<
" strip #" << pld->getStrip()
854 std::vector<int> bx_times = pld->getTimeBinsOn();
855 for (
unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
856 strstrm <<
" " << bx_times[tbin];
857 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
862 int thisComparator = pld->getComparator();
863 if (thisComparator != 0 && thisComparator != 1) {
865 <<
"+++ Found comparator digi with wrong comparator value = " 866 << thisComparator <<
"; skipping it... +++\n";
871 int thisStrip = pld->getStrip() - 1;
872 if (thisStrip < 0 || thisStrip >=
numStrips) {
874 <<
"+++ Found comparator digi with wrong strip number = " 876 <<
" (max strips = " <<
numStrips <<
"); skipping it... +++\n";
882 int thisHalfstrip = 2*thisStrip + thisComparator +
stagger[i_layer];
885 <<
"+++ Found wrong halfstrip number = " << thisHalfstrip
886 <<
"; skipping this digi... +++\n";
891 std::vector<int> bx_times = pld->getTimeBinsOn();
892 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
900 if (bx_times[
i] > 1 && bx_times[
i] < static_cast<int>(
fifo_tbins)) {
902 if (
i == 0 || (
i > 0 && bx_times[
i]-bx_times[
i-1] >=
908 <<
"Comp digi: layer " << i_layer+1
909 <<
" digi #" << i_digi+1
910 <<
" strip " << thisStrip
911 <<
" halfstrip " << thisHalfstrip
912 <<
" distrip " << thisStrip/2 +
913 ((thisStrip%2 == 1 && thisComparator == 1 && stagger[i_layer] == 1) ? 1 : 0)
914 <<
" time " << bx_times[
i]
915 <<
" comparator " << thisComparator
916 <<
" stagger " << stagger[i_layer];
917 halfstrip[i_layer][thisHalfstrip].push_back(bx_times[
i]);
921 <<
" Skipping comparator digi: strip = " << thisStrip
922 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i]
923 <<
", bx of previous hit = " << bx_times[
i-1];
928 <<
"+++ Skipping comparator digi: strip = " << thisStrip
929 <<
", layer = " << i_layer+1 <<
", bx = " << bx_times[
i] <<
" +++";
950 digiNum[
i][j] = -999;
955 std::vector <CSCComparatorDigi> layerDigiV =
digiV[
i];
956 for (
unsigned int j = 0; j < layerDigiV.size(); j++) {
962 <<
"Comparator digi: comparator = " << thisDigi.
getComparator()
963 <<
" strip #" << thisDigi.
getStrip()
969 if (thisComparator != 0 && thisComparator != 1) {
971 <<
"+++ Comparator digi with wrong comparator value: digi #" << j
972 <<
", comparator = " << thisComparator <<
"; skipping it... +++\n";
977 int thisStrip = thisDigi.
getStrip() - 1;
978 if (thisStrip < 0 || thisStrip >=
numStrips) {
980 <<
"+++ Comparator digi with wrong strip number: digi #" << j
981 <<
", strip = " << thisStrip
982 <<
", max strips = " <<
numStrips <<
"; skipping it... +++\n";
991 if (thisDigiBx >= 0 && thisDigiBx < static_cast<int>(
fifo_tbins)) {
1000 if (time[
i][thisStrip] == -999 || time[
i][thisStrip] > thisDigiBx) {
1001 digiNum[
i][thisStrip] = j;
1002 time[
i][thisStrip] = thisDigiBx;
1003 comp[
i][thisStrip] = thisComparator;
1005 <<
"Comp digi: layer " <<
i+1
1007 <<
" strip " << thisStrip
1008 <<
" halfstrip " << 2*thisStrip + comp[
i][thisStrip] +
stagger[
i]
1009 <<
" distrip " << thisStrip/2 +
1010 ((thisStrip%2 == 1 && comp[
i][thisStrip] == 1 &&
stagger[
i] == 1) ? 1 : 0)
1011 <<
" time " << time[
i][thisStrip]
1012 <<
" comparator " << comp[
i][thisStrip]
1018 <<
"+++ Skipping comparator digi: strip = " << thisStrip
1019 <<
", layer = " <<
i+1 <<
", bx = " << thisDigiBx <<
" +++";
1030 if (time[
i][j] >= 0) {
1031 int i_halfstrip = 2*j + comp[
i][j] +
stagger[
i];
1037 <<
"+++ Found wrong halfstrip number = " << i_halfstrip
1038 <<
"; skipping this digi... +++\n";
1041 halfstrip[
i][i_halfstrip].push_back(time[
i][j]);
1050 static std::atomic<int> test_iteration{0};
1052 if (time[
i][j] >= 0) {
1053 int i_distrip = j/2;
1054 if (j%2 == 1 && comp[
i][j] == 1 &&
stagger[
i] == 1) {
1056 bool stagger_debug = (
infoV > 2);
1065 if (
infoV > 2 && test_iteration == 1) {
1071 <<
"+++ Found wrong distrip number = " << i_distrip
1072 <<
"; skipping this digi... +++\n";
1075 distrip[
i][i_distrip].push_back(time[
i][j]);
1083 int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1084 int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS],
1085 int i_strip,
bool debug) {
1103 <<
"+++ Found wrong strip number = " << i_strip
1104 <<
"; cannot apply distrip staggering... +++\n";
1110 <<
" Enter distripStagger: i_strip = " << i_strip
1111 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1112 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1113 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1114 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1125 if (stag_time[i_strip+2] >= 0) {
1126 if (stag_time[i_strip] < stag_time[i_strip+2]) {
1127 stag_time[i_strip+2] = stag_time[i_strip];
1128 stag_digi[i_strip+2] = stag_digi[i_strip];
1134 stag_time[i_strip+2] = stag_time[i_strip];
1135 stag_digi[i_strip+2] = stag_digi[i_strip];
1142 stag_time[i_strip] = -999;
1143 stag_triad[i_strip] = 4;
1144 stag_digi[i_strip] = -999;
1148 <<
" Exit distripStagger: i_strip = " << i_strip
1149 <<
" stag_triad[i_strip] = " << stag_triad[i_strip]
1150 <<
" stag_time[i_strip] = " << stag_time[i_strip]
1151 <<
" stag_triad[i_strip+2] = " << stag_triad[i_strip+2]
1152 <<
" stag_time[i_strip+2] = " << stag_time[i_strip+2];
1170 const int adjacent_strips = 2;
1173 int highest_quality = 0;
1178 std::vector <CSCCLCTDigi> lctList;
1181 if (stripType == 1) nStrips = 2*
numStrips + 1;
1182 else if (stripType == 0) nStrips =
numStrips/2 + 1;
1194 final_lcts[j] = -999;
1200 final_lcts[0] = best_strip;
1202 for (
int key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1204 if (
abs(best_strip - key_strip) > adjacent_strips){
1206 if (keystrip_data[key_strip][
CLCT_QUALITY] > highest_quality){
1207 highest_quality = keystrip_data[key_strip][
CLCT_QUALITY];
1208 final_lcts[1] = key_strip;
1216 int keystrip = final_lcts[j];
1217 if (keystrip >= 0 &&
1218 keystrip_data[keystrip][
CLCT_QUALITY] >= static_cast<int>(ptrn_thrsh[stripType])) {
1226 int halfstrip_in_cfeb =
1235 keystrip_data[keystrip][
CLCT_BX]);
1240 (keystrip_data[keystrip][
CLCT_BEND] == 0) ?
'L' :
'R';
1243 <<
"Key Strip: " << std::setw(3)
1245 <<
" Pattern: " << std::setw(2)
1247 <<
" Bend: " << std::setw(1) << bend
1248 <<
" Quality: " << std::setw(1)
1250 <<
" stripType: " << std::setw(1) << stripType
1251 <<
" BX: " << std::setw(1)
1252 << keystrip_data[keystrip][
CLCT_BX];
1254 lctList.push_back(thisLCT);
1265 const int stripType,
const int nStrips,
1272 int i_layer, i_strip, this_layer, this_strip;
1273 int hits, layers_hit;
1276 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1283 for (
unsigned int bx_time = 0; bx_time <
fifo_tbins; bx_time++) {
1289 for (
int key_strip = 0; key_strip < nStrips; key_strip++){
1294 hit_layer[i_layer] =
false;
1299 if (this_strip >= 0 && this_strip < nStrips) {
1301 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1304 if (hit_layer[this_layer] ==
false) {
1305 hit_layer[this_layer] =
true;
1310 if (layers_hit >= pre_trigger_layer_min) {
1328 int nStrips,
int first_bx,
int& best_strip,
int stripType) {
1330 int key_strip, this_layer, this_strip;
1333 int highest_quality = 0;
1336 for (key_strip = 0; key_strip < nStrips; key_strip++)
1338 keystrip_data[key_strip][
i] = 0;
1343 for (key_strip = 0; key_strip < (nStrips-stripType); key_strip++){
1350 if ((this_strip >= 0 && this_strip < nStrips) &&
1351 !
strip[this_layer][this_strip].empty()) {
1352 if (nullPattern) nullPattern =
false;
1353 std::vector<int> bx_times =
strip[this_layer][this_strip];
1354 lct_pattern[pattern_strip] = bx_times[0];
1357 lct_pattern[pattern_strip] = -999;
1361 if (nullPattern)
continue;
1375 getPattern(pattern_num, lct_pattern, latch_bx, quality, bend);
1377 <<
"Key_strip " << key_strip <<
" quality of pattern_num " 1378 << pattern_num <<
": " <<
quality;
1379 if (quality > best_quality){
1382 keystrip_data[key_strip][
CLCT_BEND] = bend;
1383 keystrip_data[key_strip][
CLCT_STRIP] = key_strip;
1384 keystrip_data[key_strip][
CLCT_BX] = first_bx;
1387 if (quality > highest_quality){
1392 best_strip = key_strip;
1414 hit_layer[i_layer] =
false;
1418 if (
hitIsGood(strip_value[strip_num], bx_time)){
1422 if (i_layer ==
pattern[pattern_num][strip_num]){
1424 if (hit_layer[i_layer] ==
false){
1426 hit_layer[i_layer] =
true;
1434 quality = layers_hit;
1442 int dt = BX - hitTime;
1443 if (dt >= 0 && dt <= static_cast<int>(
hit_persist)) {
return true;}
1444 else {
return false;}
1462 std::vector <CSCCLCTDigi> lctList;
1463 int _bx[2] = {999, 999};
1482 bool pre_trig[2] = {
false,
false};
1486 pre_trig[0] =
preTrigger(halfstrip, h_pulse, 1, nhStrips, 0, _bx[0]);
1487 pre_trig[1] =
preTrigger( distrip, d_pulse, 0, ndStrips, 0, _bx[1]);
1491 if (pre_trig[0] || pre_trig[1]) {
1492 first_bx = (_bx[0] < _bx[1]) ? _bx[0] : _bx[1];
1494 <<
"half bx " << _bx[0] <<
" di bx " << _bx[1] <<
" first " << first_bx
1495 <<
"\n ..... waiting drift delay ..... ";
1534 <<
"...............................\n" 1535 <<
"Final halfstrip hits and keys (after drift delay) ...";
1538 <<
"cfeb " << icfeb <<
" key: " << h_keyStrip[icfeb]
1539 <<
" hits " << h_nhits[icfeb];
1542 <<
"Final distrip hits and keys (after drift delay) ...";
1545 <<
"cfeb " << icfeb <<
" key: " << d_keyStrip[icfeb]
1546 <<
" hits " << d_nhits[icfeb];
1549 priorityEncode(h_keyStrip, h_nhits, d_keyStrip, d_nhits, keystrip_data);
1552 for (
int ilct = 0; ilct < 2; ilct++) {
1554 <<
"found lcts: ilct " << ilct
1555 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP];
1557 int halfstrip_in_cfeb = 0;
1559 halfstrip_in_cfeb = 4*keystrip_data[ilct][
CLCT_STRIP] -
1562 halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
1571 keystrip_data[ilct][
CLCT_BX]);
1572 lctList.push_back(thisLCT);
1586 const int stripType,
const int nStrips,
1587 const int start_bx,
int& first_bx) {
1589 <<
"....................PreTrigger...........................";
1591 if (start_bx == 0) {
1596 bool pre_trig =
false;
1598 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
1604 pre_trig =
preTrigLookUp(pulse, stripType, nStrips, bx_time);
1612 <<
"no pretrigger for strip type " << stripType <<
", returning \n";
1621 const int stripType,
const int nStrips,
1622 const unsigned int bx_time) {
1627 int key_strip, this_layer, this_strip, layers_hit;
1630 const int pre_trigger_layer_min = (stripType == 1) ? hs_thresh : ds_thresh;
1632 if (stripType != 0 && stripType != 1) {
1634 <<
"+++ preTrigLookUp: stripType = " << stripType
1635 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1641 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1643 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1646 hit_layer[ilayer] =
false;
1653 if (this_strip >= 0 && this_strip < nStrips) {
1655 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1656 if (hit_layer[this_layer] ==
false) {
1657 hit_layer[this_layer] =
true;
1659 if (layers_hit >= pre_trigger_layer_min) {
1661 <<
"pretrigger at bx: " << bx_time
1662 <<
", cfeb " << icfeb <<
", returning";
1681 const int stripType,
const int nStrips,
const int bx_time) {
1684 int key_strip, this_layer, this_strip;
1685 int layers_hit, prev_hits;
1688 keyStrip[icfeb] = -1;
1692 if (stripType != 0 && stripType != 1) {
1694 <<
"+++ latchLCTs: stripType = " << stripType
1695 <<
" does not correspond to half-strip/di-strip patterns! +++\n";
1702 for (
int istrip = 0; istrip <
cfeb_strips[stripType]; istrip++) {
1704 key_strip = icfeb*cfeb_strips[stripType] + istrip;
1707 hit_layer[ilayer] =
false;
1714 if (this_strip >= 0 && this_strip < nStrips) {
1716 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
1717 if (hit_layer[this_layer] ==
false) {
1718 hit_layer[this_layer] =
true;
1725 if (layers_hit > 0)
LogTrace(
"CSCCathodeLCTProcessor")
1726 <<
"cfeb: " << icfeb <<
" key_strip: " << key_strip
1727 <<
" n_hits: " << layers_hit;
1732 if (layers_hit > prev_hits) {
1733 prev_hits = layers_hit;
1734 keyStrip[icfeb] = key_strip;
1735 n_hits[icfeb] = layers_hit;
1745 const int d_keyStrip[CSCConstants::MAX_CFEBS],
const unsigned int d_nhits[CSCConstants::MAX_CFEBS],
1762 key_strip[icfeb] = -1;
1763 key_phits[icfeb] = -1;
1764 strip_type[icfeb] = -1;
1769 <<
".....................PriorityEncode.......................";
1770 std::ostringstream strstrm;
1771 strstrm <<
"hkeys:";
1773 strstrm << std::setw(4) << h_keyStrip[icfeb];
1775 strstrm <<
"\ndkeys:";
1777 strstrm << std::setw(4) << d_keyStrip[icfeb];
1779 LogTrace(
"CSCCathodeLCTProcessor") << strstrm.str();
1785 if (h_keyStrip[icfeb] != -1 && d_keyStrip[icfeb] != -1) {
1786 if (h_nhits[icfeb] >= hs_thresh) {
1787 key_strip[icfeb] = h_keyStrip[icfeb];
1788 key_phits[icfeb] = h_nhits[icfeb] + 8;
1789 strip_type[icfeb]= 1;
1795 key_strip[icfeb] = d_keyStrip[icfeb];
1796 key_phits[icfeb] = d_nhits[icfeb];
1797 strip_type[icfeb]= 0;
1800 else if (h_keyStrip[icfeb] != -1) {
1801 if (h_nhits[icfeb] >= hs_thresh) {
1802 key_strip[icfeb] = h_keyStrip[icfeb];
1803 key_phits[icfeb] = h_nhits[icfeb] + 8;
1804 strip_type[icfeb]= 1;
1807 else if (d_keyStrip[icfeb] != -1) {
1809 key_strip[icfeb] = d_keyStrip[icfeb];
1810 key_phits[icfeb] = d_nhits[icfeb];
1811 strip_type[icfeb]= 0;
1814 if (
infoV > 1 && strip_type[icfeb] != -1) {
1815 if (strip_type[icfeb] == 0)
1817 <<
" taking distrip pattern on cfeb " << icfeb;
1818 else if (strip_type[icfeb] == 1)
1820 <<
" taking halfstrip pattern on cfeb " << icfeb;
1822 <<
" cfeb " << icfeb <<
" key " << key_strip[icfeb]
1823 <<
" hits " << key_phits[icfeb] <<
" type " << strip_type[icfeb];
1834 <<
"...... Remove Duplicates ......";
1836 if(strip_type[icfeb] == 0) key[icfeb] = key_strip[icfeb]*4;
1837 else key[icfeb] = key_strip[icfeb];
1839 for (
int icfeb = 0; icfeb < CSCConstants::MAX_CFEBS-1; icfeb++) {
1840 if (key[icfeb] >= 0 && key[icfeb+1] >= 0) {
1844 <<
" key 1: " << key[icfeb] <<
" key 2: " << key[icfeb+1]
1845 <<
" low edge: " << loedge <<
" high edge: " << hiedge;
1846 if (key[icfeb] >= loedge && key[icfeb+1] <= hiedge) {
1848 <<
"Duplicate LCTs found at boundary of CFEB " << icfeb <<
" ...";
1849 if (key_phits[icfeb+1] > key_phits[icfeb]) {
1851 <<
" deleting LCT on CFEB " << icfeb;
1852 key_strip[icfeb] = -1;
1853 key_phits[icfeb] = -1;
1857 <<
" deleting LCT on CFEB " << icfeb+1;
1858 key_strip[icfeb+1] = -1;
1859 key_phits[icfeb+1] = -1;
1868 <<
"\n...... Select best LCTs ......";
1870 if (key_phits[icfeb] > ihits[0]) {
1871 ihits[1] = ihits[0];
1872 cfebs[1] = cfebs[0];
1873 ihits[0] = key_phits[icfeb];
1876 std::ostringstream strstrm;
1878 strstrm << std::setw(4) << strip_type[icfeb];
1881 <<
"strip_type" << strstrm.str()
1882 <<
"\n best: ihits " << ihits[0] <<
" cfeb " << cfebs[0]
1883 <<
" strip_type " << ((cfebs[0] >= 0) ? strip_type[cfebs[0]] : -1)
1884 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1885 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1888 else if (key_phits[icfeb] > ihits[1]) {
1889 ihits[1] = key_phits[icfeb];
1892 <<
"\n next: ihits " << ihits[1] <<
" cfeb " << cfebs[1]
1893 <<
" strip_type " << ((cfebs[1] >= 0) ? strip_type[cfebs[1]] : -1);
1900 if (cfebs[ilct] != -1) {
1901 keystrip_data[jlct][
CLCT_CFEB] = cfebs[ilct];
1902 keystrip_data[jlct][
CLCT_STRIP] = key_strip[cfebs[ilct]];
1905 <<
"filling key: " << key_strip[cfebs[ilct]]
1906 <<
" type: " << strip_type[cfebs[ilct]];
1920 int this_layer, this_strip;
1921 unsigned int quality = 0, bend = 0;
1922 unsigned int best_quality, best_pattern;
1923 bool valid[2] = {
false,
false};
1933 <<
"...............getKeyStripData....................";
1935 for (
int ilct = 0; ilct < 2; ilct++) {
1937 <<
"lct " << ilct <<
" keystrip " << keystrip_data[ilct][
CLCT_STRIP]
1941 <<
"no lct at ilct " << ilct;
1946 lct_pattern[pattern_strip] = -999;
1955 if (((h_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1956 lct_pattern[pattern_strip] = 1;
1962 if (((d_pulse[this_layer][this_strip] >> latch_bx) & 1) == 1)
1963 lct_pattern[pattern_strip] = 1;
1973 for (
unsigned int pattern_num = 0;
1975 getPattern(pattern_num, lct_pattern, quality, bend);
1977 <<
"pattern " << pattern_num <<
" quality " << quality
1978 <<
" bend " << bend;
1985 if ((quality == best_quality && pattern_num > best_pattern) ||
1986 (quality > best_quality)) {
1988 <<
"valid = true at quality " << quality
1993 keystrip_data[ilct][
CLCT_BX] = first_bx;
1997 best_pattern = pattern_num;
2005 <<
"lct " << ilct <<
" not over threshold: deleting";
2009 <<
"\n" <<
"--------- final LCT: " << ilct <<
" -------------\n" 2010 <<
" key strip " << keystrip_data[ilct][
CLCT_STRIP]
2011 <<
" pattern_num " << keystrip_data[ilct][
CLCT_PATTERN]
2013 <<
" bend " << keystrip_data[ilct][
CLCT_BEND]
2014 <<
" bx " << keystrip_data[ilct][
CLCT_BX]
2024 unsigned int&
quality,
unsigned int& bend) {
2031 unsigned int layers_hit = 0;
2036 hit_layer[i_layer] =
false;
2040 if (strip_value[strip_num] == 1){
2044 if (i_layer ==
pattern[pattern_num][strip_num]){
2046 if (hit_layer[i_layer] ==
false){
2048 hit_layer[i_layer] =
true;
2056 quality = layers_hit;
2069 std::vector<CSCCLCTDigi> lctList;
2072 const int maxHalfStrips = 2*
numStrips + 1;
2088 while (start_bx < stop_bx) {
2092 bool pre_trig =
preTrigger(pulse, start_bx, first_bx);
2099 <<
"..... pretrigger at bx = " << first_bx
2100 <<
"; waiting drift delay .....";
2104 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, latch_bx);
2108 hstrip < maxHalfStrips; hstrip++) {
2109 if (
nhits[hstrip] > 0) {
2111 <<
" bx = " << std::setw(2) << latch_bx <<
" --->" 2112 <<
" halfstrip = " << std::setw(3) << hstrip
2113 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2114 <<
" nhits = " <<
nhits[hstrip];
2121 start_bx = first_bx + 1;
2127 best_halfstrip[ilct] = -1;
2128 best_quality[ilct] = 0;
2135 hstrip < maxHalfStrips; hstrip++) {
2138 quality[hstrip] = (
best_pid[hstrip] & 14) | (
nhits[hstrip] << 5);
2139 if (quality[hstrip] > best_quality[0]) {
2140 best_halfstrip[0] = hstrip;
2141 best_quality[0] = quality[hstrip];
2143 if (
infoV > 1 && quality[hstrip] > 0) {
2145 <<
" 1st CLCT: halfstrip = " << std::setw(3) << hstrip
2146 <<
" quality = " << std::setw(3) << quality[hstrip]
2147 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[0]
2148 <<
" best quality = " << std::setw(3) << best_quality[0];
2154 if (best_halfstrip[0] >= 0) {
2160 hstrip < maxHalfStrips; hstrip++) {
2161 if (quality[hstrip] > best_quality[1]) {
2162 best_halfstrip[1] = hstrip;
2163 best_quality[1] = quality[hstrip];
2165 if (
infoV > 1 && quality[hstrip] > 0) {
2167 <<
" 2nd CLCT: halfstrip = " << std::setw(3) << hstrip
2168 <<
" quality = " << std::setw(3) << quality[hstrip]
2169 <<
" best halfstrip = " << std::setw(3) << best_halfstrip[1]
2170 <<
" best quality = " << std::setw(3) << best_quality[1];
2175 bool ptn_trig =
false;
2177 int best_hs = best_halfstrip[ilct];
2186 keystrip_data[ilct][
CLCT_BX] = first_bx;
2191 int halfstrip_in_cfeb = keystrip_data[ilct][
CLCT_STRIP] -
2195 <<
" Final selection: ilct " << ilct
2196 <<
" key halfstrip " << keystrip_data[ilct][
CLCT_STRIP]
2199 <<
" bx " << keystrip_data[ilct][
CLCT_BX];
2207 keystrip_data[ilct][
CLCT_BX]);
2208 lctList.push_back(thisLCT);
2223 for (
unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
2224 bool return_to_idle =
true;
2225 bool hits_in_time =
ptnFinding(pulse, maxHalfStrips, bx);
2228 hstrip < maxHalfStrips; hstrip++) {
2231 <<
" State machine busy at bx = " << bx;
2232 return_to_idle =
false;
2237 if (return_to_idle) {
2239 <<
" State machine returns to idle state at bx = " << bx;
2248 start_bx = first_bx + 1;
2262 static const unsigned int bits_in_pulse = 8*
sizeof(pulse[0][0]);
2273 for (
int i_strip = 0; i_strip < nStrips; i_strip++)
2274 pulse[i_layer][i_strip] = 0;
2278 for (
int i_strip = 0; i_strip < nStrips; i_strip++) {
2282 std::vector<int> bx_times =
time[i_layer][i_strip];
2283 for (
unsigned int i = 0;
i < bx_times.size();
i++) {
2285 if (bx_times[
i] < 0 || bx_times[
i] +
hit_persist >= bits_in_pulse) {
2287 <<
"+++ BX time of comparator digi (halfstrip = " << i_strip
2288 <<
" layer = " << i_layer <<
") bx = " << bx_times[
i]
2289 <<
" is not within the range (0-" << bits_in_pulse
2290 <<
"] allowed for pulse extension. Skip this digi! +++\n";
2294 for (
unsigned int bx = bx_times[
i]; bx < bx_times[
i] +
hit_persist; ++bx)
2295 pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
2307 const int start_bx,
int& first_bx) {
2309 <<
"....................PreTrigger...........................";
2314 bool pre_trig =
false;
2316 for (
unsigned int bx_time = start_bx; bx_time <
fifo_tbins; bx_time++) {
2322 bool hits_in_time =
ptnFinding(pulse, nStrips, bx_time);
2325 hstrip < nStrips; hstrip++) {
2327 if (
nhits[hstrip] > 0) {
2329 <<
" bx = " << std::setw(2) << bx_time <<
" --->" 2330 <<
" halfstrip = " << std::setw(3) << hstrip
2331 <<
" best pid = " << std::setw(2) <<
best_pid[hstrip]
2332 <<
" nhits = " <<
nhits[hstrip];
2351 "no pretrigger, returning \n";
2360 const int nStrips,
const unsigned int bx_time)
2367 unsigned int layers_hit = 0;
2370 for (
int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++)
2372 if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1)
2381 for (
int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++)
2384 nhits[key_hstrip] = 0;
2397 hit_layer[ilayer] =
false;
2399 double num_pattern_hits=0., times_sum=0.;
2400 std::multiset<int> mset_for_median;
2401 mset_for_median.clear();
2408 if (this_layer >= 0 && this_layer < CSCConstants::NUM_LAYERS)
2411 if (this_strip >= 0 && this_strip < nStrips) {
2413 <<
" In ptnFinding: key_strip = " << key_hstrip
2414 <<
" pid = " <<
pid <<
" strip_num = " << strip_num
2415 <<
" layer = " << this_layer <<
" strip = " << this_strip;
2417 if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1)
2419 if (hit_layer[this_layer] ==
false)
2421 hit_layer[this_layer] =
true;
2427 int first_bx_layer = bx_time;
2428 for (
unsigned int dbx = 0; dbx <
hit_persist; dbx++)
2430 if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
2435 times_sum += (double) first_bx_layer;
2436 num_pattern_hits += 1.;
2437 mset_for_median.insert(first_bx_layer);
2439 LogTrace(
"CSCCathodeLCTProcessor") <<
" 1st bx in layer: " << first_bx_layer <<
" sum bx: " << times_sum
2440 <<
" #pat. hits: " << num_pattern_hits;
2446 if (layers_hit >
nhits[key_hstrip])
2449 nhits[key_hstrip] = layers_hit;
2452 const int sz = mset_for_median.size();
2454 std::multiset<int>::iterator im = mset_for_median.begin();
2455 if (sz>1) std::advance(im,sz/2-1);
2462 for (im = mset_for_median.begin(); im != mset_for_median.end(); im++)
2463 sprintf(bxs,
"%s %d", bxs, *im);
2471 if (
nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
break;
2481 const int best_patid,
2490 for (
int hstrip = best_hstrip-nspan; hstrip <= best_hstrip+pspan; hstrip++) {
2491 if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
2503 std::vector<CSCCLCTDigi>
2506 std::vector<CSCCLCTDigi> lctList;
2509 const int maxHalfStrips = 2 *
numStrips + 1;
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;
2577 best_halfstrip[ilct] = -1;
2578 best_quality[ilct] = 0;
2590 pretrig_zone[hstrip] =
false;
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] =
true;
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;
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++) {
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;
2849 static std::atomic<int> lct_bins;
2851 static std::atomic<int> late_tbins;
2854 static std::atomic<int> ifois{0};
2859 <<
"; in-time CLCTs are not getting read-out!!! +++" <<
"\n";
2864 <<
"+++ Allowed range of time bins, [0-" << late_tbins
2866 <<
"+++ Set late_tbins to max allowed +++\n";
2867 late_tbins = CSCConstants::MAX_CLCT_TBINS-1;
2874 int bx_readout = -1;
2875 std::vector<CSCCLCTDigi> all_lcts =
getCLCTs();
2876 for (std::vector <CSCCLCTDigi>::const_iterator plct = all_lcts.begin();
2877 plct != all_lcts.end(); plct++) {
2878 if (!plct->isValid())
continue;
2880 int bx = (*plct).getBX();
2884 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2885 <<
": found at bx " << bx <<
", whereas the earliest allowed bx is " 2891 if (bx > late_tbins) {
2893 <<
" Do not report CLCT on key halfstrip " << plct->getKeyStrip()
2894 <<
": found at bx " << bx <<
", whereas the latest allowed bx is " 2903 if (bx_readout == -1 || bx == bx_readout) {
2904 tmpV.push_back(*plct);
2905 if (bx_readout == -1) bx_readout = bx;
2908 else tmpV.push_back(*plct);
2915 std::vector<CSCCLCTDigi> tmpV;
2935 test_triad[distrip] = 3;
2936 test_triad[distrip+1] = 3;
2937 test_triad[distrip+2] = 3;
2938 test_triad[distrip+3] = 3;
2939 test_triad[distrip+4] = 3;
2940 test_triad[distrip+5] = 3;
2941 test_triad[distrip+6] = 3;
2942 test_triad[distrip+7] = 3;
2943 test_triad[distrip+8] = 3;
2944 test_triad[distrip+9] = 3;
2945 test_triad[distrip+10] = 2;
2947 test_time[distrip] = 4;
2948 test_time[distrip+1] = 10;
2949 test_time[distrip+2] = 2;
2950 test_time[distrip+3] = 0;
2951 test_time[distrip+4] = 6;
2952 test_time[distrip+5] = 8;
2953 test_time[distrip+6] = 10;
2954 test_time[distrip+7] = 1;
2955 test_time[distrip+8] = 8;
2956 test_time[distrip+9] = 5;
2957 test_time[distrip+10] = 6;
2959 std::cout <<
"\n ------------------------------------------------- \n";
2960 std::cout <<
"!!!!!!Testing distripStagger routine!!!!!!" << std::endl;
2961 std::cout <<
"Values before distripStagger routine:" << std::endl;
2962 for (
int i=distrip;
i<distrip+11;
i++){
2964 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2965 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2967 distripStagger(test_triad, test_time, test_digi, distrip, debug);
2968 std::cout <<
"Values after distripStagger routine:" << std::endl;
2969 for (
int i=distrip;
i<distrip+11;
i++){
2970 std::cout <<
"test_triad[" <<
i <<
"] = " << test_triad[
i];
2971 std::cout <<
" test_time[" <<
i <<
"] = " << test_time[
i] << std::endl;
2973 std::cout <<
"\n ------------------------------------------------- \n \n";
2978 for (
int ptn = 0; ptn < 8; ptn++) {
2979 for (
int bend = 0; bend < 2; bend++) {
2982 for (
int bx = 0; bx < 7; bx++) {
2983 for (
int stripType = 0; stripType < 2; stripType++) {
2986 key_strip, cfeb, bx);
2989 <<
"pattern mismatch: " << ptn <<
" " 2991 if (bend != thisLCT.
getBend())
2993 <<
"bend mismatch: " << bend <<
" " << thisLCT.
getBend();
2994 if (cfeb != thisLCT.
getCFEB())
2996 <<
"cfeb mismatch: " << cfeb <<
" " << thisLCT.
getCFEB();
2999 <<
"strip mismatch: " << key_strip <<
" " 3001 if (bx != thisLCT.
getBX())
3003 <<
"bx mismatch: " << bx <<
" " << thisLCT.
getBX();
3006 <<
"Strip Type mismatch: " << stripType <<
" " 3010 <<
"quality mismatch: " <<
quality <<
" " 3023 std::cout<<
" Printing patterns for Cathode LCT"<<std::endl;
3026 std::cout<<
" Pattern "<<patternNum<<
" ";
3036 if (patternNum == 0)
std::cout<<
" "<<layer<<
" ";
3044 minStrip = 3*layer - 2;
3068 for (
int possibleHits = 0; possibleHits < 65536; possibleHits++) {
3071 stripsHit[0][ 9].push_back(( possibleHits & 1 ) != 0);
3072 stripsHit[0][10].push_back(( possibleHits & 2 ) != 0);
3073 stripsHit[0][11].push_back(( possibleHits & 4 ) != 0);
3074 stripsHit[1][ 9].push_back(( possibleHits & 8 ) != 0);
3075 stripsHit[1][10].push_back(( possibleHits & 16 ) != 0);
3076 stripsHit[1][11].push_back(( possibleHits & 32 ) != 0);
3077 stripsHit[2][ 9].push_back(( possibleHits & 64 ) != 0);
3078 stripsHit[2][10].push_back(( possibleHits & 128 ) != 0);
3079 stripsHit[2][11].push_back(( possibleHits & 256 ) != 0);
3080 stripsHit[3][10].push_back(( possibleHits & 512 ) != 0);
3081 stripsHit[4][ 9].push_back(( possibleHits & 1024 ) != 0);
3082 stripsHit[4][10].push_back(( possibleHits & 2048 ) != 0);
3083 stripsHit[4][11].push_back(( possibleHits & 4096 ) != 0);
3084 stripsHit[5][ 9].push_back(( possibleHits & 8192 ) != 0);
3085 stripsHit[5][10].push_back(( possibleHits & 16384 ) != 0);
3086 stripsHit[5][11].push_back(( possibleHits & 32768 ) != 0);
3095 if (numLayersHit > 3 || !results.empty()) {
3096 std::cout<<
"Input "<<possibleHits<<
"/"<< 65536 <<
" # Found Patterns "<<results.size()<<std::endl<<
" ";
3102 if (!results.empty()) {
3103 int thePatternStrip =
strip - (results[0].getKeyStrip() - 2) + 3*layer;
3106 thePatternStrip -= 2;
3128 minStrip = 3*layer - 2;
3140 if (!stripsHit[layer][10].
empty()) {
3148 if (layer < static_cast<int>(results.size()) ) {
3163 if ((!stripsHit[layer][ 9].
empty()) ||
3164 (!stripsHit[layer][10].
empty()) ||
3165 (!stripsHit[layer][11].
empty()) ) number++;
int getQuality() const
return quality of a pattern (number of layers hit!)
static const unsigned int def_drift_delay
static const int pattern[CSCConstants::NUM_CLCT_PATTERNS_PRE_TMB07][CSCConstants::MAX_STRIPS_IN_PATTERN+1]
T getParameter(std::string const &) const
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
void setDefaultConfigParameters()
std::vector< CSCCLCTDigi > readoutCLCTs()
bool use_dead_time_zoning
unsigned int nplanes_hit_pretrig
static const unsigned int def_fifo_tbins
static void distripStagger(int stag_triad[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_time[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int stag_digi[CSCConstants::MAX_NUM_STRIPS_7CFEBS], int i_distrip, bool debug=false)
int getStrip() const
Get the strip number. Counts from 1.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int min_separation
static const int cfeb_strips[2]
unsigned int clctHitPersist() const
const unsigned theTrigChamber
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
unsigned int clctNplanesHitPattern() const
const unsigned theSubsector
void dumpConfigParams() const
const unsigned theStation
static const int pattern2007_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
static const unsigned int def_min_separation
unsigned int clctMinSeparation() const
int getComparator() const
Get Comparator readings. Can be 0 or 1.
unsigned int clctNplanesHitPretrig() const
static const unsigned int def_nplanes_hit_pretrig
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
static int ringFromTriggerLabels(int station, int triggerCSCID)
const CSCGeometry * csc_g
int getStripType() const
return striptype
unsigned int clctDriftDelay() const
int getBend() const
return bend
static const unsigned int def_pid_thresh_pretrig
unsigned int fifo_pretrig
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
bool preTrigLookUp(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, const unsigned int bx_time)
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int clctPidThreshPretrig() const
void latchLCTs(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keyStrip[CSCConstants::MAX_CFEBS], unsigned int nhits[CSCConstants::MAX_CFEBS], const int stripType, const int nStrips, const int bx_time)
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips) const
int getCFEB() const
return Key CFEB ID
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
void testDistripStagger()
static const unsigned int def_tmb_l1a_window_size
int getBX() const
return BX
bool getDigis(const CSCComparatorDigiCollection *compdc)
static const unsigned int def_nplanes_hit_pattern
Abs< T >::type abs(const T &t)
unsigned int pretrig_trig_zone
unsigned int clctFifoPretrig() const
bool preTrigger(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int stripType, const int nStrips, int &first_bx)
unsigned int clct_state_machine_zone
unsigned int nplanes_hit_pattern
void getPattern(int pattern_num, int strip_value[CSCConstants::MAX_STRIPS_IN_PATTERN], int bx_time, int &quality, int &bend)
bool ptnFinding(const unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, const unsigned int bx_time)
void priorityEncode(const int h_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int h_nhits[CSCConstants::MAX_CFEBS], const int d_keyStrip[CSCConstants::MAX_CFEBS], const unsigned int d_nhits[CSCConstants::MAX_CFEBS], int keystrip_data[2][7])
void checkConfigParameters()
static const unsigned int def_fifo_pretrig
int getPattern() const
return pattern
std::vector< int > thePreTriggerBXs
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
static const unsigned int def_hit_persist
std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int stripType)
int stagger[CSCConstants::NUM_LAYERS]
std::vector< CSCComparatorDigi >::const_iterator const_iterator
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
unsigned int clctFifoTbins() const
int findNumLayersHit(std::vector< int > stripsHit[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
bool hitIsGood(int hitTime, int BX)
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
void clear()
clear this CLCT
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
std::pair< const_iterator, const_iterator > Range
void readComparatorDigis(std::vector< int >halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], std::vector< int > distrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
unsigned int tmb_l1a_window_size
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, unsigned int pulse[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
void getKeyStripData(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], int keystrip_data[CSCConstants::NUM_HALF_STRIPS_7CFEBS][7], int nStrips, int first_bx, int &best_strip, int stripType)
static const int pre_hit_pattern[2][CSCConstants::MAX_STRIPS_IN_PATTERN]
std::vector< CSCCLCTDigi > findLCTsSLHC(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
unsigned int pid_thresh_pretrig
std::vector< CSCCLCTDigi > getCLCTs()
void setConfigParameters(const CSCDBL1TPParameters *conf)
bool dynamic_state_machine_zone
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.