Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSS.h"
00020
00021
00022
00023
00024 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSCand.h"
00025 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTSPhi.h"
00026
00027
00028
00029
00030 #include <iostream>
00031 #include <algorithm>
00032
00033
00034
00035
00036 DTTSS::DTTSS(int n) : _n(n), _ignoreSecondTrack(0) {
00037
00038
00039
00040
00041
00042 _logWord1 = "1/----";
00043 _logWord2 = "2/----";
00044
00045 }
00046
00047
00048
00049
00050
00051 DTTSS::~DTTSS(){
00052 clear();
00053 }
00054
00055
00056
00057
00058
00059
00060 void
00061 DTTSS::clear() {
00062 _ignoreSecondTrack=0;
00063 for(int itk=0;itk<=1;itk++){
00064
00065 _tctrig[itk].clear();
00066 }
00067
00068 _outcand.clear();
00069
00070
00071 _logWord1 = "1/----";
00072 _logWord2 = "2/----";
00073 }
00074
00075 void
00076 DTTSS::run() {
00077
00078 if(config()->debug()){
00079 std::cout << "DTTSS::run: Processing DTTSS number " << _n << " : ";
00080 std::cout << nFirstT() << " first & " << nSecondT() << " second tracks" << std::endl;
00081 }
00082
00083 if(nFirstT()<1)return;
00084
00085
00086
00087
00088 if(config()->debug()){
00089 std::cout << "Vector of first tracks in DTTSS: " << std::endl;
00090 std::vector<DTTSCand*>::const_iterator p;
00091 for(p=_tctrig[0].begin(); p!=_tctrig[0].end(); p++) {
00092 (*p)->print();
00093 }
00094 }
00095
00096
00097 DTTSCand* first=sortTSS1();
00098 if(first!=0) {
00099 _outcand.push_back(first);
00100 }
00101
00102 if(nSecondT()<1)return;
00103
00104
00105
00106
00107 if(config()->debug()){
00108 std::vector<DTTSCand*>::const_iterator p;
00109 std::cout << "Vector of second tracks (including carry) in DTTSS: " << std::endl;
00110 for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
00111 (*p)->print();
00112 }
00113 }
00114
00115
00116 DTTSCand* second=sortTSS2();
00117 if(second!=0) {
00118 _outcand.push_back(second);
00119 }
00120
00121 }
00122
00123 DTTSCand*
00124 DTTSS::sortTSS1() {
00125
00126
00127 DTTSCand* best=0;
00128 DTTSCand* carry=0;
00129 std::vector<DTTSCand*>::iterator p;
00130 for(p=_tctrig[0].begin(); p!=_tctrig[0].end(); p++) {
00131 DTTSCand* curr= (*p) ? (*p) : 0;
00132
00133 curr->setBitsTss();
00134 if(curr->dataword()==0x1ff)continue;
00135 _logWord1[1+curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
00136
00137 if(best==0){
00138 best=curr;
00139 }
00140 else if((*curr)<=(*best)){
00141 carry=best;
00142 best=curr;
00143 }
00144 else if(carry==0){
00145 carry=curr;
00146 }
00147 else if((*curr)<=(*carry)){
00148 carry=curr;
00149 }
00150 }
00151
00152
00153
00154 if(carry!=0) {
00155
00156
00157 bool inner_or_corr;
00158 if(config()->TssGhost1Corr())
00159 {inner_or_corr=carry->isInner() || carry->isCorr();
00160
00161 }
00162 else
00163 {inner_or_corr=carry->isInner();
00164
00165 }
00166 if(config()->TssGhost1Flag()<2 && (
00167 config()->TssGhost1Flag()==0 ||
00168
00169 inner_or_corr ||
00170 abs(carry->TcPos()-best->TcPos())!=1)
00171 ) {
00172
00173 carry->setSecondTrack();
00174 carry->setBitsTss();
00175 _tctrig[1].push_back(carry);
00176 } else {
00177 _logWord1[1+carry->TcPos()] = 'g';
00178 }
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 return best;
00198
00199 }
00200
00201 DTTSCand*
00202 DTTSS::sortTSS2() {
00203
00204
00205 if(nTracks()<1){
00206 std::cout << "DTTSS::DTTSSsort2: called with no first track.";
00207 std::cout << " empty pointer returned!" << std::endl;
00208 return 0;
00209 }
00210
00211 if(_ignoreSecondTrack){
00212
00213
00214
00215
00216
00217
00218
00219 std::vector<DTTSCand*>::iterator p;
00220 for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
00221 if(!(*p)->isCarry())_logWord2[1+(*p)->TcPos()] = 'o';
00222 return 0;
00223 }
00224
00225
00226 if(config()->TssGhost2Flag()==3) {
00227
00228 std::vector<DTTSCand*>::iterator p;
00229 for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
00230 _logWord2[1+(*p)->TcPos()] = 'G';
00231 return 0;
00232 }
00233
00234
00235 DTTSCand* best=getTrack(1);
00236 DTTSCand* second=0;
00237 std::vector<DTTSCand*>::iterator p;
00238 for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
00239 DTTSCand* curr=(*p);
00240
00241 curr->setBitsTss();
00242
00243 if(!curr->isCarry()) {
00244 _logWord2[1+curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
00245 if(curr->dataword()==0x1ff)continue;
00246 }
00247
00248 if(config()->TssGhost2Flag()!=0){
00249
00250 bool inner_or_corr;
00251 if(config()->TssGhost2Corr())
00252 {inner_or_corr=curr->isInner() || curr->isCorr();
00253
00254 }
00255 else
00256 {inner_or_corr=curr->isInner();
00257
00258 }
00259
00260 if(
00262 !inner_or_corr &&
00263 curr->TcPos()==best->TcPos()) {
00264 if(config()->TssGhost2Flag()==2 ||
00265 ( (!best->isCorr() ) && config()->TssGhost2Flag()!=4) ||
00266 ( (!best->isCorr() ) && best->isInner() && config()->TssGhost2Flag()==4) )
00267 {
00268 _logWord2[1+curr->TcPos()] = 'G';
00269
00270 continue;
00271 }
00272 }
00273 }
00274 if(second==0){
00275 second=curr;
00276 }
00277 else if((*curr)<=(*second)){
00278 second=curr;
00279 }
00280 }
00281
00282
00283
00284
00285 return second;
00286
00287 }
00288
00289 void
00290 DTTSS::addDTTSCand(DTTSCand* cand) {
00291 int ifs = (cand->isFirst()) ? 0 : 1;
00292
00293 _tctrig[ifs].push_back(cand);
00294 }
00295
00296 unsigned
00297 DTTSS::nTracoT(int ifs) const {
00298 if(ifs<1||ifs>2){
00299 std::cout << "DTTSS::nTracoT: wrong track number: " << ifs;
00300 std::cout << " 0 returned!" << std::endl;
00301 return 0;
00302 }
00303 return _tctrig[ifs-1].size();
00304 }
00305
00306 DTTSCand*
00307 DTTSS::getDTTSCand(int ifs, unsigned n) const {
00308 if(ifs<1||ifs>2){
00309 std::cout << "DTTSS::getDTTSCand: wrong track number: " << ifs;
00310 std::cout << " empty pointer returned!" << std::endl;
00311 return 0;
00312 }
00313 if(n<1 || n>nTracoT(ifs)) {
00314 std::cout << "DTTSS::getDTTSCand: requested trigger not present: " << n;
00315 std::cout << " empty pointer returned!" << std::endl;
00316 return 0;
00317 }
00318 std::vector<DTTSCand*>::const_iterator p=_tctrig[ifs-1].begin()+n-1;
00319 return (*p);
00320 }
00321
00322 const DTTracoTrigData*
00323 DTTSS::getTracoT(int ifs, unsigned n) const {
00324 if(ifs<1||ifs>2){
00325 std::cout << "DTTSS::getTracoT: wrong track number: " << ifs;
00326 std::cout << " empty pointer returned!" << std::endl;
00327 return 0;
00328 }
00329 if(n<1 || n>nTracoT(ifs)) {
00330 std::cout << "DTTSS::getTracoT: requested trigger not present: " << n;
00331 std::cout << " empty pointer returned!" << std::endl;
00332 return 0;
00333 }
00334 return getDTTSCand(ifs, n)->tracoTr();
00335 }
00336
00337 DTTSCand*
00338 DTTSS::getTrack(int n) const {
00339 if(n<1 || n>nTracks()) {
00340 std::cout << "DTTSS::getTrack: requested track not present: " << n;
00341 std::cout << " empty pointer returned!" << std::endl;
00342 return 0;
00343 }
00344 std::vector<DTTSCand*>::const_iterator p = _outcand.begin()+n-1;
00345 return (*p);
00346 }
00347
00348 DTTSCand*
00349 DTTSS::getCarry() const {
00350 std::vector<DTTSCand*>::const_iterator p;
00351 for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
00352 if((*p)->isCarry()) return (*p);
00353 return 0;
00354 }
00355
00356 std::string
00357 DTTSS::logWord(int n) const {
00358 std::string lw = "";
00359 switch (n) {
00360 case 1:
00361 lw = _logWord1; break;
00362 case 2:
00363 lw = _logWord2; break;
00364 default:
00365 std::cout << "DTTSS::logWord: requested track not present: " << n;
00366 std::cout << " empty string returned!" << std::endl;
00367 }
00368 return lw;
00369 }
00370
00371
00372
00373
00374