#include "TFile.h" #include "TCanvas.h" #include "TStyle.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TGaxis.h" #include "TRandom.h" #include "TLegend.h" #include "TPaveStats.h" #include "TGraph.h" #include "TSystem.h" #include "TTree.h" #include "TTreePlayer.h" #include "TF1.h" #include "TCut.h" #include "TPaletteAxis.h" #include "TFitResult.h" #include "TMath.h" char resfile[50]; char det[50]; char detfixed[50]; char restit[50]; char rootfile[50]; int x1; int x2; int Epeaki; std::vector Epeak={1824,4028,5014,5045,5060,6414,6997}; void edepcoincroot() { int run=610; float fillcolor=0.35; gStyle->SetFitFormat("8.6g"); gStyle->SetOptStat(111110); ofstream results; sprintf(det,"GePD"); sprintf(detfixed,"GeDD"); sprintf(resfile,"CoincidencesRun0%d.txt",run); sprintf(rootfile,"%s_run0%d.root",det,run); TFile *fin = TFile::Open("run0610.root"); TFile *RootOut = new TFile(rootfile,"RECREATE"); fin->ls (); TGaxis::SetMaxDigits(3); if (fin == 0) { printf("Error: cannot open the file!\n"); } else { for (int i=0; iGetObject("tree",te); gStyle->SetOptFit(); gStyle->SetOptStat(111110); te->SetLineColor(kBlue); TH1::StatOverflows(true); TCanvas *c01 = new TCanvas("c01","c01",1280,1024); c01->SetLogy(); TString string = TString::Format("e0 >> htemp(7500, 0, 7500)"); TCut pulser0 = TString::Format("e2==0").Data(); TCut pulser1 = TString::Format("e3==0").Data(); TCut detection = TString::Format("e0>0").Data(); TCut winsx = TString::Format("e1>%d",x1).Data(); TCut windx= TString::Format("e1<%d",x2).Data(); te->Draw(string, detection && winsx && windx && pulser0 && pulser1); te->GetHistogram()->SetTitle(""); te->SetScanField(0); TH1F *hGe[i]= (TH1F*)gPad->GetPrimitive("htemp"); hGe[i]->GetXaxis()->SetTitle("Energy (keV)"); hGe[i]->GetYaxis()->SetTitle("Counts"); hGe[i]->GetYaxis()->SetTitleSize(40); hGe[ì]->GetYaxis()->SetTitleFont(43); hGe[i]->GetYaxis()->SetTitleOffset(1.1); hGe[i]->GetYaxis()->SetLabelFont(43); hGe[i]->GetYaxis()->SetLabelSize(40); hGe[i]->GetXaxis()->SetTitleSize(40); hGe[i]->GetXaxis()->SetTitleFont(43); hGe[i]->GetXaxis()->SetTitleOffset(1.1); hGe[i]->GetXaxis()->SetLabelFont(43); hGe[i]->GetXaxis()->SetLabelSize(40); hGe[i]->SetFillStyle(3005); hGe[i]->SetFillColorAlpha(kBlue, fillcolor); hGe[i]->SetStats(0); hGe[i]->SetName(title); hGe[i]->Draw(); double Nentries= hGe->GetEntries(); double mean= hGe->GetMean(); double stddev= hGe->GetRMS(); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn /*TLegend* leg = new TLegend(0.25, 0.7, .35, .75); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(hGe, "MC", "l"); leg->Draw();*/ c01->Update(); gPad->Modified(); gPad->Update(); /*TPaveStats *stats = (TPaveStats*)hGe->GetListOfFunctions()->FindObject("stats"); stats->SetTextColor(kBlue); stats->SetX1NDC(0.80); stats->SetX2NDC(0.98); stats->SetY1NDC(0.83); stats->SetY2NDC(0.98); //stats->AddText(TString::Format("Text"); stats->DrawClone();*/ c01->Update(); gPad->Modified(); c01->Print(outfile); results << restit << endl; results << detfixed << " range [" << x1 << ";" << x2 << "]" <