ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
LArSamples::History Class Reference

#include <History.h>

Collaboration diagram for LArSamples::History:

Public Member Functions

 History (const HistoryContainer &container, const std::vector< const EventData * > &eventData, unsigned int hash, const AbsShapeErrorGetter *shapeErrorGetter=0)
 Constructor
More...
 
 History (const std::vector< const Data * > &data, const CellInfo &info, const std::vector< const EventData * > &eventData, unsigned int hash, const AbsShapeErrorGetter *shapeErrorGetter=0)
 
virtual ~History ()
 
HistoryContainerdissolve ()
 
unsigned int nData () const
 
const Datadata (unsigned int i) const
 
const Datadata_for_event (int event, int run=-1) const
 
const Datadata_for_event (const EventData &eventData) const
 
const CellInfocellInfo () const
 
const std::vector< const EventData * > & eventData () const
 
bool sum (SimpleShape *&sum, SimpleShape *&reference) const
 
bool allShape (GraphShape *&allData, SimpleShape *&allRef) const
 
double allChi2 (Chi2Params pars) const
 
double chi2 (int i, int lwb=-1, int upb=-1, int chi2Params=DefaultChi2, ShapeErrorType shapeErrorType=BestShapeError, unsigned int *nDof=0) const
 
double chi2_k (int i, double k, int lwb=-1, int upb=-1, int chi2Params=DefaultChi2) const
 
double maxChi2 (int lwb=-1, int upb=-1, int chi2Params=DefaultChi2) const
 
OFCofc (unsigned int i, int lwb=-1, int upb=-1, double time=Definitions::none, bool useCorrs=true) const
 
Historyrefit (Chi2Params pars=DefaultChi2) const
 
Historyadjust () const
 
Historyfilter (const TString &cuts) const
 
bool refVal (unsigned int i, unsigned int sample, double &val, double &err) const
 
bool delta (unsigned int i, unsigned int sample, double &del) const
 
TVectorD deltas (unsigned int i, int lwb=-1, int upb=-1, bool correct=true) const
 
bool isValid () const
 
TString description (unsigned int verbosity=1) const
 
SimpleShapereferenceShape (unsigned int k, double adcMax=-1, double time=Definitions::none, bool samplesOnly=false) const
 
SimpleShapedeltaShape (unsigned int k, int lwb=-1, int upb=-1) const
 
unsigned int hash () const
 
void setShapeErrorGetter (const AbsShapeErrorGetter *err) const
 
const AbsShapeErrorGettershapeErrorGetter () const
 
const ShapeErrorDatashapeErrorData (CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
 
const ScaledErrorDatascaledErrorData (unsigned int i, double adcMax=-1, double time=Definitions::none, ShapeErrorType shapeErrorType=BestShapeError) const
 
bool residualOffset (unsigned int i, short sample, double &offset, double adcMax=-1, double time=Definitions::none) const
 
bool residualError (unsigned int i, short sample1, short sample2, double &offset, double adcMax=-1, double time=Definitions::none) const
 
bool drawWithReference (int i, const TString &atlasTitle="") const
 
bool drawSumWithReference () const
 
bool drawAllWithReference (bool refit=false) const
 
bool drawResiduals (int k=-1, bool errors=true, bool rescale=true) const
 
AveragercalculatePedestal (int i) const
 
Residualresidual (unsigned int k, bool correct=true, bool zeroTime=false) const
 
Residualsresiduals (CaloGain::CaloGain gain=CaloGain::LARNGAIN, double absResTrunc=-1, bool correct=true, bool zeroTime=false) const
 
double upstreamEnergy (unsigned int k) const
 
double chi2Anomaly (double chi2Cut, unsigned int nDof=3) const
 
void setInterface (const Interface *interface) const
 

Private Attributes

std::vector< const Data * > m_data
 
CellInfo m_cellInfo
 
std::vector< const EventData * > m_eventData
 
unsigned int m_hash
 
const AbsShapeErrorGetterm_shapeErrorGetter
 
const Interfacem_interface = nullptr
 

Detailed Description

Definition at line 40 of file History.h.

Constructor & Destructor Documentation

◆ History() [1/2]

LArSamples::History::History ( const HistoryContainer container,
const std::vector< const EventData * > &  eventData,
unsigned int  hash,
const AbsShapeErrorGetter shapeErrorGetter = 0 
)

Constructor

◆ History() [2/2]

History::History ( const std::vector< const Data * > &  data,
const CellInfo info,
const std::vector< const EventData * > &  eventData,
unsigned int  hash,
const AbsShapeErrorGetter shapeErrorGetter = 0 
)

Definition at line 53 of file History.cxx.

58 {
60  unsigned int i = 0;
61  for (const Data* data : m_data)
62  data->setCallBacks(this, i);
63 }

◆ ~History()

History::~History ( )
virtual

Definition at line 66 of file History.cxx.

67 {
69  for (const Data* data : m_data)
70  delete data;
71  for (const EventData* eventData : m_eventData)
72  delete eventData;
73 }

Member Function Documentation

◆ adjust()

History * History::adjust ( ) const

Definition at line 256 of file History.cxx.

257 {
258  std::vector<const Data*> datas;
259  DataTweaker tw;
260  tw.setAdjust(true);
261 
262  for (unsigned int j = 0; j < nData(); j++) {
263  Data* newData = tw.tweak(*data(j));
264  if (!newData) {
265  for (unsigned int k = 0; k < datas.size(); k++) delete datas[k];
266  return nullptr;
267  }
268  datas.push_back(newData);
269  }
270 
271  std::vector<const EventData*> eventData;
272  for (const EventData* event : m_eventData)
273  eventData.push_back(new EventData(*event));
274 
275  return new History(datas, *cellInfo(), eventData, hash(), shapeErrorGetter());
276 }

◆ allChi2()

double History::allChi2 ( Chi2Params  pars) const

Definition at line 436 of file History.cxx.

437 {
438  Chi2Calc c2c(pars);
439 
440  GraphShape* allData = nullptr;
441  SimpleShape* allRef = nullptr;
442  if (!allShape(allData, allRef)) return -1;
443  double chi2Value = c2c.chi2(*allData, *allRef);
444  delete allData;
445  delete allRef;
446  return chi2Value;
447 }

◆ allShape()

bool History::allShape ( GraphShape *&  allData,
SimpleShape *&  allRef 
) const

Definition at line 410 of file History.cxx.

411 {
412  allData = nullptr;
413  allRef = nullptr;
414 
415  for (unsigned int j = 0; j < nData(); j++) {
416  if ( m_data[j]->isDisconnected()) continue;
417  if (m_data[j]->adcMax() < 1) continue;
418  GraphShape* thisData = new GraphShape(*m_data[j], 1/m_data[j]->adcMax(), -m_data[j]->ofcTime());
419  if (allData) {
420  allData->add(*thisData);
421  delete thisData;
422  }
423  else allData = thisData;
424  SimpleShape* thisRef = referenceShape(j, 1); // normalized to 1, like the data
425  if (allRef) {
426  allRef->add(*thisRef);
427  delete thisRef;
428  }
429  else allRef = thisRef;
430  }
431 
432  return true;
433 }

◆ calculatePedestal()

Averager * History::calculatePedestal ( int  i) const

Definition at line 583 of file History.cxx.

584 {
585  Averager* avg = new Averager(1);
586  for (unsigned int k = 0; k < nData(); k++) {
587  if (i >= 0 && i != (int)k) continue;
589  if (!reference) continue;
590  double v,e;
591  for (unsigned int l = 0; l < data(k)->nPoints(); l++)
592  if (reference->interpolate(data(k)->time(l), v, e) == -1) { // we're before the ref shapeError
593  TVectorD ped(1);
594  ped(0) = data(k)->value(l);
595  avg->fill(ped);
596  }
597  delete reference;
598  }
599  return avg;
600 }

◆ cellInfo()

const CellInfo* LArSamples::History::cellInfo ( ) const
inline

Definition at line 61 of file History.h.

61 { return &m_cellInfo; }

◆ chi2()

double History::chi2 ( int  i,
int  lwb = -1,
int  upb = -1,
int  chi2Params = DefaultChi2,
ShapeErrorType  shapeErrorType = BestShapeError,
unsigned int *  nDof = 0 
) const

Definition at line 161 of file History.cxx.

162 {
164  if (!reference) return -1;
165  Chi2Calc c2c(chi2Params);
166  if ( m_data[i]->isDisconnected()) return -1;
167  const ScaledErrorData* sea = scaledErrorData(i, -1, Definitions::none, shapeErrorType);
168  if (!sea && shapeErrorType != NoShapeError && shapeErrorType != BestShapeError) return -1;
169  double chi2Value = c2c.chi2(*m_data[i], *reference, sea, lwb, upb);
170  if (nDof) *nDof = c2c.nDof();
171  if (sea) delete sea;
172  delete reference;
173  return chi2Value;
174 }

◆ chi2_k()

double History::chi2_k ( int  i,
double  k,
int  lwb = -1,
int  upb = -1,
int  chi2Params = DefaultChi2 
) const

Definition at line 177 of file History.cxx.

178 {
179  const AbsShapeErrorGetter* oldGetter = shapeErrorGetter();
182  if (oldGetter) combGetter->add(*oldGetter);
183  combGetter->add(*uniGetter);
184  setShapeErrorGetter(combGetter);
185  double chi2Value = chi2(i, lwb, upb, chi2Params);
186  setShapeErrorGetter(oldGetter);
187  delete combGetter;
188  delete uniGetter;
189  return chi2Value;
190 }

◆ chi2Anomaly()

double History::chi2Anomaly ( double  chi2Cut,
unsigned int  nDof = 3 
) const

Definition at line 661 of file History.cxx.

662 {
663  if (nData() == 0 || chi2Cut <= 0) return -1;
664  double nBadChi2 = 0;
665  for (unsigned int k = 0; k < nData(); k++) if (chi2(k) > chi2Cut) nBadChi2++;
666  double effBad = nBadChi2/nData();
667  double effRef = TMath::Prob(chi2Cut, nDof);
668  double dEff = sqrt(effRef*(1 - effRef))/sqrt(nData());
669  if (dEff == 0) dEff = 1/sqrt(nData());
670  return (effBad - effRef)/dEff;
671 }

◆ data()

const Data * History::data ( unsigned int  i) const

Definition at line 88 of file History.cxx.

89 {
90  if (i >= nData()) return nullptr;
91  return m_data[i];
92 }

◆ data_for_event() [1/2]

const Data * History::data_for_event ( const EventData eventData) const

Definition at line 106 of file History.cxx.

107 {
108  // turn off caching
109 
110  //if (m_dataForEvent.size() == 0)
111  // for (unsigned int k = 0; k < nData(); k++)
112  // m_dataForEvent[data(k)->event()] = std::make_pair(data(k)->run(), data(k));
113 
114  //std::unordered_map<int, std::pair<int, const Data*> >::const_iterator
115  // data = m_dataForEvent.find(eventData.event());
116  //if (data == m_dataForEvent.end()) return 0;
117  //if (data->second.first != eventData.run()) return data_for_event(eventData.event(), eventData.run()); // wrong run: revert to pedestrian method...
118  //return data->second.second;
119 
120  return data_for_event(eventData.event(), eventData.run());
121 }

◆ data_for_event() [2/2]

const Data * History::data_for_event ( int  event,
int  run = -1 
) const

Definition at line 95 of file History.cxx.

96 {
97  for (unsigned int k = 0; k < nData(); k++) {
98  if (data(k)->event() != event) continue;
99  if (run > 0 && data(k)->run() != run) continue;
100  return data(k);
101  }
102  return nullptr;
103 }

◆ delta()

bool History::delta ( unsigned int  i,
unsigned int  sample,
double &  del 
) const

Definition at line 363 of file History.cxx.

364 {
365  if (k >= nData()) return 0;
366  TVectorD dv = deltas(k, sample, sample);
367  if (dv.GetNrows() == 0) return false;
368  del = dv[sample];
369  return true;
370 }

◆ deltas()

TVectorD History::deltas ( unsigned int  i,
int  lwb = -1,
int  upb = -1,
bool  correct = true 
) const

Definition at line 373 of file History.cxx.

374 {
375  if (k >= nData()) return TVectorD();
377  if (!reference) return TVectorD();
378  Chi2Calc c2c;
380  const ScaledErrorData* sea = (correct ? scaledErrorData(k) : nullptr);
381  TVectorD dv = c2c.deltas(*data(k), *reference, errors, sea, lwb, upb);
382  if (sea) delete sea;
383  delete reference;
384  return dv;
385 }

◆ deltaShape()

SimpleShape * History::deltaShape ( unsigned int  k,
int  lwb = -1,
int  upb = -1 
) const

Definition at line 555 of file History.cxx.

556 {
557  if (k >= nData()) return nullptr;
559  if (!reference) return nullptr;
560  Chi2Calc c2c;
562  const ScaledErrorData* sea = scaledErrorData(k);
563  TVectorD dv = c2c.deltas(*data(k), *reference, errors, sea, lwb, upb);
564  if (sea) delete sea;
565  delete reference;
566  if (dv.GetNrows() == 0) return nullptr;
567  SimpleShape* shape = new SimpleShape(dv.GetNrows(), Definitions::samplingInterval, data(k)->time(c2c.lwb()) + data(k)->ofcTime());
568  for (int l = c2c.lwb(); l <= c2c.upb(); l++) shape->set(l - c2c.lwb(), dv(l), TMath::Sqrt(errors(l, l)));
569  return shape;
570 }

◆ description()

TString History::description ( unsigned int  verbosity = 1) const

Definition at line 573 of file History.cxx.

574 {
575  TString desc = "";
576  for (unsigned int i = 0; i < nData(); i++)
577  desc += Form(" #%-2d : ", i) + data(i)->description(verbosity) + "\n";
578  if (desc == "") return desc;
579  return cellInfo()->location(2) + "\n" + desc;
580 }

◆ dissolve()

HistoryContainer * History::dissolve ( )

Definition at line 76 of file History.cxx.

77 {
78  HistoryContainer* histCont = new HistoryContainer(new CellInfo(*cellInfo()));
79  for (unsigned int k = 0; k < nData(); k++) {
80  Data* newData = new Data(*data(k));
81  histCont->add(newData->dissolve());
82  }
83  delete this;
84  return histCont;
85 }

◆ drawAllWithReference()

bool History::drawAllWithReference ( bool  refit = false) const

Definition at line 483 of file History.cxx.

484 {
485  if (!nData()) {
486  cout << "No data" << endl;
487  return false;
488  }
489 
490  if (doRefit) {
491  History* refitted_history = refit(DefaultChi2);
492  if (!refitted_history) return false;
493  bool result = refitted_history->drawAllWithReference(false);
494  delete refitted_history;
495  return result;
496  }
497 
498  // Use the shape of the gain of the first pulse...
499  SimpleShape* refShape = referenceShape(0, 1000, 0);
500  SimpleShape* smpShape = referenceShape(0, 1000, 0, true);
501  std::vector<const AbsShape*> shapes;
502 
503  for (unsigned int i = 0; i < nData(); i++) {
504  if (m_data[i]->adcMax() < 1) continue;
505  SimpleShape* shape = new SimpleShape(*m_data[i], 1000/m_data[i]->adcMax(), -m_data[i]->ofcTime());
506  const ScaledErrorData* sed = scaledErrorData(i, 1000);
507  if (sed) {
508  for (unsigned int k = 0; k < shape->nPoints(); k++)
509  if (sed->isInRange(k))
510  shape->set(k, shape->value(k) - sed->offsets()(k));
511  delete sed;
512  }
513  shapes.push_back(shape);
514  }
515 
517  return drawer.drawAndDelete(Form("%s (Normalized Shape, max at 1000)", cellInfo()->location(2).Data()), shapes, refShape, smpShape);
518 }

◆ drawResiduals()

bool History::drawResiduals ( int  k = -1,
bool  errors = true,
bool  rescale = true 
) const

Definition at line 521 of file History.cxx.

522 {
523  std::vector<const AbsShape*> shapes;
524  for (unsigned int i = 0; i < nData(); i++) {
525  if (m_data[i]->adcMax() < 1) continue;
526  if (k >= 0 && k != (int)i) continue;
527  SimpleShape* shape = deltaShape(i);
528  if (!errors)
529  for (unsigned int k = 0; k < shape->nPoints(); k++) shape->setError(k, 0);
530  if (!shape) continue;
531  if (rescale) {
532  SimpleShape* scaled = new SimpleShape(*shape, 1/m_data[i]->adcMax(), 9.0*i/nData() - m_data[i]->ofcTime());
533  delete shape;
534  shape = scaled;
535  }
536  shapes.push_back(shape);
537  }
539  TString title = (rescale ? "Normalized " : "") + TString("residuals for %s");
540  return drawer.drawAndDelete(Form(title.Data(), cellInfo()->location(2).Data()), shapes);
541 }

◆ drawSumWithReference()

bool History::drawSumWithReference ( ) const

Definition at line 473 of file History.cxx.

474 {
475  SimpleShape* dataShape, *refShape;
476  if (!sum(dataShape, refShape)) return false;
477 
479  return drawer.drawAndDelete("", dataShape, refShape);
480 }

◆ drawWithReference()

bool History::drawWithReference ( int  i,
const TString &  atlasTitle = "" 
) const

Definition at line 450 of file History.cxx.

451 {
452  if ((unsigned int)k >= nData()) return false;
453  SimpleShape* refShape = referenceShape(k);
454  SimpleShape* smpShape = referenceShape(k, -1, Definitions::none, true);
455 
456  if (!refShape || !smpShape) return false;
457  int pars = DataFirst | Legend;
458  TString title = "";
459  if (atlasTitle != "") { // Make sure AtlasStyle is set in ROOT, otherwise will not be as pretty...
460  pars |= AtlasStyle;
461  title = atlasTitle;
462  }
463  else
464  title = Form("%s, run %d, event %d", cellInfo()->location(1).Data(), m_data[k]->run(), m_data[k]->event());
466  bool result = drawer.draw(title, m_data[k], refShape, smpShape);
467  delete refShape;
468  delete smpShape;
469  return result;
470 }

◆ eventData()

const std::vector<const EventData*>& LArSamples::History::eventData ( ) const
inline

Definition at line 63 of file History.h.

63 { return m_eventData; }

◆ filter()

History * History::filter ( const TString &  cuts) const

Definition at line 279 of file History.cxx.

280 {
281  FilterParams f;
282  if (!f.set(cuts)) return nullptr;
283 
284  std::vector<const Data*> datas;
285 
286  for (unsigned int j = 0; j < nData(); j++) {
287  if (!f.pass(hash(), *this, j)) continue;
288  datas.push_back(new Data(*data(j)));
289  }
290 
291  std::vector<const EventData*> eventData;
292  for (const EventData* event : m_eventData)
293  eventData.push_back(new EventData(*event));
294 
295  return new History(datas, *cellInfo(), eventData, hash(), shapeErrorGetter());
296 }

◆ hash()

unsigned int LArSamples::History::hash ( ) const
inline

Definition at line 91 of file History.h.

91 { return m_hash; }

◆ isValid()

bool History::isValid ( ) const

Definition at line 149 of file History.cxx.

150 {
151  if (!m_cellInfo.isValid()) return false;
152  if (nData() == 0) return false;
153 
154  for (const Data* data : m_data)
155  if (!data->isValid()) return false;
156 
157  return true;
158 }

◆ maxChi2()

double History::maxChi2 ( int  lwb = -1,
int  upb = -1,
int  chi2Params = DefaultChi2 
) const

Definition at line 193 of file History.cxx.

194 {
195  double maxChi2 = -2;
196  for (unsigned int i = 0; i < nData(); i++) {
197  double chi2Value = chi2(i, lwb, upb, chi2Params);
198  if (chi2Value > maxChi2) maxChi2 = chi2Value;
199  }
200  return maxChi2;
201 }

◆ nData()

unsigned int LArSamples::History::nData ( ) const
inline

Definition at line 56 of file History.h.

56 { return m_data.size(); }

◆ ofc()

OFC * History::ofc ( unsigned int  i,
int  lwb = -1,
int  upb = -1,
double  time = Definitions::none,
bool  useCorrs = true 
) const

Definition at line 204 of file History.cxx.

205 {
206  if (k >= nData()) return nullptr;
207  if (Definitions::isNone(time)) {
208  time = data(k)->ofcTime();
209  //cout << "Using reference time = " << time << endl;
210  }
211  SimpleShape* reference = referenceShape(k, 1, time); // ADC=1 : we need a normalized shape
212  if (!reference) return nullptr;
213  OFC* result = new OFC(*reference, *m_data[k], lwb, upb, shapeErrorData(CaloGain::LARHIGHGAIN), withAutoCorr); // FixMe
214  delete reference;
215  if (!result) return nullptr;
216  if (result->g().GetNrows() == 0) { delete result; result = nullptr; }
217  return result;
218 }

◆ referenceShape()

SimpleShape * History::referenceShape ( unsigned int  k,
double  adcMax = -1,
double  time = Definitions::none,
bool  samplesOnly = false 
) const

Definition at line 544 of file History.cxx.

546 {
547  if (!cellInfo()->shape(m_data[k]->gain())) return nullptr;
548  if (adcMax < 0) adcMax = m_data[k]->adcMax();
549  if (Definitions::isNone(time)) time = m_data[k]->ofcTime();
550  SimpleShape* shape = new SimpleShape(*cellInfo()->shape(m_data[k]->gain()), adcMax, time, samplesOnly);
551  return shape;
552 }

◆ refit()

History * History::refit ( Chi2Params  pars = DefaultChi2) const

Definition at line 232 of file History.cxx.

233 {
234  std::vector<const Data*> datas;
235  DataTweaker tw;
236  tw.setRefit(true);
237  tw.setFitParams(pars);
238 
239  for (unsigned int j = 0; j < nData(); j++) {
240  Data* refitData = tw.tweak(*data(j));
241  if (!refitData) {
242  for (unsigned int k = 0; k < datas.size(); k++) delete datas[k];
243  return nullptr;
244  }
245  datas.push_back(refitData);
246  }
247 
248  std::vector<const EventData*> eventData;
249  for (const EventData* event : m_eventData)
250  eventData.push_back(new EventData(*event));
251 
252  return new History(datas, *cellInfo(), eventData, hash(), shapeErrorGetter());
253 }

◆ refVal()

bool History::refVal ( unsigned int  i,
unsigned int  sample,
double &  val,
double &  err 
) const

Definition at line 221 of file History.cxx.

222 {
223  if (k >= nData()) return false;
225  if (!reference) return false;
226  if (reference->interpolate(m_data[k]->time(sample), val, err) != 0) { delete reference; return false; }
227  delete reference;
228  return true;
229 }

◆ residual()

Residual * History::residual ( unsigned int  k,
bool  correct = true,
bool  zeroTime = false 
) const

Definition at line 603 of file History.cxx.

604 {
605  if (k >= nData()) return nullptr;
606  TVectorD del = deltas(k, -1, -1, correct);
607  return new Residual(del, data(k)->run(), data(k)->event(), data(k)->adcMax(),
608  (zeroTime ? 0 : data(k)->ofcTime() /*- Definitions::samplingTime(del.GetLwb()) */));
609 }

◆ residualError()

bool History::residualError ( unsigned int  i,
short  sample1,
short  sample2,
double &  offset,
double  adcMax = -1,
double  time = Definitions::none 
) const

Definition at line 399 of file History.cxx.

400 {
401  const ScaledErrorData* sea = scaledErrorData(k, adcMax, time);
402  if (!sea) return false;
403  if (!sea->isInRange(sample1) || !sea->isInRange(sample2)) { delete sea; return false; }
404  error = sea->errors()(sample1, sample2);
405  delete sea;
406  return true;
407 }

◆ residualOffset()

bool History::residualOffset ( unsigned int  i,
short  sample,
double &  offset,
double  adcMax = -1,
double  time = Definitions::none 
) const

Definition at line 388 of file History.cxx.

389 {
390  const ScaledErrorData* sea = scaledErrorData(k, adcMax, time);
391  if (!sea) return false;
392  if (!sea->isInRange(sample)) { delete sea; return false; }
393  offset = sea->offsets()(sample);
394  delete sea;
395  return true;
396 }

◆ residuals()

Residuals * History::residuals ( CaloGain::CaloGain  gain = CaloGain::LARNGAIN,
double  absResTrunc = -1,
bool  correct = true,
bool  zeroTime = false 
) const

Definition at line 612 of file History.cxx.

613 {
614  Chi2Calc c2c;
615  CovMatrix dummyErrors;
616  Residuals* residuals = new Residuals();
617  for (unsigned int k = 0; k < nData(); k++) {
618  if (gain != CaloGain::LARNGAIN && data(k)->gain() != gain) continue;
619  //if (goodForCorrOnly && !data(k)->goodForShapeCorr()) continue;
620  Residual* res = residual(k, correct, zeroTime);
621  if (!res) { cout << "Error calculating residual for hash = " << m_hash << ", index = " << k << endl; return nullptr; }
622  if (residuals->size() > 0 && !residuals->hasSameRange(*res)) {
623  cout << "Warning for hash = " << m_hash << ", index = " << k << " : index interval changed from ["
624  << residuals->lwb() << ", " << residuals->upb() << "] to " << res->rangeStr() << endl;
625  delete res;
626  delete residuals;
627  return nullptr;
628  }
629  bool pass = true;
630  for (int i = res->lwb(); i < res->upb(); i++) {
631  if (absResCut > 0 && TMath::Abs(res->scaledDelta(i)) > absResCut) {
632  pass = false;
633  break;
634  }
635  }
636  if (pass) residuals->add(*res);
637  delete res;
638  }
639  return residuals;
640 }

◆ scaledErrorData()

const ScaledErrorData * History::scaledErrorData ( unsigned int  i,
double  adcMax = -1,
double  time = Definitions::none,
ShapeErrorType  shapeErrorType = BestShapeError 
) const

Definition at line 346 of file History.cxx.

348 {
349  if (shapeErrorType == NoShapeError || !shapeErrorGetter()) return nullptr;
350  if (k >= nData() || data(k)->adcMax() <= 0) return nullptr;
351 
352  const ShapeErrorData* sed = shapeErrorData(data(k)->gain(), shapeErrorType, residual(k, false));
353  if (!sed) return nullptr;
354 
355  double sf = (adcMax < 0 ? data(k)->adcMax() : adcMax);
356  double ts = (Definitions::isNone(time) ? data(k)->ofcTime() : time);
357  ScaledErrorData* sced = new ScaledErrorData(*sed, sf, ts);
358  delete sed;
359  return sced;
360 }

◆ setInterface()

void LArSamples::History::setInterface ( const Interface interface) const
inline

Definition at line 112 of file History.h.

112 { m_interface = interface; }

◆ setShapeErrorGetter()

void LArSamples::History::setShapeErrorGetter ( const AbsShapeErrorGetter err) const
inline

Definition at line 92 of file History.h.

◆ shapeErrorData()

const ShapeErrorData * History::shapeErrorData ( CaloGain::CaloGain  gain,
ShapeErrorType  shapeErrorType = BestShapeError,
const Residual res = 0 
) const

Definition at line 299 of file History.cxx.

300 {
301  if (shapeErrorType == NoShapeError || !shapeErrorGetter()) return nullptr;
302  if (shapeErrorType == BestShapeError) {
303  for (unsigned int i = 0; i < NShapeErrorTypes; i++) {
305  if (sed) return sed;
306  }
307  return nullptr;
308  }
309 
310  if (shapeErrorType == CellShapeError) {
312  if (!sed) return nullptr;
314  return sed;
315  }
316 
317  if (shapeErrorType == LowGainCellShapeError || shapeErrorType == MedGainCellShapeError || shapeErrorType == HighGainCellShapeError) {
318  CaloGain::CaloGain fbGain = (shapeErrorType == LowGainCellShapeError ? CaloGain::LARLOWGAIN :
321  if (!sed) return nullptr;
322  sed->setShapeErrorType(shapeErrorType);
323  return sed;
324  }
325 
326  if (shapeErrorType == RingShapeError) {
328  if (!sed) return nullptr;
330  return sed;
331  }
332 
333  if (shapeErrorType == LowGainRingShapeError || shapeErrorType == MedGainRingShapeError || shapeErrorType == HighGainRingShapeError) {
334  CaloGain::CaloGain fbGain = (shapeErrorType == LowGainRingShapeError ? CaloGain::LARLOWGAIN :
336  ShapeErrorData* sed = shapeErrorGetter()->phiSymShapeErrorData(cellInfo()->globalPhiRing(), fbGain, res);
337  if (!sed) return nullptr;
338  sed->setShapeErrorType(shapeErrorType);
339  return sed;
340  }
341 
342  return nullptr;
343 }

◆ shapeErrorGetter()

const AbsShapeErrorGetter* LArSamples::History::shapeErrorGetter ( ) const
inline

Definition at line 93 of file History.h.

93 { return m_shapeErrorGetter; }

◆ sum()

bool History::sum ( SimpleShape *&  sum,
SimpleShape *&  reference 
) const

Definition at line 124 of file History.cxx.

125 {
126  reference = sum = nullptr;
127  if (nData() == 0) return false;
128 
129  sum = new SimpleShape(m_data[0]->nSamples());
130  reference = nullptr;
131 
132  for (unsigned int j = 0; j < nData(); j++) {
133  if (sum->nPoints() != m_data[j]->nSamples()) return false;
134  for (unsigned int k = 0; k < m_data[j]->nSamples(); k++)
135  sum->add(k, m_data[j]->pedestalSubtractedSample(k), m_data[j]->error(k));
136  SimpleShape* thisRef = referenceShape(j);
137  if (!thisRef) { delete sum; return false; }
138  if (reference) {
139  reference->add(*thisRef);
140  delete thisRef;
141  }
142  else reference = thisRef;
143  }
144 
145  return true;
146 }

◆ upstreamEnergy()

double History::upstreamEnergy ( unsigned int  k) const

Definition at line 643 of file History.cxx.

644 {
645  if (!m_interface || !cellInfo()) return -1;
646  if (k >= nData() || !data(k)->eventData()) return -1;
647  std::vector<unsigned int> upstreamNeighbors;
648  if (!m_interface->firstNeighbors(hash(), upstreamNeighbors, cellInfo()->layer() - 1)) return -1;
649  if (upstreamNeighbors.empty()) return -1;
650  std::vector<const Data*> unData;
651  if (!m_interface->data(upstreamNeighbors, *data(k)->eventData(), unData)) return -1;
652  double upstreamE = 0;
653  for (const Data* data : unData) {
654  upstreamE += data->energy();
655  delete data;
656  }
657  return upstreamE;
658 }

Member Data Documentation

◆ m_cellInfo

CellInfo LArSamples::History::m_cellInfo
private

Definition at line 117 of file History.h.

◆ m_data

std::vector<const Data*> LArSamples::History::m_data
private

Definition at line 116 of file History.h.

◆ m_eventData

std::vector<const EventData*> LArSamples::History::m_eventData
private

Definition at line 118 of file History.h.

◆ m_hash

unsigned int LArSamples::History::m_hash
private

Definition at line 119 of file History.h.

◆ m_interface

const Interface* LArSamples::History::m_interface = nullptr
mutableprivate

Definition at line 121 of file History.h.

◆ m_shapeErrorGetter

const AbsShapeErrorGetter* LArSamples::History::m_shapeErrorGetter
mutableprivate

Definition at line 120 of file History.h.


The documentation for this class was generated from the following files:
LArSamples::Data::description
TString description(unsigned int verbosity=1) const
Definition: Data.cxx:511
grepfile.info
info
Definition: grepfile.py:38
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
LArSamples::LowGainRingShapeError
@ LowGainRingShapeError
Definition: Definitions.h:24
LArSamples::History::data_for_event
const Data * data_for_event(int event, int run=-1) const
Definition: History.cxx:95
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
LArSamples::CellInfo::isValid
bool isValid() const
Definition: CellInfo.cxx:173
LArSamples::History::m_eventData
std::vector< const EventData * > m_eventData
Definition: History.h:118
LArSamples::Chi2Calc::deltas
TVectorD deltas(const AbsShape &data, const AbsShape &reference, CovMatrix &errors, const ScaledErrorData *shapeError=0, int lwb=-1, int upb=-1, bool noDataError=false)
Definition: Chi2Calc.cxx:36
LArSamples::History::hash
unsigned int hash() const
Definition: History.h:91
get_generator_info.result
result
Definition: get_generator_info.py:21
PlotCalibFromCool.dv
dv
Definition: PlotCalibFromCool.py:762
LArSamples::DataTweaker::setRefit
void setRefit(bool refit=true)
Definition: DataTweaker.h:40
LArSamples::FilterParams
Definition: FilterParams.h:50
LArSamples::History::scaledErrorData
const ScaledErrorData * scaledErrorData(unsigned int i, double adcMax=-1, double time=Definitions::none, ShapeErrorType shapeErrorType=BestShapeError) const
Definition: History.cxx:346
LArSamples::History::m_shapeErrorGetter
const AbsShapeErrorGetter * m_shapeErrorGetter
Definition: History.h:120
LArSamples::History::cellInfo
const CellInfo * cellInfo() const
Definition: History.h:61
LArSamples::CovMatrix
TMatrixTSym< double > CovMatrix
Definition: Definitions.h:11
LArSamples::History::referenceShape
SimpleShape * referenceShape(unsigned int k, double adcMax=-1, double time=Definitions::none, bool samplesOnly=false) const
Definition: History.cxx:544
LArSamples::HighGainCellShapeError
@ HighGainCellShapeError
Definition: Definitions.h:22
LArSamples::DataTweaker::setAdjust
void setAdjust(bool adjust=true)
Definition: DataTweaker.h:42
LArSamples::Data::setCallBacks
void setCallBacks(const History *history, unsigned int index) const
Definition: Data.h:277
LArSamples::Data::adcMax
double adcMax() const
Definition: Data.h:129
Data
@ Data
Definition: BaseObject.h:11
LArSamples::History
Definition: History.h:40
LArSamples::History::m_data
std::vector< const Data * > m_data
Definition: History.h:116
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArSamples::IndexRange::hasSameRange
bool hasSameRange(int lw, int up) const
Definition: IndexRange.h:29
LArSamples::SimpleShape
Definition: SimpleShape.h:25
LArSamples::Data::run
int run() const
Definition: Data.cxx:27
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
LArSamples::AbsShapeErrorGetter::shapeErrorData
virtual ShapeErrorData * shapeErrorData(unsigned int hash, CaloGain::CaloGain gain, const Residual *toExclude=0) const =0
LArSamples::History::residuals
Residuals * residuals(CaloGain::CaloGain gain=CaloGain::LARNGAIN, double absResTrunc=-1, bool correct=true, bool zeroTime=false) const
Definition: History.cxx:612
LArSamples::Chi2Calc::lwb
int lwb() const
Definition: Chi2Calc.h:45
LArSamples::History::m_interface
const Interface * m_interface
Definition: History.h:121
LArSamples::SimpleShape::nPoints
unsigned int nPoints() const
Definition: SimpleShape.h:48
LArSamples::ShapeDrawer
Definition: ShapeDrawer.h:26
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LArSamples::Data::ofcTime
double ofcTime() const
Definition: Data.h:116
reference
Definition: hcg.cxx:437
LArSamples::Averager
storage of the time histories of all the cells
Definition: Averager.h:23
yodamerge_tmp.rescale
rescale
Definition: yodamerge_tmp.py:198
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
LArSamples::MedGainCellShapeError
@ MedGainCellShapeError
Definition: Definitions.h:22
LArSamples::AbsShapeErrorGetter
Definition: AbsShapeErrorGetter.h:23
LArSamples::CombinedShapeErrorGetter::add
void add(const AbsShapeErrorGetter &getter)
Definition: CombinedShapeErrorGetter.h:25
LArSamples::Data::event
int event() const
Definition: Data.cxx:28
LArSamples::GraphShape::add
bool add(const AbsShape &other)
Definition: GraphShape.cxx:26
LArSamples::History::deltaShape
SimpleShape * deltaShape(unsigned int k, int lwb=-1, int upb=-1) const
Definition: History.cxx:555
LArSamples::ScaledErrorData
Definition: ScaledErrorData.h:17
LArSamples::History::maxChi2
double maxChi2(int lwb=-1, int upb=-1, int chi2Params=DefaultChi2) const
Definition: History.cxx:193
LArSamples::SimpleShape::add
bool add(unsigned int k, double value, double error)
Definition: SimpleShape.cxx:92
LArSamples::History::data
const Data * data(unsigned int i) const
Definition: History.cxx:88
LArSamples::SimpleShape::set
void set(unsigned int i, double value, double error=-1)
Definition: SimpleShape.h:53
LArSamples::Data::value
double value(unsigned int i) const
Definition: Data.h:151
LArSamples::Interface::firstNeighbors
bool firstNeighbors(unsigned int hash, std::vector< unsigned int > &hashes, short layer=-2) const
Definition: Interface.cxx:727
LArSamples::Chi2Calc
Definition: Chi2Calc.h:26
LArSamples::IndexRange::isInRange
bool isInRange(int i) const
Definition: IndexRange.h:27
LArSamples::History::residual
Residual * residual(unsigned int k, bool correct=true, bool zeroTime=false) const
Definition: History.cxx:603
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
LArSamples::History::refit
History * refit(Chi2Params pars=DefaultChi2) const
Definition: History.cxx:232
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
LArSamples::History::allShape
bool allShape(GraphShape *&allData, SimpleShape *&allRef) const
Definition: History.cxx:410
lumiFormat.i
int i
Definition: lumiFormat.py:92
Recovery.avg
def avg(a, b)
Definition: Recovery.py:79
LArSamples::Definitions::none
static const double none
Definition: Definitions.h:17
python.sizes.location
string location
Definition: sizes.py:11
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LArSamples::ClassCounts::decrementInstanceCount
void decrementInstanceCount() const
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:33
LArSamples::History::setShapeErrorGetter
void setShapeErrorGetter(const AbsShapeErrorGetter *err) const
Definition: History.h:92
covarianceTool.title
title
Definition: covarianceTool.py:542
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
LArSamples::CellInfo::location
TString location(int verbose=1) const
Definition: CellInfo.cxx:139
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
LArSamples::ShapeErrorType
ShapeErrorType
Definition: Definitions.h:21
LArSamples::BestShapeError
@ BestShapeError
Definition: Definitions.h:25
ITk::EventData
InDet::SiSpacePointsSeedMakerEventData EventData
Definition: ITkSiSpacePointsSeedMaker.h:63
run
Definition: run.py:1
LArSamples::DataTweaker
Definition: DataTweaker.h:23
LArSamples::History::sum
bool sum(SimpleShape *&sum, SimpleShape *&reference) const
Definition: History.cxx:124
LArSamples::History::nData
unsigned int nData() const
Definition: History.h:56
LArSamples::History::chi2
double chi2(int i, int lwb=-1, int upb=-1, int chi2Params=DefaultChi2, ShapeErrorType shapeErrorType=BestShapeError, unsigned int *nDof=0) const
Definition: History.cxx:161
LArSamples::Residual
storage of a pulse shape residual set
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:29
LArSamples::History::History
History(const HistoryContainer &container, const std::vector< const EventData * > &eventData, unsigned int hash, const AbsShapeErrorGetter *shapeErrorGetter=0)
Constructor
LArSamples::OFC
Definition: OFC.h:27
LArSamples::Residuals
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:72
LArSamples::DataTweaker::setFitParams
void setFitParams(Chi2Params params)
Definition: DataTweaker.h:41
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
LArSamples::Data::nPoints
unsigned int nPoints() const
Definition: Data.h:149
LArSamples::DataTweaker::tweak
Data * tweak(const Data &data, int evtIndex=-1) const
Definition: DataTweaker.cxx:47
LArSamples::NShapeErrorTypes
@ NShapeErrorTypes
Definition: Definitions.h:25
LArSamples::Data
Definition: Data.h:77
LArSamples::ClassCounts::incrementInstanceCount
void incrementInstanceCount() const
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:32
LArSamples::Data::dissolve
const DataContainer * dissolve()
Definition: Data.cxx:56
LArSamples::AtlasStyle
@ AtlasStyle
Definition: ShapeDrawer.h:22
LArSamples::Data::gain
CaloGain::CaloGain gain() const
Definition: Data.h:90
covarianceTool.verbosity
verbosity
Definition: covarianceTool.py:513
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
LArSamples::CellInfo
Definition: CellInfo.h:31
LArSamples::ShapeErrorData::setShapeErrorType
void setShapeErrorType(ShapeErrorType type)
Definition: ShapeErrorData.h:59
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
LArSamples::History::m_cellInfo
CellInfo m_cellInfo
Definition: History.h:117
LArSamples::History::shapeErrorGetter
const AbsShapeErrorGetter * shapeErrorGetter() const
Definition: History.h:93
LArSamples::DefaultChi2
@ DefaultChi2
Definition: Chi2Calc.h:24
python.PyAthena.v
v
Definition: PyAthena.py:157
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
LArSamples::History::drawAllWithReference
bool drawAllWithReference(bool refit=false) const
Definition: History.cxx:483
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
LArSamples::History::shapeErrorData
const ShapeErrorData * shapeErrorData(CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
Definition: History.cxx:299
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
LArSamples::HistoryContainer
Definition: HistoryContainer.h:29
LArSamples::Residuals::size
unsigned int size() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:80
LArSamples::Residuals::add
bool add(const Residual &residual)
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:86
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
LArSamples::HistoryContainer::add
void add(const DataContainer *data)
append data (takes ownership)
Definition: HistoryContainer.h:46
LArSamples::SimpleShape::setError
void setError(unsigned int i, double error)
Definition: SimpleShape.h:54
LArSamples::GraphShape
Definition: GraphShape.h:32
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
LArSamples::History::deltas
TVectorD deltas(unsigned int i, int lwb=-1, int upb=-1, bool correct=true) const
Definition: History.cxx:373
LArSamples::CombinedShapeErrorGetter
Definition: CombinedShapeErrorGetter.h:18
LArSamples::LowGainCellShapeError
@ LowGainCellShapeError
Definition: Definitions.h:22
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LArSamples::Definitions::isNone
static bool isNone(double x)
Definition: Definitions.h:18
LArSamples::Interface::data
bool data(const std::vector< unsigned int > &hashes, const EventData &event, std::vector< const Data * > &data) const
Definition: Interface.cxx:752
LArSamples::CellShapeError
@ CellShapeError
Definition: Definitions.h:21
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
LArSamples::History::m_hash
unsigned int m_hash
Definition: History.h:119
LArSamples::MedGainRingShapeError
@ MedGainRingShapeError
Definition: Definitions.h:24
LArSamples::NoShapeError
@ NoShapeError
Definition: Definitions.h:25
LArSamples::Residuals::upb
int upb() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:84
LArSamples::ShapeErrorData
Definition: ShapeErrorData.h:19
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
LArSamples::History::eventData
const std::vector< const EventData * > & eventData() const
Definition: History.h:63
LArSamples::FitterData::sed
const ScaledErrorData * sed
Definition: ShapeFitter.cxx:26
LArSamples::Legend
@ Legend
Definition: ShapeDrawer.h:22
LArSamples::Definitions::samplingInterval
static const unsigned int samplingInterval
Definition: Definitions.h:15
python.CaloScaleNoiseConfig.ts
ts
Definition: CaloScaleNoiseConfig.py:86
LArSamples::ScaledErrorData::errors
const CovMatrix errors(int first=-1, int last=-1) const
Definition: ScaledErrorData.cxx:31
LArSamples::SimpleShape::value
double value(unsigned int i) const
Definition: SimpleShape.h:49
error
Definition: IImpactPoint3dEstimator.h:70
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
LArSamples::Residuals::lwb
int lwb() const
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:83
LArSamples::Chi2Calc::upb
int upb() const
Definition: Chi2Calc.h:46
LArSamples::RingShapeError
@ RingShapeError
Definition: Definitions.h:23
LArSamples::AbsShapeErrorGetter::phiSymShapeErrorData
virtual ShapeErrorData * phiSymShapeErrorData(short ring, CaloGain::CaloGain gain, const Residual *toExclude=0) const =0
LArSamples::ScaledErrorData::offsets
const TVectorD offsets(int first=-1, int last=-1) const
Definition: ScaledErrorData.cxx:14
LArSamples::Data::energy
double energy() const
Definition: Data.h:113
LArSamples::DataFirst
@ DataFirst
Definition: ShapeDrawer.h:22
fitman.k
k
Definition: fitman.py:528
Legend
slightly more convenient legend class
Definition: computils.h:333
LArSamples::HighGainRingShapeError
@ HighGainRingShapeError
Definition: Definitions.h:24
LArSamples::Data::isValid
bool isValid() const
Definition: Data.cxx:154
LArSamples::UniformShapeErrorGetter
Definition: UniformShapeErrorGetter.h:17