25void CosmicsBox::Print_Phi_ew(vector<int> phi_chx, vector<float> ly_C0, vector<int> SiPMchannels,
float windowmin,
float windowmax,
float maxfrom,
float maxto,
int nbins,
bool corr,
bool periodic) {
30 int sipmnum = SiPMchannels.size();
32 for (
const auto& channel : SiPMchannels) ch_index.push_back(
GetChannelIndex(channel));
35 vector<float> ly_corr;
39 for (
int i = 0; i < sipmnum; i++) ly_av += ly_C0[i];
41 for (
int i = 0; i < sipmnum; i++) ly_corr.push_back(sipmnum * ly_C0[i] / ly_av);
43 else for (
int i = 0; i < sipmnum; i++) ly_corr.push_back(1);
46 for (
int i = 0; i < sipmnum; i++) cout <<
"Correction factor for channel " << SiPMchannels[i] <<
":" << ly_corr[i] << endl;
49 gStyle->SetOptStat(
"emr"); gStyle->SetOptFit(1111);
50 TString his_name(Form(
"#phi_ew-spectrum_from_ch%d_to_ch%d", SiPMchannels.front(), SiPMchannels.back()));
51 auto hisc =
new TCanvas(his_name, his_name, 600, 400);
53 double min_angle = -180, max_angle = 180;
54 if (periodic) { min_angle = -540; max_angle = 540; }
55 auto his =
new TH1F(his_name, his_name, nbins, min_angle, max_angle);
58 for (
int i = 0; i <
nevents; i++) {
59 float anglevaluex = 0., anglevaluey = 0., phi_ew = 0.;
61 for (
int j = 0; j < sipmnum; j++) {
63 if (wf_index < 0)
continue;
65 anglevaluex += cos(phi_chx[j] * TMath::Pi() / 180) * lightyield / ly_corr[j];
66 anglevaluey += sin(phi_chx[j] * TMath::Pi() / 180) * lightyield / ly_corr[j];
69 phi_ew = atan2(anglevaluey, anglevaluex) * 180 / TMath::Pi();
72 his->Fill(phi_ew + 360);
73 his->Fill(phi_ew - 360);
79 his->GetXaxis()->SetTitle(
"#phi_{ew} [#circ]");
80 his->GetYaxis()->SetTitle(
"#Entries");
86 auto f =
new TF1(
"fitf", fitf, min_angle, max_angle, n_par);
90 double max = his->GetMaximum();
91 double min = his->GetMinimum();
92 his->GetXaxis()->SetRangeUser(-180, 180);
93 double phi_est = his->GetXaxis()->GetBinCenter(his->GetMaximumBin());
94 his->GetXaxis()->SetRangeUser(0, 0);
96 f->SetParName(0,
"A"); f->SetParameter(0, max - min); f->SetParLimits(0, 1, 1e9);
97 f->SetParName(1,
"#bar{#phi_{ew}}"); f->SetParameter(1, phi_est); f->SetParLimits(1, -180, 180);
98 f->SetParName(2,
"#sigma"); f->SetParameter(2, 40); f->SetParLimits(2, 5, 360);
99 f->SetParName(3,
"offset"); f->SetParameter(3, min); f->SetParLimits(3, TMath::Min(min - 1, 0.1), 1e9);
101 TFitResultPtr fresults = his->Fit(f,
"LRS");
106 root_out->WriteObject(hisc,
"Phi_ew");
107 root_out->WriteObject(his,
"Phi_ew_his");
109 string pdf_name =
"phi_ew_spectrum";
110 pdf_name += corr ?
"_corr.pdf" :
"_uncorr.pdf";
111 hisc->SaveAs(pdf_name.c_str());
void Print_Phi_ew(vector< int >, vector< float >, vector< int >, float=1, float=1, float=100, float=140, int=400, bool=true, bool=false)
Angular distribution of passing particles in the cosmics setup.
float GetPeakIntegral(TH1F *, float, float, float, float, int=0)
Calculate the integral around a peak with several options explained in GetIntWindow().