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

storage of the time histories of all the cells More...

#include <DigitMonitor.h>

Inheritance diagram for LArSamples::DigitMonitor:
Collaboration diagram for LArSamples::DigitMonitor:

Public Member Functions

 DigitMonitor (const Interface &interface)
 Constructor.
TH1D * chi2Dist (const TString &name, int nBins, double max, double kFactor=0, double fitMax=-1, int lwb=-1, int upb=-1, unsigned int chi2Pars=DefaultChi2, ShapeErrorType shapeErrorType=BestShapeError, unsigned int nDof=0) const
TH1D * bestChi2Dist (const TString &name, int nBins, double max, double refErrMin, double refErrMax, unsigned int refErrNBins, int lwb=-1, int upb=-1, unsigned int chi2Pars=DefaultChi2, unsigned int nDof=0) const
TH1D * gainDist (const TString &name) const
TH1D * layerDist (const TString &name) const
TH1D * energyDist (const TString &name, int nBins, double eMax=10000) const
TH1D * timeDist (const TString &name, int nBins, double tMin=-25, double tMax=25) const
TH1D * adcMaxDist (const TString &name, int nBins, double aMin=0, double aMax=4096) const
TH1D * noiseDist (const TString &name, int nBins, double max) const
TH2D * maxValueMap (TString name, PartitionId partition) const
TH2D * minValueMap (TString name, PartitionId partition) const
TH1D * residualDist (unsigned int k, const TString &name, int nBins, double rMin, double rMax, bool norm=false) const
bool residualPlots (CaloId calo, unsigned int layer, CaloGain::CaloGain gain=CaloGain::LARHIGHGAIN, bool xip=false, bool ring=false, double lo=-0.05, double hi=0.05, const TString &fileName="residuals")
bool residualPlotsRingComp (CaloId calo, unsigned int layer, CaloGain::CaloGain gain=CaloGain::LARHIGHGAIN, bool xip=false, double lo=-0.05, double hi=0.05, const TString &fileName="residuals")
bool residualPlotsGainComp (CaloId calo, unsigned int layer, bool ring=false, bool xip=false, double lo=-0.05, double hi=0.05, const TString &fileName="residuals")
TH1D * shapeErrorDist (unsigned int k, const TString &name, int nBins, double rMin, double rMax, double mean=0) const
double residualCorr (unsigned int k1, unsigned int k2) const
bool makeResidualCorrections (const TString &outputFile, short resTrunc=-1, short timeTrunc=-1, double absResTrunc=-1, unsigned int minSize=0, bool weigh=false, bool adjust=false, bool zeroTime=false) const
std::unique_ptr< ResidualsgetResiduals (unsigned int hash, CaloGain::CaloGain gain, double absResTrunc=-1, bool adjust=false, bool zeroTime=false) const
bool residualParams (int lwb, int upb, CovMatrix &k, TVectorD &means) const
CovMatrix kMatrix (int lwb, int upb)
TVectorD means (int lwb, int upb)
int combine (SimpleShape *&shape, SimpleShape *&ref, const TString &selection="", bool timeAligned=true) const
TH1D * dist (const DataFuncSet &func, const DataFuncArgs &args, const TString &name, int nBins, double xMin, double xMax, const TString &title="", const TString &xTitle="", const TString &yTitle="", const FilterParams &f=FilterParams()) const
TH2D * dist (const DataFuncSet &funcX, const DataFuncArgs &argsX, const DataFuncSet &funcY, const DataFuncArgs &argsY, const TString &name, int nBinsX, double xMin, double xMax, int nBinsY, double yMin, double yMax, const TString &title="", const TString &xTitle="", const TString &yTitle="", const FilterParams &f=FilterParams()) const
TH2D * partitionMap (const DataFuncSet &func, const DataFuncArgs &args, TString name, PartitionId partition, const TString &title="", CombinationType comb=AverageValue, const FilterParams &f=FilterParams()) const
TH2D * etaPhiMap (const DataFuncSet &func, const DataFuncArgs &args, const TString &name, CaloId calo, short layer, TString title="", CombinationType comb=AverageValue, const FilterParams &f=FilterParams()) const
bool prepareDumpParams (const TString &vars, int verbosity, std::vector< TString > &variables, std::vector< DataFuncSet > &funcs, std::vector< DataFuncArgs > &args, std::vector< TString > &formats, TString &locFormat, TString &locHeader, TString &varHeader) const
bool dump (const TString &vars, const FilterParams &f=FilterParams(), unsigned int verbosity=1) const
bool dump (const TString &vars, CombinationType comb=AverageValue, const FilterParams &f=FilterParams(), const TString &ranges="", unsigned int verbosity=1) const
bool statParams (const std::vector< DataFuncSet > &funcs, const std::vector< DataFuncArgs > &args, TVectorD &mean, TVectorD &meanErr, TMatrixD &covMatrix, TMatrixD &covMatrixErr, const FilterParams &f=FilterParams()) const
const Interfaceinterface () const
virtual unsigned int nChannels () const override
virtual std::unique_ptr< const HistorygetCellHistory (unsigned int i) const override
virtual std::unique_ptr< const HistorygetSCHistory (unsigned int i) const override
virtual std::unique_ptr< const CellInfogetCellInfo (unsigned int i) const override
virtual std::unique_ptr< const HistorynewCellHistory (unsigned int i) const
virtual const HistorycellHistory (unsigned int i) const
virtual std::unique_ptr< const CellInfocellInfo (unsigned int i) const
virtual unsigned int nChannelsSC () const
virtual void resetCache () const
const CellInfocellInfoCache (unsigned int i) const
const Historypass (unsigned int i, const FilterParams &f) const
const HistorycellCache () const
unsigned int cachePos () const

Static Public Member Functions

static TF1 * chi2Func (const char *name, double xMin, double xMax)
static TF1 * fitChi2 (TH1D &h, const char *name, double xMin, double xMax, double nDof=-1, double fitMin=Definitions::none, double fitMax=Definitions::none)
static double history_value (const History &history, const DataFuncSet &func, const DataFuncArgs &args, CombinationType comb, const FilterParams &f, unsigned int &nValues)
static DataFuncSet func (const TString &var)
static bool parseVariables (TString varStr, std::vector< TString > &vars, std::vector< DataFuncSet > &funcs, std::vector< DataFuncArgs > &args)
static TString str (CombinationType comb)

Static Public Attributes

static const int printPeriodicity = 10000

Private Attributes

const Interfacem_interface
unsigned int m_pos
std::unique_ptr< const Historym_cellCache
std::vector< std::unique_ptr< CellInfo > > m_cellInfoCache

Detailed Description

storage of the time histories of all the cells

Definition at line 28 of file DigitMonitor.h.

Constructor & Destructor Documentation

◆ DigitMonitor()

LArSamples::DigitMonitor::DigitMonitor ( const Interface & interface)
inline

Constructor.

Definition at line 34 of file DigitMonitor.h.

Member Function Documentation

◆ adcMaxDist()

TH1D * DigitMonitor::adcMaxDist ( const TString & name,
int nBins,
double aMin = 0,
double aMax = 4096 ) const

Definition at line 47 of file DigitMonitor.cxx.

48{ return dist(&Data::_adcMax, DataFuncArgs(), name, nBins, aMin, aMax, "ADCMax distribution", "ADCMax (counts)"); }
double _adcMax(const DataFuncArgs &) const
Definition Data.h:198
TH1D * dist(const DataFuncSet &func, const DataFuncArgs &args, const TString &name, int nBins, double xMin, double xMax, const TString &title="", const TString &xTitle="", const TString &yTitle="", const FilterParams &f=FilterParams()) const

◆ bestChi2Dist()

TH1D * DigitMonitor::bestChi2Dist ( const TString & name,
int nBins,
double max,
double refErrMin,
double refErrMax,
unsigned int refErrNBins,
int lwb = -1,
int upb = -1,
unsigned int chi2Pars = DefaultChi2,
unsigned int nDof = 0 ) const

Definition at line 125 of file DigitMonitor.cxx.

128{
129 TF1* fChi2 = chi2Func("fChi2", 0, max);
130 if (nDof > 0) fChi2->FixParameter(1, nDof);
131
132 double delta = (refErrMax - refErrMin)/refErrNBins;
133 TH1D* fitResults = new TH1D("fitResults", "", refErrNBins, refErrMin - delta/2, refErrMax - delta/2);
134
135 for (unsigned int k = 0; k < refErrNBins; k++) {
136 double refErr = refErrMin + delta*k;
137 TH1D* h = new TH1D(name, "#chi^{2} distribution", nBins, 0, max);
138 UniformShapeErrorGetter kFactorGetter(refErr);
139 CombinedShapeErrorGetter shapeErrorGetter;
140 if (interface().shapeErrorGetter()) shapeErrorGetter.add(*interface().shapeErrorGetter());
141 shapeErrorGetter.add(kFactorGetter);
142 for (unsigned int i = 0; i < nChannels(); i++) {
143 const History* history = cellHistory(i);
144 if (!history) continue;
145 history->setShapeErrorGetter(&shapeErrorGetter);
146 for (unsigned int j = 0; j < history->nData(); j++) {
147 h->Fill(history->chi2(j, lwb, upb, chi2Pars));
148 }
149 }
150 h->Fit(fChi2);
151 fitResults->SetBinContent(k+1, fChi2->GetChisquare());
152 delete h;
153 }
154
155 TF1* fPol2 = new TF1("fPol2", "[0]*(x - [1])*(x - [1]) + [2]", refErrMin, refErrMax);
156
157 double center = fitResults->GetBinCenter(fitResults->GetMinimumBin());
158 fPol2->SetParameter(0, (fitResults->GetMaximum() - fitResults->GetMinimum())/center/center);
159 fPol2->SetParameter(1, center);
160 fPol2->SetParameter(2, fitResults->GetMinimum());
161
162 fitResults->Draw();
163 fitResults->Fit(fPol2);
164
165 TPaveText* p = new TPaveText(0.6, 0.85, 0.85, 0.65, "NDC");
166 p->AddText(Form("Fit k_{best} = %.1f%%", fPol2->GetParameter(1)*100));
167 p->AddText(Form("Fit #delta k_{best} = %.2f%%", 1/TMath::Sqrt(fPol2->GetParameter(0))*100));
168 p->AddText(Form("Fit #chi^{2}_{min} = %.2f", fPol2->GetParameter(2)));
169 p->Draw();
170
171 return fitResults;
172}
#define max(a, b)
Definition cfImp.cxx:41
virtual const History * cellHistory(unsigned int i) const
void add(const AbsShapeErrorGetter &getter)
static TF1 * chi2Func(const char *name, double xMin, double xMax)
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
void setShapeErrorGetter(const AbsShapeErrorGetter *err) const
Definition History.h:93
unsigned int nData() const
Definition History.h:54
virtual unsigned int nChannels() const override
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ cachePos()

unsigned int LArSamples::AbsLArCells::cachePos ( ) const
inlineinherited

Definition at line 49 of file AbsLArCells.h.

49{ return m_pos; }

◆ cellCache()

const History * LArSamples::AbsLArCells::cellCache ( ) const
inlineinherited

Definition at line 48 of file AbsLArCells.h.

48{ return m_cellCache.get(); }
std::unique_ptr< const History > m_cellCache
Definition AbsLArCells.h:55

◆ cellHistory()

const History * AbsLArCells::cellHistory ( unsigned int i) const
virtualinherited

Reimplemented in LArSamples::Interface.

Definition at line 54 of file AbsLArCells.cxx.

55{
56 if (m_pos == i) return m_cellCache.get();
57 resetCache();
58 std::unique_ptr<const History> history = newCellHistory(i);
59 if (!history) return nullptr;
60 m_cellCache = std::move(history);
61 m_pos = i;
62 return m_cellCache.get();
63}
virtual void resetCache() const
virtual std::unique_ptr< const History > newCellHistory(unsigned int i) const

◆ cellInfo()

std::unique_ptr< const CellInfo > AbsLArCells::cellInfo ( unsigned int i) const
virtualinherited

Definition at line 66 of file AbsLArCells.cxx.

67{
68 const CellInfo* info = cellInfoCache(i);
69 if (info) {
70 if (info->isValid()) {
71 return std::make_unique<CellInfo> (*info);
72 }
73 return nullptr;
74 }
75 std::unique_ptr<const CellInfo> infop = getCellInfo(i);
76 if (infop) m_cellInfoCache[i] = std::make_unique<CellInfo>(*infop, false);
77 return infop;
78}
virtual std::unique_ptr< const CellInfo > getCellInfo(unsigned int i) const
std::vector< std::unique_ptr< CellInfo > > m_cellInfoCache
Definition AbsLArCells.h:56
const CellInfo * cellInfoCache(unsigned int i) const

◆ cellInfoCache()

const CellInfo * AbsLArCells::cellInfoCache ( unsigned int i) const
inherited

Definition at line 81 of file AbsLArCells.cxx.

82{
83 return m_cellInfoCache[i].get();
84}

◆ chi2Dist()

TH1D * DigitMonitor::chi2Dist ( const TString & name,
int nBins,
double max,
double kFactor = 0,
double fitMax = -1,
int lwb = -1,
int upb = -1,
unsigned int chi2Pars = DefaultChi2,
ShapeErrorType shapeErrorType = BestShapeError,
unsigned int nDof = 0 ) const

Definition at line 60 of file DigitMonitor.cxx.

63{
64 TH1D* h = new TH1D(name, "#chi^{2} distribution", nBins, 0, max);
65 unsigned int nDofEff = 0, nDofLast = 0;
66 std::unique_ptr<UniformShapeErrorGetter> kFactorGetter;
67 std::unique_ptr<CombinedShapeErrorGetter> shapeErrorGetter;
68 if (kFactor > 0) {
69 kFactorGetter = std::make_unique<UniformShapeErrorGetter>(kFactor);
70 shapeErrorGetter = std::make_unique<CombinedShapeErrorGetter>();
71 if (interface().shapeErrorGetter()) shapeErrorGetter->add(*interface().shapeErrorGetter());
72 shapeErrorGetter->add(*kFactorGetter);
73 }
74 for (unsigned int i = 0; i < nChannels(); i++) {
75 if ((i+1) % 10000 == 0) cout << "Processing entry # " << i+1 << endl;
76 const History* history = cellHistory(i);
77 if (!history) continue;
78 if (shapeErrorGetter) history->setShapeErrorGetter(shapeErrorGetter.get()); // Do it at history level so it doesn't "stick" afterwards,,,
79 for (unsigned int j = 0; j < history->nData(); j++) {
80 h->Fill(history->chi2(j, lwb, upb, chi2Pars, shapeErrorType, &nDofEff));
81 if (nDofLast > 0 && nDofLast != nDofEff) cout << "WARNING @ hash = " << i << ", index = " << j << " : nDof varied from " << nDofLast << " to " << nDofEff << endl;
82 nDofLast = nDofEff;
83 }
84 }
85
86 if (nDof > 0 && nDof != nDofEff) cout << "WARNING : fixing nDof = " << nDof << ", but computer nDofEff = " << nDofEff << endl;
87 h->Draw();
88 if (fitMax < 0) return h;
89 TF1* fChi2 = fitChi2(*h, "chi2", 0, max, nDof, 0, fitMax);
90 TPaveText* p = new TPaveText(0.6, 0.85, 0.85, 0.65, "NDC");
91 p->AddText(Form("k = %.1f%%", kFactor*100));
92 p->AddText(Form("Fit #chi^{2} = %.1f", fChi2->GetChisquare()));
93 p->AddText(Form("Fit nDOF = %.1f", fChi2->GetParameter(1)));
94 p->Draw();
95 return h;
96}
static TF1 * fitChi2(TH1D &h, const char *name, double xMin, double xMax, double nDof=-1, double fitMin=Definitions::none, double fitMax=Definitions::none)

◆ chi2Func()

TF1 * DigitMonitor::chi2Func ( const char * name,
double xMin,
double xMax )
static

Definition at line 99 of file DigitMonitor.cxx.

100{
101 TF1* fChi2 = new TF1(name, "[0]*TMath::Power(x/2, [1]/2)/x*TMath::Exp(-x/2)/TMath::Gamma([1]/2)", xMin, xMax);
102 fChi2->SetParameter(0, 100);
103 fChi2->SetParameter(1, 3);
104 fChi2->SetParLimits(1, 1, 7);
105 return fChi2;
106}

◆ combine()

int DigitMonitor::combine ( SimpleShape *& shape,
SimpleShape *& ref,
const TString & selection = "",
bool timeAligned = true ) const

Definition at line 520 of file DigitMonitor.cxx.

521{
522 FilterParams f;
523 if (!f.set(selection)) return 0;
524 int n = 0;
525 pshape = pref = nullptr;
526 //don't change existing interface, use these internally
527 std::unique_ptr<SimpleShape> shape;
528 std::unique_ptr<SimpleShape> ref;
529 double maxSum = 0;
530
531 for (unsigned int i = 0; i < nChannels(); i++) {
532 if ((i+1) % 50000 == 0) cout << "Cell # " << i+1 << "/" << nChannels() << endl;
533 const History* history = pass(i, f);
534 if (!history) continue;
535 for (unsigned int j = 0; j < history->nData(); j++) {
536 if (!f.passEvent(*history->data(j))) continue;
537 maxSum += history->data(j)->maxValue();
538 cout << "Adding pulse (" << n+1 << ") at hash " << i << ", index " << j << ", max = " << maxSum/(n+1) << endl;
539 //cout << i << " " << j << endl;
540 auto thisData = std::make_unique<SimpleShape>(*history->data(j));
541 auto thisRef = history->referenceShape(j);
542 if (timeAligned) {
543 if (!SimpleShape::scaleAndShift(thisData, 1, -history->data(j)->ofcTime())) return -1;
544 if (!SimpleShape::scaleAndShift(thisRef, 1, -history->data(j)->ofcTime())) return -1;
545 }
546 if (!SimpleShape::add(shape, *thisData)) return -1;
547 if (!SimpleShape::add(ref, *thisRef)) return -1;
548 n++;
549 }
550 }
551
552 if (n==0) return -1;
553 if (!SimpleShape::scaleAndShift(shape, 1.0/n)) return -1;
554 if (!SimpleShape::scaleAndShift(ref, 1.0/n)) return -1;
555 //hand these back in existing interface
556 pshape = shape.release();
557 pref = ref.release();
558 return n;
559}
const boost::regex ref(r_ef)
static Double_t * pref
const History * pass(unsigned int i, const FilterParams &f) const
double maxValue(bool withErrors=false) const
Definition AbsShape.cxx:30
double ofcTime() const
Definition Data.h:113
std::unique_ptr< SimpleShape > referenceShape(unsigned int k, double adcMax=-1, double time=Definitions::none, bool samplesOnly=false) const
Definition History.cxx:527
const Data * data(unsigned int i) const
Definition History.cxx:88
bool add(unsigned int k, double value, double error)
static bool scaleAndShift(std::unique_ptr< SimpleShape > &s1, double scale, double shift=0)
const std::string selection

◆ dist() [1/2]

TH1D * MonitorBase::dist ( const DataFuncSet & func,
const DataFuncArgs & args,
const TString & name,
int nBins,
double xMin,
double xMax,
const TString & title = "",
const TString & xTitle = "",
const TString & yTitle = "",
const FilterParams & f = FilterParams() ) const
inherited

Definition at line 69 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

72{
73 TH1D* h = new TH1D(name, title, nBins, xMin, xMax);
74 if (xTitle != "") h->GetXaxis()->SetTitle(xTitle);
75 if (yTitle != "") h->GetYaxis()->SetTitle(yTitle);
76 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
77 if ((i+1) % printPeriodicity == 0) cout << "Cell # " << i+1 << "/" << m_interface->nChannels() << endl;
78 const History* history = pass(i, f);
79 if (!history) continue;
80 for (unsigned int j = 0; j < history->nData(); j++) {
81 if (!f.passEvent(*history->data(j))) continue;
82 h->Fill(func.val(*history->data(j), args));
83 }
84 }
85 return h;
86}
static DataFuncSet func(const TString &var)

◆ dist() [2/2]

TH2D * MonitorBase::dist ( const DataFuncSet & funcX,
const DataFuncArgs & argsX,
const DataFuncSet & funcY,
const DataFuncArgs & argsY,
const TString & name,
int nBinsX,
double xMin,
double xMax,
int nBinsY,
double yMin,
double yMax,
const TString & title = "",
const TString & xTitle = "",
const TString & yTitle = "",
const FilterParams & f = FilterParams() ) const
inherited

Definition at line 89 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

96{
97 TH2D* h = new TH2D(name, title, nBinsX, xMin, xMax, nBinsY, yMin, yMax);
98 if (xTitle != "") h->GetXaxis()->SetTitle(xTitle);
99 if (yTitle != "") h->GetYaxis()->SetTitle(yTitle);
100 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
101 if ((i+1) % printPeriodicity == 0) cout << "Cell # " << i+1 << "/" << m_interface->nChannels() << endl;
102 const History* history = pass(i, f);
103 if (!history) continue;
104 for (unsigned int j = 0; j < history->nData(); j++) {
105 if (!f.passEvent(*history->data(j))) continue;
106 h->Fill(funcX.val(*history->data(j), argsX),
107 funcY.val(*history->data(j), argsY));
108 }
109 }
110 return h;
111}
double val(const Data &data, const DataFuncArgs &args) const
Definition Data.h:62

◆ dump() [1/2]

bool MonitorBase::dump ( const TString & vars,
CombinationType comb = AverageValue,
const FilterParams & f = FilterParams(),
const TString & ranges = "",
unsigned int verbosity = 1 ) const
inherited

Definition at line 317 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

319{
320 std::vector<TString> variables, formats;
321 std::vector<DataFuncSet> funcs;
322 std::vector<DataFuncArgs> args;
323 TString locFormat, locHeader, varHeader;
324 if (!prepareDumpParams(vars, verbosity, variables, funcs, args,
325 formats, locFormat, locHeader, varHeader)) return false;
326
327 std::vector<double> minVals, maxVals;
328 TObjArray* rangeList = ranges.Tokenize(":");
329 for (unsigned int k = 0; k < variables.size(); k++) {
330 TString range = (k < (unsigned int)rangeList->GetEntries() ? ((TObjString*)rangeList->At(k))->String() : "");
331 if (range == "") {
332 minVals.push_back(-DBL_MAX);
333 maxVals.push_back(+DBL_MAX);
334 continue;
335 }
336 TObjArray* minMaxList = range.Tokenize(",");
337 if (minMaxList->GetEntries() == 2) {
338 minVals.push_back(((TObjString*)minMaxList->At(0))->String().Atof());
339 maxVals.push_back(((TObjString*)minMaxList->At(1))->String().Atof());
340 }
341 else {
342 cout << "Invalid range specification " << range << endl;
343 return false;
344 }
345 delete minMaxList;
346 }
347 delete rangeList;
348
349 TString header = locHeader + varHeader;
350 TString separator = "";
351 for (int i = 0; i < header.Length(); i++) separator += "-";
352 cout << separator << endl << header << endl << separator << endl;
353
354 unsigned int nEntries = 0, nValues = 0;
355
356 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
357 const History* history = pass(i, f);
358 if (!history) continue;
359 TString line = Form(locFormat, i, history->cellInfo()->location(verbosity).Data());
360 bool ok = true;
361 for (unsigned int k = 0; k < variables.size(); k++) {
362 double val = history_value(*history, funcs[k], args[k], comb, f, nValues);
363 if (nValues == 0 || val < minVals[k] || val >= maxVals[k]) { ok = false; break; }
364 line += Form(formats[k].Data(), val);
365 }
366 if (!ok) continue;
367 cout << line << endl;
368 nEntries++;
369 }
370 cout << nEntries << " entries selected" << endl;
371 return true;
372}
@ Data
Definition BaseObject.h:11
TString location(int verbose=1) const
Definition CellInfo.cxx:139
const CellInfo * cellInfo() const
Definition History.h:59
bool prepareDumpParams(const TString &vars, int verbosity, std::vector< TString > &variables, std::vector< DataFuncSet > &funcs, std::vector< DataFuncArgs > &args, std::vector< TString > &formats, TString &locFormat, TString &locHeader, TString &varHeader) const
static double history_value(const History &history, const DataFuncSet &func, const DataFuncArgs &args, CombinationType comb, const FilterParams &f, unsigned int &nValues)

◆ dump() [2/2]

bool MonitorBase::dump ( const TString & vars,
const FilterParams & f = FilterParams(),
unsigned int verbosity = 1 ) const
inherited

Definition at line 284 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

285{
286 std::vector<TString> variables, formats;
287 std::vector<DataFuncSet> funcs;
288 std::vector<DataFuncArgs> args;
289 TString locFormat, locHeader, varHeader;
290 if (!prepareDumpParams(vars, verbosity, variables, funcs, args,
291 formats, locFormat, locHeader, varHeader)) return false;
292 TString header = locHeader + " idx |" + varHeader;
293 TString separator = "";
294 for (int i = 0; i < header.Length(); i++) separator += "-";
295 cout << separator << endl << header << endl << separator << endl;
296
297 unsigned int nEntries = 0;
298
299 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
300 const History* history = pass(i, f);
301 if (!history) continue;
302 TString part1 = Form(locFormat, i, history->cellInfo()->location(verbosity).Data());
303 for (unsigned int j = 0; j < history->nData(); j++) {
304 if (!f.passEvent(*history->data(j))) continue;
305 TString line = part1 + Form(" %3d |", j);
306 for (unsigned int k = 0; k < variables.size(); k++)
307 line += Form(formats[k].Data(), funcs[k].val(*history->data(j), args[k]));
308 cout << line << endl;
309 nEntries++;
310 }
311 }
312 cout << nEntries << " entries selected" << endl;
313 return true;
314}

◆ energyDist()

TH1D * DigitMonitor::energyDist ( const TString & name,
int nBins,
double eMax = 10000 ) const

Definition at line 41 of file DigitMonitor.cxx.

42{return dist(&Data::_energy, DataFuncArgs(), name, nBins, 0, eMax, "Energy distribution", "Energy (MeV)"); }
double _energy(const DataFuncArgs &) const
Definition Data.h:193

◆ etaPhiMap()

TH2D * MonitorBase::etaPhiMap ( const DataFuncSet & func,
const DataFuncArgs & args,
const TString & name,
CaloId calo,
short layer,
TString title = "",
CombinationType comb = AverageValue,
const FilterParams & f = FilterParams() ) const
inherited

Definition at line 131 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

134{
135 if (title == "") title = Form("%s %s (%s, layer %d)", name.Data(), str(comb).Data(), Id::str(calo).Data(), layer);
136 TH2D* h = Geo::etaPhiHist(calo, layer, name, title);
137 FilterParams ff(f);
138 ff.addCalo(calo);
139 ff.addLayer(layer);
140 unsigned int nValues = 0;
141 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
142 if ((i+1) % printPeriodicity == 0) cout << "Cell # " << i+1 << "/" << m_interface->nChannels() << endl;
143 const History* history = pass(i, ff);
144 if (!history) continue;
145 h->Fill(history->cellInfo()->eta(), history->cellInfo()->phi(),
146 history_value(*history, func, args, comb, f, nValues));
147 }
148 return h;
149}
double eta() const
Definition CellInfo.h:93
double phi() const
Definition CellInfo.h:94
static TH2D * etaPhiHist(CaloId calo, short layer, const TString &name, const TString &title)
Definition Geometry.cxx:549
static TString str(CaloId id)
Definition CaloId.cxx:15

◆ fitChi2()

TF1 * DigitMonitor::fitChi2 ( TH1D & h,
const char * name,
double xMin,
double xMax,
double nDof = -1,
double fitMin = Definitions::none,
double fitMax = Definitions::none )
static

Definition at line 109 of file DigitMonitor.cxx.

111{
112 if (fitMin == Definitions::none) fitMin = xMin;
113 if (fitMax == Definitions::none) fitMin = xMax;
114
115 TF1* fChi2 = chi2Func(name, xMin, xMax);
116 fChi2->SetParameter(0, 4*h.GetMaximum());
117 if (nDof > 0) fChi2->FixParameter(1, nDof);
118
119 h.Fit(fChi2, "", "", fitMin, fitMax);
120 fChi2->SetRange(xMin, xMax);
121 return fChi2;
122}

◆ func()

DataFuncSet MonitorBase::func ( const TString & var)
staticinherited

Definition at line 431 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

432{
433 if (var == "sample") return DataFuncSet(&Data::_sample);
434 if (var == "pedSubSample") return DataFuncSet(&Data::_pedestalSubstractedSample);
435 if (var == "energy") return DataFuncSet(&Data::_energy);
436 if (var == "adcMax") return DataFuncSet(&Data::_adcMax);
437 if (var == "adcMax_new") return DataFuncSet(&Data::_adcMax_new);
438 if (var == "gain") return DataFuncSet(&Data::_gain);
439 if (var == "peakSignif") return DataFuncSet(&Data::_peakSignif);
440 if (var == "energySignif") return DataFuncSet(&Data::_energySignif);
441 if (var == "ofcTime") return DataFuncSet(&Data::_ofcTime);
442 if (var == "sampleMax") return DataFuncSet(&Data::_maxValue);
443 if (var == "maxPosition") return DataFuncSet(&Data::_maxPosition);
444 if (var == "quality") return DataFuncSet(&Data::_quality);
445 if (var == "noise") return DataFuncSet(&Data::_noise);
446 if (var == "pedestal") return DataFuncSet(&Data::_pedestal);
447 if (var == "pedestalRMS") return DataFuncSet(&Data::_pedestalRMS);
448 if (var == "maxValue") return DataFuncSet(&Data::_maxValue);
449 if (var == "minValue") return DataFuncSet(&Data::_minValue);
450 if (var == "count") return DataFuncSet(&Data::_count);
451 if (var == "chi2") return DataFuncSet(&Data::_chi2);
452 if (var == "chi2_noCorr") return DataFuncSet(&Data::_chi2_noCorr);
453 if (var == "chi2_ringCorr") return DataFuncSet(&Data::_chi2_ringCorr);
454 if (var == "chi2_cellCorr") return DataFuncSet(&Data::_chi2_cellCorr);
455 if (var == "chi2_k") return DataFuncSet(&Data::_chi2_k);
456 if (var == "refitScale") return DataFuncSet(&Data::_refitScale);
457 if (var == "refitDeltaT") return DataFuncSet(&Data::_refitDeltaT);
458 if (var == "refitChi2") return DataFuncSet(&Data::_refitChi2);
459 if (var == "adjScale") return DataFuncSet(&Data::_adjScale);
460 if (var == "adjDeltaT") return DataFuncSet(&Data::_adjDeltaT);
461 if (var == "run") return DataFuncSet(&Data::_run);
462 if (var == "event") return DataFuncSet(&Data::_event);
463 if (var == "lumiBlock") return DataFuncSet(&Data::_lumiBlock);
464 if (var == "bunchId") return DataFuncSet(&Data::_bunchId);
465 if (var == "x") return DataFuncSet(&Data::_x);
466 if (var == "y") return DataFuncSet(&Data::_y);
467 if (var == "z") return DataFuncSet(&Data::_z);
468 if (var == "rt") return DataFuncSet(&Data::_rt);
469 if (var == "eta") return DataFuncSet(&Data::_eta);
470 if (var == "phi") return DataFuncSet(&Data::_phi);
471 if (var == "iEta") return DataFuncSet(&Data::_iEta);
472 if (var == "iPhi") return DataFuncSet(&Data::_iPhi);
473 if (var == "region") return DataFuncSet(&Data::_region);
474 if (var == "calo") return DataFuncSet(&Data::_calo);
475 if (var == "layer") return DataFuncSet(&Data::_layer);
476 if (var == "feedthrough") return DataFuncSet(&Data::_feedThrough);
477 if (var == "FT") return DataFuncSet(&Data::_feedThrough);
478 if (var == "slot") return DataFuncSet(&Data::_slot);
479 if (var == "channel") return DataFuncSet(&Data::_channel);
480 if (var == "ring") return DataFuncSet(&Data::_ring);
481 if (var == "index") return DataFuncSet(&Data::_index);
482 if (var == "hash") return DataFuncSet(&Data::_hash);
483 if (var == "nData") return DataFuncSet(&Data::_nData);
484 if (var == "timeNoTOF") return DataFuncSet(&Data::_timeNoTOF);
485 if (var == "timeForSplash1") return DataFuncSet(&Data::_timeForSplash1);
486 if (var == "timeForSplash2") return DataFuncSet(&Data::_timeForSplash2);
487 if (var == "delta") return DataFuncSet(&Data::_delta);
488 if (var == "residual") return DataFuncSet(&Data::_residual);
489 if (var == "residualOffset") return DataFuncSet(&Data::_residualOffset);
490 if (var == "resCorrN") return DataFuncSet(&Data::_resCorrN);
491 if (var == "xi") return DataFuncSet(&Data::_xi);
492 if (var == "xiCell") return DataFuncSet(&Data::_xiCell);
493 if (var == "xiRing") return DataFuncSet(&Data::_xiRing);
494 if (var == "xiNormCell") return DataFuncSet(&Data::_xiNormCell);
495 if (var == "xiNormRing") return DataFuncSet(&Data::_xiNormRing);
496 if (var == "xip") return DataFuncSet(&Data::_xip);
497 if (var == "residualError") return DataFuncSet(&Data::_residualError);
498 if (var == "ofcSigma") return DataFuncSet(&Data::_ofcSigma);
499 if (var == "ofcGamma") return DataFuncSet(&Data::_ofcGamma);
500 if (var == "normResidualOffset") return DataFuncSet(&Data::_normResidualOffset);
501 if (var == "normResidualError") return DataFuncSet(&Data::_normResidualError);
502 if (var == "pass") return DataFuncSet(&Data::_pass);
503 if (var == "goodForShapeCorr") return DataFuncSet(&Data::_goodForShapeCorr);
504 if (var == "upstreamE") return DataFuncSet(&Data::_upstreamE);
505 if (var == "upstreamERatio") return DataFuncSet(&Data::_upstreamERatio);
506 if (var == "chi2Anomaly") return DataFuncSet(&Data::_chi2Anomaly);
507 if (var == "timeECorr") return DataFuncSet(&Data::_timeECorr);
508
509 return DataFuncSet();
510}
double _residualOffset(const DataFuncArgs &args) const
Definition Data.h:213
double _z(const DataFuncArgs &args) const
Definition Data.cxx:500
int _region(const DataFuncArgs &args) const
Definition Data.cxx:318
double _phi(const DataFuncArgs &args) const
Definition Data.cxx:503
double _sample(const DataFuncArgs &args) const
Definition Data.h:191
double _energySignif(const DataFuncArgs &args) const
Definition Data.cxx:408
int _maxPosition(const DataFuncArgs &) const
Definition Data.h:237
double _xiCell(const DataFuncArgs &args) const
Definition Data.h:216
double _chi2Anomaly(const DataFuncArgs &args) const
Definition Data.cxx:596
double _y(const DataFuncArgs &args) const
Definition Data.cxx:499
double _ofcGamma(const DataFuncArgs &args) const
Definition Data.cxx:577
double _xip(const DataFuncArgs &args) const
Definition Data.h:220
double _x(const DataFuncArgs &args) const
Definition Data.cxx:498
double _normResidualOffset(const DataFuncArgs &args) const
Definition Data.h:222
double _residualError(const DataFuncArgs &args) const
Definition Data.h:221
int _calo(const DataFuncArgs &args) const
Definition Data.cxx:325
int _gain(const DataFuncArgs &) const
Definition Data.h:210
double _adcMax_new(const DataFuncArgs &) const
Definition Data.h:199
double _delta(const DataFuncArgs &args) const
Definition Data.h:211
double _ofcSigma(const DataFuncArgs &args) const
Definition Data.cxx:566
double _quality(const DataFuncArgs &) const
Definition Data.h:195
int _lumiBlock(const DataFuncArgs &) const
Definition Data.h:207
int _goodForShapeCorr(const DataFuncArgs &) const
Definition Data.h:262
double _chi2(const DataFuncArgs &) const
Definition Data.h:241
double _minValue(const DataFuncArgs &) const
Definition Data.h:202
double _pass(const DataFuncArgs &args) const
Definition Data.h:272
int _layer(const DataFuncArgs &args) const
Definition Data.cxx:332
double _pedestalRMS(const DataFuncArgs &) const
Definition Data.h:197
int _run(const DataFuncArgs &) const
Definition Data.h:205
double _normResidualError(const DataFuncArgs &args) const
Definition Data.h:223
int _feedThrough(const DataFuncArgs &args) const
Definition Data.cxx:339
int _iEta(const DataFuncArgs &args) const
Definition Data.cxx:304
double _timeForSplash1(const DataFuncArgs &args) const
Definition Data.cxx:388
double _adjScale(const DataFuncArgs &args) const
Definition Data.cxx:296
double _timeForSplash2(const DataFuncArgs &args) const
Definition Data.cxx:395
double _timeNoTOF(const DataFuncArgs &args) const
Definition Data.cxx:381
double _maxValue(const DataFuncArgs &) const
Definition Data.h:201
double _xi(const DataFuncArgs &args) const
Definition Data.h:215
double _timeECorr(const DataFuncArgs &args) const
Definition Data.cxx:641
int _ring(const DataFuncArgs &args) const
Definition Data.cxx:367
int _iPhi(const DataFuncArgs &args) const
Definition Data.cxx:311
double _adjDeltaT(const DataFuncArgs &args) const
Definition Data.cxx:288
double _count(const DataFuncArgs &) const
Definition Data.h:239
double _upstreamERatio(const DataFuncArgs &args) const
Definition Data.cxx:588
int _slot(const DataFuncArgs &args) const
Definition Data.cxx:346
double _chi2_noCorr(const DataFuncArgs &args) const
Definition Data.cxx:211
double _xiNormRing(const DataFuncArgs &) const
Definition Data.h:219
int _hash(const DataFuncArgs &args) const
Definition Data.cxx:360
double _noise(const DataFuncArgs &) const
Definition Data.h:200
double _upstreamE(const DataFuncArgs &) const
Definition Data.h:263
double _xiRing(const DataFuncArgs &args) const
Definition Data.h:217
double _chi2_k(const DataFuncArgs &args) const
Definition Data.cxx:232
double _eta(const DataFuncArgs &args) const
Definition Data.cxx:502
double _refitScale(const DataFuncArgs &args) const
Definition Data.cxx:260
double _chi2_ringCorr(const DataFuncArgs &args) const
Definition Data.cxx:218
double _ofcTime(const DataFuncArgs &) const
Definition Data.h:194
double _residual(const DataFuncArgs &args) const
Definition Data.h:212
double _pedestalSubstractedSample(const DataFuncArgs &args) const
Definition Data.h:192
int _bunchId(const DataFuncArgs &) const
Definition Data.h:208
int _index(const DataFuncArgs &) const
Definition Data.h:209
double _pedestal(const DataFuncArgs &) const
Definition Data.h:196
int _nData(const DataFuncArgs &args) const
Definition Data.cxx:374
double _chi2_cellCorr(const DataFuncArgs &args) const
Definition Data.cxx:225
int _channel(const DataFuncArgs &args) const
Definition Data.cxx:353
double _peakSignif(const DataFuncArgs &args) const
Definition Data.cxx:402
double _resCorrN(const DataFuncArgs &) const
Definition Data.h:214
int _event(const DataFuncArgs &) const
Definition Data.h:206
double _rt(const DataFuncArgs &args) const
Definition Data.cxx:501
double _refitChi2(const DataFuncArgs &args) const
Definition Data.cxx:268
double _refitDeltaT(const DataFuncArgs &args) const
Definition Data.cxx:252
double _xiNormCell(const DataFuncArgs &) const
Definition Data.h:218

◆ gainDist()

TH1D * DigitMonitor::gainDist ( const TString & name) const

Definition at line 176 of file DigitMonitor.cxx.

177{
178 TH1D* h = new TH1D(name, "gain distribution", 3, -0.5, 2.5);
179 h->GetXaxis()->SetBinLabel(1, "Low");
180 h->GetXaxis()->SetBinLabel(2, "Medium");
181 h->GetXaxis()->SetBinLabel(3, "High");
182 for (unsigned int i = 0; i < nChannels(); i++) {
183 const History* history = cellHistory(i);
184 if (!history) continue;
185 for (unsigned int j = 0; j < history->nData(); j++) h->Fill(history->data(j)->gain());
186 }
187 return h;
188}
CaloGain::CaloGain gain() const
Definition Data.h:87

◆ getCellHistory()

std::unique_ptr< const History > MonitorBase::getCellHistory ( unsigned int i) const
overridevirtualinherited

Implements LArSamples::AbsLArCells.

Definition at line 34 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

35{
36 return interface().getCellHistory(i);
37}
virtual std::unique_ptr< const History > getCellHistory(unsigned int i) const override

◆ getCellInfo()

std::unique_ptr< const CellInfo > MonitorBase::getCellInfo ( unsigned int i) const
overridevirtualinherited

Reimplemented from LArSamples::AbsLArCells.

Definition at line 44 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

45{
46 return interface().getCellInfo(i);
47}
virtual std::unique_ptr< const CellInfo > getCellInfo(unsigned int i) const override

◆ getResiduals()

std::unique_ptr< Residuals > DigitMonitor::getResiduals ( unsigned int hash,
CaloGain::CaloGain gain,
double absResTrunc = -1,
bool adjust = false,
bool zeroTime = false ) const

Definition at line 561 of file DigitMonitor.cxx.

562{
563 const History* history = cellHistory(hash);
564 if (!history) return nullptr;
565 std::unique_ptr<const History> historyptr;
566 if (adjust) {
567 historyptr = history->adjust();
568 history = historyptr.get();
569 }
570 return history->residuals(gain, absResTrunc, false, zeroTime);
571}
std::unique_ptr< Residuals > residuals(CaloGain::CaloGain gain=CaloGain::LARNGAIN, double absResTrunc=-1, bool correct=true, bool zeroTime=false) const
Definition History.cxx:593
std::unique_ptr< History > adjust() const
Definition History.cxx:250

◆ getSCHistory()

std::unique_ptr< const History > MonitorBase::getSCHistory ( unsigned int i) const
overridevirtualinherited

Implements LArSamples::AbsLArCells.

Definition at line 39 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

40{
41 return interface().getSCHistory(i);
42}
virtual std::unique_ptr< const History > getSCHistory(unsigned int i) const override

◆ history_value()

double MonitorBase::history_value ( const History & history,
const DataFuncSet & func,
const DataFuncArgs & args,
CombinationType comb,
const FilterParams & f,
unsigned int & nValues )
staticinherited

Definition at line 404 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

406{
407 double val = 0, sum1 = 0, sum2 = 0;
408 nValues = 0;
409 if (comb == MaxValue) val = DBL_MIN;
410 if (comb == MinValue) val = DBL_MAX;
411 for (unsigned int j = 0; j < history.nData(); j++) {
412 if (!f.passEvent(*history.data(j))) continue;
413 double thisVal = func.val(*history.data(j), args);
414 nValues++;
415 switch (comb) {
416 case AverageValue : val += thisVal; break;
417 case MaxValue : if (thisVal > val) val = thisVal; break;
418 case MinValue : if (thisVal < val) val = thisVal; break;
419 case TotalValue : val += thisVal; break;
420 case RMSValue : sum1 += thisVal; sum2 += thisVal*thisVal; break;
421 }
422 }
423 if (comb == AverageValue && nValues > 0) val /= nValues;
424 if (comb == RMSValue)
425 val = (nValues > 0 ? TMath::Sqrt((sum2 - sum1*sum1/nValues)/nValues) : -1);
426 if (TMath::Abs(val) > 0.9*DBL_MAX) val = 0;
427 return val;
428}

◆ interface()

const Interface & LArSamples::MonitorBase::interface ( ) const
inlineinherited

Definition at line 74 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/MonitorBase.h.

74{ return *m_interface; }

◆ kMatrix()

CovMatrix LArSamples::DigitMonitor::kMatrix ( int lwb,
int upb )
inline

Definition at line 78 of file DigitMonitor.h.

78{ CovMatrix k; TVectorD means; residualParams(lwb, upb, k, means); return k; }
bool residualParams(int lwb, int upb, CovMatrix &k, TVectorD &means) const
TVectorD means(int lwb, int upb)

◆ layerDist()

TH1D * DigitMonitor::layerDist ( const TString & name) const

Definition at line 191 of file DigitMonitor.cxx.

192{
193 TH1D* h = new TH1D(name, "layer distribution", 4, -0.5, 3.5);
194 h->GetXaxis()->SetBinLabel(1, "PS");
195 h->GetXaxis()->SetBinLabel(2, "Strips");
196 h->GetXaxis()->SetBinLabel(3, "Middle");
197 h->GetXaxis()->SetBinLabel(4, "Back");
198 for (unsigned int i = 0; i < nChannels(); i++) {
199 const History* history = cellHistory(i);
200 if (!history) continue;
201 for (unsigned int j = 0; j < history->nData(); j++) h->Fill(history->cellInfo()->layer());
202 }
203 return h;
204}
short layer() const
Definition CellInfo.h:53

◆ makeResidualCorrections()

bool DigitMonitor::makeResidualCorrections ( const TString & outputFile,
short resTrunc = -1,
short timeTrunc = -1,
double absResTrunc = -1,
unsigned int minSize = 0,
bool weigh = false,
bool adjust = false,
bool zeroTime = false ) const

Definition at line 574 of file DigitMonitor.cxx.

576{
577 TreeShapeErrorGetter* shapeError = new TreeShapeErrorGetter(outputFile, true);
578 std::vector< std::vector<ResidualCalculator> > ringCalcs;
579 std::vector<ResidualCalculator> gainRingCalcs(Geo::nPhiRings());
580 for (unsigned int g = 0; g < CaloGain::LARNGAIN; g++) ringCalcs.push_back(gainRingCalcs);
581
582 cout << "Processing cells" << endl;
583
584 for (unsigned int i = 0; i < nChannels(); i++) {
585 if ((i+1) % 10000 == 0) cout << "Processing hash = " << (i+1) << endl;
586 for (unsigned int g = 0; g < CaloGain::LARNGAIN; g++) {
587 std::unique_ptr<Residuals> residuals = getResiduals(i, (CaloGain::CaloGain)g, absResTrunc, adjust, zeroTime);
588 if (residuals && (resTrunc > 0 || timeTrunc > 0)) {
589 residuals = residuals->truncate(resTrunc, timeTrunc);
590 }
591
592 if (residuals && residuals->size() < minSize) {
593 residuals = nullptr;
594 }
595
596 ResidualCalculator* resCalc = nullptr;
597 if (residuals) {
598 resCalc = residuals->calculator(weigh);
599 }
600
601 if (!resCalc) {
602 shapeError->addCell(ResidualCalculator(), (CaloGain::CaloGain)g);
603 continue;
604 }
605
606 cout << i << " : Phi ring " << cellHistory(i)->cellInfo()->globalPhiRing() << " : adding " << resCalc->size() << endl;
607 shapeError->addCell(*resCalc, (CaloGain::CaloGain)g);
608 short iring = cellHistory(i)->cellInfo()->globalPhiRing();
609 if (iring >= 0) {
610 ringCalcs[g][iring].append(*resCalc);
611 if (iring == 1142) cout << ringCalcs[g][iring].regresser()->mean(0) << endl;
612 }
613 delete resCalc;
614 }
615 }
616
617 cout << "Processing phi-symmetric data" << endl;
618
619 for (unsigned int g = 0; g < CaloGain::LARNGAIN; g++) {
620 for (short i = 0; i < Geo::nPhiRings(); i++) {
621 if (ringCalcs[g][i].size() > 0)
622 cout << "Saving data for gain " << g << ", phi ring " << i << ", n = " << ringCalcs[g][i].size() << ", range = " << ringCalcs[g][i].rangeStr() << endl;
623 shapeError->addRing(ringCalcs[g][i], (CaloGain::CaloGain)g);
624 }
625 }
626
627 cout << "Done!" << endl;
628
629 delete shapeError;
630 return true;
631}
short globalPhiRing() const
Definition CellInfo.cxx:125
std::unique_ptr< Residuals > getResiduals(unsigned int hash, CaloGain::CaloGain gain, double absResTrunc=-1, bool adjust=false, bool zeroTime=false) const
static short nPhiRings()
Definition Geometry.cxx:84
int addCell(const ResidualCalculator &calc, CaloGain::CaloGain gain)
int addRing(const ResidualCalculator &calc, CaloGain::CaloGain gain)
@ LARNGAIN
Definition CaloGain.h:19

◆ maxValueMap()

TH2D * DigitMonitor::maxValueMap ( TString name,
PartitionId partition ) const

Definition at line 53 of file DigitMonitor.cxx.

54{ return partitionMap(&Data::_maxValue, DataFuncArgs(), std::move(name), partition, "Max sample value (ADC counts)", MaxValue); }
TH2D * partitionMap(const DataFuncSet &func, const DataFuncArgs &args, TString name, PartitionId partition, const TString &title="", CombinationType comb=AverageValue, const FilterParams &f=FilterParams()) const

◆ means()

TVectorD LArSamples::DigitMonitor::means ( int lwb,
int upb )
inline

Definition at line 79 of file DigitMonitor.h.

79{ CovMatrix k; TVectorD means; residualParams(lwb, upb, k, means); return means; }

◆ minValueMap()

TH2D * DigitMonitor::minValueMap ( TString name,
PartitionId partition ) const

Definition at line 56 of file DigitMonitor.cxx.

57{ return partitionMap(&Data::_minValue, DataFuncArgs(), std::move(name), partition, "Min sample value (ADC counts)", MinValue); }

◆ nChannels()

unsigned int MonitorBase::nChannels ( ) const
overridevirtualinherited

Reimplemented from LArSamples::AbsLArCells.

Definition at line 50 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

51{
52 return interface().nChannels();
53}
virtual unsigned int nChannels() const
Definition AbsLArCells.h:35

◆ nChannelsSC()

virtual unsigned int LArSamples::AbsLArCells::nChannelsSC ( ) const
inlinevirtualinherited

Definition at line 36 of file AbsLArCells.h.

◆ newCellHistory()

std::unique_ptr< const History > AbsLArCells::newCellHistory ( unsigned int i) const
virtualinherited

Definition at line 39 of file AbsLArCells.cxx.

40{
41 std::unique_ptr<const History> history = getCellHistory(i);
42 if (!history) return nullptr;
43 if (!m_cellInfoCache[i]) {
44 const CellInfo* ci=history->cellInfo();
45 if (ci) {
46 m_cellInfoCache[i]=std::make_unique<CellInfo>(*ci,false);
47 }
48 }
49 // m_cellInfoCache[i] = (history->cellInfo() ? new CellInfo(*history->cellInfo(), false) : new CellInfo());
50 return history;
51}
virtual std::unique_ptr< const History > getCellHistory(unsigned int i) const =0

◆ noiseDist()

TH1D * DigitMonitor::noiseDist ( const TString & name,
int nBins,
double max ) const

Definition at line 50 of file DigitMonitor.cxx.

51{ return dist(&Data::_noise, DataFuncArgs(), name, nBins, 0, max, "Noise distribution", "Noise (ADC counts)"); }

◆ parseVariables()

bool MonitorBase::parseVariables ( TString varStr,
std::vector< TString > & vars,
std::vector< DataFuncSet > & funcs,
std::vector< DataFuncArgs > & args )
staticinherited

Definition at line 152 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

154{
155 varStr.ReplaceAll(" ", "");
156 TObjArray* varList = varStr.Tokenize(":");
157 for (int i = 0; i < varList->GetEntries(); i++) {
158 TString varAndSample = ((TObjString*)varList->At(i))->String();
159 TString var = varAndSample;
160 short sample1 = -1, sample2 = -1;
161 double par = Definitions::none;
162 TString str = "";
163 if (varAndSample.CountChar('[') + varAndSample.CountChar(']') > 0) {
164 if (varAndSample.CountChar('[') != 1 || varAndSample.CountChar(']') != 1 || varAndSample[varAndSample.Length() - 1] != ']') {
165 cout << "Invalid use of [ ] delimiters" << endl;
166 delete varList;
167 return false;
168 }
169 TObjArray* varSampList = varAndSample.Tokenize("[,]");
170 if (varSampList->GetEntries() == 2) {
171 var = ((TObjString*)varSampList->At(0))->String();
172 TString sampStr = ((TObjString*)varSampList->At(1))->String();
173 delete varSampList;
174 if (!sampStr.IsDigit()) {
175 cout << "Sample argument [sample] should be an integer" << endl;
176 delete varList;
177 return false;
178 }
179 sample1 = sampStr.Atoi();
180 }
181 else if (varSampList->GetEntries() == 3) {
182 var = ((TObjString*)varSampList->At(0))->String();
183 TString sampStr1 = ((TObjString*)varSampList->At(1))->String();
184 TString sampStr2 = ((TObjString*)varSampList->At(2))->String();
185 delete varSampList;
186 if (!sampStr1.IsDigit() || !sampStr2.IsDigit()) {
187 cout << "Sample arguments [sample1, sample2] should be an integer" << endl;
188 delete varList;
189 return false;
190 }
191 sample1 = sampStr1.Atoi();
192 sample2 = sampStr2.Atoi();
193 }
194 else {
195 cout << "Invalid specification of sample argument (expected var[sample])" << endl;
196 delete varSampList;
197 delete varList;
198 return false;
199 }
200 }
201 if (varAndSample.CountChar('(') + varAndSample.CountChar(')') > 0) {
202 if (varAndSample.CountChar('(') != 1 || varAndSample.CountChar(')') != 1 || varAndSample[varAndSample.Length() - 1] != ')') {
203 cout << "Invalid use of ( ) delimiters" << endl;
204 delete varList;
205 return false;
206 }
207 TObjArray* varSampList = varAndSample.Tokenize("(,)");
208 if (varSampList->GetEntries() == 2) {
209 var = ((TObjString*)varSampList->At(0))->String();
210 TString sampStr = ((TObjString*)varSampList->At(1))->String();
211 delete varSampList;
212 if (!sampStr.IsFloat()) {
213 cout << "floating-point argument expected between ()" << endl;
214 delete varList;
215 return false;
216 }
217 par = sampStr.Atof();
218 }
219 else {
220 cout << "Invalid specification of floating-point argument (expected func(arg))" << endl;
221 delete varSampList;
222 delete varList;
223 return false;
224 }
225 }
226 if (varAndSample(0, 5) == "pass_") {
227 str = varAndSample(5, varAndSample.Length() - 5);
228 var = "pass";
229 }
230 DataFuncSet fcn = func(var);
231 if (fcn.isNull()) {
232 cout << "Unknown variable " << var << endl;
233 return false;
234 }
235 vars.push_back(varAndSample);
236 funcs.push_back(fcn);
237 args.emplace_back(sample1, sample2, par, Definitions::none, str);
238 }
239 delete varList;
240 return true;
241}

◆ partitionMap()

TH2D * MonitorBase::partitionMap ( const DataFuncSet & func,
const DataFuncArgs & args,
TString name,
PartitionId partition,
const TString & title = "",
CombinationType comb = AverageValue,
const FilterParams & f = FilterParams() ) const
inherited

Definition at line 113 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

115{
116 TH2D* h = Geo::partitionHist(partition, std::move(name), title + " " + Id::str(partition));
117 unsigned int nValues = 0;
118 FilterParams ff(f);
119 ff.addPartition(partition);
120 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
121 if ((i+1) % printPeriodicity == 0) cout << "Cell # " << i+1 << "/" << m_interface->nChannels() << endl;
122 const History* history = pass(i, ff);
123 if (!history) continue;
124 h->SetBinContent(history->cellInfo()->feb() + 1, history->cellInfo()->channel() + 1,
125 history_value(*history, func, args, comb, f, nValues));
126 }
127 return h;
128}
short feb() const
Definition CellInfo.cxx:102
short channel() const
Definition CellInfo.h:76
static TH2D * partitionHist(PartitionId part, const TString &name, const TString &title)
Definition Geometry.cxx:18

◆ pass()

const History * AbsLArCells::pass ( unsigned int i,
const FilterParams & f ) const
inherited

Definition at line 96 of file AbsLArCells.cxx.

97{
98 //std::cout << "Called AbsLArCells with hash " << i << std::endl;
99 if (!f.passHash(i)) return nullptr;
100 std::unique_ptr<const CellInfo> info = cellInfo(i);
101 if (!info) {
102 return nullptr;
103 }
104 //std::cout << "Called AbsLArCells::pass on a cell belonging to " << Id::str(info->calo()) << std::endl;
105 bool result = f.passCell(*info);
106 return result ? cellHistory(i) : nullptr;
107}
virtual std::unique_ptr< const CellInfo > cellInfo(unsigned int i) const

◆ prepareDumpParams()

bool MonitorBase::prepareDumpParams ( const TString & vars,
int verbosity,
std::vector< TString > & variables,
std::vector< DataFuncSet > & funcs,
std::vector< DataFuncArgs > & args,
std::vector< TString > & formats,
TString & locFormat,
TString & locHeader,
TString & varHeader ) const
inherited

Definition at line 244 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

249{
250 if (!parseVariables(vars, variables, funcs, args)) {
251 cout << "Invalid variable specification " << vars << endl;
252 return false;
253 }
254
255 locFormat = "| %6d | %-";
256 if (verbosity <= 1)
257 locFormat += "26";
258 else if (verbosity == 2)
259 locFormat += "80";
260 else if (verbosity == 3)
261 locFormat += "108";
262 else
263 locFormat += "120";
264 locFormat += "s |";
265
266 TString locFormatHeader = locFormat; locFormatHeader.ReplaceAll("d", "s");
267 locHeader = Form(locFormatHeader, "hash", "location");
268
269 for (unsigned int i = 0; i < variables.size(); i++) {
270 formats.emplace_back(" %-9.8g |");
271 TString fH = formats[i]; fH.ReplaceAll("g", "s");
272 TString varName = variables[i];
273 if (args[i].i2 != -1) varName += Form("[%d, %d]", args[i].i1, args[i].i2);
274 else if (args[i].i1 != -1) varName += Form("[%d]", args[i].i1);
275 if (!Definitions::isNone(args[i].x1)) varName += Form("[%.5f]", args[i].x1);
276 if (args[i].str != "") varName += Form("_%s", args[i].str.Data());
277 varHeader += Form(fH, varName.Data());
278 }
279 return true;
280}
static bool parseVariables(TString varStr, std::vector< TString > &vars, std::vector< DataFuncSet > &funcs, std::vector< DataFuncArgs > &args)
str varName
end cluster ToT and charge

◆ resetCache()

void AbsLArCells::resetCache ( ) const
virtualinherited

Definition at line 32 of file AbsLArCells.cxx.

33{
34 m_cellCache.reset();
35 m_pos = nChannels() + 1;
36}

◆ residualCorr()

double DigitMonitor::residualCorr ( unsigned int k1,
unsigned int k2 ) const

Definition at line 446 of file DigitMonitor.cxx.

447{
448 double sum = 0;
449 int n = 0;
450
451 for (unsigned int i = 0; i < nChannels(); i++) {
452 const History* history = cellHistory(i);
453 if (!history) continue;
454 for (unsigned int j = 0; j < history->nData(); j++) {
455 double residual1 = history->data(j)->delta(k1);
456 double residual2 = history->data(j)->delta(k2);
457 sum += residual1*residual2;
458 n++;
459 }
460 }
461
462 return n==0 ? 0 : sum/n;
463}
double delta(short sample) const
Definition Data.cxx:430

◆ residualDist()

TH1D * DigitMonitor::residualDist ( unsigned int k,
const TString & name,
int nBins,
double rMin,
double rMax,
bool norm = false ) const

Definition at line 207 of file DigitMonitor.cxx.

208{
209 TH1D* h = new TH1D(name, "Residual distribution", nBins, rMin, rMax);
210 h->GetXaxis()->SetTitle(norm ? "Residual/ADCMax (%)" : "Residual (ADC counts)");
211
212 for (unsigned int i = 0; i < nChannels(); i++) {
213 const History* history = cellHistory(i);
214 if (!history) continue;
215 for (unsigned int j = 0; j < history->nData(); j++)
216 h->Fill(history->data(j)->delta(k)*(norm ? 100/history->data(j)->adcMax() : 1));
217 }
218 return h;
219}
double adcMax() const
Definition Data.h:126

◆ residualParams()

bool DigitMonitor::residualParams ( int lwb,
int upb,
CovMatrix & k,
TVectorD & means ) const

Definition at line 466 of file DigitMonitor.cxx.

467{
468 CovMatrix sum2N(lwb, upb), sumCN(lwb, upb);
469 TVectorD sum(lwb, upb), sumN(lwb, upb);
470 double sumA = 0, n = 0;
471 for (unsigned int i = 0; i < nChannels(); i++) {
472 const History* history = cellHistory(i);
473 if (!history) continue;
474 for (unsigned int j = 0; j < history->nData(); j++) {
475 if (history->data(j)->adcMax() < 0) continue;
476 std::unique_ptr<OFC> ofc = history->ofc(j);
477 if (!ofc || ofc->hasSameRange(lwb, upb)) { cout << "Invalid index bounds!" << endl; return false; }
478 for (int i1 = lwb; i1 <= upb; i1++) {
479 sum(i1) = sum(i1) + history->data(j)->delta(i1);
480 sumN(i1) = sumN(i1) + history->data(j)->delta(i1)/TMath::Power(history->data(j)->adcMax(), 2);
481 for (int i2 = lwb; i2 <= upb; i2++) {
482 sumCN(i1, i2) = sumCN(i1, i2) + ofc->Gamma()(i1, i2)/TMath::Power(history->data(j)->adcMax(), 2);
483 sum2N(i1, i2) = sum2N(i1, i2) + history->data(j)->delta(i1)*history->data(j)->delta(i2)/TMath::Power(history->data(j)->adcMax(),2);
484 }
485 }
486 sumA += 1/TMath::Power(history->data(j)->adcMax(), 2);
487 n++;
488 }
489 }
490
491 if (n > 0) {
492 sumA /= n;
493 }
494 k.ResizeTo(lwb, upb);
495 means.ResizeTo(lwb, upb);
496
497 for (int i1 = lwb; i1 <= upb; i1++) {
498 if (n > 0) {
499 sum(i1) = sum(i1)/n;
500 sumN(i1) = sumN(i1)/n;
501 }
502 means(i1) = sum(i1);
503 }
504
505 for (int i1 = lwb; i1 <= upb; i1++) {
506 for (int i2 = lwb; i2 <= upb; i2++) {
507 if (n != 0) {
508 sumCN(i1, i2) = sumCN(i1, i2)/n;
509 sum2N(i1, i2) = sum2N(i1, i2)/n;
510 }
511 k(i1, i2) = sum2N(i1, i2) - sumN(i1)*sum(i2) - sum(i1)*sumN(i2)
512 + sum(i1)*sum(i2)*sumA - sumCN(i1,i2);
513 k(i1, i2) = (k(i1, i2) >= 0 ? sqrt(k(i1, i2)) : -sqrt(-k(i1, i2)));
514 }
515 }
516 return true;
517}
std::unique_ptr< OFC > ofc(unsigned int i, int lwb=-1, int upb=-1, double time=Definitions::none, bool useCorrs=true) const
Definition History.cxx:201

◆ residualPlots()

bool DigitMonitor::residualPlots ( CaloId calo,
unsigned int layer,
CaloGain::CaloGain gain = CaloGain::LARHIGHGAIN,
bool xip = false,
bool ring = false,
double lo = -0.05,
double hi = 0.05,
const TString & fileName = "residuals" )

Definition at line 222 of file DigitMonitor.cxx.

224{
225 TH1D* h1[5];
226 TH2D* hEtaPhi[5];
227 TString globalTitle = TString(xip ? "Derivative" : "Offset") + " correction";
228 for (unsigned short k = 0; k < 5; k++) {
229 TString title = globalTitle + " for sampling " + Form("%d", k);
230 h1[k] = new TH1D(Form("h%d", k), title, 100, lo, hi);
231 h1[k]->GetXaxis()->SetTitle("correction");
232 hEtaPhi[k] = Geo::etaPhiHist(calo, layer, Form("hEtaPhi%d", k), title);
233 hEtaPhi[k]->SetMinimum(lo);
234 hEtaPhi[k]->SetMaximum(hi);
235 }
236 FilterParams f;
237 f.addCalo(calo);
238 f.addLayer(layer);
239 TH2D* hAll = new TH2D("hAll", globalTitle + " vs. sampling", 5, 0, 5, 100, lo, hi);
240 hAll->GetXaxis()->SetTitle("sampling");
241 hAll->GetYaxis()->SetTitle("correction");
242 for (unsigned int i = 0; i < nChannels(); i++) {
243 if ((i+1) % 10000 == 0) cout << "Cell # " << i+1 << "/" << nChannels() << endl;
244 const History* history = pass(i, f);
245 if (!history || history->nData() == 0) continue;
246 for (unsigned short k = 0; k < 5; k++) {
248 double xi = history->data(0)->xi(k, type, gain, xip);
249 h1[k]->Fill(xi);
250 hEtaPhi[k]->Fill(history->cellInfo()->eta(), history->cellInfo()->phi(), xi);
251 if (Id::matchCalo(calo, HEC) && history->cellInfo()->region() == 1) // For HEC, take care of larger phi size in region 1
252 hEtaPhi[k]->Fill(history->cellInfo()->eta(), history->cellInfo()->phi() - Geo::phiSize(HEC_A, 1, 1), xi);
253 }
254 }
255 for (unsigned int i = 1; i <= 100; i++)
256 for (unsigned short k = 0; k < 5; k++)
257 hAll->SetBinContent(k+1, i, h1[k]->GetBinContent(i));
258 TFile* ff = TFile::Open(fileName + ".root", "RECREATE");
259 for (unsigned short k = 0; k < 5; k++) {
260 h1[k]->Write();
261 hEtaPhi[k]->Write();
262 }
263 hAll->Write();
264 ff->Close();
265 TCanvas* c1 = new TCanvas("c1", Id::str(calo) + " layer " + Form("%d", layer), 1600, 2000);
266 c1->Divide(2,3);
267 for (unsigned short k = 0; k < 5; k++) {
268 c1->cd(k+1);
269 hEtaPhi[k]->Draw("COLZ");
270 }
271 c1->cd(6);
272 hAll->Draw();
273 c1->Print(fileName + ".png");
274 c1->Print(fileName + ".eps");
275 return true;
276}
short region() const
Definition CellInfo.h:59
double xi(short sample, ShapeErrorType shapeErrorType=BestShapeError, CaloGain::CaloGain g=CaloGain::UNKNOWNGAIN, bool xip=false) const
Definition Data.cxx:462
static double phiSize(CaloId calo, short layer, short region, short iPhi=-1)
Definition Geometry.cxx:344
static bool matchCalo(CaloId id, CaloId idSpec)
Definition CaloId.cxx:188

◆ residualPlotsGainComp()

bool DigitMonitor::residualPlotsGainComp ( CaloId calo,
unsigned int layer,
bool ring = false,
bool xip = false,
double lo = -0.05,
double hi = 0.05,
const TString & fileName = "residuals" )

Definition at line 350 of file DigitMonitor.cxx.

352{
353 unsigned int nBins = 100;
354 TH1D* h[5][5];
355 TString globalTitle = TString(xip ? "Derivative" : "Offset") + " correction";
356 for (unsigned short l = 0; l < 5; l++)
357 for (unsigned short k = 0; k < 5; k++)
358 h[l][k] = new TH1D(Form("h%d%d", l, k), "", nBins, l < 2 ? -15 : lo, l < 2 ? 15 : hi);
359 FilterParams f;
360 f.addCalo(calo);
361 f.addLayer(layer);
362 TH2D* hAll[5];
363 hAll[0] = new TH2D("h0All", "#xi_{high}/#delta#xi vs. sampling", 5, 0, 5, nBins, -15, 15);
364 hAll[1] = new TH2D("hDAll", "(#xi_{high} - #xi_{low})/#delta#xi vs. sampling", 5, 0, 5, nBins, -15, 15);
365 hAll[2] = new TH2D("hEAll", globalTitle + " higher-gain value vs. sampling", 5, 0, 5, nBins, 0, hi);
366 hAll[3] = new TH2D("hRAll", globalTitle + " lower-gain value vs. sampling", 5, 0, 5, nBins, lo, hi);
367 hAll[4] = new TH2D("hCAll", globalTitle + " higher-gain error vs. sampling", 5, 0, 5, nBins, lo, hi);
368 TH2D* hCor = new TH2D("hCor", globalTitle + " lower-gain vs. higher-gain values", nBins, lo, hi, nBins, lo, hi);
369 hCor->GetXaxis()->SetTitle("#xi_{high}");
370 hCor->GetYaxis()->SetTitle("#xi_{low}");
371 for (unsigned short l = 0; l < 4; l++) {
372 hAll[l]->GetXaxis()->SetTitle("sampling");
373 hAll[l]->GetYaxis()->SetTitle("significance");
374 }
375
378
379 for (unsigned int i = 0; i < nChannels(); i++) {
380 if ((i+1) % 10000 == 0) cout << "Cell # " << i+1 << "/" << nChannels() << endl;
381 const History* history = pass(i, f);
382 if (!history || history->nData() == 0) continue;
383 for (unsigned short k = 0; k < 5; k++) {
384 std::unique_ptr<const ShapeErrorData> hgSED = history->shapeErrorData(hiGain, ring ? RingShapeError : CellShapeError);
385 std::unique_ptr<const ShapeErrorData> lgSED = history->shapeErrorData(loGain, ring ? RingShapeError : CellShapeError);
386 if (!hgSED || !lgSED) {
387 continue;
388 }
389 double hgVal = (xip ? hgSED->xi()(k) : hgSED->xip()(k));
390 double lgVal = (xip ? lgSED->xi()(k) : lgSED->xip()(k));
391 double hgErr = TMath::Sqrt(xip ? hgSED->xiErr()(k,k) : hgSED->xipErr()(k,k));
392 double error = TMath::Sqrt(xip ? hgSED->xiErr()(k,k) + lgSED->xiErr()(k,k) : hgSED->xipErr()(k,k) + lgSED->xipErr()(k,k));
393 h[0][k]->Fill(hgVal/hgErr);
394 h[1][k]->Fill((hgVal - lgVal)/error);
395 h[2][k]->Fill(hgVal);
396 h[3][k]->Fill(lgVal);
397 h[4][k]->Fill(hgErr);
398 hCor->Fill(hgVal, lgVal);
399 }
400 }
401 for (unsigned int i = 1; i <= nBins; i++)
402 for (unsigned short l = 0; l < 5; l++)
403 for (unsigned short k = 0; k < 5; k++)
404 hAll[l]->SetBinContent(k+1, i, h[l][k]->GetBinContent(i));
405 TFile* ff = TFile::Open(fileName + ".root", "RECREATE");
406 for (unsigned short l = 0; l < 5; l++) {
407 for (unsigned short k = 0; k < 5; k++)
408 h[l][k]->Write();
409 hAll[l]->Write();
410 }
411 ff->Close();
412 TCanvas* c1 = new TCanvas("c1", Id::str(calo) + " layer " + Form("%d", layer), 1600, 500);
413 c1->Divide(3,1);
414 c1->cd(1); hCor->Draw();
415 TLatex l; l.SetNDC();
416 TString corrStr = Form("Correlation : %.1f%%", 100*hCor->GetCorrelationFactor());
417 l.DrawLatex(0.2, 0.8, corrStr);
418 c1->cd(2); hAll[0]->Draw("COL");
419 c1->cd(3); hAll[1]->Draw("COL");
420 c1->Print(fileName + ".png");
421 c1->Print(fileName + ".eps");
422 return true;
423}
std::unique_ptr< const ShapeErrorData > shapeErrorData(CaloGain::CaloGain gain, ShapeErrorType shapeErrorType=BestShapeError, const Residual *res=0) const
Definition History.cxx:293
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ LARHIGHGAIN
Definition CaloGain.h:18
l
Printing final latex table to .tex output file.

◆ residualPlotsRingComp()

bool DigitMonitor::residualPlotsRingComp ( CaloId calo,
unsigned int layer,
CaloGain::CaloGain gain = CaloGain::LARHIGHGAIN,
bool xip = false,
double lo = -0.05,
double hi = 0.05,
const TString & fileName = "residuals" )

Definition at line 279 of file DigitMonitor.cxx.

281{
282 unsigned int nBins = 100;
283 TH1D* h[5][5];
284 TString globalTitle = TString(xip ? "Derivative" : "Offset") + " correction";
285 for (unsigned short l = 0; l < 5; l++)
286 for (unsigned short k = 0; k < 5; k++)
287 h[l][k] = new TH1D(Form("h%d%d", l, k), "", nBins, l < 2 ? -15 : lo, l < 2 ? 15 : hi);
288 FilterParams f;
289 f.addCalo(calo);
290 f.addLayer(layer);
291 TH2D* hAll[5];
292 hAll[0] = new TH2D("h0All", "#xi_{cell}/#delta#xi vs. sampling", 5, 0, 5, nBins, -15, 15);
293 hAll[1] = new TH2D("hDAll", "(#xi_{cell} - #xi_{ring})/#delta#xi vs. sampling", 5, 0, 5, nBins, -15, 15);
294 hAll[2] = new TH2D("hEAll", globalTitle + " per-cell value vs. sampling", 5, 0, 5, nBins, 0, hi);
295 hAll[3] = new TH2D("hRAll", globalTitle + " per-ring value vs. sampling", 5, 0, 5, nBins, lo, hi);
296 hAll[4] = new TH2D("hCAll", globalTitle + " per-cell error vs. sampling", 5, 0, 5, nBins, lo, hi);
297 TH2D* hCor = new TH2D("hCor", globalTitle + " per-ring vs. per-cell values", nBins, lo, hi, nBins, lo, hi);
298 hCor->GetXaxis()->SetTitle("#xi_{cell}");
299 hCor->GetYaxis()->SetTitle("#xi_{ring}");
300 for (unsigned short l = 0; l < 4; l++) {
301 hAll[l]->GetXaxis()->SetTitle("sampling");
302 hAll[l]->GetYaxis()->SetTitle("significance");
303 }
304 for (unsigned int i = 0; i < nChannels(); i++) {
305 if ((i+1) % 10000 == 0) cout << "Cell # " << i+1 << "/" << nChannels() << endl;
306 const History* history = pass(i, f);
307 if (!history || history->nData() == 0) continue;
308 for (unsigned short k = 0; k < 5; k++) {
309 std::unique_ptr<const ShapeErrorData> cellSED = history->shapeErrorData(gain, CellShapeError);
310 std::unique_ptr<const ShapeErrorData> ringSED = history->shapeErrorData(gain, RingShapeError);
311 if (!cellSED || !ringSED) {
312 continue;
313 }
314 double cellVal = (xip ? cellSED->xi()(k) : cellSED->xip()(k));
315 double ringVal = (xip ? ringSED->xi()(k) : ringSED->xip()(k));
316 double cellErr = TMath::Sqrt(xip ? cellSED->xiErr()(k,k) : cellSED->xipErr()(k,k));
317 h[0][k]->Fill(cellVal/cellErr);
318 h[1][k]->Fill((cellVal - ringVal)/cellErr);
319 h[2][k]->Fill(cellVal);
320 h[3][k]->Fill(ringVal);
321 h[4][k]->Fill(cellErr);
322 hCor->Fill(cellVal, ringVal);
323 }
324 }
325 for (unsigned int i = 1; i <= nBins; i++)
326 for (unsigned short l = 0; l < 5; l++)
327 for (unsigned short k = 0; k < 5; k++)
328 hAll[l]->SetBinContent(k+1, i, h[l][k]->GetBinContent(i));
329 TFile* ff = TFile::Open(fileName + ".root", "RECREATE");
330 for (unsigned short l = 0; l < 5; l++) {
331 for (unsigned short k = 0; k < 5; k++)
332 h[l][k]->Write();
333 hAll[l]->Write();
334 }
335 ff->Close();
336 TCanvas* c1 = new TCanvas("c1", Id::str(calo) + " layer " + Form("%d", layer), 1600, 500);
337 c1->Divide(3,1);
338 c1->cd(1); hCor->Draw();
339 TLatex l; l.SetNDC();
340 TString corrStr = Form("Correlation : %.1f%%", 100*hCor->GetCorrelationFactor());
341 l.DrawLatex(0.2, 0.8, corrStr);
342 c1->cd(2); hAll[0]->Draw("COL");
343 c1->cd(3); hAll[1]->Draw("COL");
344 c1->Print(fileName + ".png");
345 c1->Print(fileName + ".eps");
346 return true;
347}

◆ shapeErrorDist()

TH1D * DigitMonitor::shapeErrorDist ( unsigned int k,
const TString & name,
int nBins,
double rMin,
double rMax,
double mean = 0 ) const

Definition at line 426 of file DigitMonitor.cxx.

427{
428 TH1D* h = new TH1D(name, "Shape error", nBins, rMin, rMax);
429 h->GetXaxis()->SetTitle("#epsilon^{2}");
430
431 for (unsigned int i = 0; i < nChannels(); i++) {
432 const History* history = cellHistory(i);
433 if (!history) continue;
434 for (unsigned int j = 0; j < history->nData(); j++) {
435 std::unique_ptr<OFC> ofc = history->ofc(j);
436 double delta = history->data(j)->delta(k) - mean;
437 double adcMax = history->data(j)->adcMax();
438 h->Fill((delta*delta - ofc->Gamma()(k, k))/(adcMax*adcMax));
439 }
440 }
441 cout << sqrt(h->GetMean())*100 << " +/- " << sqrt(h->GetMeanError())*100 << endl;
442 return h;
443}
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")

◆ statParams()

bool MonitorBase::statParams ( const std::vector< DataFuncSet > & funcs,
const std::vector< DataFuncArgs > & args,
TVectorD & mean,
TVectorD & meanErr,
TMatrixD & covMatrix,
TMatrixD & covMatrixErr,
const FilterParams & f = FilterParams() ) const
inherited

Definition at line 375 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

379{
380 Averager avg(funcs.size());
381
382 for (unsigned int i = 0; i < m_interface->nChannels(); i++) {
383 if ((i+1) % printPeriodicity == 0) cout << "Cell # " << i+1 << "/" << m_interface->nChannels() << endl;
384 const History* history = pass(i, f);
385 if (!history) continue;
386 for (unsigned int j = 0; j < history->nData(); j++) {
387 if (!f.passEvent(*history->data(j))) continue;
388 TVectorD vals(funcs.size());
389 for (unsigned int k = 0; k < funcs.size(); k++)
390 vals(k) = funcs[k].val(*history->data(j), args[k]);
391 avg.fill(vals);
392 }
393 }
394
395 mean = avg.means();
396 meanErr = avg.meanErrors();
397 covMatrix = avg.covarianceMatrix();
398 covMatrixErr = avg.covarianceMatrixErrors();
399
400 return true;
401}
avg(a, b)
Definition Recovery.py:79

◆ str()

TString MonitorBase::str ( CombinationType comb)
staticinherited

Definition at line 56 of file LArCalorimeter/LArSamplesMon/src/MonitorBase.cxx.

57{
58 switch (comb) {
59 case AverageValue : return "average";
60 case MaxValue : return "max value";
61 case MinValue : return "min value";
62 case TotalValue : return "total value";
63 case RMSValue : return "RMS";
64 }
65 return "";
66}

◆ timeDist()

TH1D * DigitMonitor::timeDist ( const TString & name,
int nBins,
double tMin = -25,
double tMax = 25 ) const

Definition at line 44 of file DigitMonitor.cxx.

45{ return dist(&Data::_ofcTime, DataFuncArgs(), name, nBins, tMin, tMax, "Time distribution", "Time (ns)"); }

Member Data Documentation

◆ m_cellCache

std::unique_ptr<const History> LArSamples::AbsLArCells::m_cellCache
mutableprivateinherited

Definition at line 55 of file AbsLArCells.h.

◆ m_cellInfoCache

std::vector<std::unique_ptr<CellInfo> > LArSamples::AbsLArCells::m_cellInfoCache
mutableprivateinherited

Definition at line 56 of file AbsLArCells.h.

◆ m_interface

const Interface* LArSamples::MonitorBase::m_interface
privateinherited

◆ m_pos

unsigned int LArSamples::AbsLArCells::m_pos
mutableprivateinherited

Definition at line 54 of file AbsLArCells.h.

◆ printPeriodicity

const int LArSamples::MonitorBase::printPeriodicity = 10000
staticinherited

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