#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 #include #include #include "TCut.h" double mean; double stddev; double entries[10]; float fillcolor=0.35; double Epartmin=21.; //particle minimum energy double Epartmax=23.;//particle ma energy void xhitb21() { gStyle->SetOptStat(111110); gSystem->mkdir(TString::Format("graph"), kTRUE); TFile *fin = TFile::Open("setup/build/LemmaMC.root"); fin->ls (); if (fin == 0) { printf("Error: cannot open the file!\n"); } else { //int Idpart[4]= {-11,11,13,22}; //negativo int Idpart[4]= {-13,-11,11,22}; //positivo //int subdett[5]= {31,33,35,37,62}; //negativo int subdett[5]= {31,32,34,36,61}; //positivo for (int i=0; i<4; i++){ for (int j=0; j<5; j++){ gSystem->mkdir(TString::Format("graph/%d",Idpart[i]), kTRUE); gSystem->mkdir(TString::Format("graph/"), kTRUE); TTree *t=0; // t->SetBranchAddress("xhit", &entries[0]); fin->GetObject("LEMMA",t); t->SetScanField(0); TCanvas *c01 = new TCanvas("c01","",1280,1024); // c01->SetLogy(); t->SetLineColor(kBlue); TH1F *hhit = new TH1F("hhit", "", 100, 0., 0.); TString outputname = TString::Format("graph/%d/xhit_Idp=%d_subdet=%d.png",Idpart[i],Idpart[i],subdett[j]); TString hhitstring = TString::Format("xhit>> hhit"); TCut Idp = TString::Format("Idp==%d", Idpart[i]).Data(); TCut subdet = TString::Format("subdet==%d", subdett[j]).Data(); TCut enepartmincut = TString::Format("Kinev > %lg", Epartmin).Data(); TCut enepartmaxcut = TString::Format("Kinev < %lg", Epartmax).Data(); t->Draw(hhitstring, Idp && subdet); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(""); hhit->GetXaxis()->SetTitle("x position (mm)"); hhit->GetYaxis()->SetTitle("Counts"); hhit->GetXaxis()->SetLabelFont(43); hhit->GetXaxis()->SetLabelSize(30); hhit->GetYaxis()->SetLabelFont(43); hhit->GetYaxis()->SetLabelSize(30); hhit->GetXaxis()->SetTitleFont(43); hhit->GetXaxis()->SetTitleSize(30); hhit->GetYaxis()->SetTitleFont(43); hhit->GetYaxis()->SetTitleSize(30); hhit->SetFillColorAlpha(kBlue, fillcolor); //hhit->Draw("COL"); hhit->SetName("Title"); hhit->SetStats(0); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn /*TLegend* leg = new TLegend(0.65, 0.7, .75, .75); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(hhit, "Data", "l"); leg->Draw();*/ gPad->Update(); /* TPaveStats *stats = (TPaveStats*)hhit->GetListOfFunctions()->FindObject("stats"); stats->SetTextColor(kBlue); stats->SetX1NDC(0.80); stats->SetX2NDC(0.98); stats->SetY1NDC(0.77); stats->SetY2NDC(0.92);*/ gPad->Update(); // if (entries[0]!=NULL){ c01->Print(outputname); //} delete c01; } } } }