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 = nullptr
 

Detailed Description

Definition at line 19 of file ErrorCorrelationMgr.h.

Constructor & Destructor Documentation

◆ ErrorCorrelationMgr()

ErrorCorrelationMgr::ErrorCorrelationMgr ( )
inlineprivate

Definition at line 21 of file ErrorCorrelationMgr.h.

Referenced by getInstance().

21 {};

Member Function Documentation

◆ findErrorCorrelation()

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

Definition at line 105 of file ErrorCorrelationMgr.cc.

References theCorrs.

Referenced by readFromReportFile().

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

◆ getCorrelation()

ErrorCorrelation * ErrorCorrelationMgr::getCorrelation ( ALIint  ii)

Definition at line 94 of file ErrorCorrelationMgr.cc.

References DMR_cfg::cerr, beamvalidation::exit(), cuy::ii, and theCorrs.

Referenced by Fit::setCorrelationsInWMatrix().

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

◆ getInstance()

ErrorCorrelationMgr * ErrorCorrelationMgr::getInstance ( )
static

Definition at line 15 of file ErrorCorrelationMgr.cc.

References ErrorCorrelationMgr(), and theInstance.

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

15  {
16  if (!theInstance) {
18  }
19 
20  return theInstance;
21 }
static ErrorCorrelationMgr * theInstance

◆ getNumberOfCorrelations()

ALIint ErrorCorrelationMgr::getNumberOfCorrelations ( )
inline

Definition at line 28 of file ErrorCorrelationMgr.h.

References theCorrs.

Referenced by Fit::setCorrelationsInWMatrix().

28 { return theCorrs.size(); }
std::vector< ErrorCorrelation * > theCorrs

◆ readFromReportFile()

void ErrorCorrelationMgr::readFromReportFile ( const ALIstring filename)

Definition at line 24 of file ErrorCorrelationMgr.cc.

References DMR_cfg::cerr, alignCSCRings::corr, gather_cfg::cout, ALIUtils::debug, ALIUtils::dumpVS(), cppFunctionSkipper::exception, corrVsCorr::filename, groupFilesInBlocks::fin, findErrorCorrelation(), ALIUtils::getFloat(), ALIFileIn::getInstance(), ALIUtils::getInt(), DeadROCCounter::nent, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, theCorrs, and LaserClient_cfi::wl.

Referenced by Model::readSystemDescription().

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

Member Data Documentation

◆ theCorrs

std::vector<ErrorCorrelation*> ErrorCorrelationMgr::theCorrs
private

◆ theInstance

ErrorCorrelationMgr * ErrorCorrelationMgr::theInstance = nullptr
staticprivate

Definition at line 34 of file ErrorCorrelationMgr.h.

Referenced by getInstance().