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