modified: GainMatchSX3.C gainmatching of backs fixed. fronts in progress
This commit is contained in:
parent
9cadfdd191
commit
e86ab5ed4d
|
@ -16,19 +16,19 @@
|
||||||
#include "TVector3.h"
|
#include "TVector3.h"
|
||||||
|
|
||||||
TH2F *hSX3FvsB;
|
TH2F *hSX3FvsB;
|
||||||
TH2F *hQQQFVB;
|
TH2F *hsx3IndexVE;
|
||||||
int padID = 0;
|
int padID = 0;
|
||||||
|
|
||||||
SX3 sx3_contr;
|
SX3 sx3_contr;
|
||||||
TCutG *cut;
|
TCutG *cut;
|
||||||
std::map<std::tuple<int, int, int>, std::vector<std::tuple<double, double, double>>> dataPoints;
|
std::map<std::tuple<int, int, int>, std::vector<std::tuple<double, double, double>>> dataPoints;
|
||||||
|
|
||||||
|
|
||||||
void GainMatchSX3::Begin(TTree * /*tree*/)
|
void GainMatchSX3::Begin(TTree * /*tree*/)
|
||||||
{
|
{
|
||||||
TString option = GetOption();
|
TString option = GetOption();
|
||||||
|
|
||||||
hSX3FvsB = new TH2F("hSX3FvsB", "SX3 Front vs Back; Front E; Back E", 400, 0, 16000, 400, 0, 16000);
|
hSX3FvsB = new TH2F("hSX3FvsB", "SX3 Front vs Back; Front E; Back E", 400, 0, 16000, 400, 0, 16000);
|
||||||
|
hsx3IndexVE = new TH2F("hsx3IndexVE", "SX3 index vs Energy; sx3 index ; Energy", 24 * 12, 0, 24 * 12, 400, 0, 5000);
|
||||||
|
|
||||||
sx3_contr.ConstructGeo();
|
sx3_contr.ConstructGeo();
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ void GainMatchSX3::Begin(TTree * /*tree*/)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cut->SetName("sx3cut"); // Ensure the cut has the correct name
|
cut->SetName("sx3cut"); // Ensure the cut has the correct name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool_t GainMatchSX3::Process(Long64_t entry)
|
Bool_t GainMatchSX3::Process(Long64_t entry)
|
||||||
|
@ -119,37 +118,49 @@ Bool_t GainMatchSX3::Process(Long64_t entry)
|
||||||
{
|
{
|
||||||
if (sx3.ch[index] % 2 == 0)
|
if (sx3.ch[index] % 2 == 0)
|
||||||
{
|
{
|
||||||
sx3ChDn = sx3.ch[index]/2;
|
sx3ChDn = sx3.ch[index] / 2;
|
||||||
sx3EDn = sx3.e[index];
|
sx3EDn = sx3.e[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sx3ChUp = sx3.ch[index]/2;
|
sx3ChUp = sx3.ch[index] / 2;
|
||||||
sx3EUp = sx3.e[index];
|
sx3EUp = sx3.e[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sx3ChBk = sx3.ch[index];
|
sx3ChBk = sx3.ch[index] - 8;
|
||||||
|
// if (sx3ChBk == 2)
|
||||||
|
// printf("Found back channel Det %d Back %d \n", sx3.id[index], sx3ChBk);
|
||||||
sx3EBk = sx3.e[index];
|
sx3EBk = sx3.e[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hSX3FvsB->Fill(sx3EUp + sx3EDn, sx3EBk);
|
hSX3FvsB->Fill(sx3EUp + sx3EDn, sx3EBk);
|
||||||
|
|
||||||
|
// Fill the histogram for the front vs back
|
||||||
|
std::array<int, 24> detectorIDs;
|
||||||
|
|
||||||
for (int i = 0; i < sx3.multi; i++)
|
for (int i = 0; i < sx3.multi; i++)
|
||||||
{
|
{
|
||||||
TString histName = Form("hSX3FVB_id%d_F%d_L+R%d", sx3.id[i], sx3ChUp, sx3ChBk);
|
if (sx3.id[i]==3)
|
||||||
TH2F *hist2d = (TH2F *)gDirectory->Get(histName);
|
|
||||||
if (!hist2d)
|
|
||||||
{
|
{
|
||||||
hist2d = new TH2F(histName, Form("hSX3FVB_id%d_F%d_L+R%d", sx3.id[i], sx3ChUp, sx3ChBk), 400, 0, 16000, 400, 0, 16000);
|
TString histName = Form("hSX3FVB_id%d_U%d_D%d_B%d", sx3.id[i], sx3ChUp, sx3ChDn, sx3ChBk);
|
||||||
}
|
TH2F *hist2d = (TH2F *)gDirectory->Get(histName);
|
||||||
|
if (!hist2d)
|
||||||
|
{
|
||||||
|
hist2d = new TH2F(histName, Form("hSX3FVB_id%d_U%d_D%d_B%d", sx3.id[i], sx3ChUp, sx3ChDn, sx3ChBk), 400, 0, 16000, 400, 0, 16000);
|
||||||
|
}
|
||||||
|
|
||||||
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
// if (sx3ChBk == 2)
|
||||||
if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk))
|
// printf("Found back channel Det %d Back %d \n", sx3.id[i], sx3ChBk);
|
||||||
{
|
hsx3IndexVE->Fill(sx3.index[i], sx3.e[i]);
|
||||||
// Accumulate data for gain matching
|
|
||||||
dataPoints[{sx3.id[i], sx3ChUp, sx3ChBk}].emplace_back(sx3EBk, sx3EUp , sx3EDn);
|
hist2d->Fill(sx3EUp + sx3EDn, sx3EBk);
|
||||||
|
if (cut && cut->IsInside(sx3EUp + sx3EDn, sx3EBk))
|
||||||
|
{
|
||||||
|
// Accumulate data for gain matching
|
||||||
|
dataPoints[{sx3.id[i], sx3ChUp, sx3ChBk}].emplace_back(sx3EBk, sx3EUp, sx3EDn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,32 +234,33 @@ void GainMatchSX3::Terminate()
|
||||||
// === Create histograms ===
|
// === Create histograms ===
|
||||||
TH2F *hFVB = new TH2F("hFVB", "Corrected Up+Dn vs Corrected Back;Corrected Back E;Up+Dn E",
|
TH2F *hFVB = new TH2F("hFVB", "Corrected Up+Dn vs Corrected Back;Corrected Back E;Up+Dn E",
|
||||||
400, 0, 16000, 400, 0, 16000);
|
400, 0, 16000, 400, 0, 16000);
|
||||||
TH2F *hAsym = new TH2F("hAsym", "Up vs Dn dvide back;Up+Dn E;(Up-Dn)/(Up+Dn)",
|
TH2F *hAsym = new TH2F("hAsym", "Up vs Dn dvide corrected back;Up/Back E;Dn/Back E",
|
||||||
400, -1.0,1.0, 400, -1.0, 1.0);
|
400, 0.0, 1.0, 400, 0.0, 1.0);
|
||||||
|
|
||||||
// Fill histograms
|
// Fill histograms
|
||||||
for (const auto &kv : dataPoints)
|
for (const auto &kv : dataPoints)
|
||||||
{
|
|
||||||
auto [id, ud, bk] = kv.first;
|
|
||||||
if (!gainValid[id][ud][bk]) continue;
|
|
||||||
double gain = gainArray[id][ud][bk];
|
|
||||||
|
|
||||||
for (const auto &pr : kv.second)
|
|
||||||
{
|
{
|
||||||
double eBk, eUp, eDn;
|
auto [id, ud, bk] = kv.first;
|
||||||
std::tie(eBk, eUp, eDn) = pr;
|
if (!gainValid[id][ud][bk])
|
||||||
|
continue;
|
||||||
|
double gain = gainArray[id][ud][bk];
|
||||||
|
|
||||||
double updn = eUp + eDn;
|
for (const auto &pr : kv.second)
|
||||||
if (updn == 0) continue;
|
{
|
||||||
|
double eBk, eUp, eDn;
|
||||||
|
std::tie(eBk, eUp, eDn) = pr;
|
||||||
|
|
||||||
double asym = (eUp - eDn) / updn;
|
double updn = eUp + eDn;
|
||||||
double correctedBack = eBk * gain;
|
if (updn == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
hFVB->Fill(correctedBack, updn);
|
double asym = (eUp - eDn) / updn;
|
||||||
hAsym->Fill(eUp/eBk,eDn/eBk);
|
double correctedBack = eBk * gain;
|
||||||
|
|
||||||
|
hFVB->Fill(correctedBack, updn);
|
||||||
|
hAsym->Fill(eUp / correctedBack, eDn / correctedBack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Optional: save histograms to a file
|
// Optional: save histograms to a file
|
||||||
// TFile *outHist = new TFile("sx3_gainmatch_hists.root", "RECREATE");
|
// TFile *outHist = new TFile("sx3_gainmatch_hists.root", "RECREATE");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user