#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" void simlemmarid() { int n=3; int c_YTitleSize=25; int c_YTitleFont=43; double c_YTitleOffset=1.; int c_YLabelFont=43; int c_YLabelSize=25; int c_XTitleSize=25; int c_XTitleFont=43; double c_XTitleOffset=1.1; int c_XLabelFont=43; int c_XLabelSize=25; float fillcolor=0.35; char dirin[50];//Directory where there is the input root file char dirout[50];//Main Directory where to save the output files char Volume1[50]; char dirv1[50]; char PDGname[50]; char PDGxname[50]; char countyname[50]; char htempname[50]; char outformat[50]; sprintf(dirin, "C:/"); sprintf(dirout, "C:/"); sprintf(dirv1, "Volume1/"); sprintf(Volume1, "B1Volume1"); sprintf(PDGname, "Particle PDG"); sprintf(htempname, "LEMMA"); sprintf(PDGxname, "PDG"); sprintf(countyname, "#Counts"); sprintf(outformat, "pdf"); TString myfilein = TString::Format("%sB1.root",dirin); gSystem->mkdir(TString::Format("%ssimulazione/", dirout), kTRUE); gSystem->mkdir(TString::Format("%ssimulazione/%s", dirout,dirv1), kTRUE); TString outfolder=TString::Format("%ssimulazione/",dirout); TString outfolderV1=TString::Format("%ssimulazione/%s",dirout,dirv1); TString cdnamePDGV1 = TString::Format("%s - %s",PDGname, Volume1); TString myplotpdgv1 = TString::Format("%s%s-%s.%s",outfolderV1.Data(), Volume1, PDGname, outformat); TString canvtitle = TString::Format("Simulation LEMMA"); TFile *fin = TFile::Open(myfilein); fin->ls (); TGaxis::SetMaxDigits(n); if (fin == 0) { printf("Error: cannot open the file!\n"); } else { TTree *t1=0; fin->GetObject(Volume1,t1); gStyle->SetOptFit(); gStyle->SetOptStat(111110); t1->SetLineColor(kBlue); //---------------------------------------------------------------------TARGET 1 -------------------------------------------------------------// TCanvas *c0 = new TCanvas("c0",canvtitle,1280,1024); t1->Draw(Form("ParticleID >> htemp(100, -25, 25)")); t1->GetHistogram()->SetTitle(cdnamePDGV1); t1->SetScanField(0); TH1F *htemppdgv1= (TH1F*)gPad->GetPrimitive("htemp"); htemppdgv1->GetXaxis()->SetTitle(PDGxname); htemppdgv1->GetYaxis()->SetTitle(countyname); htemppdgv1->GetYaxis()->SetTitleSize(c_YTitleSize); htemppdgv1->GetYaxis()->SetTitleFont(c_YTitleFont); htemppdgv1->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemppdgv1->GetYaxis()->SetLabelFont(c_YLabelFont); htemppdgv1->GetYaxis()->SetLabelSize(c_YLabelSize); htemppdgv1->GetXaxis()->SetTitleSize(c_XTitleSize); htemppdgv1->GetXaxis()->SetTitleFont(c_XTitleFont); htemppdgv1->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemppdgv1->GetXaxis()->SetLabelFont(c_XLabelFont); htemppdgv1->GetXaxis()->SetLabelSize(c_XLabelSize); htemppdgv1->SetFillColorAlpha(kBlue, fillcolor); htemppdgv1->Draw(); htemppdgv1->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c0->Update(); TLegend* legpdgv1 = new TLegend(0.25, 0.7, .35, .75); legpdgv1->SetHeader("Legend"); legpdgv1->SetNColumns(1); legpdgv1->AddEntry(htemppdgv1, "MC", "l"); legpdgv1->Draw(); c0->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statspdgv1 = (TPaveStats*)htemppdgv1->GetListOfFunctions()->FindObject("stats"); statspdgv1->SetTextColor(kBlue); statspdgv1->SetX1NDC(0.80); statspdgv1->SetX2NDC(0.98); statspdgv1->SetY1NDC(0.77); statspdgv1->SetY2NDC(0.92); statspdgv1->DrawClone(); gPad->Update(); c0->Print(myplotpdgv1); delete c0; } }