ATLAS Offline Software
Loading...
Searching...
No Matches
LArSamples::OFC Class Reference

#include <OFC.h>

Inheritance diagram for LArSamples::OFC:
Collaboration diagram for LArSamples::OFC:

Public Member Functions

 OFC (const AbsShape &shape, const AbsShape &data, int lwb=-1, int upb=-1, const ShapeErrorData *sed=0, bool withAutoCorr=true)
 Constructor.
 OFC (const AbsShape &shape, const AbsShape &data, const CovMatrix &refErr, int lwb=-1, int upb=-1, const ShapeErrorData *sed=0, bool withAutoCorr=true)
bool initGValues (const AbsShape &shape, const AbsShape &data, const ShapeErrorData *sed)
bool initOFCs (const AbsShape &data, const CovMatrix &refErr, bool useCorrs)
bool initRVectors ()
 OFC (const OFC &other)
virtual ~OFC ()
unsigned int nSamples () const
int lwb () const
int upb () const
double g (unsigned int i) const
double gp (unsigned int i) const
const TVectorD & g () const
const TVectorD & gp () const
double G () const
double Gp () const
double Gpp () const
double a (unsigned int i) const
double b (unsigned int i) const
const TVectorD & a () const
const TVectorD & b () const
const TVectorD & r (unsigned int i) const
unsigned int rIdx (unsigned int i) const
const TMatrixD & resProj () const
double A (const AbsShape &data) const
double B (const AbsShape &data) const
double time (const AbsShape &data) const
const CovMatrixinvGamma () const
const CovMatrixGamma () const
double dot (const TVectorD &form, const TVectorD &v) const
TVectorD residual (const TVectorD &v) const
bool isInRange (int i) const
bool hasSameRange (int lw, int up) const
bool hasSameRange (const IndexRange &other) const
bool hasSameRange (const TVectorD &v) const
bool providesRange (int lw, int up) const
bool providesRange (const IndexRange &other) const
bool providesRange (const TVectorD &v) const
TString rangeStr () const
int commonLwb (const IndexRange &other) const
int commonUpb (const IndexRange &other) const
bool checkRange (int &l, int &h) const

Private Attributes

TVectorD m_g
TVectorD m_gp
TVectorD m_a
TVectorD m_b
double m_G = 0.0
double m_Gp = 0.0
double m_Gpp = 0.0
CovMatrix m_invGamma
CovMatrix m_Gamma
TMatrixD m_resProj
std::vector< TVectorD > m_r
std::vector< unsigned int > m_rIdx

Detailed Description

Definition at line 27 of file OFC.h.

Constructor & Destructor Documentation

◆ OFC() [1/3]

OFC::OFC ( const AbsShape & shape,
const AbsShape & data,
int lwb = -1,
int upb = -1,
const ShapeErrorData * sed = 0,
bool withAutoCorr = true )

Constructor.

Definition at line 21 of file OFC.cxx.

22 : m_g(lw, up), m_gp(lw, up)
23{
25 if (!initGValues(shape, data, sed)) return;
26 if (!initOFCs(data, CovMatrix(), withAutoCorr)) return;
27}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
TVectorD m_gp
Definition OFC.h:90
bool initOFCs(const AbsShape &data, const CovMatrix &refErr, bool useCorrs)
Definition OFC.cxx:71
bool initGValues(const AbsShape &shape, const AbsShape &data, const ShapeErrorData *sed)
Definition OFC.cxx:46
TVectorD m_g
Definition OFC.h:90

◆ OFC() [2/3]

OFC::OFC ( const AbsShape & shape,
const AbsShape & data,
const CovMatrix & refErr,
int lwb = -1,
int upb = -1,
const ShapeErrorData * sed = 0,
bool withAutoCorr = true )

Definition at line 30 of file OFC.cxx.

32 : m_g(lw, up), m_gp(lw, up)
33{
35 if (!initGValues(shape, data, sed)) return;
36 if (!initOFCs(data, refErr, withAutoCorr)) return;
37}

◆ OFC() [3/3]

LArSamples::OFC::OFC ( const OFC & other)
inline

Definition at line 41 of file OFC.h.

41 :
42 IndexRange(),
43 m_g(other.m_g), m_gp(other.m_gp), m_a(other.m_a), m_b(other.m_b),
44 m_G(other.m_G), m_Gp(other.m_Gp), m_Gpp(other.m_Gpp),
45 m_invGamma(other.m_invGamma) { }
double m_Gp
Definition OFC.h:91
TVectorD m_b
Definition OFC.h:90
double m_G
Definition OFC.h:91
double m_Gpp
Definition OFC.h:91
CovMatrix m_invGamma
Definition OFC.h:92
TVectorD m_a
Definition OFC.h:90

◆ ~OFC()

OFC::~OFC ( )
virtual

Definition at line 40 of file OFC.cxx.

Member Function Documentation

◆ A()

double OFC::A ( const AbsShape & data) const

Definition at line 145 of file OFC.cxx.

146{
147 TVectorD vals(lwb(), upb());
148
149 for (int i = lwb(); i <= upb(); i++)
150 vals[i] = data.value(i);
151
152 return dot(a(), vals);
153}
const TVectorD & a() const
Definition OFC.h:67
int upb() const
Definition OFC.h:52
int lwb() const
Definition OFC.h:51
double dot(const TVectorD &form, const TVectorD &v) const
Definition OFC.cxx:173

◆ a() [1/2]

const TVectorD & LArSamples::OFC::a ( ) const
inline

Definition at line 67 of file OFC.h.

67{ return m_a; }

◆ a() [2/2]

double LArSamples::OFC::a ( unsigned int i) const
inline

Definition at line 64 of file OFC.h.

64{ return m_a[i]; }

◆ B()

double OFC::B ( const AbsShape & data) const

Definition at line 156 of file OFC.cxx.

157{
158 TVectorD vals(lwb(), upb());
159
160 for (int i = lwb(); i <= upb(); i++)
161 vals[i] = data.value(i);
162
163 return dot(b(), vals);
164}
const TVectorD & b() const
Definition OFC.h:68

◆ b() [1/2]

const TVectorD & LArSamples::OFC::b ( ) const
inline

Definition at line 68 of file OFC.h.

68{ return m_b; }

◆ b() [2/2]

double LArSamples::OFC::b ( unsigned int i) const
inline

Definition at line 65 of file OFC.h.

65{ return m_b[i]; }

◆ checkRange()

bool IndexRange::checkRange ( int & l,
int & h ) const
inherited

Definition at line 14 of file IndexRange.cxx.

15{
16 if (l < 0)
17 l = lwb();
18 else if (!isInRange(l)) {
19 cout << "IndexRange::checkRange : lower bound " << l << " is out of bounds" << endl;
20 return false;
21 }
22
23 if (h < 0)
24 h = upb();
25 else if (!isInRange(h)) {
26 cout << "IndexRange::checkRange : upper bound " << h << " is out of bounds" << endl;
27 return false;
28 }
29
30 return true;
31}
virtual int lwb() const =0
bool isInRange(int i) const
Definition IndexRange.h:27
virtual int upb() const =0
l
Printing final latex table to .tex output file.

◆ commonLwb()

int LArSamples::IndexRange::commonLwb ( const IndexRange & other) const
inlineinherited

Definition at line 39 of file IndexRange.h.

39{ return (other.lwb() > lwb() ? other.lwb() : lwb()); }

◆ commonUpb()

int LArSamples::IndexRange::commonUpb ( const IndexRange & other) const
inlineinherited

Definition at line 40 of file IndexRange.h.

40{ return (other.upb() < upb() ? other.upb() : upb()); }

◆ dot()

double OFC::dot ( const TVectorD & form,
const TVectorD & v ) const

Definition at line 173 of file OFC.cxx.

174{
175 double s = 0;
176 for (int i = lwb(); i <= upb(); i++) s += form[i]*v[i];
177 return s;
178}

◆ G()

double LArSamples::OFC::G ( ) const
inline

Definition at line 60 of file OFC.h.

60{ return m_G; }

◆ g() [1/2]

const TVectorD & LArSamples::OFC::g ( ) const
inline

Definition at line 57 of file OFC.h.

57{ return m_g; }

◆ g() [2/2]

double LArSamples::OFC::g ( unsigned int i) const
inline

Definition at line 54 of file OFC.h.

54{ return m_g[i]; }

◆ Gamma()

const CovMatrix & LArSamples::OFC::Gamma ( ) const
inline

Definition at line 83 of file OFC.h.

83{ return m_Gamma; }
CovMatrix m_Gamma
Definition OFC.h:92

◆ Gp()

double LArSamples::OFC::Gp ( ) const
inline

Definition at line 61 of file OFC.h.

61{ return m_Gp; }

◆ gp() [1/2]

const TVectorD & LArSamples::OFC::gp ( ) const
inline

Definition at line 58 of file OFC.h.

58{ return m_gp; }

◆ gp() [2/2]

double LArSamples::OFC::gp ( unsigned int i) const
inline

Definition at line 55 of file OFC.h.

55{ return m_gp[i]; }

◆ Gpp()

double LArSamples::OFC::Gpp ( ) const
inline

Definition at line 62 of file OFC.h.

62{ return m_Gpp; }

◆ hasSameRange() [1/3]

bool LArSamples::IndexRange::hasSameRange ( const IndexRange & other) const
inlineinherited

Definition at line 30 of file IndexRange.h.

30{ return hasSameRange(other.lwb(), other.upb()); }
bool hasSameRange(int lw, int up) const
Definition IndexRange.h:29

◆ hasSameRange() [2/3]

bool LArSamples::IndexRange::hasSameRange ( const TVectorD & v) const
inlineinherited

Definition at line 31 of file IndexRange.h.

31{ return hasSameRange(v.GetLwb(), v.GetUpb()); }

◆ hasSameRange() [3/3]

bool LArSamples::IndexRange::hasSameRange ( int lw,
int up ) const
inlineinherited

Definition at line 29 of file IndexRange.h.

29{ return (lwb() == lw && upb() == up); }

◆ initGValues()

bool OFC::initGValues ( const AbsShape & shape,
const AbsShape & data,
const ShapeErrorData * sed )

Definition at line 46 of file OFC.cxx.

47{
49 if (!shape.interpolate(data, m_g, errors, lwb(), upb())) {
50 cout <<"ERROR in OFC::initGValues : indices were invalid!" << endl;
51 m_g.ResizeTo(0);
52 return false;
53 }
54 if (!shape.interpolateDiff(data, m_gp, lwb(), upb())) { // lwb and upb come from g, so set above correctly...
55 cout <<"ERROR in OFC::initGValues : (diff) indices were invalid!" << endl;
56 m_g.ResizeTo(0);
57 m_gp.ResizeTo(0);
58 return false;
59 }
60 m_g.ResizeTo(m_gp.GetLwb(), m_gp.GetUpb()); // in case gp was more restricted
61 if (sed) {
62 TVectorD xi = sed->xi(m_gp.GetLwb(), m_gp.GetUpb());
63 TVectorD xip = sed->xip(m_gp.GetLwb(), m_gp.GetUpb());
64 m_g += xi;
65 m_gp += xip;
66 }
67 return true;
68}
int interpolate(double time, double &value, double &error) const
Definition AbsShape.cxx:83
int interpolateDiff(double time, double &diff) const
Definition AbsShape.cxx:108
const TVectorD & xi() const
const TVectorD & xip() const
const ScaledErrorData * sed

◆ initOFCs()

bool OFC::initOFCs ( const AbsShape & data,
const CovMatrix & refErr,
bool useCorrs )

Definition at line 71 of file OFC.cxx.

72{
73 m_a.ResizeTo(lwb(), upb());
74 m_b.ResizeTo(lwb(), upb());
75
76 //cout << nSamples() << endl;
77 //data.covarianceMatrix().Print();
78
79 CovMatrix noiseCov = data.covarianceMatrix(lwb(), upb(), refErr, withAutoCorr);
80 CovMatrix noiseInvCov = data.invCovarianceMatrix(lwb(), upb(), refErr, withAutoCorr);
81 //noiseCov.Print();
82
83 TVectorD gam = m_g;
84 TVectorD gamp = m_gp;
85 gam *= noiseInvCov;
86 gamp *= noiseInvCov;
87
88 m_G = m_g*gam;
89 m_Gp = m_g*gamp;
90 m_Gpp = m_gp*gamp;
91
92 double denom = G()*Gpp() - Gp()*Gp();
93 //cout << m_G << " " << m_g*gam << endl;
94 //cout << m_Gp << " " << m_g*gamp << " " << m_gp*gam << endl;
95 //cout << m_Gpp << " " << m_gp*gamp << endl;
96
97 for (int i = lwb(); i <= upb(); i++) {
98 m_a(i) = (Gpp()*gam(i) - Gp()*gamp(i))/denom;
99 m_b(i) = (Gp()*gam(i) - G()*gamp(i))/denom;
100 }
101
102 m_resProj.ResizeTo(lwb(), upb(), lwb(), upb());
103 for (int i = lwb(); i <= upb(); i++) {
104 for (int j = lwb(); j <= upb(); j++) {
105 m_resProj(i,j) = (i == j ? 1 : 0) - g(i)*a(j) + gp(i)*b(j);
106 }
107 }
108
109 //m_a.Print();
110 //cout << m_a*m_g << " " << m_a*m_gp << " " << m_b*m_g << " "<< m_b*m_gp << endl;
111
112 CovMatrix resNorm(lwb(), upb());
113 for (int i = lwb(); i <= upb(); i++) {
114 for (int j = lwb(); j <= upb(); j++) {
115 double rn = noiseCov(i, j) - (Gpp()*g(i)*g(j) - Gp()*(g(i)*gp(j) + g(j)*gp(i)) + G()*gp(i)*gp(j))/denom;
116 resNorm(i, j) = rn;
117 }
118 }
119
120 m_Gamma.ResizeTo(lwb(), upb(), lwb(), upb());
121 m_Gamma = noiseCov;
122 m_Gamma.Similarity(m_resProj);
123
124 m_invGamma.ResizeTo(lwb(), upb(), lwb(), upb());
125 m_invGamma = noiseInvCov;
126 m_invGamma.Similarity(m_resProj);
127 return true;
128}
double Gp() const
Definition OFC.h:61
double Gpp() const
Definition OFC.h:62
const TVectorD & gp() const
Definition OFC.h:58
double G() const
Definition OFC.h:60
const TVectorD & g() const
Definition OFC.h:57
TMatrixD m_resProj
Definition OFC.h:93

◆ initRVectors()

bool OFC::initRVectors ( )

Definition at line 131 of file OFC.cxx.

132{
133 m_r.clear();
134 m_rIdx.clear();
135 for (unsigned int k = 0; k < nSamples() - 2; k++) {
136 TVectorD res(nSamples());
137 res[k] = 1;
138 m_r.push_back(residual(res));
139 m_rIdx.push_back(k);
140 }
141 return true;
142}
std::pair< std::vector< unsigned int >, bool > res
TVectorD residual(const TVectorD &v) const
Definition OFC.cxx:167
unsigned int nSamples() const
Definition OFC.h:49
std::vector< unsigned int > m_rIdx
Definition OFC.h:95
std::vector< TVectorD > m_r
Definition OFC.h:94

◆ invGamma()

const CovMatrix & LArSamples::OFC::invGamma ( ) const
inline

Definition at line 82 of file OFC.h.

82{ return m_invGamma; }

◆ isInRange()

bool LArSamples::IndexRange::isInRange ( int i) const
inlineinherited

Definition at line 27 of file IndexRange.h.

27{ return (i >= lwb() && i <= upb()); }

◆ lwb()

int LArSamples::OFC::lwb ( ) const
inlinevirtual

Implements LArSamples::IndexRange.

Definition at line 51 of file OFC.h.

51{ return g().GetLwb(); }

◆ nSamples()

unsigned int LArSamples::OFC::nSamples ( ) const
inline

Definition at line 49 of file OFC.h.

49{ return m_g.GetNoElements(); }

◆ providesRange() [1/3]

bool LArSamples::IndexRange::providesRange ( const IndexRange & other) const
inlineinherited

Definition at line 34 of file IndexRange.h.

34{ return providesRange(other.lwb(), other.upb()); }
bool providesRange(int lw, int up) const
Definition IndexRange.h:33

◆ providesRange() [2/3]

bool LArSamples::IndexRange::providesRange ( const TVectorD & v) const
inlineinherited

Definition at line 35 of file IndexRange.h.

35{ return providesRange(v.GetLwb(), v.GetUpb()); }

◆ providesRange() [3/3]

bool LArSamples::IndexRange::providesRange ( int lw,
int up ) const
inlineinherited

Definition at line 33 of file IndexRange.h.

33{ return (lwb() <= lw && upb() >= up); }

◆ r()

const TVectorD & LArSamples::OFC::r ( unsigned int i) const
inline

Definition at line 70 of file OFC.h.

70{ return m_r[i]; }

◆ rangeStr()

TString LArSamples::IndexRange::rangeStr ( ) const
inlineinherited

Definition at line 37 of file IndexRange.h.

37{ return Form("[%d, %d]", lwb(), upb()); }

◆ residual()

TVectorD OFC::residual ( const TVectorD & v) const

Definition at line 167 of file OFC.cxx.

168{
169 return v + (-1)*dot(a(), v)*g() + (-1)*dot(b(), v)*gp();
170}

◆ resProj()

const TMatrixD & LArSamples::OFC::resProj ( ) const
inline

Definition at line 73 of file OFC.h.

73{ return m_resProj; }

◆ rIdx()

unsigned int LArSamples::OFC::rIdx ( unsigned int i) const
inline

Definition at line 71 of file OFC.h.

71{ return m_rIdx[i]; }

◆ time()

double LArSamples::OFC::time ( const AbsShape & data) const
inline

Definition at line 77 of file OFC.h.

77 {
78 double den = A(data);
79 return den == 0 ? 0 : B(data)/den;
80 }
double B(const AbsShape &data) const
Definition OFC.cxx:156
double A(const AbsShape &data) const
Definition OFC.cxx:145

◆ upb()

int LArSamples::OFC::upb ( ) const
inlinevirtual

Implements LArSamples::IndexRange.

Definition at line 52 of file OFC.h.

52{ return g().GetUpb(); }

Member Data Documentation

◆ m_a

TVectorD LArSamples::OFC::m_a
private

Definition at line 90 of file OFC.h.

◆ m_b

TVectorD LArSamples::OFC::m_b
private

Definition at line 90 of file OFC.h.

◆ m_G

double LArSamples::OFC::m_G = 0.0
private

Definition at line 91 of file OFC.h.

◆ m_g

TVectorD LArSamples::OFC::m_g
private

Definition at line 90 of file OFC.h.

◆ m_Gamma

CovMatrix LArSamples::OFC::m_Gamma
private

Definition at line 92 of file OFC.h.

◆ m_Gp

double LArSamples::OFC::m_Gp = 0.0
private

Definition at line 91 of file OFC.h.

◆ m_gp

TVectorD LArSamples::OFC::m_gp
private

Definition at line 90 of file OFC.h.

◆ m_Gpp

double LArSamples::OFC::m_Gpp = 0.0
private

Definition at line 91 of file OFC.h.

◆ m_invGamma

CovMatrix LArSamples::OFC::m_invGamma
private

Definition at line 92 of file OFC.h.

◆ m_r

std::vector<TVectorD> LArSamples::OFC::m_r
private

Definition at line 94 of file OFC.h.

◆ m_resProj

TMatrixD LArSamples::OFC::m_resProj
private

Definition at line 93 of file OFC.h.

◆ m_rIdx

std::vector<unsigned int> LArSamples::OFC::m_rIdx
private

Definition at line 95 of file OFC.h.


The documentation for this class was generated from the following files: