CMS 3D CMS Logo

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

ErrorCorrelationMgr Class Reference

#include <ErrorCorrelationMgr.h>

List of all members.

Public Member Functions

ErrorCorrelationgetCorrelation (ALIint ii)
ALIint getNumberOfCorrelations ()
void readFromReportFile (const ALIstring &filename)

Static Public Member Functions

static ErrorCorrelationMgrgetInstance ()

Private Member Functions

 ErrorCorrelationMgr ()
std::vector< ErrorCorrelation * >
::iterator 
findErrorCorrelation (pss &entry1, pss &entry2)

Private Attributes

std::vector< ErrorCorrelation * > theCorrs

Static Private Attributes

static ErrorCorrelationMgrtheInstance = 0

Detailed Description

Definition at line 19 of file ErrorCorrelationMgr.h.


Constructor & Destructor Documentation

ErrorCorrelationMgr::ErrorCorrelationMgr ( ) [inline, private]

Definition at line 23 of file ErrorCorrelationMgr.h.

Referenced by getInstance().

:

Member Function Documentation

std::vector< ErrorCorrelation * >::iterator ErrorCorrelationMgr::findErrorCorrelation ( pss entry1,
pss entry2 
) [private]

Definition at line 102 of file ErrorCorrelationMgr.cc.

References theCorrs.

Referenced by readFromReportFile().

{
  std::vector<ErrorCorrelation*>::iterator itecorr;
  for( itecorr = theCorrs.begin(); itecorr != theCorrs.end(); itecorr++ ) {
    if( (*itecorr)->getEntry1() == entry1 &&  (*itecorr)->getEntry2() == entry2 ) {
      return itecorr;
    }
  }

  return itecorr;

}
ErrorCorrelation * ErrorCorrelationMgr::getCorrelation ( ALIint  ii)

Definition at line 91 of file ErrorCorrelationMgr.cc.

References dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, cuy::ii, and theCorrs.

Referenced by Fit::setCorrelationsInWMatrix().

{
  if( ii < 0 || ii >= ALIint(theCorrs.size()) ){
    std::cerr << "!!!EXITING: ErrorCorrelationMgr::getCorrelation. incorrect nubmer = " << ii << " size = " << theCorrs.size() << std::endl;
    exit(1);
  } else {
    return theCorrs[ii];
  }
}
ErrorCorrelationMgr * ErrorCorrelationMgr::getInstance ( ) [static]

Definition at line 15 of file ErrorCorrelationMgr.cc.

References ErrorCorrelationMgr(), and theInstance.

Referenced by readFromReportFile(), and Model::readSystemDescription().

ALIint ErrorCorrelationMgr::getNumberOfCorrelations ( ) [inline]

Definition at line 30 of file ErrorCorrelationMgr.h.

Referenced by Fit::setCorrelationsInWMatrix().

        :
void ErrorCorrelationMgr::readFromReportFile ( const ALIstring filename)

Definition at line 27 of file ErrorCorrelationMgr.cc.

References dtNoiseDBValidation_cfg::cerr, corr, gather_cfg::cout, ALIUtils::debug, ALIUtils::dumpVS(), exception, groupFilesInBlocks::fin, findErrorCorrelation(), ALIUtils::getFloat(), getInstance(), getInt(), ALIFileIn::getWordsInLine(), p1, p2, and theCorrs.

Referenced by Model::readSystemDescription().

{
  if( ALIUtils::debug >= 4 ) std::cout << " ErrorCorrelationMgr::readFromReportFile " << std::endl;
  //------ Open the file
  ALIFileIn fin = ALIFileIn::getInstance( filename );

  //------ Read the file
  std::vector<ALIstring> wl;
  typedef std::map< ALIint, std::pair<ALIstring,ALIstring>, std::less<ALIint> > miss;
  miss theEntries;
  miss::iterator missite;

  for(;;) {
    if( fin.getWordsInLine( wl ) == 0 ) break;
    // build the list of entries 
    if( wl[0] == "CAL:" || wl[0] == "UNK:" ) {
      if( ALIUtils::debug >= 4 ) ALIUtils::dumpVS( wl, " ErrorCorrelationMgr: reading entry ");
      theEntries[ALIUtils::getInt( wl[1] )] = std::pair<ALIstring,ALIstring>( wl[2], wl[3] );
    //    } else if( wl[0][0] == '(' ) {
    } else if( wl[0].substr(0,5) == "CORR:" ) {
      // find the two entries 
      int p1 = wl[1].find('(');
      int p2 = wl[1].find(')');
      //      std::cout << "( found " << p1 << " " << p2 << " = " << wl[1].substr(p1+1,p2-p1-1) << std::endl;
      if( p2 == -1 ) {
        std::cerr << "!!!ERROR:  ErrorCorrelationMgr::readFromReportFile. Word found that starts with '(' but has no ')'" << wl[1] << std::endl;
        std::exception(); 
      }
      ALIint nent = ALIUtils::getInt( wl[1].substr(p1+1,p2-p1-1));
      missite = theEntries.find( nent );
      std::pair<ALIstring,ALIstring> entry1 = (*missite).second;
      
      p1 = wl[2].find('(');
      p2 = wl[2].find(')');
      //      std::cout << "( found " << p1 << " " << p2 << " = " << wl[2].substr(p1+1,p2-p1-1) << std::endl;
      if( p2 == -1 ){
        std::cerr << "!!!ERROR:  ErrorCorrelationMgr::readFromReportFile. Word found that starts with '(' but has no ')'" << wl[2] << std::endl;
        std::exception(); 
      }
      nent = ALIUtils::getInt( wl[2].substr(p1+1,p2-p1-1));
      missite = theEntries.find( nent );
      std::pair<ALIstring,ALIstring> entry2 = (*missite).second;

      // build an ErrorCorrelation or update it if it exists
      std::vector<ErrorCorrelation*>::iterator itecorr = findErrorCorrelation( entry1, entry2 );
      if( itecorr == theCorrs.end() ){
        ErrorCorrelation* corr = new ErrorCorrelation( entry1, entry2, ALIUtils::getFloat( wl[3] ) );
        if( ALIUtils::debug >= 4 ) {
          std::cout << " ErrorCorrelationMgr: correlation created " << entry1.first << " " << entry1.second << "  " << entry2.first << " " << entry2.second << "  " << wl[3] << std::endl;
        }
        theCorrs.push_back( corr );
      } else {
        (*itecorr)->update( ALIUtils::getFloat( wl[3] ) );
        if( ALIUtils::debug >=  4 ) {
          std::cout << " ErrorCorrelationMgr: correlation updated " << entry1.first << " " << entry1.second << "  " << entry2.first << " " << entry2.second << "  " << wl[3] << std::endl;
        }
      }
    }
  }

}

Member Data Documentation

Definition at line 38 of file ErrorCorrelationMgr.h.

Referenced by findErrorCorrelation(), getCorrelation(), and readFromReportFile().

Definition at line 37 of file ErrorCorrelationMgr.h.

Referenced by getInstance().