#include #include using namespace std; void CanvasPartition(TCanvas *C,const Int_t Nx = 2,const Int_t Ny = 2, Float_t lMargin = 0.15, Float_t rMargin = 0.05, Float_t bMargin = 0.15, Float_t tMargin = 0.05); void multipad() { gStyle->SetOptStat(0); TCanvas *C = (TCanvas*) gROOT->FindObject("C"); if (C) delete C; C = new TCanvas("C","canvas",1024,640); C->SetFillStyle(4000); ifstream f1; ifstream f2; ifstream f3; double Evt, q0, Pvis, Q2, q3; f1.open ("DUNECCQEnew.dat"); f2.open ("DUNECCQERPAnew.dat"); f3.open ("DUNECC2p2hnew.dat"); // Number of PADS const Int_t Nx = 3; const Int_t Ny = 2; // Margins Float_t lMargin = 0.12; Float_t rMargin = 0.05; Float_t bMargin = 0.15; Float_t tMargin = 0.05; // Canvas setup CanvasPartition(C,Nx,Ny,lMargin,rMargin,bMargin,tMargin); // Dummy histogram. TH1F *h1 = new TH1F("h1", "0 < q_{3}/GeV <0.2", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h2 = new TH1F("h2", "0.2 < q_{3}/GeV <0.3", 25,0.0,.5); TH1F *h3 = new TH1F("h3", "0.3 < q_{3}/GeV <0.4", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h4 = new TH1F("h4", "0.4 < q_{3}/GeV <0.5", 25,0.0,.5); TH1F *h5 = new TH1F("h5", "0.5 < q_{3}/GeV <0.6", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h6 = new TH1F("h6", "0.6 < q_{3}/GeV <0.8", 25,0.0,.5); TH1F *h11 = new TH1F("h11", "0 < q_{3}/GeV <0.2", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h22 = new TH1F("h22", "0.2 < q_{3}/GeV <0.3", 25,0.0,.5); TH1F *h33 = new TH1F("h33", "0.3 < q_{3}/GeV <0.4", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h44 = new TH1F("h44", "0.4 < q_{3}/GeV <0.5", 25,0.0,.5); TH1F *h55 = new TH1F("h55", "0.5 < q_{3}/GeV <0.6", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h66 = new TH1F("h66", "0.6 < q_{3}/GeV <0.8", 25,0.0,.5); TH1F *h11a = new TH1F("h11a", "", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h22a = new TH1F("h22a", "", 25,0.0,.5); TH1F *h33a = new TH1F("h33a", "", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h44a = new TH1F("h44a", "", 25,0.0,.5); TH1F *h55a = new TH1F("h55a", "", 25,0.0,.5); // here p1 u hv already used as variable so can nt use it as histogram name TH1F *h66a = new TH1F("h66a", "", 25,0.0,.5); /* TH1F *h = (TH1F*) gROOT->FindObject("histo"); // if (h) delete h; h = new TH1F("histo","",100,0,0.5); //range of Xaxis h->FillRandom("gaus",10000); h->GetXaxis()->SetTitle("x axis"); h->GetYaxis()->SetTitle("y axis");*/ while(!f1.eof()) { f1>>Evt>>q0>>Pvis>>Q2>>q3; if(q3>0.0 && q3<0.2) {h1->Fill(q0);} if(q3>0.2 && q3<0.3) {h2->Fill(q0);} if(q3>0.3 && q3<0.4) {h3->Fill(q0);} if(q3>0.4 && q3<0.5) {h4->Fill(q0);} if(q3>0.5 && q3<0.6) {h5->Fill(q0);} if(q3>0.6 && q3<0.8) {h6->Fill(q0);} } while(!f2.eof()) { f2>>Evt>>q0>>Pvis>>Q2>>q3; if(q3>0.0 && q3<0.2) {h11->Fill(q0);} if(q3>0.2 && q3<0.3) {h22->Fill(q0);} if(q3>0.3 && q3<0.4) {h33->Fill(q0);} if(q3>0.4 && q3<0.5) {h44->Fill(q0);} if(q3>0.5 && q3<0.6) {h55->Fill(q0);} if(q3>0.6 && q3<0.8) {h66->Fill(q0);} } while(!f3.eof()) { f3>>Evt>>q0>>Pvis>>Q2>>q3; if(q3>0.0 && q3<0.2) {h11a->Fill(q0);} if(q3>0.2 && q3<0.3) {h22a->Fill(q0);} if(q3>0.3 && q3<0.4) {h33a->Fill(q0);} if(q3>0.4 && q3<0.5) {h44a->Fill(q0);} if(q3>0.5 && q3<0.6) {h55a->Fill(q0);} if(q3>0.6 && q3<0.8) {h66a->Fill(q0);} } gStyle->SetOptStat(0); h1->Scale(1/8.665e25); h11->Scale(1/8.665e25); h11a->Scale(1/8.665e25); h1->GetXaxis()->SetTitle("Reconstructed available energy(GeV)"); h11->GetYaxis()->SetTitle("d^{2}#sigma/dE_{avail}dq_{3}(10^{-42}cm^{2}/GeV^{2})"); h1->GetYaxis()->CenterTitle(); h1->GetYaxis()->SetTitleOffset(1.0); h1->GetXaxis()->CenterTitle(); h1->SetLineWidth(1); h11->SetLineWidth(1); h11->SetLineColor(3); h11a->SetLineColor(2); h1->SetMarkerStyle(21); h1->GetXaxis()->SetTitleSize(0.04); h1->GetYaxis()->SetTitleSize(0.04); h1->SetMaximum(0.5e-21); TH1F *h1c = (TH1F*) h1->Clone(); h11->Add(h1c); h11a->Add(h11); h11->GetYaxis()->SetRangeUser(0.0,0.5e-21); h2->Scale(1/8.665e25); // Here we have devide the events by No of Target* Ave Flux h22->Scale(1/8.665e25); h22a->Scale(1/8.665e25); h2->GetXaxis()->SetTitle("Reconstructed available energy(GeV)"); h2->GetYaxis()->SetTitle("Events"); h2->GetYaxis()->CenterTitle(); h2->GetYaxis()->SetTitleOffset(1.0); h2->GetXaxis()->CenterTitle(); h2->SetLineWidth(1); h22->SetLineWidth(1); h22->SetLineColor(3); h22a->SetLineColor(2); // h1->SetMarkerStyle(21); h2->GetXaxis()->SetTitleSize(0.04); h2->GetYaxis()->SetTitleSize(0.04); h2->SetMaximum(0.5e-21); TH1F *h2c = (TH1F*) h2->Clone(); h22->Add(h2c); h22a->Add(h22); // h22->Draw(); // h2->Draw("same"); // h22a->Draw("same"); h22->GetYaxis()->SetRangeUser(0.0,0.5e-21); h3->Scale(1/8.665e25); h33->Scale(1/8.665e25); h33a->Scale(1/8.665e25); h3->GetXaxis()->SetTitle("Reconstructed available energy(GeV)"); h3->GetYaxis()->SetTitle("Events"); h3->GetYaxis()->CenterTitle(); h3->GetYaxis()->SetTitleOffset(1.0); h3->GetXaxis()->CenterTitle(); h3->SetLineWidth(1); h33->SetLineWidth(1); h33->SetLineColor(3); h33a->SetLineColor(2); // h1->SetMarkerStyle(21); h3->GetXaxis()->SetTitleSize(0.04); h3->GetYaxis()->SetTitleSize(0.04); h3->SetMaximum(0.5e-21); TH1F *h3c = (TH1F*) h3->Clone(); h33->Add(h3c); h33a->Add(h33); // h33->Draw(); // h3->Draw("same"); // h33a->Draw("same"); h33->GetYaxis()->SetRangeUser(0.0,0.5e-21); TPad *pad[Nx][Ny]; for (Int_t i=0;icd(0); // Get the pads previously created. char pname[16]; sprintf(pname,"pad_%i_%i",i,j); pad[i][j] = (TPad*) gROOT->FindObject(pname); pad[i][j]->Draw(); pad[i][j]->SetFillStyle(4000); pad[i][j]->SetFrameFillStyle(4000); pad[i][j]->cd(); // Size factors Float_t xFactor = pad[0][0]->GetAbsWNDC()/pad[i][j]->GetAbsWNDC(); Float_t yFactor = pad[0][0]->GetAbsHNDC()/pad[i][j]->GetAbsHNDC(); char hname[16]; sprintf(hname,"h_%i_%i",i,j); TH1F *hFrame = (TH1F*) h->Clone(hname); hFrame->Reset(); hFrame->Draw(); // y axis range hFrame->GetYaxis()->SetRangeUser(0,0.5e-21); // range of Yaxis // Format for y axis hFrame->GetYaxis()->SetLabelFont(43); hFrame->GetYaxis()->SetLabelSize(16); hFrame->GetYaxis()->SetLabelOffset(0.02); hFrame->GetYaxis()->SetTitleFont(43); hFrame->GetYaxis()->SetTitleSize(16); hFrame->GetYaxis()->SetTitleOffset(5); hFrame->GetYaxis()->CenterTitle(); hFrame->GetYaxis()->SetNdivisions(505); // TICKS Y Axis hFrame->GetYaxis()->SetTickLength(xFactor*0.04/yFactor); // Format for x axis hFrame->GetXaxis()->SetLabelFont(43); hFrame->GetXaxis()->SetLabelSize(16); hFrame->GetXaxis()->SetLabelOffset(0.02); hFrame->GetXaxis()->SetTitleFont(43); hFrame->GetXaxis()->SetTitleSize(16); hFrame->GetXaxis()->SetTitleOffset(5); hFrame->GetXaxis()->CenterTitle(); hFrame->GetXaxis()->SetNdivisions(505); // TICKS X Axis hFrame->GetXaxis()->SetTickLength(yFactor*0.06/xFactor); h->Draw("same"); } } C->cd(); } void CanvasPartition(TCanvas *C,const Int_t Nx,const Int_t Ny, Float_t lMargin, Float_t rMargin, Float_t bMargin, Float_t tMargin) { if (!C) return; // Setup Pad layout: Float_t vSpacing = 0.0; Float_t vStep = (1.- bMargin - tMargin - (Ny-1) * vSpacing) / Ny; Float_t hSpacing = 0.0; Float_t hStep = (1.- lMargin - rMargin - (Nx-1) * hSpacing) / Nx; Float_t vposd,vposu,vmard,vmaru,vfactor; Float_t hposl,hposr,hmarl,hmarr,hfactor; for (Int_t i=0;icd(0); char name[16]; sprintf(name,"pad_%i_%i",i,j); TPad *pad = (TPad*) gROOT->FindObject(name); if (pad) delete pad; pad = new TPad(name,"",hposl,vposd,hposr,vposu); pad->SetLeftMargin(hmarl); pad->SetRightMargin(hmarr); pad->SetBottomMargin(vmard); pad->SetTopMargin(vmaru); pad->SetFrameBorderMode(0); pad->SetBorderMode(0); pad->SetBorderSize(0); pad->Draw(); } } }