Commit de4a357f authored by Jens Kroeger's avatar Jens Kroeger
Browse files

AnalysisTimingATLASpix: fix seg fault when not providing row correction file -...

AnalysisTimingATLASpix: fix seg fault when not providing row correction file - bug in if conditions introduced in MR \!281
parent 56acbb4b
Pipeline #1547687 passed with stages
in 21 minutes and 1 second
...@@ -448,7 +448,9 @@ void AnalysisTimingATLASpix::initialise() { ...@@ -448,7 +448,9 @@ void AnalysisTimingATLASpix::initialise() {
gTimeCorrelationVsRow->SetTitle("gTimeCorrelationVsRow"); gTimeCorrelationVsRow->SetTitle("gTimeCorrelationVsRow");
gTimeCorrelationVsRow->GetXaxis()->SetTitle("row"); gTimeCorrelationVsRow->GetXaxis()->SetTitle("row");
gTimeCorrelationVsRow->GetYaxis()->SetTitle("time correlation peak [ns]"); gTimeCorrelationVsRow->GetYaxis()->SetTitle("time correlation peak [ns]");
}
if(m_pointwise_correction_row) {
int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY(); int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY();
gTimeCorrelationVsTot_rowCorr = new TGraphErrors(nBinsToT); gTimeCorrelationVsTot_rowCorr = new TGraphErrors(nBinsToT);
gTimeCorrelationVsTot_rowCorr->SetName("gTimeCorrelationVsTot_rowCorr"); gTimeCorrelationVsTot_rowCorr->SetName("gTimeCorrelationVsTot_rowCorr");
...@@ -800,129 +802,135 @@ void AnalysisTimingATLASpix::finalise() { ...@@ -800,129 +802,135 @@ void AnalysisTimingATLASpix::finalise() {
} // for(iBin) } // for(iBin)
/// TIME WALK CORRECTION on top of ROW CORRECTION: /// /// TIME WALK CORRECTION on top of ROW CORRECTION: ///
fitOption = "q"; // set to "" if you want terminal output if(m_pointwise_correction_row) {
binMax = 0; fitOption = "q"; // set to "" if you want terminal output
timePeak = 0.; binMax = 0;
timePeakErr = 0.; timePeak = 0.;
int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY(); timePeakErr = 0.;
LOG(DEBUG) << "nBinsToT = " << nBinsToT; int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY();
LOG(DEBUG) << "nBinsToT = " << nBinsToT;
for(int iBin = 0; iBin < nBinsToT; iBin++) {
TH1D* hTemp = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1); for(int iBin = 0; iBin < nBinsToT; iBin++) {
TH1D* hTemp = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1);
// if(hTemp->GetEntries() < 500) { // too few entries to fit
if(hTemp->GetEntries() < 1000) { // too few entries to fit // if(hTemp->GetEntries() < 500) { // too few entries to fit
timePeak = hTemp->GetMean(); if(hTemp->GetEntries() < 1000) { // too few entries to fit
timePeakErr = hTemp->GetStdDev(); timePeak = hTemp->GetMean();
delete hTemp; timePeakErr = hTemp->GetStdDev();
} else { delete hTemp;
binMax = hTemp->GetMaximumBin(); } else {
timePeak = hTemp->GetXaxis()->GetBinCenter(binMax); binMax = hTemp->GetMaximumBin();
timePeak = hTemp->GetXaxis()->GetBinCenter(binMax);
// fitting a Gaus for a good estimate of the peak positon:
// initial parameters are hardcoded at the moment! // fitting a Gaus for a good estimate of the peak positon:
TF1* fPeak = new TF1("fPeak", "gaus"); // initial parameters are hardcoded at the moment!
fPeak->SetParameters(1, 100, 45); TF1* fPeak = new TF1("fPeak", "gaus");
double timeInt = 50; fPeak->SetParameters(1, 100, 45);
hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt); double timeInt = 50;
fPeak = hTemp->GetFunction("fPeak"); hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
timePeak = fPeak->GetParameter(1); fPeak = hTemp->GetFunction("fPeak");
timePeakErr = fPeak->GetParError(1); timePeak = fPeak->GetParameter(1);
timePeakErr = fPeak->GetParError(1);
delete fPeak;
delete hTemp; delete fPeak;
} delete hTemp;
gTimeCorrelationVsTot_rowCorr->SetPoint(iBin, iBin, timePeak); }
gTimeCorrelationVsTot_rowCorr->SetPointError(iBin, 0, timePeakErr); gTimeCorrelationVsTot_rowCorr->SetPoint(iBin, iBin, timePeak);
gTimeCorrelationVsTot_rowCorr->SetPointError(iBin, 0, timePeakErr);
} // for(iBin)
} // for(iBin)
// SAME FOR SINGLE-PIXEL CLUSTERS:
nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_1px->GetNbinsY(); // SAME FOR SINGLE-PIXEL CLUSTERS:
for(int iBin = 0; iBin < nBinsToT; iBin++) { nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_1px->GetNbinsY();
TH1D* hTemp = hTrackCorrelationTimeVsTot_rowCorr_1px->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1); for(int iBin = 0; iBin < nBinsToT; iBin++) {
TH1D* hTemp =
// if(hTemp->GetEntries() < 500) { // too few entries to fit hTrackCorrelationTimeVsTot_rowCorr_1px->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1);
if(hTemp->GetEntries() < 1000) { // too few entries to fit
delete hTemp; // if(hTemp->GetEntries() < 500) { // too few entries to fit
timePeak = 0; if(hTemp->GetEntries() < 1000) { // too few entries to fit
timePeakErr = 0; delete hTemp;
continue; timePeak = 0;
} else { timePeakErr = 0;
binMax = hTemp->GetMaximumBin(); continue;
timePeak = hTemp->GetXaxis()->GetBinCenter(binMax); } else {
binMax = hTemp->GetMaximumBin();
// fitting a Gaus for a good estimate of the peak positon: timePeak = hTemp->GetXaxis()->GetBinCenter(binMax);
// initial parameters are hardcoded at the moment!
TF1* fPeak = new TF1("fPeak", "gaus"); // fitting a Gaus for a good estimate of the peak positon:
fPeak->SetParameters(1, 100, 45); // initial parameters are hardcoded at the moment!
double timeInt = 50; TF1* fPeak = new TF1("fPeak", "gaus");
hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt); fPeak->SetParameters(1, 100, 45);
fPeak = hTemp->GetFunction("fPeak"); double timeInt = 50;
timePeak = fPeak->GetParameter(1); hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
timePeakErr = fPeak->GetParError(1); fPeak = hTemp->GetFunction("fPeak");
timePeak = fPeak->GetParameter(1);
delete fPeak; timePeakErr = fPeak->GetParError(1);
delete hTemp;
} delete fPeak;
gTimeCorrelationVsTot_rowCorr_1px->SetPoint(iBin, iBin, timePeak); delete hTemp;
gTimeCorrelationVsTot_rowCorr_1px->SetPointError(iBin, 0, timePeakErr); }
} // for(iBin) gTimeCorrelationVsTot_rowCorr_1px->SetPoint(iBin, iBin, timePeak);
gTimeCorrelationVsTot_rowCorr_1px->SetPointError(iBin, 0, timePeakErr);
// SAME FOR MULTI-PIXEL CLUSTERS: } // for(iBin)
nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_npx->GetNbinsY();
for(int iBin = 0; iBin < nBinsToT; iBin++) { // SAME FOR MULTI-PIXEL CLUSTERS:
TH1D* hTemp = hTrackCorrelationTimeVsTot_rowCorr_npx->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1); nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_npx->GetNbinsY();
for(int iBin = 0; iBin < nBinsToT; iBin++) {
// if(hTemp->GetEntries() < 500) { // too few entries to fit TH1D* hTemp =
if(hTemp->GetEntries() < 1000) { // too few entries to fit hTrackCorrelationTimeVsTot_rowCorr_npx->ProjectionX("timeCorrelationInOneTotBin", iBin, iBin + 1);
delete hTemp;
timePeak = 0; // if(hTemp->GetEntries() < 500) { // too few entries to fit
timePeakErr = 0; if(hTemp->GetEntries() < 1000) { // too few entries to fit
continue; delete hTemp;
} else { timePeak = 0;
binMax = hTemp->GetMaximumBin(); timePeakErr = 0;
timePeak = hTemp->GetXaxis()->GetBinCenter(binMax); continue;
} else {
// fitting a Gaus for a good estimate of the peak positon: binMax = hTemp->GetMaximumBin();
// initial parameters are hardcoded at the moment! timePeak = hTemp->GetXaxis()->GetBinCenter(binMax);
TF1* fPeak = new TF1("fPeak", "gaus");
fPeak->SetParameters(1, 100, 45); // fitting a Gaus for a good estimate of the peak positon:
double timeInt = 50; // initial parameters are hardcoded at the moment!
hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt); TF1* fPeak = new TF1("fPeak", "gaus");
fPeak = hTemp->GetFunction("fPeak"); fPeak->SetParameters(1, 100, 45);
timePeak = fPeak->GetParameter(1); double timeInt = 50;
timePeakErr = fPeak->GetParError(1); hTemp->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
fPeak = hTemp->GetFunction("fPeak");
delete fPeak; timePeak = fPeak->GetParameter(1);
delete hTemp; timePeakErr = fPeak->GetParError(1);
}
gTimeCorrelationVsTot_rowCorr_npx->SetPoint(iBin, iBin, timePeak); delete fPeak;
gTimeCorrelationVsTot_rowCorr_npx->SetPointError(iBin, 0, timePeakErr); delete hTemp;
} // for(iBin) }
gTimeCorrelationVsTot_rowCorr_npx->SetPoint(iBin, iBin, timePeak);
/// END TIME WALK CORRECTION /// gTimeCorrelationVsTot_rowCorr_npx->SetPointError(iBin, 0, timePeakErr);
} // for(iBin)
// Example Slice to investigate quality of Gaussian fit:
hTrackCorrelationTime_example = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX( /// END TIME WALK CORRECTION ///
("hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample)).c_str(),
m_totBinExample, // Example Slice to investigate quality of Gaussian fit:
m_totBinExample + 1); hTrackCorrelationTime_example = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX(
("hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample)).c_str(),
binMax = hTrackCorrelationTime_example->GetMaximumBin(); m_totBinExample,
timePeak = hTrackCorrelationTime_example->GetXaxis()->GetBinCenter(binMax); m_totBinExample + 1);
TF1* fPeak = new TF1("fPeak", "gaus"); binMax = hTrackCorrelationTime_example->GetMaximumBin();
fPeak->SetParameters(1, 100, 45); timePeak = hTrackCorrelationTime_example->GetXaxis()->GetBinCenter(binMax);
double timeInt = 50;
fitOption = "q"; // set to "q" = quiet for suppressed terminial output TF1* fPeak = new TF1("fPeak", "gaus");
hTrackCorrelationTime_example->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt); fPeak->SetParameters(1, 100, 45);
delete fPeak; double timeInt = 50;
fitOption = "q"; // set to "q" = quiet for suppressed terminial output
hTrackCorrelationTime_example->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
delete fPeak;
}
gTimeCorrelationVsRow->Write(); gTimeCorrelationVsRow->Write();
gTimeCorrelationVsTot_rowCorr->Write(); if(m_pointwise_correction_row) {
gTimeCorrelationVsTot_rowCorr_1px->Write(); gTimeCorrelationVsTot_rowCorr->Write();
gTimeCorrelationVsTot_rowCorr_npx->Write(); gTimeCorrelationVsTot_rowCorr_1px->Write();
gTimeCorrelationVsTot_rowCorr_npx->Write();
}
} // if(m_calcCorrections) } // if(m_calcCorrections)
LOG(INFO) << "matched/total tracks: " << matched_tracks << "/" << total_tracks; LOG(INFO) << "matched/total tracks: " << matched_tracks << "/" << total_tracks;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment