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)
std::unique_ptr< 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 204 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

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

◆ append()

bool ResidualCalculator::append ( const ResidualCalculator & other)

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

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

◆ 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 287 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

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

◆ 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 212 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

213{
214 if (find(residual.run(), residual.event()) >= 0) return true;
215 add(residual.run(), residual.event());
216 return fill_with_weight(residual, +1);
217}
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 269 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

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

◆ find()

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

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

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

◆ 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 220 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

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

std::unique_ptr< ShapeErrorData > ResidualCalculator::shapeErrorData ( ) const

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

236{
237 TVectorD xi = regresser()->means().GetSub(lwb(), upb(), "I");
238 CovMatrix xiErr = regresser()->meanErrorMatrix().GetSub(lwb(), upb(), lwb(), upb(), "I");
239 double tbar = regresser()->mean(upb() + 1);
240
241 double denom = regresser()->covarianceMatrix()(upb() + 1, upb() + 1);
242 if (denom < 1E-6) {
243 TVectorD xip(lwb(), upb());
244 CovMatrix xipErr(lwb(), upb());
245 // happens for size==2 if we are removing one of the residuals.
246 if (size() > 2) cout << "WARNING: variance of t < 1E-6, returning correction without derivative term. (V = " << denom << ", N = " << size() << ")" << endl;
247 return std::make_unique<ShapeErrorData>(xi, xip, xiErr, xipErr, tbar, regresser()->nEntries());
248 }
249
250 TVectorD xip = TVectorD(regresser()->covarianceMatrix()[upb() + 1]).GetSub(lwb(), upb(), "I");
251 xip *= -1/denom;
252
253 TVectorD xipErrVect = TVectorD(regresser()->covarianceMatrixErrors()[upb() + 1]).GetSub(lwb(), upb(), "I");
254 xipErrVect *= 1/denom;
255 CovMatrix xipErr(lwb(), upb());
256 for (int k1 = lwb(); k1 <= upb(); k1++) xipErr(k1, k1) = TMath::Power(xipErrVect(k1), 2);
257
258 return std::make_unique<ShapeErrorData>(xi, xip, xiErr, xipErr, tbar, regresser()->nEntries());
259}
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 262 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

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

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: