My program has been giving the error of break segmentation violation but if I try running the code in chunk it works fine.
‘’'void Percent_beyond_threshold(TString file1, TString file2)
{
TH1D* beyondthreshold_stable =new TH1D("Beyond Threshold", "Threshold", Numbins, MinBound, MaxBound);
beyondthreshold_stable->GetXaxis()->SetTitle("Current[#muA]");
beyondthreshold_stable->GetYaxis()->SetTitle("Percentage");
beyondthreshold_stable->SetLineColor(kRed);
beyondthreshold_stable->SetMarkerStyle(7);
beyondthreshold_stable->SetName("Stable Current Distribution");
beyondthreshold_stable->Sumw2(kTRUE);
for (ULong64_t i = 0; i< Numbins;i++)
{
threshold1 = i;
Int_t abovee=0;
for(ULong64_t e=0; e<n;e++)
{
t1->GetEntry(e);
if(abs(curr2)>=threshold1)
{
abovee++;
}
np = (1.0*abovee)/(1*n);
beyondthreshold_stable->SetBinContent(i+1,np);
}
/*if(i)
beyondthreshold_stable->SetBinError(i+1, sqrt(np*(1-np)/m));
else
beyondthreshold_stable->SetBinError(i+1,0.0);*/
}
hs.Add(beyondthreshold);
TCanvas* c1= new TCanvas();
TText T; T.SetTextFont(42); T.SetTextAlign(21);
beyondthreshold->Draw();
beyondthreshold_stable->Draw("same");
c1->Divide(1,1);
c1->cd(1);
gStyle->SetOptStat(0);
hs.Draw();
hs.DrawClone("nostack");
return c1;
TFile outputFile("Decvsjan.root", "recreate");
curr_vals_raw->Write("Current December");
curr_vals_stable->Write("Current January");
outputFile.Close();
}’’’