CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ErrorCorrelationMgr Class Reference

#include <ErrorCorrelationMgr.h>

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

Definition at line 22 of file ErrorCorrelationMgr.h.

References corrVsCorr::filename, getCorrelation(), getInstance(), cuy::ii, and readFromReportFile().

Referenced by getInstance().

22 {};

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 getNumberOfCorrelations(), and readFromReportFile().

103 {
104  std::vector<ErrorCorrelation*>::iterator itecorr;
105  for( itecorr = theCorrs.begin(); itecorr != theCorrs.end(); ++itecorr ) {
106  if( (*itecorr)->getEntry1() == entry1 && (*itecorr)->getEntry2() == entry2 ) {
107  return itecorr;
108  }
109  }
110 
111  return itecorr;
112 
113 }
std::vector< ErrorCorrelation * > theCorrs
ErrorCorrelation * ErrorCorrelationMgr::getCorrelation ( ALIint  ii)

Definition at line 91 of file ErrorCorrelationMgr.cc.

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

Referenced by ErrorCorrelationMgr(), and Fit::setCorrelationsInWMatrix().

92 {
93  if( ii < 0 || ii >= ALIint(theCorrs.size()) ){
94  std::cerr << "!!!EXITING: ErrorCorrelationMgr::getCorrelation. incorrect nubmer = " << ii << " size = " << theCorrs.size() << std::endl;
95  exit(1);
96  } else {
97  return theCorrs[ii];
98  }
99 }
int ALIint
Definition: CocoaGlobals.h:15
ii
Definition: cuy.py:588
std::vector< ErrorCorrelation * > theCorrs
ErrorCorrelationMgr * ErrorCorrelationMgr::getInstance ( )
static

Definition at line 15 of file ErrorCorrelationMgr.cc.

References ErrorCorrelationMgr(), and theInstance.

Referenced by ErrorCorrelationMgr(), Model::readSystemDescription(), and Fit::setCorrelationsInWMatrix().

16 {
17  if( !theInstance ) {
19  }
20 
21  return theInstance;
22 
23 }
static ErrorCorrelationMgr * theInstance
ALIint ErrorCorrelationMgr::getNumberOfCorrelations ( )
inline

Definition at line 29 of file ErrorCorrelationMgr.h.

References findErrorCorrelation(), and theCorrs.

Referenced by Fit::setCorrelationsInWMatrix().

29  {
30  return theCorrs.size(); }
std::vector< ErrorCorrelation * > theCorrs
void ErrorCorrelationMgr::readFromReportFile ( const ALIstring filename)

Definition at line 27 of file ErrorCorrelationMgr.cc.

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

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

28 {
29  if( ALIUtils::debug >= 4 ) std::cout << " ErrorCorrelationMgr::readFromReportFile " << std::endl;
30  //------ Open the file
32 
33  //------ Read the file
34  std::vector<ALIstring> wl;
35  typedef std::map< ALIint, std::pair<ALIstring,ALIstring>, std::less<ALIint> > miss;
36  miss theEntries;
37  miss::iterator missite;
38 
39  for(;;) {
40  if( fin.getWordsInLine( wl ) == 0 ) break;
41  // build the list of entries
42  if( wl[0] == "CAL:" || wl[0] == "UNK:" ) {
43  if( ALIUtils::debug >= 4 ) ALIUtils::dumpVS( wl, " ErrorCorrelationMgr: reading entry ");
44  theEntries[ALIUtils::getInt( wl[1] )] = std::pair<ALIstring,ALIstring>( wl[2], wl[3] );
45  // } else if( wl[0][0] == '(' ) {
46  } else if( wl[0].substr(0,5) == "CORR:" ) {
47  // find the two entries
48  int p1 = wl[1].find('(');
49  int p2 = wl[1].find(')');
50  // std::cout << "( found " << p1 << " " << p2 << " = " << wl[1].substr(p1+1,p2-p1-1) << std::endl;
51  if( p2 == -1 ) {
52  std::cerr << "!!!ERROR: ErrorCorrelationMgr::readFromReportFile. Word found that starts with '(' but has no ')'" << wl[1] << std::endl;
53  std::exception();
54  }
55  ALIint nent = ALIUtils::getInt( wl[1].substr(p1+1,p2-p1-1));
56  missite = theEntries.find( nent );
57  std::pair<ALIstring,ALIstring> entry1 = (*missite).second;
58 
59  p1 = wl[2].find('(');
60  p2 = wl[2].find(')');
61  // std::cout << "( found " << p1 << " " << p2 << " = " << wl[2].substr(p1+1,p2-p1-1) << std::endl;
62  if( p2 == -1 ){
63  std::cerr << "!!!ERROR: ErrorCorrelationMgr::readFromReportFile. Word found that starts with '(' but has no ')'" << wl[2] << std::endl;
64  std::exception();
65  }
66  nent = ALIUtils::getInt( wl[2].substr(p1+1,p2-p1-1));
67  missite = theEntries.find( nent );
68  std::pair<ALIstring,ALIstring> entry2 = (*missite).second;
69 
70  // build an ErrorCorrelation or update it if it exists
71  std::vector<ErrorCorrelation*>::iterator itecorr = findErrorCorrelation( entry1, entry2 );
72  if( itecorr == theCorrs.end() ){
73  ErrorCorrelation* corr = new ErrorCorrelation( entry1, entry2, ALIUtils::getFloat( wl[3] ) );
74  if( ALIUtils::debug >= 4 ) {
75  std::cout << " ErrorCorrelationMgr: correlation created " << entry1.first << " " << entry1.second << " " << entry2.first << " " << entry2.second << " " << wl[3] << std::endl;
76  }
77  theCorrs.push_back( corr );
78  } else {
79  (*itecorr)->update( ALIUtils::getFloat( wl[3] ) );
80  if( ALIUtils::debug >= 4 ) {
81  std::cout << " ErrorCorrelationMgr: correlation updated " << entry1.first << " " << entry1.second << " " << entry2.first << " " << entry2.second << " " << wl[3] << std::endl;
82  }
83  }
84  }
85  }
86 
87 }
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:23
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:36
static double getFloat(const ALIstring &str)
Convert a string to an float, checking that it is really a number.
Definition: ALIUtils.cc:404
double p2[4]
Definition: TauolaWrapper.h:90
JetCorrectorParameters corr
Definition: classes.h:5
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:83
std::vector< ErrorCorrelation * > theCorrs
static void dumpVS(const std::vector< ALIstring > &wl, const std::string &msg, std::ostream &outs=std::cout)
dumps a vector of strings with a message to outs
Definition: ALIUtils.cc:501
double p1[4]
Definition: TauolaWrapper.h:89
std::vector< ErrorCorrelation * >::iterator findErrorCorrelation(pss &entry1, pss &entry2)
static int getInt(const ALIstring &str)
Convert a string to an integer, checking that it is really an integer.
Definition: ALIUtils.cc:417

Member Data Documentation

std::vector<ErrorCorrelation*> ErrorCorrelationMgr::theCorrs
private
ErrorCorrelationMgr * ErrorCorrelationMgr::theInstance = 0
staticprivate

Definition at line 36 of file ErrorCorrelationMgr.h.

Referenced by getInstance().