I was trying to construct a histogram to compare two different data set but the plot is not as expected or as even it shows through new TBrowser
Can some one help me out please?
void current_data(TString file1, TString file2)
{
TFile f1(file1);
TTree* t1 = (TTree*) f1.Get("current_ntuple");
Float_t Current_ntuple1;
t1->SetBranchAddress("Current",&Current_ntuple1);
ULong64_t n = t1->GetEntries();
Double_t MinBound = 0;
Double_t MaxBound = 100;
Int_t Numbins = 100;
TH1D* Raw_data = new TH1D("Raw data","Current Comparision", Numbins, MinBound, MaxBound);
Raw_data -> GetXaxis() ->SetTitle("Current[#muA]");
Raw_data -> GetYaxis() ->SetTitle("Frequency");
for (Int_t f = 0; f<n;f++)
{
t1 -> GetEntry(f);
Raw_data -> Fill(Current_ntuple1);
}
Raw_data ->SetName("February Raw Data");
Raw_data -> SetDirectory(0);
f1.Close();
TFile f2(file2);
TTree* t2 = (TTree*) f2.Get("current_ntuple");
Float_t Current_ntuple2;
t2->SetBranchAddress("Current",&Current_ntuple2);
ULong64_t m = t2->GetEntries();
TH1D* stable_data = new TH1D("Stable_data.txt", "", Numbins, MinBound, MaxBound);
stable_data -> GetXaxis()-> SetTitle("Current [#muA] ");
stable_data -> GetYaxis()-> SetTitle("Frequency");
stable_data -> SetLineColor(kRed);
stable_data -> SetMarkerStyle(7);
stable_data->SetName("February Stable Current");
for(Int_t g = 0; g < m; g++)
{
t2->GetEntry(g);
stable_data->Fill(Current_ntuple2);
}
stable_data->SetDirectory(0);
f2.Close();
TCanvas* c1 = new TCanvas();
Raw_data->Draw();
stable_data->Draw();
c1 ->SetLogy();
gStyle -> SetOptStat(0);
c1->Update();
TFile outputFile("Comparing Raw and Stable Data");
Raw_data->Write("Current Distribution");
stable_data->Write("Stable Current Distribution");
outputFile.Close();
}
BTW. Note that ``` is not the same as "’ nor ‘’’