CMS 3D CMS Logo

DTTSM Class Reference

Implementation of TSM trigger algorithm. More...

#include <L1Trigger/DTTriggerServerPhi/interface/DTTSM.h>

List of all members.

Public Member Functions

void addCand (DTTSCand *cand)
 Add a TSS candidate to the TSM, ifs is first/second track flag.
void clear ()
 Clear.
DTConfigTSPhiconfig () const
 Configuration set.
 DTTSM (int)
 Constructor.
DTTSCandgetDTTSCand (int ifs, unsigned n) const
 Return requested TS candidate.
DTTSCandgetTrack (int n) const
 Return the requested track.
const DTTracoTrigDatagetTracoT (int ifs, unsigned n) const
 Return requested TRACO trigger.
void ignoreSecondTrack ()
 Set a flag to skip sort2.
unsigned nCand (int ifs) const
 Return the number of input tracks (first/second).
int nFirstT () const
 Return the number of input first tracks.
int nSecondT () const
 Return the number of input second tracks.
int nTracks () const
 Return the number of sorted tracks.
int number () const
 Return identifier.
void run (int bkmod)
 Run the TSM algorithm.
void setConfig (DTConfigTSPhi *config)
 Set configuration.
DTTSCandsortTSM1 (int bkmod)
 Sort 1.
DTTSCandsortTSM2 (int bkmod)
 Sort 2.
 ~DTTSM ()
 Destructor.

Private Attributes

DTConfigTSPhi_config
int _ignoreSecondTrack
std::vector< DTTSCand * > _incand [2]
int _n
std::vector< DTTSCand * > _outcand


Detailed Description

Implementation of TSM trigger algorithm.

Date
2008/09/05 15:59:57
Revision
1.3

Author:
C. Grandi, D. Bonacorsi, S. Marcellini

Definition at line 40 of file DTTSM.h.


Constructor & Destructor Documentation

DTTSM::DTTSM ( int  n  ) 

Constructor.

Definition at line 38 of file DTTSM.cc.

References _incand, _outcand, and DTConfigTSPhi::NTSSTSM.

00038                   : _n(n), _ignoreSecondTrack(0) {
00039   // reserve the appropriate amount of space for vectors
00040   _incand[0].reserve(DTConfigTSPhi::NTSSTSM);
00041   _incand[1].reserve(DTConfigTSPhi::NTSSTSM);
00042   _outcand.reserve(2);
00043 }

DTTSM::~DTTSM (  ) 

Destructor.

Definition at line 49 of file DTTSM.cc.

References clear().

00049              {
00050   clear();
00051 }


Member Function Documentation

void DTTSM::addCand ( DTTSCand cand  ) 

Add a TSS candidate to the TSM, ifs is first/second track flag.

Definition at line 276 of file DTTSM.cc.

References _incand, and DTTSCand::isFirst().

Referenced by DTTSPhi::runTSPhi().

00276                              {
00277   // NEW DESIGN: DTTSM is not configurable!
00278   //  cand->resetCarry(); // reset carry information
00279   //  cand->setBitsTsm(); // set quality bits for DTTSM sorting
00280   _incand[(1-cand->isFirst())].push_back(cand); 
00281 }

void DTTSM::clear ( void   ) 

Clear.

Definition at line 59 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, and _outcand.

Referenced by ~DTTSM().

00059              {
00060   _ignoreSecondTrack=0;
00061   for(int itk=0;itk<=1;itk++){
00062     // content of _incand is deleted by DTTSPhi
00063     _incand[itk].clear();
00064   }
00065   // content of _outcand is deleted by DTTSPhi
00066   _outcand.clear(); 
00067 }

DTConfigTSPhi* DTTSM::config (  )  const [inline]

Configuration set.

Definition at line 77 of file DTTSM.h.

References _config.

Referenced by run(), sortTSM1(), and sortTSM2().

00077 { return _config; }

DTTSCand * DTTSM::getDTTSCand ( int  ifs,
unsigned  n 
) const

Return requested TS candidate.

Definition at line 295 of file DTTSM.cc.

References _incand, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), nCand(), and p.

Referenced by getTracoT().

00295                                             {
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 }

DTTSCand * DTTSM::getTrack ( int  n  )  const

Return the requested track.

Definition at line 326 of file DTTSM.cc.

References _outcand, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), nTracks(), and p.

Referenced by sortTSM2().

00326                            {
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 }

const DTTracoTrigData * DTTSM::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 311 of file DTTSM.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), getDTTSCand(), nCand(), and DTTSCand::tracoTr().

00311                                           {
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 }

void DTTSM::ignoreSecondTrack (  )  [inline]

Set a flag to skip sort2.

Definition at line 61 of file DTTSM.h.

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

00061 { _ignoreSecondTrack=1; }

unsigned DTTSM::nCand ( int  ifs  )  const

Return the number of input tracks (first/second).

Definition at line 284 of file DTTSM.cc.

References _incand, GenMuonPlsPt100GeV_cfg::cout, and lat::endl().

Referenced by getDTTSCand(), and getTracoT().

00284                           {
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 }

int DTTSM::nFirstT (  )  const [inline]

Return the number of input first tracks.

Definition at line 83 of file DTTSM.h.

References _incand.

Referenced by run().

00083 { return _incand[0].size(); }

int DTTSM::nSecondT (  )  const [inline]

Return the number of input second tracks.

Definition at line 86 of file DTTSM.h.

References _incand.

Referenced by run().

00086 { return _incand[1].size(); }

int DTTSM::nTracks (  )  const [inline]

Return the number of sorted tracks.

Definition at line 95 of file DTTSM.h.

References _outcand.

Referenced by getTrack(), and sortTSM2().

00095 { return _outcand.size(); }

int DTTSM::number (  )  const [inline]

Return identifier.

Definition at line 52 of file DTTSM.h.

References _n.

00052 { return _n; }

void DTTSM::run ( int  bkmod  ) 

Run the TSM algorithm.

Definition at line 70 of file DTTSM.cc.

References _incand, _outcand, begin, config(), GenMuonPlsPt100GeV_cfg::cout, debug, lat::endl(), first, nFirstT(), nSecondT(), p, edm::second(), sortTSM1(), and sortTSM2().

00070                     {
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; // skip if no first tracks
00078   //
00079   // SORT 1
00080   //
00081   
00082   // debugging
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   // end debugging
00091   
00092   
00093   DTTSCand* first=sortTSM1(bkmod);
00094   if(first!=0) {
00095     _outcand.push_back(first); 
00096   }
00097   if(nSecondT()<1)return; // skip if no second tracks
00098 
00099   //
00100   // SORT 2
00101   //
00102   
00103   // debugging
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   // end debugging
00112   
00113   DTTSCand* second=sortTSM2(bkmod);
00114   if(second!=0) {
00115     
00116     _outcand.push_back(second); 
00117   }
00118   
00119 }

void DTTSM::setConfig ( DTConfigTSPhi config  )  [inline]

Set configuration.

Definition at line 55 of file DTTSM.h.

References _config.

00055 {  _config=config; }

DTTSCand * DTTSM::sortTSM1 ( int  bkmod  ) 

Sort 1.

Definition at line 122 of file DTTSM.cc.

References _incand, funct::abs(), begin, config(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), DTTSCand::isCorr(), DTTSCand::isInner(), DTConfig::NTCTSS, p, DTTSCand::setBitsBkmod(), DTTSCand::setBitsTss(), DTTSCand::setSecondTrack(), DTTSCand::TcPos(), DTConfigTSPhi::TsmGhost1Flag(), and DTTSCand::tssNumber().

Referenced by run().

00122                          {
00123   // Do a sort 1
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 ) { // NORMAL mode ---> sorting on dataword
00131       curr->setBitsTss(); // maybe not necessary, as they are the same as for TSS in the default
00132     } else if( bkmod == 0) { //  { // BACKUP mode ---> sorting on modified dataword
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     } //else { }    
00152   }
00153   
00154   
00155   // Ghost 1 suppression: use carry only if not suppressed
00156   if(carry!=0) {   // A carry is present
00157     
00158     // Carry enabled if correlated and TRACO is next to best
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){ // Carry isn't always suppressed
00167       // check if adjacent DTTracoChips
00168       int adj = (carry->tssNumber()==best->tssNumber()+1 &&          //next DTTracoChip
00169                  best->TcPos()==DTConfigTSPhi::NTCTSS && carry->TcPos()==1 ) ||
00170         (carry->tssNumber()==best->tssNumber()-1 &&         // prev DTTracoChip
00171          best->TcPos()==1 && carry->TcPos()==DTConfigTSPhi::NTCTSS ) ||
00172         (carry->tssNumber()==best->tssNumber() &&           // same DTTracoChip
00173          abs(carry->TcPos()-best->TcPos())==1                     );   
00174       
00175       if(config()->TsmGhost1Flag()==0 ||          // Carry always enabled
00176          //       carry->isInner() ||                      // Carry is inner
00177          inner_or_corr ||                         // Carry is inner or corr
00178          !adj                          ) {        // Carry not adj. to best   
00179         // add carry to second tracks to for sort 2
00180         carry->setSecondTrack(); // change value of first/second track bit
00181         // NEW DESIGN: DTTSM is not configurable!
00182         // carry->setBitsTsm();     // set quality bits as for second tracks
00183         _incand[1].push_back(carry); // add to list of second tracks
00184       }
00185     }
00186   }
00187   // best->print();
00188   return best;
00189 }

DTTSCand * DTTSM::sortTSM2 ( int  bkmod  ) 

Sort 2.

curr->isInner() && // outer track

Definition at line 195 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, begin, config(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), getTrack(), DTTSCand::isCorr(), DTTSCand::isInner(), nTracks(), p, edm::second(), DTTSCand::setBitsBkmod(), DTTSCand::setBitsTss(), DTTSCand::TcPos(), DTConfigTSPhi::TsmGhost2Corr(), DTConfigTSPhi::TsmGhost2Flag(), and DTTSCand::tssNumber().

Referenced by run().

00195                          {
00196 
00197   // If second tracks are always suppressed skip processing
00198   if(config()->TsmGhost2Flag()==3)return 0;
00199   
00200   // Check if there are second tracks
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   // If a first track at the following BX is present, ignore second tracks of any kind
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   // If no first tracks at the following BX, do a sort 2
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     // ghost 2 suppression: skip track if suppressed
00223     // this is not needed if config of DTTSM == config of DTTSS
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){     // 2nd tracks not always enabled
00234       if(
00236          !inner_or_corr &&                    // outer and not corr
00237          (curr->tssNumber()==best->tssNumber() &&
00238           curr->TcPos()==best->TcPos()) ) { // same correlator of 1st track
00239         if(config()->TsmGhost2Flag()==2 ||    // do not look to corr bit of 1st
00240            (!best->isCorr() ) &&  config()->TsmGhost2Flag()!=4 || // skip if best is not corr
00241            (!best->isCorr() ) &&  best->isInner() && config()->TsmGhost2Flag()==4 )   // skip only if best is inner and not corr
00242           {                 
00243             continue;                             // skip track
00244           }
00245       }
00246     }
00247     
00248     // added DBSM
00249     // SM double TSM    if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
00250     if ( bkmod == 1 ) { // NORMAL mode ---> sorting on dataword
00251       curr->setBitsTss(); // maybe not necessary, as they are the same as for TSS in the default
00252     } else if( bkmod == 0) { //  { // BACKUP mode ---> sorting on modified dataword
00253       curr->setBitsBkmod();
00254     } else {
00255       std::cout << " DTTSM::sortTSM2 bkmod not properly assigned!" << std::endl;
00256     }
00257     
00258     
00259     
00260     // added DBSM
00261     // SM double TSM    if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
00262     
00263     if(second==0){
00264       second=curr;
00265     } 
00266     else if((*curr)<(*second)){
00267       second=curr;
00268     }  
00269   }
00270   return second;
00271 }


Member Data Documentation

DTConfigTSPhi* DTTSM::_config [private]

Definition at line 102 of file DTTSM.h.

Referenced by config(), and setConfig().

int DTTSM::_ignoreSecondTrack [private]

Definition at line 116 of file DTTSM.h.

Referenced by clear(), ignoreSecondTrack(), and sortTSM2().

std::vector<DTTSCand*> DTTSM::_incand[2] [private]

Definition at line 110 of file DTTSM.h.

Referenced by addCand(), clear(), DTTSM(), getDTTSCand(), nCand(), nFirstT(), nSecondT(), run(), sortTSM1(), and sortTSM2().

int DTTSM::_n [private]

Definition at line 107 of file DTTSM.h.

Referenced by number().

std::vector<DTTSCand*> DTTSM::_outcand [private]

Definition at line 113 of file DTTSM.h.

Referenced by clear(), DTTSM(), getTrack(), nTracks(), and run().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:19:10 2009 for CMSSW by  doxygen 1.5.4