CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTTSS Class Reference

#include <DTTSS.h>

List of all members.

Public Member Functions

void addDTTSCand (DTTSCand *cand)
 Add a TS candidate to the TSS, ifs is first/second track flag.
void clear ()
 Clear.
DTConfigTSPhiconfig () const
 Configuration set.
 DTTSS (int)
 Constructor.
DTTSCandgetCarry () const
 Return the carry (for debugging)
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.
std::string logWord (int n) const
 Return the requested log word.
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.
unsigned nTracoT (int ifs) const
 Return the number of input tracks (first/second)
int number () const
 Return identifier.
void run ()
 Run the TSS algorithm.
void setConfig (DTConfigTSPhi *config)
 Set configuration.
DTTSCandsortTSS1 ()
 Sort 1.
DTTSCandsortTSS2 ()
 Sort 2.
 ~DTTSS ()
 Destructor.

Private Attributes

DTConfigTSPhi_config
int _ignoreSecondTrack
std::string _logWord1
std::string _logWord2
int _n
std::vector< DTTSCand * > _outcand
std::vector< DTTSCand * > _tctrig [2]

Detailed Description

Implementation of TSS trigger algorithm

Date:
2008/09/05 15:59:57
Revision:
1.3
Author:
C. Grandi, D. Bonacorsi, S. Marcellini

Definition at line 38 of file DTTSS.h.


Constructor & Destructor Documentation

DTTSS::DTTSS ( int  n)

Constructor.

Definition at line 36 of file DTTSS.cc.

References _logWord1, and _logWord2.

                  : _n(n), _ignoreSecondTrack(0) {

  // reserve the appropriate amount of space for vectors
  //_tctrig[0].reserve(DTConfigTSPhi::NTCTSS);
  //_tctrig[1].reserve(DTConfigTSPhi::NTCTSS);
  //_outcand.reserve(2);
  _logWord1 = "1/----";
  _logWord2 = "2/----";

}
DTTSS::~DTTSS ( )

Destructor.

Definition at line 51 of file DTTSS.cc.

References clear().

             {
  clear();
}

Member Function Documentation

void DTTSS::addDTTSCand ( DTTSCand cand)

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

Definition at line 290 of file DTTSS.cc.

References _tctrig, and DTTSCand::isFirst().

Referenced by DTTSPhi::addTracoT().

                                 {
  int ifs = (cand->isFirst()) ? 0 : 1;
  //  std::cout << "SM DTTSS::addDTTSCand ifs = " << ifs << std::endl;
  _tctrig[ifs].push_back(cand); 
}
void DTTSS::clear ( void  )

Clear.

Definition at line 61 of file DTTSS.cc.

References _ignoreSecondTrack, _logWord1, _logWord2, _outcand, and _tctrig.

Referenced by ~DTTSS().

             {
  _ignoreSecondTrack=0;
  for(int itk=0;itk<=1;itk++){
    // content of _tctrig is deleted in the DTTSPhi
    _tctrig[itk].clear();
  }
  // content of _outcand is deleted in the DTTSPhi
  _outcand.clear(); 

  // log words
  _logWord1 = "1/----";
  _logWord2 = "2/----";
}
DTConfigTSPhi* DTTSS::config ( void  ) const [inline]

Configuration set.

Definition at line 73 of file DTTSS.h.

References _config.

Referenced by DTTSCand::config(), run(), setConfig(), sortTSS1(), and sortTSS2().

{ return _config; }
DTTSCand * DTTSS::getCarry ( ) const

Return the carry (for debugging)

Definition at line 349 of file DTTSS.cc.

References _tctrig, begin, and L1TEmulatorMonitor_cff::p.

                      {
  std::vector<DTTSCand*>::const_iterator p;
  for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
    if((*p)->isCarry()) return (*p);
  return 0;
}
DTTSCand * DTTSS::getDTTSCand ( int  ifs,
unsigned  n 
) const

Return requested TS candidate.

Definition at line 307 of file DTTSS.cc.

References _tctrig, gather_cfg::cout, n, nTracoT(), and L1TEmulatorMonitor_cff::p.

Referenced by getTracoT().

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

Return the requested track.

Definition at line 338 of file DTTSS.cc.

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

Referenced by sortTSS2().

                           {
  if(n<1 || n>nTracks()) {
    std::cout << "DTTSS::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 * DTTSS::getTracoT ( int  ifs,
unsigned  n 
) const

Return requested TRACO trigger.

Definition at line 323 of file DTTSS.cc.

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

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

Set a flag to skip sort2.

Definition at line 55 of file DTTSS.h.

References _ignoreSecondTrack.

Referenced by DTTSPhi::ignoreSecondTrack().

std::string DTTSS::logWord ( int  n) const

Return the requested log word.

Definition at line 357 of file DTTSS.cc.

References _logWord1, _logWord2, gather_cfg::cout, and n.

                          {
  std::string lw = "";
  switch (n) {
  case 1:
    lw = _logWord1; break;
  case 2:
    lw = _logWord2; break;
  default:
    std::cout << "DTTSS::logWord: requested track not present: " << n;
    std::cout << " empty string returned!" << std::endl;
  }
  return lw;
}
int DTTSS::nFirstT ( ) const [inline]

Return the number of input first tracks.

Definition at line 79 of file DTTSS.h.

References _tctrig.

Referenced by run().

{ return _tctrig[0].size(); }
int DTTSS::nSecondT ( ) const [inline]

Return the number of input second tracks.

Definition at line 82 of file DTTSS.h.

References _tctrig.

Referenced by run().

{ return _tctrig[1].size(); }
int DTTSS::nTracks ( ) const [inline]

Return the number of sorted tracks.

Definition at line 94 of file DTTSS.h.

References _outcand.

Referenced by getTrack(), and sortTSS2().

{ return _outcand.size(); }
unsigned DTTSS::nTracoT ( int  ifs) const

Return the number of input tracks (first/second)

Definition at line 297 of file DTTSS.cc.

References _tctrig, and gather_cfg::cout.

Referenced by getDTTSCand(), and getTracoT().

                            {
  if(ifs<1||ifs>2){
    std::cout << "DTTSS::nTracoT: wrong track number: " << ifs;
    std::cout << " 0 returned!" << std::endl;
    return 0;
  }
  return _tctrig[ifs-1].size();
}
int DTTSS::number ( ) const [inline]

Return identifier.

Definition at line 70 of file DTTSS.h.

References _n.

Referenced by DTTSPhi::addTracoT(), and DTTSCand::tssNumber().

{ return _n; }
void DTTSS::run ( void  )

Run the TSS algorithm.

Definition at line 76 of file DTTSS.cc.

References _n, _outcand, _tctrig, begin, config(), gather_cfg::cout, debug, first, nFirstT(), nSecondT(), L1TEmulatorMonitor_cff::p, edm::second(), sortTSS1(), and sortTSS2().

           {

  if(config()->debug()){
    std::cout << "DTTSS::run: Processing DTTSS number " << _n << " : ";
    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 DTTSS: " << std::endl;
    std::vector<DTTSCand*>::const_iterator p;
    for(p=_tctrig[0].begin(); p!=_tctrig[0].end(); p++) {
      (*p)->print();
    }
  }
  // end debugging

  DTTSCand* first=sortTSS1();
  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 DTTSS: " << std::endl;
    for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
      (*p)->print();
    }
  }
  // end debugging
  
  DTTSCand* second=sortTSS2();
  if(second!=0) {
    _outcand.push_back(second); 
  }

}
void DTTSS::setConfig ( DTConfigTSPhi config) [inline]

Set configuration.

Definition at line 52 of file DTTSS.h.

References _config, and config().

DTTSCand * DTTSS::sortTSS1 ( )

Sort 1.

Definition at line 124 of file DTTSS.cc.

References _logWord1, _tctrig, abs, begin, config(), DTTSCand::dataword(), DTTSCand::isCorr(), DTTSCand::isFirst(), DTTSCand::isInner(), L1TEmulatorMonitor_cff::p, DTTSCand::setBitsTss(), DTTSCand::setSecondTrack(), DTTSCand::TcPos(), and DTConfigTSPhi::TssGhost1Corr().

Referenced by run().

                {

  // Do a sort 1
  DTTSCand* best=0;
  DTTSCand* carry=0;
  std::vector<DTTSCand*>::iterator p;
  for(p=_tctrig[0].begin(); p!=_tctrig[0].end(); p++) {
    DTTSCand* curr= (*p) ? (*p) : 0;
    // SM sector collector Set bits for tss
    curr->setBitsTss(); 
    if(curr->dataword()==0x1ff)continue;   
    _logWord1[1+curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
//     std::cout << "Running TSS: --->curr->dataword() sort 1 " << curr->dataword()  << 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;
    }
  }

  // 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()->TssGhost1Corr())
      {inner_or_corr=carry->isInner() || carry->isCorr();

      }
    else 
      {inner_or_corr=carry->isInner(); 

    }
    if(config()->TssGhost1Flag()<2 && (       // Carry isn't always suppressed
       config()->TssGhost1Flag()==0 ||        // Carry always enabled
       //       carry->isInner() ||                    // Carry is inner
       inner_or_corr ||                       // carry is inner or corr
       abs(carry->TcPos()-best->TcPos())!=1)  // Carry not adj. to best   
                                             ) {
       // add carry to second tracks for sort 2
      carry->setSecondTrack(); // change value of first/second track bit
      carry->setBitsTss();     // set quality bits as for second tracks
      _tctrig[1].push_back(carry); // add to list of second tracks
    } else {
      _logWord1[1+carry->TcPos()] = 'g';
    }
  }

  /*
  if(carry!=0 && config()->TssGhost1Flag()<2){ // Carry isn't always suppressed
    if(config()->TssGhost1Flag()==0 ||           // Carry always enabled
       carry->isInner() ||                       // Carry is inner
       abs(carry->TcPos()-best->TcPos())!=1) {   // Carry not adj. to best   
       // add carry to second tracks to for sort 2
      carry->setSecondTrack(); // change value of first/second track bit
      carry->setBitsTss();     // set quality bits as for second tracks
      _tctrig[1].push_back(carry); // add to list of second tracks
    }
  }
  */
  //std::cout << " best TSS sort 1 = " << best->dataword() << std::endl;
  //std::cout << " SM end of TSS sort 1: best = " <<  std::endl;
  //best->print();
  
  return best;

}
DTTSCand * DTTSS::sortTSS2 ( )

Sort 2.

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

Definition at line 202 of file DTTSS.cc.

References _ignoreSecondTrack, _logWord2, _tctrig, begin, config(), gather_cfg::cout, DTTSCand::dataword(), getTrack(), DTTSCand::isCarry(), DTTSCand::isCorr(), DTTSCand::isFirst(), DTTSCand::isInner(), nTracks(), L1TEmulatorMonitor_cff::p, edm::second(), DTTSCand::setBitsTss(), DTTSCand::TcPos(), DTConfigTSPhi::TssGhost2Corr(), and DTConfigTSPhi::TssGhost2Flag().

Referenced by run().

                {

  // Check if there are second tracks
  if(nTracks()<1){
    std::cout << "DTTSS::DTTSSsort2: called with no first track.";
    std::cout << " empty pointer returned!" << std::endl;
    return 0;
  }

  if(_ignoreSecondTrack){
    // At the time being if a a first track at the following BX is present,
    // the carry is thrown
    //    std::vector<DTTSCand*>::iterator p;
    //    for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
    //      if((*p)->isCarry()) return (*p);
    //    }
    // Fill log word
    std::vector<DTTSCand*>::iterator p;
    for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
      if(!(*p)->isCarry())_logWord2[1+(*p)->TcPos()] = 'o'; // out of time
    return 0;
  }

  // If second tracks are always suppressed skip processing
  if(config()->TssGhost2Flag()==3) {
    // Fill log word
    std::vector<DTTSCand*>::iterator p;
    for(p=_tctrig[1].begin(); p!=_tctrig[1].end(); p++)
      _logWord2[1+(*p)->TcPos()] = 'G';
    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=_tctrig[1].begin(); p!=_tctrig[1].end(); p++) {
    DTTSCand* curr=(*p);
    // SM sector collector set bits for tss
        curr->setBitsTss(); 
//     std::cout << "Running TSS sort 2: --- curr->dataword() "  << curr->dataword()  << std::endl;
    if(!curr->isCarry()) {
      _logWord2[1+curr->TcPos()] = (curr->isFirst()) ? '1' : '2';
      if(curr->dataword()==0x1ff)continue;
    }
    // ghost 2 suppression: skip track if suppressed
    if(config()->TssGhost2Flag()!=0){    // 2nd tracks not always enabled

       bool inner_or_corr;
       if(config()->TssGhost2Corr())
          {inner_or_corr=curr->isInner() || curr->isCorr();

          }
       else
          {inner_or_corr=curr->isInner();

          }

      if(
         !inner_or_corr &&                    // outer and not corr
         curr->TcPos()==best->TcPos()) {   // same correlator of 1st track
        if(config()->TssGhost2Flag()==2 ||   // do not look to corr bit of 1st
           ( (!best->isCorr() ) && config()->TssGhost2Flag()!=4)  || // skip if best is not corr
           ( (!best->isCorr() ) && best->isInner() && config()->TssGhost2Flag()==4) )   // skip only if best is inner and not corr
 {                
          _logWord2[1+curr->TcPos()] = 'G';
//        std::cout << " skip sort 2 in TSS" << std::endl;
          continue;                            // skip track
        }
      }
    }
    if(second==0){
      second=curr;
    } 
    else if((*curr)<=(*second)){
      second=curr;
    } 
  }
 //  if(!second==0) {std::cout << " best sort 2 = " << second->dataword() << std::endl;
//   std::cout << " SM end of TSS sort 2: second = " <<  std::endl;
//   second->print(); }

  return second;

}

Member Data Documentation

Definition at line 104 of file DTTSS.h.

Referenced by config(), and setConfig().

Definition at line 116 of file DTTSS.h.

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

std::string DTTSS::_logWord1 [private]

Definition at line 119 of file DTTSS.h.

Referenced by clear(), DTTSS(), logWord(), and sortTSS1().

std::string DTTSS::_logWord2 [private]

Definition at line 120 of file DTTSS.h.

Referenced by clear(), DTTSS(), logWord(), and sortTSS2().

int DTTSS::_n [private]

Definition at line 107 of file DTTSS.h.

Referenced by number(), and run().

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

Definition at line 113 of file DTTSS.h.

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

std::vector<DTTSCand*> DTTSS::_tctrig[2] [private]