Feat: merge pad and ec

This commit is contained in:
liuyihui 2024-11-24 17:50:16 +08:00
parent ffaab92d94
commit 0369ef03fe
2 changed files with 66 additions and 63 deletions

View File

@ -153,5 +153,5 @@ private:
void draw1DFeatures(); void draw1DFeatures();
void draw2DFeatures(); void draw2DFeatures();
void drawPadFeatures(); void drawPadFeatures();
void drawExcitationCurve(); // void drawExcitationCurve();
}; };

View File

@ -63,8 +63,8 @@ void fitdgaus(TH1F *hist, TF1 *func, double *&par, double m0) {
double amp2 = pars[3]; double amp2 = pars[3];
double sigma2 = pars[4]; double sigma2 = pars[4];
sigma = sqrt(sigma1 * sigma1 + sigma2 * sigma2); sigma = sqrt(sigma1 * sigma1 + sigma2 * sigma2);
xl = max(mean - 3. * sigma, m0 * 0.6); xl = max(mean - 3. * sigma, m0 * 0.5);
xr = min(mean + 3. * sigma, m0 * 1.4); xr = min(mean + 3. * sigma, m0 * 1.5);
par = new double[7]{mean, amp1, sigma1, amp2, sigma2, xl, xr}; par = new double[7]{mean, amp1, sigma1, amp2, sigma2, xl, xr};
} }
@ -221,9 +221,9 @@ void BluetAnalyzer::defineFitFunctions() {
fdgaus->SetParNames("#mu", "amp_1", "#sigma_1", "amp_2", "#sigma_2"); fdgaus->SetParNames("#mu", "amp_1", "#sigma_1", "amp_2", "#sigma_2");
fdgaus->SetParLimits(0, 0., 1.e6); fdgaus->SetParLimits(0, 0., 1.e6);
fdgaus->SetParLimits(1, 0., 1.e8); fdgaus->SetParLimits(1, 0., 1.e8);
fdgaus->SetParLimits(2, 0., 1.e6); fdgaus->SetParLimits(2, 1., 1.e6);
fdgaus->SetParLimits(3, 0., 1.e8); fdgaus->SetParLimits(3, 0., 1.e8);
fdgaus->SetParLimits(4, 0., 1.e6); fdgaus->SetParLimits(4, 1., 1.e6);
} }
void BluetAnalyzer::defineHistograms() { void BluetAnalyzer::defineHistograms() {
@ -466,6 +466,11 @@ void BluetAnalyzer::FillHistograms() {
if (!isGoodEvent(fEvent)) if (!isGoodEvent(fEvent))
continue; continue;
double ts = fEvent->TimeStamp;
double tof = fEvent->TOF0;
double tcath = fEvent->CathodeTime;
hts->Fill(ts, tof);
// convert time of flight to neutron energy using relativistic formula // convert time of flight to neutron energy using relativistic formula
double tof1 = fEvent->TOF0 - kickdT; double tof1 = fEvent->TOF0 - kickdT;
double vn = flighL / tof1 * 1e9; double vn = flighL / tof1 * 1e9;
@ -484,13 +489,11 @@ void BluetAnalyzer::FillHistograms() {
if (!isGoodTrack(&(fEvent->Tracks[itrk]))) if (!isGoodTrack(&(fEvent->Tracks[itrk])))
continue; continue;
double ts = fEvent->TimeStamp;
double tof = fEvent->TOF0;
double sumE = fEvent->Tracks[itrk].TrSumEdep; double sumE = fEvent->Tracks[itrk].TrSumEdep;
double length = fEvent->Tracks[itrk].TrRawLength; double length = fEvent->Tracks[itrk].TrRawLength;
double tmax = fEvent->Tracks[itrk].Tmax; double tmax = fEvent->Tracks[itrk].Tmax;
double tmin = fEvent->Tracks[itrk].Tmin; double tmin = fEvent->Tracks[itrk].Tmin;
double tcath = fEvent->CathodeTime; double cost = fEvent->Tracks[itrk].TrCosTheta;
double *xypos = fEvent->Tracks[itrk].ZmaxHit_xy; double *xypos = fEvent->Tracks[itrk].ZmaxHit_xy;
double radius = double radius =
TMath::Sqrt((xypos[0] - CenterPos[0]) * (xypos[0] - CenterPos[0]) + TMath::Sqrt((xypos[0] - CenterPos[0]) * (xypos[0] - CenterPos[0]) +
@ -508,16 +511,13 @@ void BluetAnalyzer::FillHistograms() {
htpad->Fill((tmax - tmin) * sampleT); htpad->Fill((tmax - tmin) * sampleT);
htcath->Fill((tmax - tcath) * sampleT); htcath->Fill((tmax - tcath) * sampleT);
hcos->Fill(fabs(fEvent->Tracks[itrk].TrCosTheta)); hcos->Fill(fabs(cost));
hphi->Fill(fEvent->Tracks[itrk].TrPhi); hphi->Fill(fEvent->Tracks[itrk].TrPhi);
hdeltacos1->Fill(fabs(fEvent->Tracks[itrk].TrCosTheta), hdeltacos1->Fill(fabs(cost), (tmax - tcath) * sampleT);
(tmax - tcath) * sampleT); hdeltacos2->Fill(fabs(cost), (tmax - tmin) * sampleT);
hdeltacos2->Fill(fabs(fEvent->Tracks[itrk].TrCosTheta),
(tmax - tmin) * sampleT);
hLengthE->Fill(length, sumE); hLengthE->Fill(length, sumE);
hprofile->Fill(xypos[0], xypos[1]); hprofile->Fill(xypos[0], xypos[1]);
hbeamr->Fill(radius); hbeamr->Fill(radius);
hts->Fill(ts, tof);
htn->Fill(ts, fEvent->Tracks[itrk].NTrHits); htn->Fill(ts, fEvent->Tracks[itrk].NTrHits);
hamp->Fill(fEvent->MeshAmp, fEvent->CathodeAmp); hamp->Fill(fEvent->MeshAmp, fEvent->CathodeAmp);
han->Fill(fEvent->Tracks[itrk].NTrHits, fEvent->CathodeAmp); han->Fill(fEvent->Tracks[itrk].NTrHits, fEvent->CathodeAmp);
@ -630,7 +630,6 @@ void BluetAnalyzer::drawVertex() {
ratio->Draw(); ratio->Draw();
c0->cd(); c0->cd();
pad = new TPad("v3d", "Vertex 3D", 0.52, 0.02, 0.98, 0.48); pad = new TPad("v3d", "Vertex 3D", 0.52, 0.02, 0.98, 0.48);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
@ -638,8 +637,8 @@ void BluetAnalyzer::drawVertex() {
hprofile->SetFillColor(kYellow); hprofile->SetFillColor(kYellow);
hprofile->Draw("lego2z 0"); hprofile->Draw("lego2z 0");
fbeam2->Draw("same surf"); fbeam2->Draw("same surf");
c0->cd();
c0->cd();
pad = new TPad("xyd", "X/Y Distribution", 0.02, 0.52, 0.48, 0.98); pad = new TPad("xyd", "X/Y Distribution", 0.02, 0.52, 0.48, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -664,8 +663,8 @@ void BluetAnalyzer::drawVertex() {
leg->AddEntry(hslicey, "y-slice"); leg->AddEntry(hslicey, "y-slice");
leg->SetTextSize(0.03); leg->SetTextSize(0.03);
leg->Draw(); leg->Draw();
c0->cd();
c0->cd();
pad = new TPad("rd", "R Distribution", 0.52, 0.52, 0.98, 0.98); pad = new TPad("rd", "R Distribution", 0.52, 0.52, 0.98, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -680,7 +679,6 @@ void BluetAnalyzer::drawVertex() {
leg1->SetTextSize(0.03); leg1->SetTextSize(0.03);
leg1->Draw(); leg1->Draw();
c0->cd();
c0->Update(); c0->Update();
} }
@ -707,8 +705,8 @@ void BluetAnalyzer::drawTOF() {
leg->AddEntry(htof, Form("r < %.1f mm", rCutMax)); leg->AddEntry(htof, Form("r < %.1f mm", rCutMax));
leg->SetTextSize(0.03); leg->SetTextSize(0.03);
leg->Draw(); leg->Draw();
c0->cd();
c0->cd();
pad = new TPad("pull", "", 0.52, 0.02, 0.98, 0.48); pad = new TPad("pull", "", 0.52, 0.02, 0.98, 0.48);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -716,15 +714,15 @@ void BluetAnalyzer::drawTOF() {
hpull->Draw("P"); hpull->Draw("P");
TLine *line = new TLine(); TLine *line = new TLine();
line->DrawLine(tmin, 0., tmax, 0.); line->DrawLine(tmin, 0., tmax, 0.);
c0->cd();
c0->cd();
pad = new TPad("ratio", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("ratio", "", 0.02, 0.52, 0.48, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
hratio->Draw("E1"); hratio->Draw("E1");
line->DrawLine(tmin, 1., tmax, 1.); line->DrawLine(tmin, 1., tmax, 1.);
c0->cd();
c0->cd();
pad = new TPad("tof.ts", "", 0.52, 0.52, 0.98, 0.98); pad = new TPad("tof.ts", "", 0.52, 0.52, 0.98, 0.98);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
@ -732,7 +730,6 @@ void BluetAnalyzer::drawTOF() {
adjustAxisRange(hts); adjustAxisRange(hts);
hts->Draw("colz"); hts->Draw("colz");
c0->cd();
c0->Update(); c0->Update();
} }
@ -756,8 +753,8 @@ void BluetAnalyzer::drawDrift() {
fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]); fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]);
htcath->Fit("fdgaus", "LQ", "", par[5], par[6]); htcath->Fit("fdgaus", "LQ", "", par[5], par[6]);
htcath->GetFunction("fdgaus")->SetLineColor(kRed); htcath->GetFunction("fdgaus")->SetLineColor(kRed);
c0->cd();
c0->cd();
pad = new TPad("dv0", "", 0.52, 0.02, 0.98, 0.48); pad = new TPad("dv0", "", 0.52, 0.02, 0.98, 0.48);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -767,8 +764,8 @@ void BluetAnalyzer::drawDrift() {
fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]); fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]);
hv0->Fit("fdgaus", "LQ", "", par[5], par[6]); hv0->Fit("fdgaus", "LQ", "", par[5], par[6]);
hv0->GetFunction("fdgaus")->SetLineColor(kRed); hv0->GetFunction("fdgaus")->SetLineColor(kRed);
c0->cd();
c0->cd();
pad = new TPad("tpad", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("tpad", "", 0.02, 0.52, 0.48, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -778,8 +775,8 @@ void BluetAnalyzer::drawDrift() {
fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]); fdgaus->SetParameters(par[0], par[1], par[2], par[3], par[4]);
htpad->Fit("fdgaus", "LQ", "", par[5], par[6]); htpad->Fit("fdgaus", "LQ", "", par[5], par[6]);
htpad->GetFunction("fdgaus")->SetLineColor(kRed); htpad->GetFunction("fdgaus")->SetLineColor(kRed);
c0->cd();
c0->cd();
pad = new TPad("dv1", "", 0.52, 0.52, 0.98, 0.98); pad = new TPad("dv1", "", 0.52, 0.52, 0.98, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
@ -789,7 +786,6 @@ void BluetAnalyzer::drawDrift() {
hv1->Draw("E1"); hv1->Draw("E1");
hv1->Fit("fdgaus", "LQ", "", par[5], par[6]); hv1->Fit("fdgaus", "LQ", "", par[5], par[6]);
hv1->GetFunction("fdgaus")->SetLineColor(kRed); hv1->GetFunction("fdgaus")->SetLineColor(kRed);
c0->cd();
c0->Update(); c0->Update();
} }
@ -808,30 +804,29 @@ void BluetAnalyzer::drawAngle() {
pad->cd(); pad->cd();
hcos->GetYaxis()->SetRangeUser(0., hcos->GetMaximum() * 1.1); hcos->GetYaxis()->SetRangeUser(0., hcos->GetMaximum() * 1.1);
hcos->Draw("HIST"); hcos->Draw("HIST");
c0->cd();
c0->cd();
pad = new TPad("phi", "", 0.52, 0.02, 0.98, 0.48); pad = new TPad("phi", "", 0.52, 0.02, 0.98, 0.48);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
hphi->GetYaxis()->SetRangeUser(0., hphi->GetMaximum() * 1.1); hphi->GetYaxis()->SetRangeUser(0., hphi->GetMaximum() * 1.1);
hphi->Draw("HIST"); hphi->Draw("HIST");
c0->cd();
c0->cd();
pad = new TPad("tcath.cos", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("tcath.cos", "", 0.02, 0.52, 0.48, 0.98);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
gPad->SetGridy(); gPad->SetGridy();
hdeltacos1->Draw("colz"); hdeltacos1->Draw("colz");
c0->cd();
c0->cd();
pad = new TPad("tpad.cos", "", 0.52, 0.52, 0.98, 0.98); pad = new TPad("tpad.cos", "", 0.52, 0.52, 0.98, 0.98);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
gPad->SetGridy(); gPad->SetGridy();
hdeltacos2->Draw("colz"); hdeltacos2->Draw("colz");
c0->cd();
c0->Update(); c0->Update();
} }
@ -852,31 +847,30 @@ void BluetAnalyzer::draw1DFeatures() {
htmp = (TH1F *)(hamp->ProjectionX()); htmp = (TH1F *)(hamp->ProjectionX());
adjustAxisRange(htmp); adjustAxisRange(htmp);
htmp->Draw("HIST"); htmp->Draw("HIST");
c0->cd();
c0->cd();
pad = new TPad("cathamp", "", 0.52, 0.02, 0.98, 0.48); pad = new TPad("cathamp", "", 0.52, 0.02, 0.98, 0.48);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
htmp = (TH1F *)(hamp->ProjectionY()); htmp = (TH1F *)(hamp->ProjectionY());
adjustAxisRange(htmp); adjustAxisRange(htmp);
htmp->Draw("HIST"); htmp->Draw("HIST");
c0->cd();
c0->cd();
pad = new TPad("length", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("length", "", 0.02, 0.52, 0.48, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
htmp = (TH1F *)(hLengthE->ProjectionX()); htmp = (TH1F *)(hLengthE->ProjectionX());
adjustAxisRange(htmp); adjustAxisRange(htmp);
htmp->Draw("HIST"); htmp->Draw("HIST");
c0->cd();
c0->cd();
pad = new TPad("energy", "", 0.52, 0.52, 0.98, 0.98); pad = new TPad("energy", "", 0.52, 0.52, 0.98, 0.98);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
htmp = (TH1F *)(hLengthE->ProjectionY()); htmp = (TH1F *)(hLengthE->ProjectionY());
adjustAxisRange(htmp); adjustAxisRange(htmp);
htmp->Draw("HIST"); htmp->Draw("HIST");
c0->cd();
c0->Update(); c0->Update();
} }
@ -896,8 +890,8 @@ void BluetAnalyzer::draw2DFeatures() {
pad->cd(); pad->cd();
adjustAxisRange(hLengthE); adjustAxisRange(hLengthE);
hLengthE->Draw("colz"); hLengthE->Draw("colz");
c0->cd();
c0->cd();
pad = new TPad("tn", "", 0.52, 0.02, 0.98, 0.48); pad = new TPad("tn", "", 0.52, 0.02, 0.98, 0.48);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
@ -905,23 +899,22 @@ void BluetAnalyzer::draw2DFeatures() {
gPad->SetLogx(); gPad->SetLogx();
adjustAxisRange(htn); adjustAxisRange(htn);
htn->Draw("colz"); htn->Draw("colz");
c0->cd();
c0->cd();
pad = new TPad("amp", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("amp", "", 0.02, 0.52, 0.48, 0.98);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
adjustAxisRange(hamp); adjustAxisRange(hamp);
hamp->Draw("colz"); hamp->Draw("colz");
c0->cd();
c0->cd();
pad = new TPad("an", "", 0.52, 0.52, 0.98, 0.98); pad = new TPad("an", "", 0.52, 0.52, 0.98, 0.98);
pad->SetRightMargin(0.15); pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
pad->cd(); pad->cd();
adjustAxisRange(han); adjustAxisRange(han);
han->Draw("colz"); han->Draw("colz");
c0->cd();
c0->Update(); c0->Update();
} }
@ -953,36 +946,13 @@ void BluetAnalyzer::drawPadFeatures() {
c0->cd(); c0->cd();
pad = new TPad("amp", "", 0.02, 0.52, 0.48, 0.98); pad = new TPad("amp", "", 0.02, 0.52, 0.48, 0.98);
pad->Draw(); pad->Draw();
pad->cd();
c0->cd();
pad = new TPad("an", "", 0.52, 0.52, 0.98, 0.98);
pad->Draw();
pad->cd();
c0->Update();
}
void BluetAnalyzer::drawExcitationCurve() {
TGCompositeFrame *tab = mTab->AddTab("Excitation Curve");
TRootEmbeddedCanvas *ec =
new TRootEmbeddedCanvas("Canva 2d", tab, sizeX, sizeY);
tab->AddFrame(ec, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
TCanvas *c0 = ec->GetCanvas();
TPad *pad;
c0->cd();
pad = new TPad("te", "", 0.02, 0.02, 0.98, 0.48);
pad->SetRightMargin(0.15);
pad->Draw();
pad->SetLogx(); pad->SetLogx();
pad->SetLogy(); pad->SetLogy();
pad->cd(); pad->cd();
hte->Draw("colz"); hte->Draw("colz");
c0->cd(); c0->cd();
pad = new TPad("ec", "", 0.02, 0.52, 0.98, 0.98); pad = new TPad("an", "", 0.52, 0.52, 0.98, 0.98);
pad->SetRightMargin(0.15);
pad->Draw(); pad->Draw();
pad->SetLogx(); pad->SetLogx();
pad->SetLogy(); pad->SetLogy();
@ -992,6 +962,35 @@ void BluetAnalyzer::drawExcitationCurve() {
c0->Update(); c0->Update();
} }
// void BluetAnalyzer::drawExcitationCurve() {
// TGCompositeFrame *tab = mTab->AddTab("Excitation Curve");
// TRootEmbeddedCanvas *ec =
// new TRootEmbeddedCanvas("Canva 2d", tab, sizeX, sizeY);
// tab->AddFrame(ec, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// TCanvas *c0 = ec->GetCanvas();
// TPad *pad;
// c0->cd();
// pad = new TPad("te", "", 0.02, 0.02, 0.98, 0.48);
// pad->SetRightMargin(0.15);
// pad->Draw();
// pad->SetLogx();
// pad->SetLogy();
// pad->cd();
// hte->Draw("colz");
// c0->cd();
// pad = new TPad("ec", "", 0.02, 0.52, 0.98, 0.98);
// pad->SetRightMargin(0.15);
// pad->Draw();
// pad->SetLogx();
// pad->SetLogy();
// pad->cd();
// hec->Draw("colz");
// c0->Update();
// }
void BluetAnalyzer::saveHistograms() { void BluetAnalyzer::saveHistograms() {
TFile *fout = new TFile("bluetAnalyzer.root", "RECREATE"); TFile *fout = new TFile("bluetAnalyzer.root", "RECREATE");
fout->cd(); fout->cd();
@ -1023,6 +1022,10 @@ void BluetAnalyzer::saveHistograms() {
htt->Write(); htt->Write();
hte->Write(); hte->Write();
hec->Write(); hec->Write();
(TH1F *)(hamp->ProjectionX())->Write();
(TH1F *)(hamp->ProjectionY())->Write();
(TH1F *)(hLengthE->ProjectionX())->Write();
(TH1F *)(hLengthE->ProjectionY())->Write();
fout->Close(); fout->Close();
} }
@ -1039,7 +1042,7 @@ void BluetAnalyzer::drawHistograms() {
draw1DFeatures(); draw1DFeatures();
draw2DFeatures(); draw2DFeatures();
drawPadFeatures(); drawPadFeatures();
drawExcitationCurve(); // drawExcitationCurve();
mFrame->SetWindowName("Bluet Analyzer"); mFrame->SetWindowName("Bluet Analyzer");
mFrame->MapSubwindows(); mFrame->MapSubwindows();