void plot2(const char *filename = "occ2.root") { gStyle->SetOptStat(0); TFile *f = TFile::Open(filename); /* f->ls(); tree->Print(); */ TCanvas *c = new TCanvas("c","c",10, 10, 700, 600); c->Divide(3,2); c_1->SetLogy(); c_2->SetLogy(); c_3->SetLogy(); c_4->SetLogy(); c_5->SetLogy(); c_6->SetLogy(); TCanvas *c2 = new TCanvas("c2","c2",10, 10, 700, 600); c2->Divide(3,2); c2_1->SetLogy(); c2_2->SetLogy(); c2_3->SetLogy(); c2_4->SetLogy(); c2_5->SetLogy(); // c2_6->SetLogy(); //not the last one TText *text = new TText; text->SetTextSize(0.05) ; char h1str[32]; const int NPANELS = 6; const int NPLANES = 5; int ipanel, iplane; int nV[NPANELS] = {64,26,64,64,26,64}; int nH[NPANELS] = {59,45,59,59,45,59}; int ntot[2] = {308, 326};//{2*(2*64+26),2*(2*59+45)}; int canvasOrder[NPANELS] = {1,2,3,6,5,4}; int histcolor[NPLANES] = {1,2,3,4,6}; char id[32], title[32], plotstr[32]; // one arm, and orientation; or fem at a time for (int ifem = 0; ifem<4; ifem++) { int iarm = ifem/2; int iorient = ifem%2; for (ipanel = 0; ipanel < NPANELS; ipanel++) { c->cd(canvasOrder[ipanel]); int nbins; if (iorient == 0) { nbins = nH[ipanel]; } else { nbins = nV[ipanel]; } sprintf(title,"Arm %d Orient %d Panel %d",iarm,iorient,ipanel); TH1F *h1[NPLANES]; Stat_t maxval = 0; int maxplane = 0; for (iplane = 0; iplane < NPLANES; iplane++) { // book histos sprintf(id,"h1[%d]",iplane); h1[iplane] = new TH1F(id,title,nbins+1,-0.5,nbins+0.5); h1[iplane]->SetLineColor(histcolor[iplane]); // and fill them sprintf(plotstr,"nchan_plane_panel[%d][%d][%d]>>%s",ifem,iplane,ipanel,id); // cout << " plotstr " << plotstr << endl; tree->Draw(plotstr); // h1[iplane]->Print(); if (h1[iplane]->GetMaximum() > maxval ) { maxval = h1[iplane]->GetMaximum(); maxplane = iplane; } } // iplane // cout << " maxval " << maxval << endl; Stat_t logmaxval = log10(maxval); // Replot h1[maxplane]->DrawCopy("hist"); for (iplane = 0; iplane < NPLANES; iplane++) { h1[iplane]->DrawCopy("hist same"); // insert some text here too text->SetTextColor(histcolor[iplane]); sprintf(h1str,"Plane %d: Mean %3.2f", iplane, h1[iplane]->GetMean()); text->DrawText(0.35*nbins,logmaxval*0.9 - 0.5*iplane,h1str); } c->Update(); for (iplane = 0; iplane < NPLANES; iplane++) { delete h1[iplane]; } } // ipanel c->cd(); c->Update(); sprintf(plotstr,"plot2_arm%d_orient%d.gif",iarm,iorient); c->SaveAs(plotstr); TH1F *h2[NPLANES]; // also do the plot showing the total hits per gap; 2nd canvas int nsumbins = NPLANES; sprintf(title,"Arm %d Orient %d Summary",iarm,iorient); TH1F *hsummary = new TH1F("hsummary",title,nsumbins,-0.5,nsumbins-0.5); for (iplane = 0; iplane < NPLANES; iplane++) { sprintf(title,"Arm %d Orient %d Plane %d",iarm,iorient,iplane); // book histos sprintf(id,"h2[%d]",iplane); h2[iplane] = new TH1F(id,title,nbins+1,-0.5,nbins+0.5); h2[iplane]->SetLineColor(histcolor[iplane]); // and fill them sprintf(plotstr,"nchan_plane[%d][%d]>>%s",ifem,iplane,id); // cout << " plotstr " << plotstr << endl; tree->Draw(plotstr); // h2[iplane]->Print(); int ibin = iplane+1; hsummary->SetBinContent(ibin,h2[iplane]->GetMean()); hsummary->SetBinError(ibin,h2[iplane]->GetRMS()); } // iplane // do the plotting for (iplane = 0; iplane < NPLANES; iplane++) { c2->cd(iplane+1); h2[iplane]->DrawCopy("hist"); // insert some text here too text->SetTextColor(histcolor[iplane]); sprintf(h1str,"Plane %d: Mean %3.2f", iplane, h2[iplane]->GetMean()); text->DrawText(20,2,h1str); } c2->cd(6); hsummary->DrawCopy(); c2->Update(); for (iplane = 0; iplane < NPLANES; iplane++) { delete h2[iplane]; } delete hsummary; sprintf(plotstr,"plot2_arm%d_orient%d_allpanels.gif",iarm,iorient); c2->SaveAs(plotstr); } // ifem return; }