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
00020 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSM.h"
00021
00022
00023
00024
00025 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigTSPhi.h"
00026 #include "L1Trigger/DTTriggerServerPhi/interface/DTTSCand.h"
00027
00028
00029
00030
00031 #include <iostream>
00032 #include <algorithm>
00033
00034
00035
00036
00037
00038 DTTSM::DTTSM(int n) : _n(n), _ignoreSecondTrack(0) {
00039
00040 _incand[0].reserve(DTConfigTSPhi::NTSSTSM);
00041 _incand[1].reserve(DTConfigTSPhi::NTSSTSM);
00042 _outcand.reserve(2);
00043 }
00044
00045
00046
00047
00048
00049 DTTSM::~DTTSM(){
00050 clear();
00051 }
00052
00053
00054
00055
00056
00057
00058 void
00059 DTTSM::clear() {
00060 _ignoreSecondTrack=0;
00061 for(int itk=0;itk<=1;itk++){
00062
00063 _incand[itk].clear();
00064 }
00065
00066 _outcand.clear();
00067 }
00068
00069 void
00070 DTTSM::run(int bkmod) {
00071
00072 if(config()->debug()){
00073 std::cout << "DTTSM::run: Processing DTTSM: ";
00074 std::cout << nFirstT() << " first & " << nSecondT() << " second tracks" << std::endl;
00075 }
00076
00077 if(nFirstT()<1)return;
00078
00079
00080
00081
00082
00083 if(config()->debug()){
00084 std::cout << "Vector of first tracks in DTTSM: " << std::endl;
00085 std::vector<DTTSCand*>::const_iterator p;
00086 for(p=_incand[0].begin(); p!=_incand[0].end(); p++) {
00087 (*p)->print();
00088 }
00089 }
00090
00091
00092
00093 DTTSCand* first=sortTSM1(bkmod);
00094 if(first!=0) {
00095 _outcand.push_back(first);
00096 }
00097 if(nSecondT()<1)return;
00098
00099
00100
00101
00102
00103
00104 if(config()->debug()){
00105 std::vector<DTTSCand*>::const_iterator p;
00106 std::cout << "Vector of second tracks (including carry) in DTTSM: " << std::endl;
00107 for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
00108 (*p)->print();
00109 }
00110 }
00111
00112
00113 DTTSCand* second=sortTSM2(bkmod);
00114 if(second!=0) {
00115
00116 _outcand.push_back(second);
00117 }
00118
00119 }
00120
00121 DTTSCand*
00122 DTTSM::sortTSM1(int bkmod) {
00123
00124 DTTSCand* best=0;
00125 DTTSCand* carry=0;
00126 std::vector<DTTSCand*>::iterator p;
00127 for(p=_incand[0].begin(); p!=_incand[0].end(); p++) {
00128 DTTSCand* curr=(*p);
00129
00130 if ( bkmod == 1 ) {
00131 curr->setBitsTss();
00132 } else if( bkmod == 0) {
00133 curr->setBitsBkmod();
00134 } else {
00135 std::cout << "DTTSM::sortTSM1: bkmod not properly assigned!" << std::endl;
00136 }
00137
00138
00139 if(best==0){
00140 best=curr;
00141 }
00142 else if((*curr)<(*best)){
00143 carry=best;
00144 best=curr;
00145 }
00146 else if(carry==0){
00147 carry=curr;
00148 }
00149 else if((*curr)<(*carry)){
00150 carry=curr;
00151 }
00152 }
00153
00154
00155
00156 if(carry!=0) {
00157
00158
00159 bool inner_or_corr;
00160 if(config()->TsmGhost1Corr()) {
00161 inner_or_corr=carry->isInner() || carry->isCorr();
00162 } else {
00163 inner_or_corr=carry->isInner();
00164 }
00165
00166 if(config()->TsmGhost1Flag()<2){
00167
00168 int adj = (carry->tssNumber()==best->tssNumber()+1 &&
00169 best->TcPos()==DTConfigTSPhi::NTCTSS && carry->TcPos()==1 ) ||
00170 (carry->tssNumber()==best->tssNumber()-1 &&
00171 best->TcPos()==1 && carry->TcPos()==DTConfigTSPhi::NTCTSS ) ||
00172 (carry->tssNumber()==best->tssNumber() &&
00173 abs(carry->TcPos()-best->TcPos())==1 );
00174
00175 if(config()->TsmGhost1Flag()==0 ||
00176
00177 inner_or_corr ||
00178 !adj ) {
00179
00180 carry->setSecondTrack();
00181
00182
00183 _incand[1].push_back(carry);
00184 }
00185 }
00186 }
00187
00188 return best;
00189 }
00190
00191
00192
00193
00194 DTTSCand*
00195 DTTSM::sortTSM2(int bkmod) {
00196
00197
00198 if(config()->TsmGhost2Flag()==3)return 0;
00199
00200
00201 if(nTracks()<1){
00202 std::cout << "DTTSM::sortTSM2: called with no first track.";
00203 std::cout << " empty pointer returned!" << std::endl;
00204 return 0;
00205 }
00206
00207
00208 if(_ignoreSecondTrack){
00209 std::vector<DTTSCand*>::iterator p;
00210 for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
00211 if((*p)->isCarry()) return (*p);
00212 }
00213 return 0;
00214 }
00215
00216
00217 DTTSCand* best=getTrack(1);
00218 DTTSCand* second=0;
00219 std::vector<DTTSCand*>::iterator p;
00220 for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
00221 DTTSCand* curr=(*p);
00222
00223
00224
00225 bool inner_or_corr;
00226 if(config()->TsmGhost2Corr())
00227 {inner_or_corr=curr->isInner() || curr->isCorr();
00228 }
00229 else
00230 {inner_or_corr=curr->isInner();
00231 }
00232
00233 if(config()->TsmGhost2Flag()!=0){
00234 if(
00236 !inner_or_corr &&
00237 (curr->tssNumber()==best->tssNumber() &&
00238 curr->TcPos()==best->TcPos()) ) {
00239 if(config()->TsmGhost2Flag()==2 ||
00240 ( (!best->isCorr() ) && config()->TsmGhost2Flag()!=4 ) ||
00241 ( (!best->isCorr() ) && best->isInner() && config()->TsmGhost2Flag()==4) )
00242 {
00243 continue;
00244 }
00245 }
00246 }
00247
00248
00249
00250 if ( bkmod == 1 ) {
00251 curr->setBitsTss();
00252 } else if( bkmod == 0) {
00253 curr->setBitsBkmod();
00254 } else {
00255 std::cout << " DTTSM::sortTSM2 bkmod not properly assigned!" << std::endl;
00256 }
00257
00258
00259
00260
00261
00262
00263 if(second==0){
00264 second=curr;
00265 }
00266 else if((*curr)<(*second)){
00267 second=curr;
00268 }
00269 }
00270 return second;
00271 }
00272
00273
00274
00275 void
00276 DTTSM::addCand(DTTSCand* cand) {
00277
00278
00279
00280 _incand[(1-cand->isFirst())].push_back(cand);
00281 }
00282
00283 unsigned
00284 DTTSM::nCand(int ifs) const {
00285 if(ifs<1||ifs>2){
00286 std::cout << "DTTSM::nCand: wrong track number: " << ifs;
00287 std::cout << " 0 returned!" << std::endl;
00288 return 0;
00289 }
00290
00291 return _incand[ifs-1].size();
00292 }
00293
00294 DTTSCand*
00295 DTTSM::getDTTSCand(int ifs, unsigned n) const {
00296 if(ifs<1||ifs>2){
00297 std::cout << "DTTSM::getDTTSCand: wrong track number: " << ifs;
00298 std::cout << " empty pointer returned!" << std::endl;
00299 return 0;
00300 }
00301 if(n<1 || n>nCand(ifs)) {
00302 std::cout << "DTTSM::getDTTSCand: requested trigger not present: " << n;
00303 std::cout << " empty pointer returned!" << std::endl;
00304 return 0;
00305 }
00306 std::vector<DTTSCand*>::const_iterator p = _incand[ifs-1].begin()+n-1;
00307 return (*p);
00308 }
00309
00310 const DTTracoTrigData*
00311 DTTSM::getTracoT(int ifs, unsigned n) const {
00312 if(ifs<1||ifs>2){
00313 std::cout << "DTTSM::getTracoT: wrong track number: " << ifs;
00314 std::cout << " empty pointer returned!" << std::endl;
00315 return 0;
00316 }
00317 if(n<1 || n>nCand(ifs)) {
00318 std::cout << "DTTSM::getTracoT: requested trigger not present: " << n;
00319 std::cout << " empty pointer returned!" << std::endl;
00320 return 0;
00321 }
00322 return getDTTSCand(ifs, n)->tracoTr();
00323 }
00324
00325 DTTSCand*
00326 DTTSM::getTrack(int n) const {
00327
00328 if(n<1 || n>nTracks()) {
00329 std::cout << "DTTSM::getTrack: requested track not present: " << n;
00330 std::cout << " empty pointer returned!" << std::endl;
00331 return 0;
00332 }
00333 std::vector<DTTSCand*>::const_iterator p = _outcand.begin()+n-1;
00334 return (*p);
00335 }
00336
00337
00338
00339
00340
00341