53 TLatex* pText=
new TLatex(posX,posY,text);
56 pText->SetTextColor(
col); pText->SetTextSize(size);
66 TString options =
"colz"; options += opt;
67 if(gPad->GetLogz() == 1 && h->GetMaximum()<
range) h->SetAxisRange(0.,
range,
"Z");
71 cout <<
"range "<<
range<<
" max "<<h->GetMaximum()<<
" min "<<h->GetMinimum()<<endl;
72 if( range < h->GetMaximum())
range = h->GetMaximum();
73 if(-
range > h->GetMinimum())
range = -1*h->GetMinimum();
75 if(h->GetMinimum() < 0.) h->SetAxisRange(-
range,
range,
"Z");
76 else h->SetAxisRange(0,
range,
"Z");
79 h->SetTitleOffset(0.8,
"T");
80 gPad->SetRightMargin(0.15);
81 h->DrawCopy(options.Data());
87 const Int_t NRGBs = 5;
88 const Int_t NCont = 99;
90 Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
91 Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
92 Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
93 Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
94 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
96 gStyle->SetNumberContours(NCont);
109 int entries = pad->GetListOfPrimitives()->GetEntries();
114 for(
int i=0;
i<entries;
i++){
115 name = pad->GetListOfPrimitives()->At(
i)->IsA()->GetName();
116 if( name.Contains(
"TH1") ){
117 TH1*
hist = (TH1*)pad->GetListOfPrimitives()->At(
i);
118 st = (TPaveStats*)hist->GetListOfFunctions()->FindObject(
"stats");
122 st->SetY1NDC(1-0.16*obj) ;
123 st->SetY2NDC( st->GetY1NDC()+0.15 ) ;
124 st->SetTextColor( hist->GetLineColor() );
125 st->SetLineColor( hist->GetLineColor() );
149 gStyle->SetOptFit ( 1011 );
150 gStyle->SetPaperSize(20,26);
151 gStyle->SetPadTopMargin(0.14);
152 gStyle->SetPadRightMargin(0.05);
153 gStyle->SetPadBottomMargin(0.14);
154 gStyle->SetPadLeftMargin(0.14);
155 gStyle->SetTextFont(22);
156 gStyle->SetTextSize(0.08);
157 gStyle->SetLabelFont(22,
"x");
158 gStyle->SetLabelFont(22,
"y");
159 gStyle->SetLabelFont(22,
"z");
160 gStyle->SetLabelSize(0.05,
"x");
161 gStyle->SetTitleSize(0.06,
"x");
162 gStyle->SetLabelSize(0.05,
"y");
163 gStyle->SetTitleSize(0.06,
"y");
164 gStyle->SetLabelSize(0.05,
"z");
165 gStyle->SetTitleSize(0.06,
"z");
167 gStyle->SetMarkerStyle(8);
168 gStyle->SetHistLineWidth(1);
169 gStyle->SetLineStyleString(2,
"[12 12]");
172 gStyle->SetOptTitle(1);
173 gStyle->SetOptStat(1);
174 gStyle->SetOptFit(1);
177 gStyle->SetPadTickX(1);
178 gStyle->SetPadTickY(1);
181 gStyle->SetNdivisions(509);
209 if( strcmp(gStyle->GetName(),
"PANDA")==0 )
return true;
223 TStyle *pandaStyle=
new TStyle(
"PANDA",
"PANDA approved plots style, modified by ralfk");
226 pandaStyle->SetFrameBorderMode(0);
227 pandaStyle->SetCanvasBorderMode(0);
228 pandaStyle->SetPadBorderMode(0);
229 pandaStyle->SetPadColor(0);
230 pandaStyle->SetCanvasColor(0);
231 pandaStyle->SetTitleColor(1);
232 pandaStyle->SetStatColor(0);
237 pandaStyle->SetTitleBorderSize(0);
238 pandaStyle->SetTitleColor(1);
239 pandaStyle->SetTitleFillColor(0);
240 pandaStyle->SetTitleFontSize(0.07);
243 pandaStyle->SetPaperSize(20,26);
244 pandaStyle->SetPadTopMargin(0.14);
245 pandaStyle->SetPadRightMargin(0.05);
246 pandaStyle->SetPadBottomMargin(0.14);
247 pandaStyle->SetPadLeftMargin(0.14);
259 pandaStyle->SetTextFont(22);
260 pandaStyle->SetTextSize(0.08);
261 pandaStyle->SetLabelFont(22,
"x");
262 pandaStyle->SetLabelFont(22,
"y");
263 pandaStyle->SetLabelFont(22,
"z");
264 pandaStyle->SetLabelSize(0.05,
"x");
265 pandaStyle->SetTitleSize(0.06,
"x");
266 pandaStyle->SetLabelSize(0.05,
"y");
267 pandaStyle->SetTitleSize(0.06,
"y");
268 pandaStyle->SetLabelSize(0.05,
"z");
269 pandaStyle->SetTitleSize(0.06,
"z");
272 pandaStyle->SetMarkerStyle(8);
273 pandaStyle->SetHistLineWidth(1);
274 pandaStyle->SetLineStyleString(2,
"[12 12]");
277 pandaStyle->SetOptTitle(1);
278 pandaStyle->SetOptStat(1);
279 pandaStyle->SetOptFit(1);
282 pandaStyle->SetPadTickX(1);
283 pandaStyle->SetPadTickY(1);
286 pandaStyle->SetNdivisions(509);
303 TH1D result(
"h1",
"h1", 1000, min, max);
304 int nbins = h2->GetNbinsX() * h2->GetNbinsY();
307 result.Fill(h2->GetBinContent(
i));
309 cout << h2->GetBinContent(
i) << endl;
320 if (!file) {cout<<
"File \""<<
filename.Data()<<
"\" is not there..."<<endl;
return true;}
321 TCanvas* can =
new TCanvas();
322 Int_t pixx = ceil(1.4*pix*divx);
323 Int_t pixy = pix*divy;
324 can->SetCanvasSize(pixx,pixy);
325 can->Divide(divx, divy);
328 ext.ReplaceAll(
"..",
".");
329 picname.ReplaceAll(
".root",
ext);
331 cout <<
"opening: " << pic.Data()<<endl;
335 TList* list = file->GetListOfKeys();
336 if (!list) {cout<<
"List not there..."<<endl;
return true;}
339 for(
int i=0;
i<list->GetEntries();
i++)
341 if(padcount > divx*divy)
343 can->Print(pic.Data());
345 can->SetCanvasSize(pixx,pixy);
346 can->Divide(divx, divy);
350 TKey*
key = (TKey*)list->At(
i);
351 keyclass = key->GetClassName();
353 if(keyclass.Contains(
"TH1"))
356 TH1* his = (TH1*)key->ReadObj();
357 his->GetXaxis()->SetNoExponent();
358 his->GetYaxis()->SetNoExponent();
359 TString options(his->GetOption());
360 if(options.Contains(
"log")){
362 options.ReplaceAll(
"log",
"");
363 his->SetOption(options.Data());
366 }
else if(keyclass.Contains(
"TH2"))
369 TH2* his2 = (TH2*)key->ReadObj();
370 his2->GetXaxis()->SetNoExponent();
371 his2->GetYaxis()->SetNoExponent();
372 TString options(his2->GetOption());
373 if(options.Contains(
"log")){
375 options.ReplaceAll(
"log",
"");
376 his2->SetOption(options.Data());
378 if(options.Contains(
"nice")){
379 options.ReplaceAll(
"nice",
"");
380 his2->SetOption(options.Data());
385 }
else if(keyclass.Contains(
"TProfile"))
388 TProfile* hpro = (TProfile*)key->ReadObj();
389 hpro->GetXaxis()->SetNoExponent();
390 hpro->GetYaxis()->SetNoExponent();
391 TString options(hpro->GetOption());
392 if(options.Contains(
"log")){
394 options.ReplaceAll(
"log",
"");
395 hpro->SetOption(options.Data());
403 can->Print(pic.Data());
405 can->Print(pic.Data());
406 cout <<
"closed: " << pic.Data()<<endl;
418 if (!file) {cout<<
"File \""<<
filename.Data()<<
"\" is not there..."<<endl;
return true;}
419 TCanvas* can =
new TCanvas();
420 Int_t pixx = ceil(1.4*pix*divx);
421 Int_t pixy = pix*divy;
422 can->SetCanvasSize(pixx,pixy);
423 can->Divide(divx, divy);
426 ext.ReplaceAll(
"..",
".");
427 picname.ReplaceAll(
".root",
ext);
429 cout <<
"opening: " << pic.Data()<<endl;
433 TList* list = file->GetListOfKeys();
434 if (!list) {cout<<
"List not there..."<<endl;
return true;}
437 for(
int i=0;
i<list->GetEntries();
i++)
439 TKey*
key = (TKey*)list->At(
i);
440 keyclass = key->GetClassName();
441 if(keyclass.CompareTo(
"TTree"))
continue;
442 TTree* baum = (TTree*)key->ReadObj();
443 printf(
"\t - Tree: %s\n",baum->GetName());
444 TObjArray* aeste = baum->GetListOfBranches();
445 for(
int asti=0;asti<aeste->GetEntriesFast();asti++)
447 TBranch* ast = (TBranch*)aeste->At(asti);
448 printf(
"\t\t - Branch: %s\n",ast->GetName());
449 TObjArray* bleatter = ast->GetListOfLeaves();
450 for(
int blatti=0;blatti<bleatter->GetEntriesFast();blatti++)
452 TLeaf* blatt = (TLeaf*)bleatter->At(blatti);
453 TString blattsorte=blatt->GetTypeName();
454 if( !blattsorte.CompareTo(
"Float_t") || !blattsorte.CompareTo(
"Int_t") || !blattsorte.CompareTo(
"Double_t"))
456 if(padcount > divx*divy)
458 printf(
" --- canvasdump ---");
459 can->Print(pic.Data());
461 can->SetCanvasSize(pixx,pixy);
462 can->Divide(divx, divy);
466 printf(
"\t\t\t - Leaf: %s (%s)\n",blatt->GetName(),blatt->GetTypeName());
467 baum->Draw(blatt->GetName());
473 can->Print(pic.Data());
475 can->Print(pic.Data());
476 cout <<
"closed: " << pic.Data()<<endl;
490 TIter
next(gROOT->GetListOfFiles());
492 TChain *
R=
new TChain(treename.Data());
493 while ( (fi=(TFile*)
next()) ) R->Add(fi->GetName());
494 cout<<(Int_t)R->GetEntries()<<endl;
500 cout <<
"-I- Using InitDefaultRun() from macro/run/Tools.C with the sim file " << filetag.Data() << endl;
501 FairRunAna*
fRun =
new FairRunAna();
502 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
504 filetag.ReplaceAll(
"_sim.root",
".root");
513 std::cout<<
"simFile="<<simFile.Data()<<std::endl;
514 std::cout<<
"parFile="<<parFile.Data()<<std::endl;
515 std::cout<<
"recoFile="<<recoFile.Data()<<std::endl;
516 std::cout<<
"trkFile="<<tracksFile.Data()<<std::endl;
517 std::cout<<
"pidFile="<<pidFile.Data()<<std::endl;
518 fRun->SetInputFile(simFile);
519 fRun->AddFriend(recoFile);
520 fRun->AddFriend(tracksFile);
521 fRun->AddFriend(pidFile);
522 FairParRootFileIo* parIO =
new FairParRootFileIo();
523 parIO->open(parFile.Data());
524 rtdb->setFirstInput(parIO);
525 rtdb->setOutput(parIO);
530 fRun->SetOutputFile(outFile.Data());
531 FairGeane* geane =
new FairGeane();
532 fRun->AddTask(geane);
540 Float_t rightmax = 1.1*hist->GetMaximum();
541 Float_t scale = gPad->GetUymax()/rightmax;
542 hist->SetLineColor(color);
547 TGaxis *
axis =
new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
548 gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,
"+L");
549 axis->SetLineColor(color);
550 axis->SetTextColor(color);
558 double range=1.1*his->GetMaximum();
559 his->SetAxisRange(0.,range,
"Y");
562 TF1* fitted =
new TF1(fitname.Data(),
"gaus",-5,5);
564 cout<<
" --- Fitting Gaussian to histogram "<<his->GetName()<<
" \""<<his->GetTitle()<<
"\" ---"<<endl;
565 fitted->SetLineColor(4);
566 fitted->SetLineWidth(2);
567 fitted->SetLineStyle(2);
569 fitted->GetParameters(par);
574 DrawText( 0.15, 0.8, str.Data(),0.06,1);
575 str=Form(
"#mu = %.3g",mean);
576 DrawText( 0.15, 0.73, str.Data(),0.06,1);
577 str=Form(
"#sigma = %.3g",sigma);
578 DrawText( 0.15, 0.66, str.Data(),0.06,1);
579 TH2F coloredbox(
"colbox",
";;",2,3.5,4.5,1,0.85*range,0.9*range);
580 coloredbox.Fill(3.8,0.86*range,2*mean+1.);
581 coloredbox.Fill(4.2,0.86*range,sigma);
582 coloredbox.SetAxisRange(0.,2.,
"Z");
583 coloredbox.DrawCopy(
"col same");
591 double range=1.1*his->GetMaximum();
592 his->SetAxisRange(0.,range,
"Y");
595 TF1* fitted =
new TF1(fitname.Data(),
"gaus",-5,5);
597 cout<<
" --- Fitting Gaussian to histogram "<<his->GetName()<<
" \""<<his->GetTitle()<<
"\" ---"<<endl;
598 fitted->SetLineColor(4);
599 fitted->SetLineWidth(2);
600 fitted->SetLineStyle(2);
602 fitted->GetParameters(par);
607 DrawText( 0.15, 0.8, str.Data(),0.06,1);
608 str=Form(
"#mu = %.3g",mean);
609 DrawText( 0.15, 0.73, str.Data(),0.06,1);
610 str=Form(
"#sigma = %.3g",sigma);
611 DrawText( 0.15, 0.66, str.Data(),0.06,1);
619 double range=1.2*his->GetMaximum();
620 his->SetAxisRange(0.,range,
"Y");
623 TF1* fitted =
new TF1(fitname.Data(),
"pol1",0.05,0.95);
624 cout<<
" --- Fitting Line to histogram "<<his->GetName()<<
" \""<<his->GetTitle()<<
"\" ---"<<endl;
625 fitted->SetLineColor(4);
626 fitted->SetLineWidth(2);
627 fitted->SetLineStyle(2);
628 his->Fit(fitted,
"R");
629 fitted->GetParameters(par);
632 DrawText( 0.2, 0.425, str.Data(),0.07,1);
633 str=Form(
"const = %.3g",par[0]);
634 DrawText( 0.2, 0.325, str.Data(),0.07,1);
635 str=Form(
"slope = %.2g",par[1]);
636 DrawText( 0.2, 0.225, str.Data(),0.07,1);
643 cout<<
"pandaroot/macro/run/Tools.C loaded. Enjoy it."<<endl;
void LineFitPlot(TH1 *his)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
std::string GetParFileName(std::string addon="", bool cut=false)
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
std::string GetSimFileName(std::string addon="", bool cut=false)
void GaussFitPlot(TH1 *his)
std::string GetRecoFileName(std::string addon="", bool cut=false)
A simple class which adds the corresponding file extensions to a given base class.
std::string GetCustomFileName(std::string ext, std::string addon="", bool cut=false)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
PndFileNameCreator namecreator("../data/Lars/MvdDtsSim.root")