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

#include <Residual.h>

Inheritance diagram for LArSamples::ResidualCalculator:
Collaboration diagram for LArSamples::ResidualCalculator:

Public Member Functions

 ResidualCalculator ()
 ResidualCalculator (unsigned int l, unsigned int u, bool weigh=false)
 ResidualCalculator (const Averager &regresser, bool weigh=false)
virtual ~ResidualCalculator ()
int lwb () const
int upb () const
unsigned int size () const
const Averagerregresser () const
bool weigh () const
double weight (const Residual &residual) const
bool fill (const Residual &residual)
bool remove (const Residual &residual)
bool append (const ResidualCalculator &other)
ShapeErrorDatashapeErrorData () const
TString description () const
int run (unsigned int i) const
int event (unsigned int i) const
int find (int run, int event) const
bool add (int run, int event)
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 Member Functions

bool fill_with_weight (const Residual &residual, double w)

Private Attributes

Averager m_regresser
std::vector< int > m_runs
std::vector< int > m_events
bool m_weigh

Detailed Description

Constructor & Destructor Documentation

◆ ResidualCalculator() [1/3]

LArSamples::ResidualCalculator::ResidualCalculator ( )
inline

◆ ResidualCalculator() [2/3]

LArSamples::ResidualCalculator::ResidualCalculator ( unsigned int l,
unsigned int u,
bool weigh = false )
inline

◆ ResidualCalculator() [3/3]

LArSamples::ResidualCalculator::ResidualCalculator ( const Averager & regresser,
bool weigh = false )
inline

◆ ~ResidualCalculator()

virtual LArSamples::ResidualCalculator::~ResidualCalculator ( )
inlinevirtual

Definition at line 112 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

112{ }

Member Function Documentation

◆ add()

bool ResidualCalculator::add ( int run,
int event )

Definition at line 205 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

206{
207 m_runs.push_back(r);
208 m_events.push_back(e);
209 return true;
210}
int r
Definition globals.cxx:22

◆ append()

bool ResidualCalculator::append ( const ResidualCalculator & other)

Definition at line 277 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

278{
279 if (!m_regresser.append(*other.regresser())) return false;
280 //for (std::map< std::pair<int, int >, bool >::const_iterator event = other.events().begin();
281 // event != other.events().end(); event++)
282 // m_events[event->first] = event->second;
283 for (unsigned int i = 0; i < other.size(); i++) add(other.run(i), other.event(i));
284 return true;
285}

◆ 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()); }

◆ description()

TString ResidualCalculator::description ( ) const

Definition at line 288 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

289{
290 TString str = "\n";
291 /*for (std::map< std::pair<int, int>, bool>::const_iterator ev = m_events.begin();
292 ev != m_events.end(); ev++)
293 str += Form("run %6d event %10d\n", ev->first.first, ev->first.second);
294 */
295 for (unsigned int i = 0; i < size(); i++)
296 str += Form("run %6d event %10d\n", run(i), event(i));
297
298 return str;
299}

◆ event()

int LArSamples::ResidualCalculator::event ( unsigned int i) const
inline

Definition at line 132 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

132{ return m_events[i]; }

◆ fill()

bool ResidualCalculator::fill ( const Residual & residual)

Definition at line 213 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

214{
215 if (find(residual.run(), residual.event()) >= 0) return true;
216 add(residual.run(), residual.event());
217 return fill_with_weight(residual, +1);
218}
bool fill_with_weight(const Residual &residual, double w)

◆ fill_with_weight()

bool ResidualCalculator::fill_with_weight ( const Residual & residual,
double w )
private

Definition at line 270 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

271{
272 w *= weight(residual);
273 return m_regresser.fill(residual.scaledDeltasAndTime(), w);
274}

◆ find()

int ResidualCalculator::find ( int run,
int event ) const

Definition at line 197 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

198{
199 for (unsigned int i = 0; i < size(); i++)
200 if (event(i) == e && run(i) == r) return i;
201 return -1;
202}

◆ 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); }

◆ 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::ResidualCalculator::lwb ( ) const
inlinevirtual

Implements LArSamples::IndexRange.

Definition at line 114 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

114{ return regresser()->lwb(); }
int lwb() const
Definition Averager.h:54

◆ 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); }

◆ rangeStr()

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

Definition at line 37 of file IndexRange.h.

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

◆ regresser()

const Averager * LArSamples::ResidualCalculator::regresser ( ) const
inline

Definition at line 119 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

119{ return &m_regresser; }

◆ remove()

bool ResidualCalculator::remove ( const Residual & residual)

Definition at line 221 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

222{
223 //std::pair<int, int> ev(residual.run(), residual.event());
224 //std::map< std::pair<int, int>, bool>::iterator findEv = m_events.find(ev);
225 //if (findEv == m_events.end()) return true;
226 //cout << "Will remove run = " << ev.first << ", event = " << ev.second << endl;
227 //m_events.erase(findEv);
228 int index = find(residual.run(), residual.event());
229 if (index == -1) return true;
230 m_events[index] = -1;
231 m_runs[index] = -1;
232 return fill_with_weight(residual, -1);
233}
str index
Definition DeMoScan.py:362

◆ run()

int LArSamples::ResidualCalculator::run ( unsigned int i) const
inline

Definition at line 131 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

131{ return m_runs[i]; }

◆ shapeErrorData()

ShapeErrorData * ResidualCalculator::shapeErrorData ( ) const

Definition at line 236 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

237{
238 TVectorD xi = regresser()->means().GetSub(lwb(), upb(), "I");
239 CovMatrix xiErr = regresser()->meanErrorMatrix().GetSub(lwb(), upb(), lwb(), upb(), "I");
240 double tbar = regresser()->mean(upb() + 1);
241
242 double denom = regresser()->covarianceMatrix()(upb() + 1, upb() + 1);
243 if (denom < 1E-6) {
244 TVectorD xip(lwb(), upb());
245 CovMatrix xipErr(lwb(), upb());
246 // happens for size==2 if we are removing one of the residuals.
247 if (size() > 2) cout << "WARNING: variance of t < 1E-6, returning correction without derivative term. (V = " << denom << ", N = " << size() << ")" << endl;
248 return new ShapeErrorData(xi, xip, xiErr, xipErr, tbar, regresser()->nEntries());
249 }
250
251 TVectorD xip = TVectorD(regresser()->covarianceMatrix()[upb() + 1]).GetSub(lwb(), upb(), "I");
252 xip *= -1/denom;
253
254 TVectorD xipErrVect = TVectorD(regresser()->covarianceMatrixErrors()[upb() + 1]).GetSub(lwb(), upb(), "I");
255 xipErrVect *= 1/denom;
256 CovMatrix xipErr(lwb(), upb());
257 for (int k1 = lwb(); k1 <= upb(); k1++) xipErr(k1, k1) = TMath::Power(xipErrVect(k1), 2);
258
259 return new ShapeErrorData(xi, xip, xiErr, xipErr, tbar, regresser()->nEntries());
260}
double mean(unsigned int i) const
Definition Averager.cxx:191
CovMatrix meanErrorMatrix() const
Definition Averager.cxx:138
TVectorD means() const
Definition Averager.cxx:112
CovMatrix covarianceMatrix() const
Definition Averager.cxx:153

◆ size()

unsigned int LArSamples::ResidualCalculator::size ( ) const
inline

Definition at line 117 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

117{ return m_events.size(); }

◆ upb()

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

Implements LArSamples::IndexRange.

Definition at line 115 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

115{ return regresser()->upb() - 1; }
int upb() const
Definition Averager.h:55

◆ weigh()

bool LArSamples::ResidualCalculator::weigh ( ) const
inline

Definition at line 120 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

120{ return m_weigh; }

◆ weight()

double ResidualCalculator::weight ( const Residual & residual) const

Definition at line 263 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

264{
265 if (!weigh()) return 1;
266 return TMath::Power(residual.adcMax(), 2);
267}

Member Data Documentation

◆ m_events

std::vector<int> LArSamples::ResidualCalculator::m_events
private

◆ m_regresser

Averager LArSamples::ResidualCalculator::m_regresser
private

◆ m_runs

std::vector<int> LArSamples::ResidualCalculator::m_runs
private

◆ m_weigh

bool LArSamples::ResidualCalculator::m_weigh
private

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