modified: .vscode/c_cpp_properties.json made changes to include the laptop
modified: GainMatchSX3.C included flags to allow interactive mode and verbose fit modified: GainMatchSX3Front.C included flags to allow interactive mode and verbose fit
This commit is contained in:
parent
3d0d176f5a
commit
b44ffd7fdf
12
.vscode/c_cpp_properties.json
vendored
12
.vscode/c_cpp_properties.json
vendored
|
@ -66,6 +66,18 @@
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
"cppStandard": "gnu++17",
|
"cppStandard": "gnu++17",
|
||||||
"intelliSenseMode": "linux-gcc-x64"
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "VigneshROG",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/home/vsitaraman/root/include/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "gnu++17",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
|
|
@ -38,6 +38,11 @@ const int MAX_BK = 4;
|
||||||
double frontGain[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{0}}}};
|
double frontGain[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{0}}}};
|
||||||
bool frontGainValid[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{false}}}};
|
bool frontGainValid[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{false}}}};
|
||||||
|
|
||||||
|
// ==== Configuration Flags ====
|
||||||
|
const bool interactiveMode = false; // If true: show canvas + wait for user
|
||||||
|
const bool verboseFit = true; // If true: print fit summary and chi²
|
||||||
|
const bool drawCanvases = true; // If false: canvases won't be drawn at all
|
||||||
|
|
||||||
void GainMatchSX3::Begin(TTree * /*tree*/)
|
void GainMatchSX3::Begin(TTree * /*tree*/)
|
||||||
{
|
{
|
||||||
TString option = GetOption();
|
TString option = GetOption();
|
||||||
|
@ -240,7 +245,7 @@ Bool_t GainMatchSX3::Process(Long64_t entry)
|
||||||
|
|
||||||
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
||||||
|
|
||||||
if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk))// && cut1 && cut1->IsInside(sx3EUp / sx3EBk, sx3EDn / sx3EBk))
|
// if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk))// && cut1 && cut1->IsInside(sx3EUp / sx3EBk, sx3EDn / sx3EBk))
|
||||||
{
|
{
|
||||||
// Accumulate data for gain matching
|
// Accumulate data for gain matching
|
||||||
// if (frontGainValid[sx3.id[i]][sx3ChBk][sx3ChUp][sx3ChDn])
|
// if (frontGainValid[sx3.id[i]][sx3ChBk][sx3ChUp][sx3ChDn])
|
||||||
|
@ -337,17 +342,20 @@ void GainMatchSX3::Terminate()
|
||||||
TGraphErrors g(xVals.size(), xVals.data(), yVals.data(), exVals.data(), eyVals.data());
|
TGraphErrors g(xVals.size(), xVals.data(), yVals.data(), exVals.data(), eyVals.data());
|
||||||
|
|
||||||
TF1 f("f", "[0]*x", 0, 16000);
|
TF1 f("f", "[0]*x", 0, 16000);
|
||||||
// f.SetParameter(0, 1.0); // Initial guess
|
f.SetParameter(0, 1.0); // Initial guess
|
||||||
|
|
||||||
// Interactive canvas
|
if (drawCanvases)
|
||||||
|
{
|
||||||
TCanvas *c = new TCanvas(Form("c_%d_%d_%d_%d", id, bk, u, d), "Fit", 800, 600);
|
TCanvas *c = new TCanvas(Form("c_%d_%d_%d_%d", id, bk, u, d), "Fit", 800, 600);
|
||||||
g.SetTitle(Form("Detector %d: U%d D%d B%d", id, u, d, bk));
|
g.SetTitle(Form("Detector %d: U%d D%d B%d", id, u, d, bk));
|
||||||
g.SetMarkerStyle(20);
|
g.SetMarkerStyle(20);
|
||||||
g.SetMarkerColor(kBlue);
|
g.SetMarkerColor(kBlue);
|
||||||
g.Draw("AP");
|
g.Draw("AP");
|
||||||
|
|
||||||
g.Fit(&f, "Q"); // Quiet fit
|
g.Fit(&f, interactiveMode ? "Q" : "QNR"); // 'R' avoids refit, 'N' skips drawing
|
||||||
|
|
||||||
|
if (verboseFit)
|
||||||
|
{
|
||||||
double chi2 = f.GetChisquare();
|
double chi2 = f.GetChisquare();
|
||||||
int ndf = f.GetNDF();
|
int ndf = f.GetNDF();
|
||||||
double reducedChi2 = (ndf != 0) ? chi2 / ndf : -1;
|
double reducedChi2 = (ndf != 0) ? chi2 / ndf : -1;
|
||||||
|
@ -355,15 +363,21 @@ void GainMatchSX3::Terminate()
|
||||||
std::cout << Form("Det%d U%d D%d B%d → Gain: %.4f | χ²/ndf = %.2f/%d = %.2f",
|
std::cout << Form("Det%d U%d D%d B%d → Gain: %.4f | χ²/ndf = %.2f/%d = %.2f",
|
||||||
id, u, d, bk, f.GetParameter(0), chi2, ndf, reducedChi2)
|
id, u, d, bk, f.GetParameter(0), chi2, ndf, reducedChi2)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Show canvas and wait for user to continue
|
if (interactiveMode)
|
||||||
|
{
|
||||||
c->Update();
|
c->Update();
|
||||||
gPad->WaitPrimitive();
|
gPad->WaitPrimitive();
|
||||||
|
}
|
||||||
if (TMath::Abs(f.GetParameter(0) - 1) > 3.0)
|
else
|
||||||
{
|
{
|
||||||
delete c; // Clean up unused canvas
|
c->Close(); // Optionally avoid clutter in batch
|
||||||
continue;
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.Fit(&f, "QNR");
|
||||||
}
|
}
|
||||||
|
|
||||||
gainArray[id][bk][u][d] = f.GetParameter(0);
|
gainArray[id][bk][u][d] = f.GetParameter(0);
|
||||||
|
|
|
@ -42,6 +42,11 @@ bool backGainValid[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{false}}}};
|
||||||
double frontGain[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{0}}}};
|
double frontGain[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{0}}}};
|
||||||
bool frontGainValid[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{false}}}};
|
bool frontGainValid[MAX_DET][MAX_BK][MAX_UP][MAX_DOWN] = {{{{false}}}};
|
||||||
|
|
||||||
|
// ==== Configuration Flags ====
|
||||||
|
const bool interactiveMode = false; // If true: show canvas + wait for user
|
||||||
|
const bool verboseFit = true; // If true: print fit summary and chi²
|
||||||
|
const bool drawCanvases = true; // If false: canvases won't be drawn at all
|
||||||
|
|
||||||
void GainMatchSX3Front::Begin(TTree * /*tree*/)
|
void GainMatchSX3Front::Begin(TTree * /*tree*/)
|
||||||
{
|
{
|
||||||
TString option = GetOption();
|
TString option = GetOption();
|
||||||
|
@ -91,7 +96,7 @@ void GainMatchSX3Front::Begin(TTree * /*tree*/)
|
||||||
while (infile >> id >> bk >> u >> d >> gain)
|
while (infile >> id >> bk >> u >> d >> gain)
|
||||||
{
|
{
|
||||||
backGain[id][bk][u][d] = gain;
|
backGain[id][bk][u][d] = gain;
|
||||||
if(backGain[id][bk][u][d] > 0)
|
if (backGain[id][bk][u][d] > 0)
|
||||||
backGainValid[id][bk][u][d] = true;
|
backGainValid[id][bk][u][d] = true;
|
||||||
else
|
else
|
||||||
backGainValid[id][bk][u][d] = false;
|
backGainValid[id][bk][u][d] = false;
|
||||||
|
@ -199,7 +204,7 @@ Bool_t GainMatchSX3Front::Process(Long64_t entry)
|
||||||
|
|
||||||
for (int i = 0; i < sx3.multi; i++)
|
for (int i = 0; i < sx3.multi; i++)
|
||||||
{
|
{
|
||||||
if ( sx3.e[i] > 100)// && sx3.id[i] == 4)
|
if (sx3.e[i] > 100) // && sx3.id[i] == 4)
|
||||||
{
|
{
|
||||||
// back gain correction
|
// back gain correction
|
||||||
|
|
||||||
|
@ -223,8 +228,7 @@ Bool_t GainMatchSX3Front::Process(Long64_t entry)
|
||||||
|
|
||||||
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
||||||
|
|
||||||
if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk)
|
if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk) && cut1 && cut1->IsInside(sx3EUp / sx3EBk, sx3EDn / sx3EBk))
|
||||||
&& cut1 && cut1->IsInside(sx3EUp / sx3EBk, sx3EDn / sx3EBk))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (backGainValid[sx3.id[i]][sx3ChBk][sx3ChUp][sx3ChDn])
|
if (backGainValid[sx3.id[i]][sx3ChBk][sx3ChUp][sx3ChDn])
|
||||||
|
@ -272,7 +276,7 @@ void GainMatchSX3Front::Terminate()
|
||||||
{
|
{
|
||||||
double eBkCorr, eUp, eDn;
|
double eBkCorr, eUp, eDn;
|
||||||
std::tie(eBkCorr, eUp, eDn) = pr;
|
std::tie(eBkCorr, eUp, eDn) = pr;
|
||||||
if( (eBkCorr < 100) || (eUp <100) || (eDn < 100))
|
if ((eBkCorr < 100) || (eUp < 100) || (eDn < 100))
|
||||||
continue; // Skip if any energy is zero
|
continue; // Skip if any energy is zero
|
||||||
uE.push_back(eUp / eBkCorr);
|
uE.push_back(eUp / eBkCorr);
|
||||||
dE.push_back(eDn / eBkCorr);
|
dE.push_back(eDn / eBkCorr);
|
||||||
|
@ -280,7 +284,7 @@ void GainMatchSX3Front::Terminate()
|
||||||
corrBkE.push_back(eBkCorr);
|
corrBkE.push_back(eBkCorr);
|
||||||
hUvD->Fill(eUp / eBkCorr, eDn / eBkCorr);
|
hUvD->Fill(eUp / eBkCorr, eDn / eBkCorr);
|
||||||
}
|
}
|
||||||
if( uE.size() < 5 || dE.size() < 5 || corrBkE.size() < 5)
|
if (uE.size() < 5 || dE.size() < 5 || corrBkE.size() < 5)
|
||||||
continue; // Ensure we have enough points for fitting
|
continue; // Ensure we have enough points for fitting
|
||||||
// TGraph g(udE.size(), udE.data(), corrBkE.data());
|
// TGraph g(udE.size(), udE.data(), corrBkE.data());
|
||||||
|
|
||||||
|
@ -308,17 +312,20 @@ void GainMatchSX3Front::Terminate()
|
||||||
TGraphErrors g(xVals.size(), xVals.data(), yVals.data(), exVals.data(), eyVals.data());
|
TGraphErrors g(xVals.size(), xVals.data(), yVals.data(), exVals.data(), eyVals.data());
|
||||||
|
|
||||||
TF1 f("f", "[0]*x", 0, 16000);
|
TF1 f("f", "[0]*x", 0, 16000);
|
||||||
// f.SetParameter(0, 1.0); // Initial guess
|
f.SetParameter(0, 1.0); // Initial guess
|
||||||
|
|
||||||
// Interactive canvas
|
if (drawCanvases)
|
||||||
|
{
|
||||||
TCanvas *c = new TCanvas(Form("c_%d_%d_%d_%d", id, bk, u, d), "Fit", 800, 600);
|
TCanvas *c = new TCanvas(Form("c_%d_%d_%d_%d", id, bk, u, d), "Fit", 800, 600);
|
||||||
g.SetTitle(Form("Detector %d: U%d D%d B%d", id, u, d, bk));
|
g.SetTitle(Form("Detector %d: U%d D%d B%d", id, u, d, bk));
|
||||||
g.SetMarkerStyle(20);
|
g.SetMarkerStyle(20);
|
||||||
g.SetMarkerColor(kBlue);
|
g.SetMarkerColor(kBlue);
|
||||||
g.Draw("AP");
|
g.Draw("AP");
|
||||||
|
|
||||||
g.Fit(&f, "Q"); // Quiet fit
|
g.Fit(&f, interactiveMode ? "Q" : "QNR"); // 'R' avoids refit, 'N' skips drawing
|
||||||
|
|
||||||
|
if (verboseFit)
|
||||||
|
{
|
||||||
double chi2 = f.GetChisquare();
|
double chi2 = f.GetChisquare();
|
||||||
int ndf = f.GetNDF();
|
int ndf = f.GetNDF();
|
||||||
double reducedChi2 = (ndf != 0) ? chi2 / ndf : -1;
|
double reducedChi2 = (ndf != 0) ? chi2 / ndf : -1;
|
||||||
|
@ -326,11 +333,22 @@ void GainMatchSX3Front::Terminate()
|
||||||
std::cout << Form("Det%d U%d D%d B%d → Gain: %.4f | χ²/ndf = %.2f/%d = %.2f",
|
std::cout << Form("Det%d U%d D%d B%d → Gain: %.4f | χ²/ndf = %.2f/%d = %.2f",
|
||||||
id, u, d, bk, f.GetParameter(0), chi2, ndf, reducedChi2)
|
id, u, d, bk, f.GetParameter(0), chi2, ndf, reducedChi2)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Show canvas and wait for user to continue
|
if (interactiveMode)
|
||||||
|
{
|
||||||
c->Update();
|
c->Update();
|
||||||
gPad->WaitPrimitive();
|
gPad->WaitPrimitive();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c->Close(); // Optionally avoid clutter in batch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.Fit(&f, "QNR");
|
||||||
|
}
|
||||||
|
|
||||||
frontGain[id][bk][u][d] = f.GetParameter(0);
|
frontGain[id][bk][u][d] = f.GetParameter(0);
|
||||||
frontGainValid[id][bk][u][d] = true;
|
frontGainValid[id][bk][u][d] = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user