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.

21 {};

Referenced by getInstance().

Member Function Documentation

◆ findErrorCorrelation()

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

Definition at line 105 of file ErrorCorrelationMgr.cc.

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 }

References theCorrs.

Referenced by readFromReportFile().

◆ getCorrelation()

ErrorCorrelation * ErrorCorrelationMgr::getCorrelation ( ALIint  ii)

Definition at line 94 of file ErrorCorrelationMgr.cc.

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 }

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

Referenced by Fit::setCorrelationsInWMatrix().

◆ getInstance()

ErrorCorrelationMgr * ErrorCorrelationMgr::getInstance ( )
static

Definition at line 15 of file ErrorCorrelationMgr.cc.

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

References ErrorCorrelationMgr(), and theInstance.

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

◆ getNumberOfCorrelations()

ALIint ErrorCorrelationMgr::getNumberOfCorrelations ( )
inline

Definition at line 28 of file ErrorCorrelationMgr.h.

28 { return theCorrs.size(); }

References theCorrs.

Referenced by Fit::setCorrelationsInWMatrix().

◆ readFromReportFile()

void ErrorCorrelationMgr::readFromReportFile ( const ALIstring filename)

Definition at line 24 of file ErrorCorrelationMgr.cc.

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 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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, p1, p2, theCorrs, and LaserClient_cfi::wl.

Referenced by Model::readSystemDescription().

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

ALIUtils::getFloat
static double getFloat(const ALIstring &str)
Convert a string to an float, checking that it is really a number.
Definition: ALIUtils.cc:373
ALIUtils::getInt
static int getInt(const ALIstring &str)
Convert a string to an integer, checking that it is really an integer.
Definition: ALIUtils.cc:384
LaserClient_cfi.wl
wl
Definition: LaserClient_cfi.py:46
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ErrorCorrelationMgr::theCorrs
std::vector< ErrorCorrelation * > theCorrs
Definition: ErrorCorrelationMgr.h:35
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
p2
double p2[4]
Definition: TauolaWrapper.h:90
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
ErrorCorrelationMgr::ErrorCorrelationMgr
ErrorCorrelationMgr()
Definition: ErrorCorrelationMgr.h:21
ErrorCorrelationMgr::theInstance
static ErrorCorrelationMgr * theInstance
Definition: ErrorCorrelationMgr.h:34
ALIFileIn::getInstance
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:22
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
p1
double p1[4]
Definition: TauolaWrapper.h:89
ErrorCorrelation
Definition: ErrorCorrelation.h:16
ALIUtils::dumpVS
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
ALIint
int ALIint
Definition: CocoaGlobals.h:15
DeadROCCounter.nent
nent
Definition: DeadROCCounter.py:67
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
cuy.ii
ii
Definition: cuy.py:590
ErrorCorrelationMgr::findErrorCorrelation
std::vector< ErrorCorrelation * >::iterator findErrorCorrelation(pss &entry1, pss &entry2)
Definition: ErrorCorrelationMgr.cc:105
ALIFileIn
Definition: ALIFileIn.h:20