#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 double mean; double stddev; //int subnumb=45; //central LG negativo //int subnumb=42 // central LG positivo int subnumb=37; //GEM negativo //int subnumb=36; //GEM positivo int subnumbHorsa=51; //HORSA float fillcolor=0.35; double EmaxLG=1.; //cut in the central LG double Epartmin=21.; //particle minimum energy double Epartmax=23.;//particle max energy double xmax=-160.; // max xhit tracker double xmin=-210.; //min xhit tracker double parID=0; //primary particle void calotb21() { 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 for (int i=0; i<4; i++){ gSystem->mkdir(TString::Format("graph/%d",Idpart[i]), kTRUE); for (int calorimetro=0; calorimetro <24; calorimetro++ ){ TTree *t=0; fin->GetObject("LEMMA",t); t->SetScanField(0); TCanvas *c01 = new TCanvas("c01","",1280,1024); // c01->SetLogy(); t->SetLineColor(kBlue); TString outputname = TString::Format("graph/%d/Calo_EnDep[%d]_Idp=%d_sub=%d_xmin_%lg-xmax_%lg.png", Idpart[i],calorimetro,Idpart[i],subnumb,xmin,xmax); TString henestring = TString::Format("Calo_EnDep[%d] >> htemp(100., 0., 0.)", calorimetro); TCut Idp = TString::Format("Idp==%d", Idpart[i]).Data(); TCut sub = TString::Format("subdet==%d", subnumb).Data(); TCut subHorsa = TString::Format("subdet==%d", subnumbHorsa).Data(); TCut xmaxcut = TString::Format("xhit < %lg", xmax).Data(); TCut xmincut = TString::Format("xhit > %lg", xmin).Data(); // TCut enecut = TString::Format("Calo_EnDep[%d] < %lg", calorimetro,EmaxLG).Data(); // TCut enepartmincut = TString::Format("Kinev > %lg", Epartmin).Data(); // TCut enepartmaxcut = TString::Format("Kinev < %lg", Epartmax).Data(); TCut Ipart = TString::Format("Ipar==%lg", parID).Data(); t->Draw(henestring, Idp && Ipart && sub && xmincut && xmaxcut); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(""); TH1F *hene = (TH1F*)gPad->GetPrimitive("htemp"); hene->SetFillStyle(1001); hene->GetXaxis()->SetTitle("Energy (GeV)"); hene->GetYaxis()->SetTitle("Counts"); hene->GetXaxis()->SetLabelFont(43); hene->GetXaxis()->SetLabelSize(30); hene->GetYaxis()->SetLabelFont(43); hene->GetYaxis()->SetLabelSize(30); hene->GetXaxis()->SetTitleFont(43); hene->GetXaxis()->SetTitleSize(30); hene->GetYaxis()->SetTitleFont(43); hene->GetYaxis()->SetTitleSize(30); hene->SetFillColorAlpha(kBlue, fillcolor); mean=hene->GetMean(); stddev=hene->GetRMS(); hene->Draw(); hene->SetName(""); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn /* TLegend* legenea = new TLegend(0.65, 0.7, .75, .75); legenea->SetHeader("Legend"); legenea->SetNColumns(1); legenea->AddEntry(hene, "Data", "l"); legenea->Draw();*/ gPad->Update(); TPaveStats *stats = (TPaveStats*)hene->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 (mean !=0 && stddev !=0){ c01->Print(outputname); } delete c01; } } } }