CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

L1MuDTPtaLut Class Reference

#include <L1MuDTPtaLut.h>

List of all members.

Public Member Functions

int getPt (int pta_ind, int address) const
 get pt-value for a given address
int getPtLutThreshold (int pta_ind) const
 get pt-assignment LUT threshold
 L1MuDTPtaLut ()
 constructor
int load ()
 load pt-assignment look-up tables
void print () const
 print pt-assignment look-up tables
void reset ()
 reset pt-assignment look-up tables
virtual ~L1MuDTPtaLut ()
 destructor

Private Types

typedef std::map< short, short,
std::less< short > > 
LUT

Private Member Functions

void setPrecision ()
 set precision for look-up tables

Private Attributes

unsigned short int nbit_phi
std::vector< LUTpta_lut
std::vector< int > pta_threshold

Detailed Description

Look-up tables for pt-assignment

Date:
2008/04/09 15:22:31
Revision:
1.3

N. Neumeister CERN EP

Definition at line 40 of file L1MuDTPtaLut.h.


Member Typedef Documentation

typedef std::map<short, short, std::less<short> > L1MuDTPtaLut::LUT [private]

Definition at line 72 of file L1MuDTPtaLut.h.


Constructor & Destructor Documentation

L1MuDTPtaLut::L1MuDTPtaLut ( )

constructor

Definition at line 52 of file L1MuDTPtaLut.cc.

References MAX_PTASSMETH, pta_lut, pta_threshold, and setPrecision().

                           : 
                  pta_lut(0), 
                  pta_threshold(MAX_PTASSMETH/2) {

  pta_lut.reserve(MAX_PTASSMETH);
  pta_threshold.reserve(MAX_PTASSMETH/2);
  setPrecision();
  
  //  if ( load() != 0 ) {
  //    cout << "Can not open files to load pt-assignment look-up tables for DTTrackFinder!" << endl;
  //  }

  //  if ( L1MuDTTFConfig::Debug(6) ) print();
  
}
L1MuDTPtaLut::~L1MuDTPtaLut ( ) [virtual]

destructor

Definition at line 73 of file L1MuDTPtaLut.cc.

References pta_lut, and pta_threshold.

                            {

  vector<LUT>::iterator iter;
  for ( iter = pta_lut.begin(); iter != pta_lut.end(); iter++ ) {
    (*iter).clear();
  }

  pta_lut.clear();
  pta_threshold.clear();

}

Member Function Documentation

int L1MuDTPtaLut::getPt ( int  pta_ind,
int  address 
) const

get pt-value for a given address

Definition at line 264 of file L1MuDTPtaLut.cc.

References dtNoiseDBValidation_cfg::cerr, end, and pta_lut.

                                                      {

  LUT::const_iterator iter = pta_lut[pta_ind].find(address);
  if ( iter != pta_lut[pta_ind].end() ) {
    return (*iter).second;
  }
  else {
    cerr << "PtaLut::getPt : can not find address " << address << endl;
    return 0;
  }

}
int L1MuDTPtaLut::getPtLutThreshold ( int  pta_ind) const

get pt-assignment LUT threshold

Definition at line 281 of file L1MuDTPtaLut.cc.

References dtNoiseDBValidation_cfg::cerr, MAX_PTASSMETH, and pta_threshold.

Referenced by print().

                                                     {

  if ( pta_ind >= 0 && pta_ind < MAX_PTASSMETH/2 ) {
    return pta_threshold[pta_ind];
  }
  else {
    cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
    return 0;
  }

}
int L1MuDTPtaLut::load ( )

load pt-assignment look-up tables

Definition at line 104 of file L1MuDTPtaLut.cc.

References L1TriggerLutFile::close(), mergeVDriftHistosByStation::file, edm::FileInPath::fullPath(), L1TriggerLutFile::good(), MAX_PTASSMETH, nbit_phi, L1TriggerLutFile::open(), PT12H, PT12HO, PT12L, PT12LO, PT13H, PT13HO, PT13L, PT13LO, PT14H, PT14HO, PT14L, PT14LO, PT15HO, PT15LO, PT23H, PT23HO, PT23L, PT23LO, PT24H, PT24HO, PT24L, PT24LO, PT25HO, PT25LO, PT34H, PT34HO, PT34L, PT34LO, pta_lut, pta_threshold, L1TriggerLutFile::readInteger(), edm::shift, and dtDQMClient_cfg::threshold.

                       {

  // get directory name
  string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
  string pta_dir = "L1TriggerData/DTTrackFinder/Ass/";
  string pta_str = "";

  // precision : in the look-up tables the following precision is used :
  // phi ...12 bits (address) and  pt ...5 bits
  // now convert phi and phib to the required precision

  int sh_phi  = 12 - nbit_phi;

  // loop over all pt-assignment methods
  for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) { 
    switch ( pam ) {
      case PT12L  : { pta_str = "pta12l"; break; }
      case PT12H  : { pta_str = "pta12h"; break; }
      case PT13L  : { pta_str = "pta13l"; break; }
      case PT13H  : { pta_str = "pta13h"; break; }
      case PT14L  : { pta_str = "pta14l"; break; }
      case PT14H  : { pta_str = "pta14h"; break; }
      case PT23L  : { pta_str = "pta23l"; break; }
      case PT23H  : { pta_str = "pta23h"; break; }
      case PT24L  : { pta_str = "pta24l"; break; }
      case PT24H  : { pta_str = "pta24h"; break; }
      case PT34L  : { pta_str = "pta34l"; break; }
      case PT34H  : { pta_str = "pta34h"; break; }
      case PT12LO : { pta_str = "pta12l_ovl"; break; }
      case PT12HO : { pta_str = "pta12h_ovl"; break; }
      case PT13LO : { pta_str = "pta13l_ovl"; break; }
      case PT13HO : { pta_str = "pta13h_ovl"; break; }
      case PT14LO : { pta_str = "pta14l_ovl"; break; }
      case PT14HO : { pta_str = "pta14h_ovl"; break; }
      case PT23LO : { pta_str = "pta23l_ovl"; break; }
      case PT23HO : { pta_str = "pta23h_ovl"; break; }
      case PT24LO : { pta_str = "pta24l_ovl"; break; }
      case PT24HO : { pta_str = "pta24h_ovl"; break; }
      case PT34LO : { pta_str = "pta34l_ovl"; break; }
      case PT34HO : { pta_str = "pta34h_ovl"; break; }
      case PT15LO : { pta_str = "pta15l_ovl"; break; }
      case PT15HO : { pta_str = "pta15h_ovl"; break; }
      case PT25LO : { pta_str = "pta25l_ovl"; break; }
      case PT25HO : { pta_str = "pta25h_ovl"; break; }      
    }

    // assemble file name
    edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + pta_dir + pta_str + ".lut"));
    string pta_file = lut_f.fullPath();

    // open file
    L1TriggerLutFile file(pta_file);
    if ( file.open() != 0 ) return -1;
    //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : " 
    //                                         << file.getName() << endl; 

    // get the right shift factor
    int shift = sh_phi;
    int adr_old = -2048 >> shift;

    LUT tmplut;

    int number = -1;
    int sum_pt = 0;

    if ( file.good() ) {
      int threshold = file.readInteger();
      pta_threshold[pam/2] = threshold;
    }
    
    // read values and shift to correct precision
    while ( file.good() ) {
        
      int adr = (file.readInteger()) >> shift;
      int pt  = file.readInteger();

      number++;
      
      if ( adr != adr_old ) {
        tmplut.insert(make_pair( adr_old, (sum_pt/number) ));

        adr_old = adr;
        number = 0;
        sum_pt = 0;
      }
      
      sum_pt += pt;
      
      if ( !file.good() ) file.close();
      
    }

    file.close();
    pta_lut.push_back(tmplut);
  }
  return 0;

}
void L1MuDTPtaLut::print ( void  ) const

print pt-assignment look-up tables

Definition at line 207 of file L1MuDTPtaLut.cc.

References abs, gather_cfg::cout, end, getPtLutThreshold(), i, MAX_PTASSMETH, nbit_phi, DTTFBitArray< N >::print(), pta_lut, DTTFBitArray< N >::twoComplement(), and relativeConstraints::value.

                               {

  cout << endl;
  cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
  cout << "=====================================================" << endl;
  cout << endl;
  cout << "Precision : " << endl;
  cout << '\t' << setw(2) << nbit_phi  << " bits are used for phi "  << endl;

  // loop over all pt-assignment methods
  for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
 
    cout << endl;
    cout << "Pt-Assignment Method : " << static_cast<PtAssMethod>(pam) << endl;
    cout << "============================" << endl;
    cout << endl;

    cout << "\t Threshold : " << getPtLutThreshold(pam/2) << endl << endl;

    int maxbits = nbit_phi;
  
    cout << "      address";
    for ( int i = 0; i < maxbits; i++ ) cout << ' ';
    cout << "  value" << endl;
    for ( int i = 0; i < maxbits; i++ ) cout << '-';    
    cout << "-------------------------" << endl;

    LUT::const_iterator iter = pta_lut[pam].begin();
    while ( iter != pta_lut[pam].end() ) {
      int address = (*iter).first;
      int value   = (*iter).second;

      DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
      DTTFBitArray<5> b_value(static_cast<unsigned>(abs(value)));

      if ( address < 0 ) b_address.twoComplement();

      cout.setf(ios::right,ios::adjustfield);
      cout << " " << setbase(10) << setw(5) << address << " (";
      for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];  
      cout << ")   " << setw(3) << value << " (";
      b_value.print();
      cout << ")" << endl;

      iter++;
    }
    
  }

  cout << endl;   
  
}
void L1MuDTPtaLut::reset ( void  )

reset pt-assignment look-up tables

Definition at line 93 of file L1MuDTPtaLut.cc.

References pta_lut, and pta_threshold.

                         {

  pta_lut.clear();
  pta_threshold.clear();

}
void L1MuDTPtaLut::setPrecision ( ) [private]

set precision for look-up tables

Definition at line 297 of file L1MuDTPtaLut.cc.

References nbit_phi.

Referenced by L1MuDTPtaLut().

                                {

  nbit_phi  = 12;  

}

Member Data Documentation

unsigned short int L1MuDTPtaLut::nbit_phi [private]

Definition at line 77 of file L1MuDTPtaLut.h.

Referenced by load(), print(), and setPrecision().

std::vector<LUT> L1MuDTPtaLut::pta_lut [private]

Definition at line 74 of file L1MuDTPtaLut.h.

Referenced by getPt(), L1MuDTPtaLut(), load(), print(), reset(), and ~L1MuDTPtaLut().

std::vector<int> L1MuDTPtaLut::pta_threshold [private]

Definition at line 75 of file L1MuDTPtaLut.h.

Referenced by getPtLutThreshold(), L1MuDTPtaLut(), load(), reset(), and ~L1MuDTPtaLut().