#include #include #include #include #include #include #include #include #include void readTree(){ //gROOT->SetStyle("Plain"); TH1F *h= new TH1F("h","h",500,0,40); TH1F *h1= new TH1F("h1","h1",1000,-10,300); TH1D *h2= new TH1D("h2","h2",200,240,250); TH1D *h3= new TH1D("h3","h3",500,0,40); TH1D *h4= new TH1D("h4","h4",1000,-10,300); TH1D *histo= new TH1D("histo","histo",1000,-10,300); TH1D **histoTab = new TH1D*[36] ; //déclaration d'un tableau d'histo double totE; unsigned int pixel; TCanvas *c= new TCanvas ("c","c",800,800); gPad->Divide(0,2); TCanvas *c1= new TCanvas ("c1","c1",800,800); gPad->Divide(0,2); TFile *myfile= new TFile("test4pixels.root","READ"); TTree *tree= (TTree*)myfile->Get("tree"); tree->SetBranchAddress("pixel",&pixel); tree->SetBranchAddress("totE",&totE); entries= tree->GetEntries(); for(Int_t j=0 ; j<36 ; j++) { histoTab[j]=(TH1D*)histo->Clone(TString(Form("histo%d" ,j+1))); } for (int i=0; iGetEntry(i); for(Int_t j=0 ; j<36 ; j++) { if (totE!=0) { if( pixel == j+1 ){ histoTab[j]->Fill(totE) ; } } } if (pixel!=0) {h->Fill(pixel);} if (totE!=0) {h1->Fill(totE);} if(totE>240 && totE<250) {h2->Fill(totE);} } c->cd(1); gPad->SetLogy(); h->SetXTitle("Pixels"); h->SetYTitle("nb de coups"); h->Draw(); c->cd(2); gPad->SetLogy(); h1->SetXTitle("Energie keV"); h1->SetYTitle("nb de coups"); h1->Draw(); c1->cd(1); gPad->SetLogy(); histoTab[36]->SetTitle(" pixel n°19"); histoTab[36]->SetXTitle("Energie keV"); histoTab[36]->SetYTitle("nb de coups"); histoTab[36]->Draw(""); c1->cd(2); gPad->SetLogy(); histoTab[19]->SetTitle("pixel n°19 et pixel n°20"); histoTab[19]->SetXTitle("Energie keV"); histoTab[19]->SetYTitle("nb de coups"); histoTab[19]->SetLineColor(2); histoTab[1]->SetLineColor(3); histoTab[2]->SetLineColor(4); histoTab[19]->Draw("hist"); histoTab[20]->Draw("histsame"); histoTab[1]->Draw("histsame"); histoTab[2]->Draw("histsame"); //h2->Draw(); TLegend *legend= new TLegend(0.1, 0.6, 0.2, 0.9); legend->AddEntry(histoTab[1], "pixel n°1", "l"); legend->AddEntry(histoTab[2], "pixel n°2", "l"); legend->AddEntry(histoTab[19], "pixel n°19", "l"); legend->AddEntry(histoTab[20], "pixel n°20", "l"); legend->Draw(); // c1->cd(3); // gPad->SetLogy(); // h4->Draw(); }