ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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

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

Constructor & Destructor Documentation

◆ ResidualCalculator() [1/3]

LArSamples::ResidualCalculator::ResidualCalculator ( )
inline

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

104 : m_weigh(false) { }

◆ ResidualCalculator() [2/3]

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

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

107  : m_regresser(l, u + 1), m_weigh(weigh) { }

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

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

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

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

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

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

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

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

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

◆ 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:
LArSamples::ResidualCalculator::m_runs
std::vector< int > m_runs
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:143
LArSamples::ResidualCalculator::m_regresser
Averager m_regresser
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:141
LArSamples::Averager::lwb
int lwb() const
Definition: Averager.h:54
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
LArSamples::IndexRange::upb
virtual int upb() const =0
LArSamples::ResidualCalculator::fill_with_weight
bool fill_with_weight(const Residual &residual, double w)
Definition: LArCalorimeter/LArSamplesMon/src/Residual.cxx:270
LArSamples::ResidualCalculator::lwb
int lwb() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:114
LArSamples::ResidualCalculator::find
int find(int run, int event) const
Definition: LArCalorimeter/LArSamplesMon/src/Residual.cxx:197
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
LArSamples::CovMatrix
TMatrixTSym< double > CovMatrix
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/Definitions.h:11
index
Definition: index.py:1
LArSamples::ResidualCalculator::weigh
bool weigh() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:120
python.LumiCalcWorking.lw
lw
Definition: LumiCalcWorking.py:112
LArSamples::IndexRange::hasSameRange
bool hasSameRange(int lw, int up) const
Definition: IndexRange.h:29
LArSamples::Averager::append
bool append(const Averager &other)
Definition: Averager.cxx:94
LArSamples::Averager::fill
bool fill(const TVectorD &values, double w=1)
Definition: Averager.cxx:69
LArSamples::Averager::mean
double mean(unsigned int i) const
Definition: Averager.cxx:191
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArSamples::ResidualCalculator::regresser
const Averager * regresser() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:119
LArSamples::ResidualCalculator::m_events
std::vector< int > m_events
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:143
LArSamples::ResidualCalculator::size
unsigned int size() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:117
LArSamples::ResidualCalculator::run
int run(unsigned int i) const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:131
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
LArSamples::ResidualCalculator::weight
double weight(const Residual &residual) const
Definition: LArCalorimeter/LArSamplesMon/src/Residual.cxx:263
LArSamples::Averager::means
TVectorD means() const
Definition: Averager.cxx:112
LArSamples::Averager::meanErrorMatrix
CovMatrix meanErrorMatrix() const
Definition: Averager.cxx:138
LArSamples::Averager::upb
int upb() const
Definition: Averager.h:55
LArSamples::IndexRange::isInRange
bool isInRange(int i) const
Definition: IndexRange.h:27
lumiFormat.i
int i
Definition: lumiFormat.py:85
h
LArSamples::Averager::covarianceMatrix
CovMatrix covarianceMatrix() const
Definition: Averager.cxx:153
CalibCoolCompareRT.up
up
Definition: CalibCoolCompareRT.py:109
compute_lumi.denom
denom
Definition: compute_lumi.py:76
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
LArSamples::IndexRange::lwb
virtual int lwb() const =0
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.index
string index
Definition: DeMoScan.py:364
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
LArSamples::ResidualCalculator::upb
int upb() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:115
LArSamples::ResidualCalculator::m_weigh
bool m_weigh
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:144
str
Definition: BTagTrackIpAccessor.cxx:11
LArSamples::ShapeErrorData
Definition: ShapeErrorData.h:19
LArSamples::IndexRange::providesRange
bool providesRange(int lw, int up) const
Definition: IndexRange.h:33
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
LArSamples::ResidualCalculator::add
bool add(int run, int event)
Definition: LArCalorimeter/LArSamplesMon/src/Residual.cxx:205
LArSamples::ResidualCalculator::event
int event(unsigned int i) const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:132