CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

L1MuDTEtaProcessor Class Reference

#include <L1MuDTEtaProcessor.h>

List of all members.

Public Member Functions

int eta (int id) const
 return eta values, index [0,11]
bool fineBit (int id) const
 return fine bit, index [0,11]
int id () const
 return Eta Processor identifier (0-11)
 L1MuDTEtaProcessor (const L1MuDTTrackFinder &, int id)
 constructor
void print () const
 print muon candidates found by the Eta Processor
virtual void reset ()
 reset the Eta Processor
virtual void run (int bx, const edm::Event &e, const edm::EventSetup &c)
 run the Eta Processor
const L1MuDTTrackFindertf () const
 return reference to barrel MTTF
virtual ~L1MuDTEtaProcessor ()
 destructor

Private Member Functions

void assign ()
 assign eta and etaFineBit
void receiveAddresses ()
 receive addresses (from 6 Sector Processors)
void receiveData (int bx, const edm::Event &e, const edm::EventSetup &c)
 receive data (eta trigger primitives)
void runEtaMatchingUnit (const edm::EventSetup &c)
 run Eta Matching Unit (EMU)
void runEtaTrackFinder (const edm::EventSetup &c)
 run Eta Track Finder (ETF)

Static Private Member Functions

static int quality (int id, int stat)
 get quality code; id [0,26], stat [1,3]

Private Attributes

int m_address [12]
int m_epid
int m_eta [12]
bool m_fine [12]
std::vector< int > m_foundPattern
int m_mask
int m_pattern [12]
const L1MuDTTrackFinderm_tf
L1MuDTTrackm_TrackCand [12]
L1MuDTTrackm_TracKCand [12]
std::vector< const
L1MuDTTrackSegEta * > 
m_tseta
edm::ESHandle< L1MuDTTFMasksmsks
edm::ESHandle
< L1MuDTEtaPatternLut
theEtaPatternLUT
edm::ESHandle
< L1MuDTQualPatternLut
theQualPatternLUT

Detailed Description

Eta Processor:

An Eta Processor consists of :

Date:
2009/06/02 14:41:48
Revision:
1.9

N. Neumeister CERN EP J. Troconiz UAM Madrid

Definition at line 54 of file L1MuDTEtaProcessor.h.


Constructor & Destructor Documentation

L1MuDTEtaProcessor::L1MuDTEtaProcessor ( const L1MuDTTrackFinder tf,
int  id 
)

constructor

Definition at line 65 of file L1MuDTEtaProcessor.cc.

References m_tseta.

                                                                          :
      m_tf(tf), m_epid(id), m_foundPattern(0), m_tseta(15) {

  m_tseta.reserve(15);
  
}
L1MuDTEtaProcessor::~L1MuDTEtaProcessor ( ) [virtual]

destructor

Definition at line 77 of file L1MuDTEtaProcessor.cc.

{}

Member Function Documentation

void L1MuDTEtaProcessor::assign ( ) [private]

assign eta and etaFineBit

Definition at line 428 of file L1MuDTEtaProcessor.cc.

References i, m_eta, m_fine, m_pattern, m_TracKCand, m_TrackCand, m_tseta, AlCaHLTBitMon_ParallelJobs::p, pos, L1MuDTEtaPattern::position(), L1MuDTTrack::setEta(), L1MuDTTrack::setFineEtaBit(), L1MuDTTrack::setTSeta(), testRegression::stat, theEtaPatternLUT, and L1MuDTEtaPattern::wheel().

Referenced by run().

                                {

  for ( int i = 0; i < 12; i++ ) {
    if ( m_TrackCand[i] ) {
      if ( m_eta[i] != 99 ) { 
        m_TrackCand[i]->setEta(m_eta[i]);
        m_TracKCand[i]->setEta(m_eta[i]);
      }
      else {  
        //        if ( i/2 != 2 ) cerr << "L1MuDTEtaProcessor: assign invalid eta" << " " << m_address[i] << endl;
      }
      if ( m_fine[i] ) {
        m_TrackCand[i]->setFineEtaBit();
        m_TracKCand[i]->setFineEtaBit();
        // find all contributing track segments 
        const L1MuDTEtaPattern p = theEtaPatternLUT->getPattern(m_pattern[i]);
        vector<const L1MuDTTrackSegEta*> TSeta;
        const L1MuDTTrackSegEta* ts = 0;
        for ( int stat = 0; stat < 3; stat++ ) {
          int wh = p.wheel(stat+1);
          int pos = p.position(stat+1);
          if ( pos == 0 ) continue;
          ts = m_tseta[wh+2 + stat*5];
          TSeta.push_back(ts);
        }
        m_TrackCand[i]->setTSeta(TSeta);
        m_TracKCand[i]->setTSeta(TSeta);
      }  
    }
  }

}
int L1MuDTEtaProcessor::eta ( int  id) const [inline]

return eta values, index [0,11]

Definition at line 80 of file L1MuDTEtaProcessor.h.

References id(), and m_eta.

{ return m_eta[id]; }
bool L1MuDTEtaProcessor::fineBit ( int  id) const [inline]

return fine bit, index [0,11]

Definition at line 83 of file L1MuDTEtaProcessor.h.

References id(), and m_fine.

{ return m_fine[id]; }
int L1MuDTEtaProcessor::id ( void  ) const [inline]

return Eta Processor identifier (0-11)

Definition at line 65 of file L1MuDTEtaProcessor.h.

References m_epid.

Referenced by eta(), fineBit(), and quality().

{ return m_epid; }
void L1MuDTEtaProcessor::print ( void  ) const

print muon candidates found by the Eta Processor

Definition at line 137 of file L1MuDTEtaProcessor.cc.

References gather_cfg::cout, L1MuDTEtaPattern::eta(), i, L1MuDTEtaPattern::id(), j, m_address, m_epid, m_eta, m_fine, m_foundPattern, m_pattern, m_tseta, AlCaHLTBitMon_ParallelJobs::p, pos, position, L1MuDTEtaPattern::quality(), quality(), relativeConstraints::station, theEtaPatternLUT, and theQualPatternLUT.

                                     {

  bool empty1 = true;
  for ( int i = 0; i < 15; i++ ) {
    empty1 &= ( m_tseta[i] == 0 || m_tseta[i]->empty() );
  }

  bool empty2 = true;
  for ( int i = 0; i < 12; i++ ) {  
    empty2 &= ( m_address[i] == 0 );
  }

  if ( !empty1 || !empty2 ) {
    cout << "Eta processor " << m_epid << " : " << endl;
  
   // print local pattern
   if ( !empty1 ) {
     cout << "Local pattern : " << endl;
     for ( int i = 0; i < 15; i++ ) {
       if ( (i+5)%5 == 0 ) cout << "station " << m_tseta[i]->station() << " : ";
       bitset<7> pos(m_tseta[i]->position());
       bitset<7> qua(m_tseta[i]->quality());
       for ( int j = 6; j >= 0; j-- ) {
         cout << pos[j]+qua[j];
       }
       cout << " ";
       if ( (i+1)%5 == 0 ) cout << endl;
     }
     cout << "Found patterns :" << endl;
     vector<int>::const_iterator iter;
     for ( iter = m_foundPattern.begin(); iter != m_foundPattern.end(); iter++ ) {
        const L1MuDTEtaPattern p = theEtaPatternLUT->getPattern(*iter);
        int qualitycode = p.quality();
        cout << "ID = " << setw(4) << p.id() << "  "
             << "eta = " << setw(3) << p.eta() << "  "
             << "quality = " << setw(2) << qualitycode << " ("
             << quality(qualitycode,1) << " "
             << quality(qualitycode,2) << " " 
             << quality(qualitycode,3) << ")";
        for ( int i = 0; i < 12; i++ ) { 
          if ( m_pattern[i] ==  p.id() ) cout << " <--";
        }
        cout << endl;     
      }
    }
    
    cout << "Received addresses : " << endl;
    for ( int i = 0; i < 12; i++ ) cout << setw(3) << m_address[i] << " ";
    cout << endl;
    
    if ( !empty1 ) {
      cout << "Matched patterns : " << endl;
      for ( int i = 0; i < 12; i++ ) {      
        if ( m_fine[i] ) {
          const L1MuDTEtaPattern p = theEtaPatternLUT->getPattern(m_pattern[i]);
          int fineeta = p.eta();
          int coarseeta = theQualPatternLUT->getCoarseEta(i/2+1,m_address[i]);
          cout << "Index = " << setw(2) << i << ", "
               << "address = " << setw(2) << m_address[i] << " --> " 
               << "pattern = " << setw(4) << m_pattern[i] << " "
               << "eta (coarse) = " << setw(3) << coarseeta << " "
               << "eta (fine) = " << setw(3) << fineeta << " "
               << "quality = " << setw(2) << p.quality() << endl;
        }
      }
    }

    cout << "Eta values and fine bits : " << endl;
    for ( int i = 0; i < 12; i++ ) cout << setw(3) << m_eta[i] << " ";
    cout << endl;
    for ( int i = 0; i < 12; i++ ) cout << setw(3) << m_fine[i] << " ";
    cout << endl;
  }

}
int L1MuDTEtaProcessor::quality ( int  id,
int  stat 
) [static, private]

get quality code; id [0,26], stat [1,3]

Definition at line 465 of file L1MuDTEtaProcessor.cc.

References id().

Referenced by print(), and runEtaTrackFinder().

                                                {

  // quality codes as defined in CMS Note 2001/027
  // This QualityPatterns are used to have a defined Quality-Identifier for
  // all possible found tracks.
  // Therefore three integer numbers ( Station 1, 2, 3 from left to right )
  // can have numbers like 0, 1 or 2
  //    0 ... no hit is given
  //    1 ... a LTRG is given
  //    2 ... a HTRG is given

  const int qualcode[27][3] = { {0,0,0},{1,0,0},{0,1,0},{0,0,1},{2,0,0},
                                {0,2,0},{0,0,2},{1,1,0},{1,0,1},{0,1,1},
                                {2,1,0},{1,2,0},{2,0,1},{1,0,2},{0,2,1},
                                {0,1,2},{2,2,0},{2,0,2},{0,2,2},{1,1,1},
                                {2,1,1},{1,2,1},{1,1,2},{2,2,1},{2,1,2},
                                {1,2,2},{2,2,2} };

  return qualcode[id][stat-1];

}
void L1MuDTEtaProcessor::receiveAddresses ( ) [private]

receive addresses (from 6 Sector Processors)

Definition at line 275 of file L1MuDTEtaProcessor.cc.

References L1MuDTTrack::address(), L1MuDTTrack::empty(), i, m_address, m_epid, m_tf, m_TracKCand, m_TrackCand, L1MuDTTrackFinder::sp(), L1MuDTSectorProcessor::track(), L1MuDTSectorProcessor::tracK(), and L1MuDTAddressArray::trackAddressCode().

Referenced by run().

                                          {

  // get track address code of all track segments
  // 6*2 times 5 bits; valid range [1-22]

  int sector = m_epid;
  
  int i = 0;
  for ( int wheel = -3; wheel <= 3; wheel++ ) {
    if ( wheel == 0 ) continue;
    L1MuDTSecProcId tmpspid(wheel,sector);
    for ( int number = 0; number < 2; number++ ) { 
      const L1MuDTTrack* cand = m_tf.sp(tmpspid)->track(number);
      const L1MuDTTrack* canD = m_tf.sp(tmpspid)->tracK(number);
      if ( cand ) {
        m_address[i] = cand->address().trackAddressCode();
        if ( !cand->empty() ) {
          m_TrackCand[i] = const_cast<L1MuDTTrack*>(cand);
          m_TracKCand[i] = const_cast<L1MuDTTrack*>(canD);
        }
        i++;
      }
    }
  }
  
}  
void L1MuDTEtaProcessor::receiveData ( int  bx,
const edm::Event e,
const edm::EventSetup c 
) [private]

receive data (eta trigger primitives)

Definition at line 217 of file L1MuDTEtaProcessor.cc.

References edm::EventSetup::get(), edm::Event::getByLabel(), L1MuDTTFConfig::getDTDigiInputTag(), i, m_epid, m_mask, m_tseta, msks, pos, L1MuDTChambThDigi::position(), L1MuDTChambThDigi::quality(), and testRegression::stat.

Referenced by run().

                                                                                      {

  c.get< L1MuDTTFMasksRcd >().get( msks );

  edm::Handle<L1MuDTChambThContainer> dttrig;
  e.getByLabel(L1MuDTTFConfig::getDTDigiInputTag(),dttrig);

  // const int bx_offset = dttrig->correctBX();
  int bx_offset=0;
  bx = bx + bx_offset;
  
  //
  // get 5*3 eta track segments
  //
  int sector = m_epid;
  for ( int stat = 1; stat <= 3; stat++ ) {
    for ( int wheel = -2; wheel <= 2; wheel++ ) {
      L1MuDTChambThDigi* tseta = dttrig->chThetaSegm(wheel,stat,sector,bx);
      bitset<7> pos;
      bitset<7> qual;

      int lwheel = wheel+1;
      if ( wheel < 0 ) lwheel = wheel-1;

      bool masked = false;
      if ( stat == 1 ) masked = msks->get_etsoc_chdis_st1(lwheel, sector);
      if ( stat == 2 ) masked = msks->get_etsoc_chdis_st2(lwheel, sector);
      if ( stat == 3 ) masked = msks->get_etsoc_chdis_st3(lwheel, sector);

      if ( !masked ) m_mask = false;

      if ( tseta && !masked ) {

        if ( wheel == -2 || wheel == -1 || 
             ( wheel == 0 && (sector == 0 || sector == 3 || sector == 4 || sector == 7 || sector == 8 || sector == 11) ) ) {
          for ( int i = 0; i < 7; i++ ) {
            if ( tseta->position(i) ) pos.set(6-i);
            if ( tseta->quality(i) ) qual.set(6-i);
          }
        } else {
          for ( int i = 0; i < 7; i++ ) {
            if ( tseta->position(i) ) pos.set(i);
            if ( tseta->quality(i) ) qual.set(i);
          }
        }
      }

      const L1MuDTTrackSegEta* tmpts = new L1MuDTTrackSegEta(wheel,sector,stat,pos.to_ulong(),qual.to_ulong(),bx-bx_offset);
      m_tseta.push_back(tmpts);
    } 
  }
  
}
void L1MuDTEtaProcessor::reset ( void  ) [virtual]

reset the Eta Processor

Definition at line 105 of file L1MuDTEtaProcessor.cc.

References i, m_address, m_eta, m_fine, m_foundPattern, m_mask, m_pattern, m_TracKCand, m_TrackCand, and m_tseta.

                               {

  vector<const L1MuDTTrackSegEta*>::iterator iter = m_tseta.begin();
  while ( iter != m_tseta.end() ) {
    if ( *iter ) {
      delete *iter;
      *iter = 0;
    }
    iter++;
  }

  m_tseta.clear();
  
  for ( int i = 0; i < 12; i++ ) {
    m_eta[i] = 99;
    m_fine[i] = false;
    m_pattern[i] = 0;
    m_address[i] = 0;
    m_TrackCand[i] = 0;
    m_TracKCand[i] = 0;
  }

  m_foundPattern.clear();

  m_mask = true;

} 
void L1MuDTEtaProcessor::run ( int  bx,
const edm::Event e,
const edm::EventSetup c 
) [virtual]
void L1MuDTEtaProcessor::runEtaMatchingUnit ( const edm::EventSetup c) [private]

run Eta Matching Unit (EMU)

Definition at line 353 of file L1MuDTEtaProcessor.cc.

References L1MuDTEtaPattern::eta(), spr::find(), edm::EventSetup::get(), i, m_address, m_eta, m_fine, m_foundPattern, m_mask, m_pattern, AlCaHLTBitMon_ParallelJobs::p, theEtaPatternLUT, and theQualPatternLUT.

Referenced by run().

                                                                  {
  
  c.get< L1MuDTQualPatternLutRcd >().get( theQualPatternLUT );

  // loop over all addresses
  for ( int i = 0; i < 12; i++ ) {
  
    int adr = m_address[i];
    if ( adr == 0 ) continue;
    int sp = i/2 + 1;       //sector processor [1,6]
    
    // assign coarse eta value
    if ( !m_mask ) m_eta[i] = theQualPatternLUT->getCoarseEta(sp,adr);
    if ( m_eta[i] == 99 ) m_eta[i] = 32;
    if ( m_eta[i] > 31 ) m_eta[i] -= 64;
    m_eta[i] += 32;
    
    if ( m_foundPattern.empty() ) continue;
    
    // get list of qualified patterns ordered by quality 
    // and compare with found patterns
    const vector<short>& qualifiedPatterns = theQualPatternLUT->getQualifiedPatterns(sp,adr);
    vector<short>::const_iterator iter;
    vector<int>::const_iterator f_iter;
    for ( iter = qualifiedPatterns.begin(); iter != qualifiedPatterns.end(); iter++ ) {
      f_iter = find(m_foundPattern.begin(),m_foundPattern.end(),(*iter));
      // found
      if ( f_iter != m_foundPattern.end() ) {
        const L1MuDTEtaPattern p = theEtaPatternLUT->getPattern(*f_iter);
        // assign fine eta value     
        m_fine[i] = true;
        m_eta[i]  = p.eta();  // improved eta
        if ( m_eta[i] == 99 ) m_eta[i] = 32;
        if ( m_eta[i] > 31 ) m_eta[i] -= 64;
        m_eta[i] += 32;
        m_pattern[i] = (*f_iter);
        break;
      }
    }
    
  }
  
  // if both tracks from one sector processor deliver the same track address
  // both tracks get only a coarse eta value!  
  
  // loop over sector processors
  for ( int i = 0; i < 6; i++ ) {
    int idx1 = 2*i;
    int idx2 = 2*i+1;
    int adr1 = m_address[idx1];
    int adr2 = m_address[idx2];
    if ( adr1 == 0 || adr2 == 0 ) continue;
    if ( adr1 == adr2 && !m_mask ) {
      // both tracks get coarse (default) eta value
      m_eta[idx1]  = theQualPatternLUT->getCoarseEta(i+1,adr1);
      if ( m_eta[idx1] == 99 ) m_eta[idx1] = 32;
      if ( m_eta[idx1] > 31 ) m_eta[idx1] -= 64;
      m_eta[idx1] += 32;
      m_pattern[idx1] = 0;
      m_fine[idx1] = false; 
      m_eta[idx2]  = theQualPatternLUT->getCoarseEta(i+1,adr2);
      if ( m_eta[idx2] == 99 ) m_eta[idx2] = 32;
      if ( m_eta[idx2] > 31 ) m_eta[idx2] -= 64;
      m_eta[idx2] += 32;
      m_pattern[idx2] = 0;
      m_fine[idx2] = false; 
    }  
  }

}  
void L1MuDTEtaProcessor::runEtaTrackFinder ( const edm::EventSetup c) [private]

run Eta Track Finder (ETF)

Definition at line 306 of file L1MuDTEtaProcessor.cc.

References newFWLiteAna::bin, relativeConstraints::empty, edm::EventSetup::get(), i, L1MuDTEtaPattern::id(), m_foundPattern, m_tseta, listBenchmarks::pattern, pos, L1MuDTEtaPattern::position(), lumiQueryAPI::q, L1MuDTEtaPattern::quality(), quality(), relativeConstraints::station, theEtaPatternLUT, and L1MuDTEtaPattern::wheel().

Referenced by run().

                                                                 {

  c.get< L1MuDTEtaPatternLutRcd >().get( theEtaPatternLUT );

  // check if there are any data
  bool empty = true;
  for ( int i = 0; i < 15; i++ ) {
    empty &= m_tseta[i]->empty();
  }
  if ( empty ) return;

  // Pattern comparator: 
  // loop over all patterns and compare with local chamber pattern
  // result : list of valid pattern IDs ( m_foundPattern )
  L1MuDTEtaPatternLut::ETFLut_iter it = theEtaPatternLUT->begin();
  while ( it != theEtaPatternLUT->end() ) {
  
    const L1MuDTEtaPattern pattern = (*it).second;
    int qualitycode = pattern.quality();

    bool good = true;

    for ( int station = 0; station < 3; station++) {
      int q = quality(qualitycode,station+1);
      int wheel = pattern.wheel(station+1);
      int bin = pattern.position(station+1);
      if ( bin == 0 ) continue;
      bitset<7> pos  = m_tseta[wheel+2 + station*5]->position();
      bitset<7> qual = m_tseta[wheel+2 + station*5]->quality();
      // compare position
      good &= pos.test(bin-1);
      // compare quality
      if ( q == 2 ) good &= qual.test(bin-1);  
    }

    if ( good ) m_foundPattern.push_back(pattern.id());

    it++;
    
  }

}
const L1MuDTTrackFinder& L1MuDTEtaProcessor::tf ( ) const [inline]

return reference to barrel MTTF

Definition at line 77 of file L1MuDTEtaProcessor.h.

References m_tf.

{ return m_tf; }

Member Data Documentation

int L1MuDTEtaProcessor::m_address[12] [private]

Definition at line 118 of file L1MuDTEtaProcessor.h.

Referenced by print(), receiveAddresses(), reset(), and runEtaMatchingUnit().

Definition at line 108 of file L1MuDTEtaProcessor.h.

Referenced by id(), print(), receiveAddresses(), and receiveData().

int L1MuDTEtaProcessor::m_eta[12] [private]

Definition at line 112 of file L1MuDTEtaProcessor.h.

Referenced by assign(), eta(), print(), reset(), and runEtaMatchingUnit().

bool L1MuDTEtaProcessor::m_fine[12] [private]

Definition at line 113 of file L1MuDTEtaProcessor.h.

Referenced by assign(), fineBit(), print(), reset(), and runEtaMatchingUnit().

std::vector<int> L1MuDTEtaProcessor::m_foundPattern [private]

Definition at line 115 of file L1MuDTEtaProcessor.h.

Referenced by print(), reset(), runEtaMatchingUnit(), and runEtaTrackFinder().

Definition at line 110 of file L1MuDTEtaProcessor.h.

Referenced by receiveData(), reset(), and runEtaMatchingUnit().

int L1MuDTEtaProcessor::m_pattern[12] [private]

Definition at line 116 of file L1MuDTEtaProcessor.h.

Referenced by assign(), print(), reset(), and runEtaMatchingUnit().

Definition at line 107 of file L1MuDTEtaProcessor.h.

Referenced by receiveAddresses(), and tf().

Definition at line 119 of file L1MuDTEtaProcessor.h.

Referenced by assign(), receiveAddresses(), and reset().

Definition at line 120 of file L1MuDTEtaProcessor.h.

Referenced by assign(), receiveAddresses(), and reset().

std::vector<const L1MuDTTrackSegEta*> L1MuDTEtaProcessor::m_tseta [private]

Definition at line 125 of file L1MuDTEtaProcessor.h.

Referenced by receiveData().

Definition at line 123 of file L1MuDTEtaProcessor.h.

Referenced by assign(), print(), runEtaMatchingUnit(), and runEtaTrackFinder().

Definition at line 124 of file L1MuDTEtaProcessor.h.

Referenced by print(), and runEtaMatchingUnit().