File indexing completed on 2024-04-06 12:19:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "L1Trigger/DTSectorCollector/interface/DTSC.h"
0022
0023
0024
0025
0026 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigSectColl.h"
0027 #include "L1Trigger/DTSectorCollector/interface/DTSectColl.h"
0028 #include "L1Trigger/DTSectorCollector/interface/DTSectCollPhCand.h"
0029 #include "L1Trigger/DTSectorCollector/interface/DTSectCollThCand.h"
0030
0031
0032
0033
0034 #include <iostream>
0035 #include <algorithm>
0036
0037
0038
0039
0040
0041 DTSC::DTSC(int istat) : _ignoreSecondTrack(0), _stat(istat) {
0042
0043
0044
0045
0046 }
0047
0048
0049
0050
0051 DTSC::~DTSC() { clear(); }
0052
0053
0054
0055
0056
0057 void DTSC::clear() {
0058 _ignoreSecondTrack = 0;
0059
0060 for (int itk = 0; itk <= 1; itk++) {
0061 _incand_ph[itk].clear();
0062 }
0063
0064 _outcand_ph.clear();
0065 _cand_th.clear();
0066 }
0067
0068
0069 void DTSC::run() {
0070 if (config()->debug()) {
0071 std::cout << "DTSC::run: Processing DTSectColl: ";
0072 std::cout << nFirstTPh() << " first & " << nSecondTPh() << " second Phi tracks ";
0073 std::cout << " - " << nCandTh() << " Theta tracks" << std::endl;
0074 }
0075
0076 if (nFirstTPh() < 1)
0077 return;
0078
0079
0080
0081
0082
0083 if (config()->debug()) {
0084 std::cout << "Vector of first Phi tracks in DTSectColl: " << std::endl;
0085 std::vector<DTSectCollPhCand*>::const_iterator p;
0086 for (p = _incand_ph[0].begin(); p != _incand_ph[0].end(); p++) {
0087 (*p)->print();
0088 }
0089 }
0090
0091
0092 DTSectCollPhCand* first = DTSectCollsort1();
0093 if (config()->debug()) {
0094 std::cout << "SC: DTSC::run: first Phi track is = " << first << std::endl;
0095 }
0096 if (first != nullptr) {
0097 _outcand_ph.push_back(first);
0098 }
0099 if (nSecondTPh() < 1)
0100 return;
0101
0102
0103
0104
0105
0106
0107 if (config()->debug()) {
0108 std::vector<DTSectCollPhCand*>::const_iterator p;
0109 std::cout << "Vector of second Phi tracks in DTSectColl: " << std::endl;
0110 for (p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
0111 (*p)->print();
0112 }
0113 }
0114
0115
0116 DTSectCollPhCand* second = DTSectCollsort2();
0117 if (second != nullptr) {
0118 _outcand_ph.push_back(second);
0119 }
0120 }
0121
0122 DTSectCollPhCand* DTSC::DTSectCollsort1() {
0123
0124 DTSectCollPhCand* best = nullptr;
0125 DTSectCollPhCand* carry = nullptr;
0126 std::vector<DTSectCollPhCand*>::iterator p;
0127 for (p = _incand_ph[0].begin(); p != _incand_ph[0].end(); p++) {
0128 DTSectCollPhCand* curr = (*p);
0129
0130 curr->setBitsSectColl();
0131
0132
0133 if (config()->SCGetCarryFlag(_stat)) {
0134
0135 if (best == nullptr) {
0136 best = curr;
0137 } else if ((*curr) < (*best)) {
0138 carry = best;
0139 best = curr;
0140 } else if (carry == nullptr) {
0141 carry = curr;
0142 } else if ((*curr) < (*carry)) {
0143 carry = curr;
0144 }
0145
0146 } else if (config()->SCGetCarryFlag(_stat) == 0) {
0147 if (best == nullptr) {
0148 best = curr;
0149 } else if ((*curr) < (*best)) {
0150 best = curr;
0151 }
0152 }
0153
0154 if (carry != nullptr && config()->SCGetCarryFlag(_stat)) {
0155 carry->setSecondTrack();
0156 _incand_ph[1].push_back(carry);
0157 }
0158 }
0159
0160 return best;
0161 }
0162
0163 DTSectCollPhCand* DTSC::DTSectCollsort2() {
0164
0165
0166 if (nTracksPh() < 1) {
0167 std::cout << "DTSC::DTSectCollsort2: called with no first Phi track.";
0168 std::cout << " empty pointer returned!" << std::endl;
0169 return nullptr;
0170 }
0171
0172 if (_ignoreSecondTrack) {
0173 for (std::vector<DTSectCollPhCand*>::iterator p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
0174 }
0175 return nullptr;
0176 }
0177
0178
0179
0180 DTSectCollPhCand* second = nullptr;
0181 std::vector<DTSectCollPhCand*>::iterator p;
0182 for (p = _incand_ph[1].begin(); p != _incand_ph[1].end(); p++) {
0183 DTSectCollPhCand* curr = (*p);
0184 curr->setBitsSectColl();
0185
0186 if (second == nullptr) {
0187 second = curr;
0188 } else if ((*curr) < (*second)) {
0189 second = curr;
0190 }
0191 }
0192
0193 return second;
0194 }
0195
0196 void DTSC::addPhCand(DTSectCollPhCand* cand) { _incand_ph[(1 - cand->isFirst())].push_back(cand); }
0197
0198 void DTSC::addThCand(DTSectCollThCand* cand) { _cand_th.push_back(cand); }
0199
0200 unsigned DTSC::nCandPh(int ifs) const {
0201 if (ifs < 1 || ifs > 2) {
0202 std::cout << "DTSC::nCandPh: wrong track number: " << ifs;
0203 std::cout << " 0 returned!" << std::endl;
0204 return 0;
0205 }
0206 return _incand_ph[ifs - 1].size();
0207 }
0208
0209 unsigned DTSC::nCandTh() const { return _cand_th.size(); }
0210
0211 DTSectCollPhCand* DTSC::getDTSectCollPhCand(int ifs, unsigned n) const {
0212 if (ifs < 1 || ifs > 2) {
0213 std::cout << "DTSC::getDTSectCollPhCand: wrong track number: " << ifs;
0214 std::cout << " empty pointer returned!" << std::endl;
0215 return nullptr;
0216 }
0217 if (n < 1 || n > nCandPh(ifs)) {
0218 std::cout << "DTSC::getDTSectCollPhCand: requested trigger not present: " << n;
0219 std::cout << " empty pointer returned!" << std::endl;
0220 return nullptr;
0221 }
0222
0223 std::vector<DTSectCollPhCand*>::const_iterator p = _incand_ph[ifs - 1].begin() + n - 1;
0224 return (*p);
0225 }
0226
0227 DTSectCollThCand* DTSC::getDTSectCollThCand(unsigned n) const {
0228 if (n < 1 || n > nCandTh()) {
0229 std::cout << "DTSC::getDTSectCollThCand: requested trigger not present: " << n;
0230 std::cout << " empty pointer returned!" << std::endl;
0231 return nullptr;
0232 }
0233
0234 std::vector<DTSectCollThCand*>::const_iterator p = _cand_th.begin() + n - 1;
0235 return (*p);
0236 }
0237
0238 void DTSC::addDTSectCollPhCand(DTSectCollPhCand* cand) {
0239 int ifs = (cand->isFirst()) ? 0 : 1;
0240
0241 _incand_ph[ifs].push_back(cand);
0242 }
0243
0244 DTSectCollPhCand* DTSC::getTrackPh(int n) const {
0245 if (n < 1 || n > nTracksPh()) {
0246 std::cout << "DTSC::getTrackPh: requested track not present: " << n;
0247 std::cout << " empty pointer returned!" << std::endl;
0248 return nullptr;
0249 }
0250
0251 std::vector<DTSectCollPhCand*>::const_iterator p = _outcand_ph.begin() + n - 1;
0252
0253 return (*p);
0254 }
0255
0256 DTSectCollThCand* DTSC::getTrackTh(int n) const {
0257 if (n < 1 || n > nTracksTh()) {
0258 std::cout << "DTSC::getTrackTh: requested track not present: " << n;
0259 std::cout << " empty pointer returned!" << std::endl;
0260 return nullptr;
0261 }
0262
0263 std::vector<DTSectCollThCand*>::const_iterator p = _cand_th.begin() + n - 1;
0264
0265 return (*p);
0266 }