#include #include #include #include #include #include #include #include "RootHeader.h" #include "TTree.h" #include "TProfile.h" #include "TH1F.h" #include "TFile.h" void draw_ped_all(int crate) { // TFile *f = new TFile("bcal_s4_348.root"); // TFile *f = new TFile("bcal_s_486.root"); // TFile *f = new TFile("bcal_n_499.root"); TFile *f = new TFile("bcal_n_502.root"); TH1F *hped = new TH1F("ped", "ped",500,50.,150.); TH1F *hped_wid = new TH1F("ped_wid", "ped_wid",100,0.7,2.1); Int_t range = 0; Int_t x_min = 150; Int_t x_max = 300; Float_t ped[21][16]; Float_t ped_w[21][16]; Int_t slot_min = 3; Int_t slot_max = 17; cout << " SLOT_MIN = " << slot_min << endl; cout << " SLOT_MAX = " << slot_max << endl; memset(ped,0,sizeof(ped)); memset(ped_w,0,sizeof(ped_w)); for(Int_t crate = 0; crate < 4; crate++){ for(Int_t sl = slot_min; sl < slot_max; sl++){ for(Int_t ch = 0; ch < 16; ch++){ char title[30]; sprintf(title,"ped_cr%d_bd%d_ch%d",crate,sl,ch); TH1F * h1 = (TH1F*)f->Get(title); cout << " Read histogram " << title << " " << h1 << endl; if(h1 == NULL){ cout << " Channel don't exist " << title << endl; continue; } if(range == 1){ h1->GetXaxis()->SetRangeUser(x_min,x_max); } h1->Fit("gaus"); Double_t mean = 0; Double_t sigma = 0; TF1 *fit = h1->GetFunction("gaus"); mean = fit->GetParameter(1); sigma = fit->GetParameter(2); cout << " CRATE = " << crate << " SLOT = " << " Channel = " << ch << endl; cout << " Mean = " << mean << " Sigma = " << sigma << endl; hped->Fill(mean); hped_wid->Fill(sigma); } // Loop over channels } // Loop over boards } // Loop over crates gStyle->SetOptStat(0); gStyle->SetOptFit(0111); hped->Fit("gaus"); hped_wid->Fit("gaus"); TCanvas *c1 = new TCanvas("c1","c1",800,400); c1->Divide(2,1); c1->cd(1); hped->GetXaxis()->SetRangeUser(50,150); hped->Draw(); hped->SetTitle(""); hped->GetXaxis()->SetTitle("FADC channel"); c1->cd(2); hped_wid->Draw(); hped_wid->SetTitle(""); hped_wid->GetXaxis()->SetTitle("FADC channel"); }