// Grafica los histogramas de Carga. #include "Riostream.h" #include "TH1.h" #include "TMath.h" #include "TF1.h" #include "TLegend.h" #include "TCanvas.h" #include #include #include void Hist() { float charge_threshold = 0; float volt_threshold = 10; ifstream in; ofstream outfile; int i,j, n_par=6; int z,suma=0; int min_charge = 0; int max_charge = 20; int bines = 3600*(max_charge-min_charge); // double res = 1/bines; // cout << res << " pC/bines"; float n,time; double Charge_pC,y,w,Max_volt,xx,yy,ww,vv; TCanvas *c1 = new TCanvas("Plot","A Simple Graph Example",100,10,1000,600); TH1 *h1 = new TH1F("Pulse charge","", 125, -3,50); gPad-> SetLogy(); string s3; in.open("AREA.txt"); for (Int_t n=0;n<44;n++) { in>> s3; //cout<< s3<> Charge_pC >> y >> w >> Max_volt; //if(n>12000) break; // if (Charge_pC>charge_threshold) { h1->Fill(Charge_pC-1469.5); // Carga en pC n++; } } in.close(); h1->GetXaxis()->SetTitle("Charge (pC)"); h1->GetYaxis()->SetTitle("Counts"); //Fit // const Double_t Ped_gaus_1_min = 157.59; // const Double_t Ped_gaus_1_max = 158.75; const Double_t Ped_gaus_1_min = -0.7; const Double_t Ped_gaus_1_max = 1.35; const Double_t ph_1_min = 68; const Double_t ph_1_max = 140; const Double_t ph_2_min = 104.69; const Double_t ph_2_max = 105.57; const Double_t landau_min = 11; const Double_t landau_max = 35; Double_t par[n_par]; Double_t par_total[n_par]; TF1 *Fit_Ped_gaus_1 = new TF1("Ped_gaus_1","gaus",Ped_gaus_1_min,Ped_gaus_1_max); Fit_Ped_gaus_1->SetLineColor(kRed); h1->Fit(Fit_Ped_gaus_1,"R+"); Fit_Ped_gaus_1->GetParameters(&par[0]); TF1 *Fit_ph_2 = new TF1("ph_2","landau",landau_min,landau_max); Fit_ph_2->SetLineColor(kBlue); h1->Fit(Fit_ph_2,"R+"); Fit_ph_2->GetParameters(&par[3]); c1->SetGrid(); //c1->SetLogy(); h1->SetMarkerStyle(20); h1->SetLineColor(kBlack); gStyle->SetOptFit(0111); h1->Draw("ep*"); }