ATLAS Offline Software
Loading...
Searching...
No Matches
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.
 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 35 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 56 of file History.cxx.

61{
63 unsigned int i = 0;
64 for (const Data* pdata : m_data)
65 pdata->setCallBacks(this, i);
66}
@ Data
Definition BaseObject.h:11
std::vector< const EventData * > m_eventData
Definition History.h:113
CellInfo m_cellInfo
Definition History.h:112
const std::vector< const EventData * > & eventData() const
Definition History.h:58
const AbsShapeErrorGetter * shapeErrorGetter() const
Definition History.h:88
unsigned int m_hash
Definition History.h:114
const AbsShapeErrorGetter * m_shapeErrorGetter
Definition History.h:115
std::vector< const Data * > m_data
Definition History.h:111
const Data * data(unsigned int i) const
Definition History.cxx:91
unsigned int hash() const
Definition History.h:86

◆ ~History()

History::~History ( )
virtual

Definition at line 69 of file History.cxx.

70{
72 for (const Data* data : m_data)
73 delete data;
74 for (const EventData* eventData : m_eventData)
75 delete eventData;
76}

Member Function Documentation

◆ adjust()

History * History::adjust ( ) const

Definition at line 259 of file History.cxx.

260{
261 std::vector<const Data*> datas;
262 DataTweaker tw;
263 tw.setAdjust(true);
264
265 for (unsigned int j = 0; j < nData(); j++) {
266 Data* newData = tw.tweak(*data(j));
267 if (!newData) {
268 for (unsigned int k = 0; k < datas.size(); k++) delete datas[k];
269 return nullptr;
270 }
271 datas.push_back(newData);
272 }
273
274 std::vector<const EventData*> eventData;
275 for (const EventData* event : m_eventData)
276 eventData.push_back(new EventData(*event));
277
278 return new History(datas, *cellInfo(), eventData, hash(), shapeErrorGetter());
279}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Data * tweak(const Data &data, int evtIndex=-1) const
void setAdjust(bool adjust=true)
Definition DataTweaker.h:41
History(const HistoryContainer &container, const std::vector< const EventData * > &eventData, unsigned int hash, const AbsShapeErrorGetter *shapeErrorGetter=0)
Constructor.
const CellInfo * cellInfo() const
Definition History.h:56
unsigned int nData() const
Definition History.h:51

◆ allChi2()

double History::allChi2 ( Chi2Params pars) const

Definition at line 439 of file History.cxx.

440{
441 Chi2Calc c2c(pars);
442
443 GraphShape* allData = nullptr;
444 SimpleShape* allRef = nullptr;
445 if (!allShape(allData, allRef)) return -1;
446 double chi2Value = c2c.chi2(*allData, *allRef);
447 delete allData;
448 delete allRef;
449 return chi2Value;
450}
bool allShape(GraphShape *&allData, SimpleShape *&allRef) const
Definition History.cxx:413

◆ allShape()

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

Definition at line 413 of file History.cxx.

414{
415 allData = nullptr;
416 allRef = nullptr;
417
418 for (unsigned int j = 0; j < nData(); j++) {
419 if ( m_data[j]->isDisconnected()) continue;
420 if (m_data[j]->adcMax() < 1) continue;
421 GraphShape* thisData = new GraphShape(*m_data[j], 1/m_data[j]->adcMax(), -m_data[j]->ofcTime());
422 if (allData) {
423 allData->add(*thisData);
424 delete thisData;
425 }
426 else allData = thisData;
427 SimpleShape* thisRef = referenceShape(j, 1); // normalized to 1, like the data
428 if (allRef) {
429 allRef->add(*thisRef);
430 delete thisRef;
431 }
432 else allRef = thisRef;
433 }
434
435 return true;
436}
bool add(const AbsShape &other)
SimpleShape * referenceShape(unsigned int k, double adcMax=-1, double time=Definitions::none, bool samplesOnly=false) const
Definition History.cxx:545
bool add(unsigned int k, double value, double error)

◆ calculatePedestal()

Averager * History::calculatePedestal ( int i) const

Definition at line 584 of file History.cxx.

585{
586 Averager* avg = new Averager(1);
587 for (unsigned int k = 0; k < nData(); k++) {
588 if (i >= 0 && i != (int)k) continue;
589 SimpleShape* reference = referenceShape(k);
590 if (!reference) continue;
591 double v,e;
592 for (unsigned int l = 0; l < data(k)->nPoints(); l++)
593 if (reference->interpolate(data(k)->time(l), v, e) == -1) { // we're before the ref shapeError
594 TVectorD ped(1);
595 ped(0) = data(k)->value(l);
596 avg->fill(ped);
597 }
598 delete reference;
599 }
600 return avg;
601}
time(flags, cells_name, *args, **kw)
l
Printing final latex table to .tex output file.
avg(a, b)
Definition Recovery.py:79

◆ cellInfo()

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

Definition at line 56 of file History.h.

56{ 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 164 of file History.cxx.

165{
166 SimpleShape* reference = referenceShape(i);
167 if (!reference) return -1;
168 Chi2Calc c2c(chi2Params);
169 if ( m_data[i]->isDisconnected()) return -1;
170 const ScaledErrorData* sea = scaledErrorData(i, -1, Definitions::none, shapeErrorType);
171 if (!sea && shapeErrorType != NoShapeError && shapeErrorType != BestShapeError) return -1;
172 double chi2Value = c2c.chi2(*m_data[i], *reference, sea, lwb, upb);
173 if (nDof) *nDof = c2c.nDof();
174 if (sea) delete sea;
175 delete reference;
176 return chi2Value;
177}
const ScaledErrorData * scaledErrorData(unsigned int i, double adcMax=-1, double time=Definitions::none, ShapeErrorType shapeErrorType=BestShapeError) const
Definition History.cxx:349

◆ chi2_k()

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

Definition at line 180 of file History.cxx.

181{
182 const AbsShapeErrorGetter* oldGetter = shapeErrorGetter();
183 UniformShapeErrorGetter* uniGetter = new UniformShapeErrorGetter(k);
184 CombinedShapeErrorGetter* combGetter = new CombinedShapeErrorGetter();
185 if (oldGetter) combGetter->add(*oldGetter);
186 combGetter->add(*uniGetter);
187 setShapeErrorGetter(combGetter);
188 double chi2Value = chi2(i, lwb, upb, chi2Params);
189 setShapeErrorGetter(oldGetter);
190 delete combGetter;
191 delete uniGetter;
192 return chi2Value;
193}
void add(const AbsShapeErrorGetter &getter)
double chi2(int i, int lwb=-1, int upb=-1, int chi2Params=DefaultChi2, ShapeErrorType shapeErrorType=BestShapeError, unsigned int *nDof=0) const
Definition History.cxx:164
void setShapeErrorGetter(const AbsShapeErrorGetter *err) const
Definition History.h:87

◆ chi2Anomaly()

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

Definition at line 658 of file History.cxx.

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

◆ data()

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

Definition at line 91 of file History.cxx.

92{
93 if (i >= nData()) return nullptr;
94 return m_data[i];
95}

◆ data_for_event() [1/2]

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

Definition at line 109 of file History.cxx.

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

◆ data_for_event() [2/2]

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

Definition at line 98 of file History.cxx.

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

◆ delta()

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

Definition at line 366 of file History.cxx.

367{
368 if (k >= nData()) return 0;
369 TVectorD dv = deltas(k, sample, sample);
370 if (dv.GetNrows() == 0) return false;
371 del = dv[sample];
372 return true;
373}
TVectorD deltas(unsigned int i, int lwb=-1, int upb=-1, bool correct=true) const
Definition History.cxx:376

◆ deltas()

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

Definition at line 376 of file History.cxx.

377{
378 if (k >= nData()) return TVectorD();
379 SimpleShape* reference = referenceShape(k);
380 if (!reference) return TVectorD();
381 Chi2Calc c2c;
383 const ScaledErrorData* sea = (correct ? scaledErrorData(k) : nullptr);
384 TVectorD dv = c2c.deltas(*data(k), *reference, errors, sea, lwb, upb);
385 if (sea) delete sea;
386 delete reference;
387 return dv;
388}
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

◆ deltaShape()

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

Definition at line 556 of file History.cxx.

557{
558 if (k >= nData()) return nullptr;
559 SimpleShape* reference = referenceShape(k);
560 if (!reference) return nullptr;
561 Chi2Calc c2c;
563 const ScaledErrorData* sea = scaledErrorData(k);
564 TVectorD dv = c2c.deltas(*data(k), *reference, errors, sea, lwb, upb);
565 if (sea) delete sea;
566 delete reference;
567 if (dv.GetNrows() == 0) return nullptr;
568 SimpleShape* shape = new SimpleShape(dv.GetNrows(), Definitions::samplingInterval, data(k)->time(c2c.lwb()) + data(k)->ofcTime());
569 for (int l = c2c.lwb(); l <= c2c.upb(); l++) shape->set(l - c2c.lwb(), dv(l), TMath::Sqrt(errors(l, l)));
570 return shape;
571}
int upb() const
Definition Chi2Calc.h:46
int lwb() const
Definition Chi2Calc.h:45
void set(unsigned int i, double value, double error=-1)
Definition SimpleShape.h:53

◆ description()

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

Definition at line 574 of file History.cxx.

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

◆ dissolve()

HistoryContainer * History::dissolve ( )

Definition at line 79 of file History.cxx.

80{
81 HistoryContainer* histCont = new HistoryContainer(new CellInfo(*cellInfo()));
82 for (unsigned int k = 0; k < nData(); k++) {
83 Data* newData = new Data(*data(k));
84 histCont->add(newData->dissolve());
85 }
86 delete this;
87 return histCont;
88}
const DataContainer * dissolve()
Definition Data.cxx:56
void add(const DataContainer *data)
append data (takes ownership)

◆ drawAllWithReference()

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

Definition at line 484 of file History.cxx.

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

◆ drawResiduals()

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

Definition at line 522 of file History.cxx.

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

◆ drawSumWithReference()

bool History::drawSumWithReference ( ) const

Definition at line 474 of file History.cxx.

475{
476 SimpleShape* dataShape, *refShape;
477 if (!sum(dataShape, refShape)) return false;
478
479 ShapeDrawer drawer(DataFirst | Legend);
480 return drawer.drawAndDelete("", dataShape, refShape);
481}
bool sum(SimpleShape *&sum, SimpleShape *&reference) const
Definition History.cxx:127

◆ drawWithReference()

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

Definition at line 453 of file History.cxx.

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

◆ eventData()

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

Definition at line 58 of file History.h.

58{ return m_eventData; }

◆ filter()

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

Definition at line 282 of file History.cxx.

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

◆ hash()

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

Definition at line 86 of file History.h.

86{ return m_hash; }

◆ isValid()

bool History::isValid ( ) const

Definition at line 152 of file History.cxx.

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

◆ maxChi2()

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

Definition at line 196 of file History.cxx.

197{
198 double maxChi2 = -2;
199 for (unsigned int i = 0; i < nData(); i++) {
200 double chi2Value = chi2(i, lwb, upb, chi2Params);
201 if (chi2Value > maxChi2) maxChi2 = chi2Value;
202 }
203 return maxChi2;
204}
double maxChi2(int lwb=-1, int upb=-1, int chi2Params=DefaultChi2) const
Definition History.cxx:196

◆ nData()

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

Definition at line 51 of file History.h.

51{ 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 207 of file History.cxx.

208{
209 if (k >= nData()) return nullptr;
210 if (Definitions::isNone(time)) {
211 time = data(k)->ofcTime();
212 //cout << "Using reference time = " << time << endl;
213 }
214 SimpleShape* reference = referenceShape(k, 1, time); // ADC=1 : we need a normalized shape
215 if (!reference) return nullptr;
216 OFC* result = new OFC(*reference, *m_data[k], lwb, upb, shapeErrorData(CaloGain::LARHIGHGAIN), withAutoCorr); // FixMe
217 delete reference;
218 if (!result) return nullptr;
219 if (result->g().GetNrows() == 0) { delete result; result = nullptr; }
220 return result;
221}
const ShapeErrorData * shapeErrorData(CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
Definition History.cxx:302
@ LARHIGHGAIN
Definition CaloGain.h:18

◆ referenceShape()

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

Definition at line 545 of file History.cxx.

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

◆ refit()

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

Definition at line 235 of file History.cxx.

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

◆ refVal()

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

Definition at line 224 of file History.cxx.

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

◆ residual()

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

Definition at line 604 of file History.cxx.

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

◆ residualError()

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

Definition at line 402 of file History.cxx.

403{
404 const ScaledErrorData* sea = scaledErrorData(k, adcMax, time);
405 if (!sea) return false;
406 if (!sea->isInRange(sample1) || !sea->isInRange(sample2)) { delete sea; return false; }
407 error = sea->errors()(sample1, sample2);
408 delete sea;
409 return true;
410}
const CovMatrix errors(int first=-1, int last=-1) const

◆ residualOffset()

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

Definition at line 391 of file History.cxx.

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

◆ residuals()

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

Definition at line 613 of file History.cxx.

614{
615 Chi2Calc c2c;
616 CovMatrix dummyErrors;
617 auto residuals = std::make_unique<Residuals>();
618 for (unsigned int k = 0; k < nData(); k++) {
619 if (gain != CaloGain::LARNGAIN && data(k)->gain() != gain) continue;
620 auto res = std::unique_ptr<Residual>(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 return nullptr;
626 }
627 bool pass = true;
628 for (int i = res->lwb(); i < res->upb(); i++) {
629 if (absResCut > 0 && TMath::Abs(res->scaledDelta(i)) > absResCut) {
630 pass = false;
631 break;
632 }
633 }
634 if (pass) residuals->add(*res);
635 }
636 return residuals.release();
637}
std::pair< std::vector< unsigned int >, bool > res
Residuals * residuals(CaloGain::CaloGain gain=CaloGain::LARNGAIN, double absResTrunc=-1, bool correct=true, bool zeroTime=false) const
Definition History.cxx:613
Residual * residual(unsigned int k, bool correct=true, bool zeroTime=false) const
Definition History.cxx:604
@ LARNGAIN
Definition CaloGain.h:19

◆ scaledErrorData()

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

Definition at line 349 of file History.cxx.

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

◆ setInterface()

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

Definition at line 107 of file History.h.

107{ m_interface = interface; }
const Interface * m_interface
Definition History.h:116

◆ setShapeErrorGetter()

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

Definition at line 87 of file History.h.

◆ shapeErrorData()

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

Definition at line 302 of file History.cxx.

303{
304 if (shapeErrorType == NoShapeError || !shapeErrorGetter()) return nullptr;
305 if (shapeErrorType == BestShapeError) {
306 for (unsigned int i = 0; i < NShapeErrorTypes; i++) {
307 const ShapeErrorData* sed = shapeErrorData(gain, (ShapeErrorType)i, res);
308 if (sed) return sed;
309 }
310 return nullptr;
311 }
312
313 if (shapeErrorType == CellShapeError) {
314 ShapeErrorData* sed = shapeErrorGetter()->shapeErrorData(hash(), gain, res);
315 if (!sed) return nullptr;
317 return sed;
318 }
319
320 if (shapeErrorType == LowGainCellShapeError || shapeErrorType == MedGainCellShapeError || shapeErrorType == HighGainCellShapeError) {
323 ShapeErrorData* sed = shapeErrorGetter()->shapeErrorData(hash(), fbGain, res);
324 if (!sed) return nullptr;
325 sed->setShapeErrorType(shapeErrorType);
326 return sed;
327 }
328
329 if (shapeErrorType == RingShapeError) {
330 ShapeErrorData* sed = shapeErrorGetter()->phiSymShapeErrorData(cellInfo()->globalPhiRing(), gain, res);
331 if (!sed) return nullptr;
333 return sed;
334 }
335
336 if (shapeErrorType == LowGainRingShapeError || shapeErrorType == MedGainRingShapeError || shapeErrorType == HighGainRingShapeError) {
339 ShapeErrorData* sed = shapeErrorGetter()->phiSymShapeErrorData(cellInfo()->globalPhiRing(), fbGain, res);
340 if (!sed) return nullptr;
341 sed->setShapeErrorType(shapeErrorType);
342 return sed;
343 }
344
345 return nullptr;
346}
virtual ShapeErrorData * shapeErrorData(unsigned int hash, CaloGain::CaloGain gain, const Residual *toExclude=0) const =0
virtual ShapeErrorData * phiSymShapeErrorData(short ring, CaloGain::CaloGain gain, const Residual *toExclude=0) const =0
void setShapeErrorType(ShapeErrorType type)
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18

◆ shapeErrorGetter()

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

Definition at line 88 of file History.h.

88{ return m_shapeErrorGetter; }

◆ sum()

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

Definition at line 127 of file History.cxx.

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

◆ upstreamEnergy()

double History::upstreamEnergy ( unsigned int k) const

Definition at line 640 of file History.cxx.

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

Member Data Documentation

◆ m_cellInfo

CellInfo LArSamples::History::m_cellInfo
private

Definition at line 112 of file History.h.

◆ m_data

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

Definition at line 111 of file History.h.

◆ m_eventData

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

Definition at line 113 of file History.h.

◆ m_hash

unsigned int LArSamples::History::m_hash
private

Definition at line 114 of file History.h.

◆ m_interface

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

Definition at line 116 of file History.h.

◆ m_shapeErrorGetter

const AbsShapeErrorGetter* LArSamples::History::m_shapeErrorGetter
mutableprivate

Definition at line 115 of file History.h.


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