CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTTSM Class Reference

#include <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.

                  : _n(n), _ignoreSecondTrack(0) {
  // reserve the appropriate amount of space for vectors
  _incand[0].reserve(DTConfigTSPhi::NTSSTSM);
  _incand[1].reserve(DTConfigTSPhi::NTSSTSM);
  _outcand.reserve(2);
}
DTTSM::~DTTSM ( )

Destructor.

Definition at line 49 of file DTTSM.cc.

References clear().

             {
  clear();
}

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().

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

Clear.

Definition at line 59 of file DTTSM.cc.

References _ignoreSecondTrack, _incand, and _outcand.

Referenced by ~DTTSM().

             {
  _ignoreSecondTrack=0;
  for(int itk=0;itk<=1;itk++){
    // content of _incand is deleted by DTTSPhi
    _incand[itk].clear();
  }
  // content of _outcand is deleted by DTTSPhi
  _outcand.clear(); 
}
DTConfigTSPhi* DTTSM::config ( void  ) const [inline]

Configuration set.

Definition at line 77 of file DTTSM.h.

References _config.

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

{ return _config; }
DTTSCand * DTTSM::getDTTSCand ( int  ifs,
unsigned  n 
) const

Return requested TS candidate.

Definition at line 295 of file DTTSM.cc.

References _incand, gather_cfg::cout, n, nCand(), and L1TEmulatorMonitor_cff::p.

Referenced by getTracoT().

                                            {
  if(ifs<1||ifs>2){
    std::cout << "DTTSM::getDTTSCand: wrong track number: " << ifs;
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  if(n<1 || n>nCand(ifs)) {
    std::cout << "DTTSM::getDTTSCand: requested trigger not present: " << n;
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  std::vector<DTTSCand*>::const_iterator p = _incand[ifs-1].begin()+n-1;
  return (*p);
}
DTTSCand * DTTSM::getTrack ( int  n) const

Return the requested track.

Definition at line 326 of file DTTSM.cc.

References _outcand, gather_cfg::cout, n, nTracks(), and L1TEmulatorMonitor_cff::p.

Referenced by sortTSM2().

                           {

  if(n<1 || n>nTracks()) {
    std::cout << "DTTSM::getTrack: requested track not present: " << n;
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  std::vector<DTTSCand*>::const_iterator p = _outcand.begin()+n-1;
  return (*p);
}
const DTTracoTrigData * DTTSM::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 311 of file DTTSM.cc.

References gather_cfg::cout, getDTTSCand(), n, nCand(), and DTTSCand::tracoTr().

                                          {
  if(ifs<1||ifs>2){
    std::cout << "DTTSM::getTracoT: wrong track number: " << ifs;
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  if(n<1 || n>nCand(ifs)) {
    std::cout << "DTTSM::getTracoT: requested trigger not present: " << n;
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  return getDTTSCand(ifs, n)->tracoTr();
}
void DTTSM::ignoreSecondTrack ( ) [inline]

Set a flag to skip sort2.

Definition at line 61 of file DTTSM.h.

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

unsigned DTTSM::nCand ( int  ifs) const

Return the number of input tracks (first/second)

Definition at line 284 of file DTTSM.cc.

References _incand, and gather_cfg::cout.

Referenced by getDTTSCand(), and getTracoT().

                          {
  if(ifs<1||ifs>2){
    std::cout << "DTTSM::nCand: wrong track number: " << ifs;
    std::cout << " 0 returned!" << std::endl;
    return 0;
  }

  return _incand[ifs-1].size();
}
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().

{ 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().

{ 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().

{ return _outcand.size(); }
int DTTSM::number ( ) const [inline]

Return identifier.

Definition at line 52 of file DTTSM.h.

References _n.

{ return _n; }
void DTTSM::run ( int  bkmod)

Run the TSM algorithm.

Definition at line 70 of file DTTSM.cc.

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

                    {
  
  if(config()->debug()){
    std::cout << "DTTSM::run: Processing DTTSM: ";
    std::cout << nFirstT() << " first & " << nSecondT() << " second tracks" << std::endl;
  }
  
  if(nFirstT()<1)return; // skip if no first tracks
  //
  // SORT 1
  //
  
  // debugging
  if(config()->debug()){
    std::cout << "Vector of first tracks in DTTSM: " << std::endl;
    std::vector<DTTSCand*>::const_iterator p;
    for(p=_incand[0].begin(); p!=_incand[0].end(); p++) {
      (*p)->print();
    }
  }
  // end debugging
  
  
  DTTSCand* first=sortTSM1(bkmod);
  if(first!=0) {
    _outcand.push_back(first); 
  }
  if(nSecondT()<1)return; // skip if no second tracks

  //
  // SORT 2
  //
  
  // debugging
  if(config()->debug()){
    std::vector<DTTSCand*>::const_iterator p;
    std::cout << "Vector of second tracks (including carry) in DTTSM: " << std::endl;
    for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
      (*p)->print();
    }
  }
  // end debugging
  
  DTTSCand* second=sortTSM2(bkmod);
  if(second!=0) {
    
    _outcand.push_back(second); 
  }
  
}
void DTTSM::setConfig ( DTConfigTSPhi config) [inline]

Set configuration.

Definition at line 55 of file DTTSM.h.

References _config, and config().

DTTSCand * DTTSM::sortTSM1 ( int  bkmod)

Sort 1.

Definition at line 122 of file DTTSM.cc.

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

Referenced by run().

                         {
  // Do a sort 1
  DTTSCand* best=0;
  DTTSCand* carry=0;
  std::vector<DTTSCand*>::iterator p;
  for(p=_incand[0].begin(); p!=_incand[0].end(); p++) {
    DTTSCand* curr=(*p);
    
    if ( bkmod == 1 ) { // NORMAL mode ---> sorting on dataword
      curr->setBitsTss(); // maybe not necessary, as they are the same as for TSS in the default
    } else if( bkmod == 0) { //  { // BACKUP mode ---> sorting on modified dataword
      curr->setBitsBkmod();
    } else {
      std::cout << "DTTSM::sortTSM1:  bkmod not properly assigned!" << std::endl;
    }
    
    
    if(best==0){
      best=curr;
    } 
    else if((*curr)<(*best)){
      carry=best;
      best=curr;
    } 
    else if(carry==0){
      carry=curr;
    } 
    else if((*curr)<(*carry)){
      carry=curr;
    } //else { }    
  }
  
  
  // Ghost 1 suppression: use carry only if not suppressed
  if(carry!=0) {   // A carry is present
    
    // Carry enabled if correlated and TRACO is next to best
    bool inner_or_corr;
    if(config()->TsmGhost1Corr()) {
      inner_or_corr=carry->isInner() || carry->isCorr();  
    } else {
      inner_or_corr=carry->isInner();
    }
    
    if(config()->TsmGhost1Flag()<2){ // Carry isn't always suppressed
      // check if adjacent DTTracoChips
      int adj = (carry->tssNumber()==best->tssNumber()+1 &&          //next DTTracoChip
                 best->TcPos()==DTConfigTSPhi::NTCTSS && carry->TcPos()==1 ) ||
        (carry->tssNumber()==best->tssNumber()-1 &&         // prev DTTracoChip
         best->TcPos()==1 && carry->TcPos()==DTConfigTSPhi::NTCTSS ) ||
        (carry->tssNumber()==best->tssNumber() &&           // same DTTracoChip
         abs(carry->TcPos()-best->TcPos())==1                     );   
      
      if(config()->TsmGhost1Flag()==0 ||          // Carry always enabled
         //       carry->isInner() ||                      // Carry is inner
         inner_or_corr ||                         // Carry is inner or corr
         !adj                          ) {        // Carry not adj. to best   
        // add carry to second tracks to for sort 2
        carry->setSecondTrack(); // change value of first/second track bit
        // NEW DESIGN: DTTSM is not configurable!
        // carry->setBitsTsm();     // set quality bits as for second tracks
        _incand[1].push_back(carry); // add to list of second tracks
      }
    }
  }
  // best->print();
  return best;
}
DTTSCand * DTTSM::sortTSM2 ( int  bkmod)

Sort 2.

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

Definition at line 195 of file DTTSM.cc.

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

Referenced by run().

                         {

  // If second tracks are always suppressed skip processing
  if(config()->TsmGhost2Flag()==3)return 0;
  
  // Check if there are second tracks
  if(nTracks()<1){
    std::cout << "DTTSM::sortTSM2: called with no first track.";
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }
  
  // If a first track at the following BX is present, ignore second tracks of any kind
  if(_ignoreSecondTrack){
    std::vector<DTTSCand*>::iterator p;
    for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
      if((*p)->isCarry()) return (*p);
    }
    return 0;
  }
  
  // If no first tracks at the following BX, do a sort 2
  DTTSCand* best=getTrack(1);
  DTTSCand* second=0;
  std::vector<DTTSCand*>::iterator p;
  for(p=_incand[1].begin(); p!=_incand[1].end(); p++) {
    DTTSCand* curr=(*p);
    // ghost 2 suppression: skip track if suppressed
    // this is not needed if config of DTTSM == config of DTTSS
    
    bool inner_or_corr;
    if(config()->TsmGhost2Corr())
      {inner_or_corr=curr->isInner() || curr->isCorr();
      }
    else
      {inner_or_corr=curr->isInner();
      }
    
    if(config()->TsmGhost2Flag()!=0){     // 2nd tracks not always enabled
      if(
         !inner_or_corr &&                    // outer and not corr
         (curr->tssNumber()==best->tssNumber() &&
          curr->TcPos()==best->TcPos()) ) { // same correlator of 1st track
        if(config()->TsmGhost2Flag()==2 ||    // do not look to corr bit of 1st
           ( (!best->isCorr() ) &&  config()->TsmGhost2Flag()!=4 ) || // skip if best is not corr
           ( (!best->isCorr() ) &&  best->isInner() && config()->TsmGhost2Flag()==4) )   // skip only if best is inner and not corr
          {                 
            continue;                             // skip track
          }
      }
    }
    
    // added DBSM
    // SM double TSM    if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
    if ( bkmod == 1 ) { // NORMAL mode ---> sorting on dataword
      curr->setBitsTss(); // maybe not necessary, as they are the same as for TSS in the default
    } else if( bkmod == 0) { //  { // BACKUP mode ---> sorting on modified dataword
      curr->setBitsBkmod();
    } else {
      std::cout << " DTTSM::sortTSM2 bkmod not properly assigned!" << std::endl;
    }
    
    
    
    // added DBSM
    // SM double TSM    if ( bkmod == 1 ) { // NORMAL mode ---> sorting with <
    
    if(second==0){
      second=curr;
    } 
    else if((*curr)<(*second)){
      second=curr;
    }  
  }
  return second;
}

Member Data Documentation

Definition at line 102 of file DTTSM.h.

Referenced by config(), and setConfig().

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().