]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliPerformanceObject.cxx
Bug removal
[u/mrichter/AliRoot.git] / PWG1 / AliPerformanceObject.cxx
CommitLineData
777a0ba6 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16//------------------------------------------------------------------------------
17// Implementation of abstract AliPerformanceObject class. It keeps information from
18// comparison of reconstructed and MC particle tracks.
19//
20// Author: J.Otwinowski 14/04/2008
21//------------------------------------------------------------------------------
22
23#include <iostream>
24
25#include "TCanvas.h"
26#include "TH1.h"
27#include "TH2.h"
28#include "TAxis.h"
29#include "TPostScript.h"
30#include "TList.h"
31#include "TMath.h"
32
33#include "AliLog.h"
34#include "AliPerformanceObject.h"
35
36using namespace std;
37
38ClassImp(AliPerformanceObject)
39
40//_____________________________________________________________________________
41AliPerformanceObject::AliPerformanceObject():
42 TNamed("AliPerformanceObject","AliPerformanceObject"),
43 fAnalysisMode(-1),
44 fHptGenerator(kFALSE)
45{
46 // constructor
47}
48
49//_____________________________________________________________________________
50AliPerformanceObject::AliPerformanceObject(const char* name, const char* title):
51 TNamed(name,title),
52 fAnalysisMode(-1),
53 fHptGenerator(kFALSE)
54{
55 // constructor
56}
57
58//_____________________________________________________________________________
59AliPerformanceObject::~AliPerformanceObject(){
60 // destructor
61}
62
63//_____________________________________________________________________________
64void AliPerformanceObject::DrawHisto(Bool_t logz) {
65 // draw all histograms from the folder
66 // and store them in the output *.ps file
67
68 // use this folder
69 TFolder *folder = this->GetAnalysisFolder();
70 if (!folder) {
71 AliDebug(AliLog::kError, "folder not available");
72 return;
73 }
74
75 TCanvas *can = new TCanvas("can");
76 can->Divide(2,2);
77
78 char fname[256];
79 const char* suffix=".ps";
80 sprintf(fname,"%s%s",folder->GetName(),suffix);
81 TPostScript *ps = new TPostScript(fname,112);
82 Printf("Histograms are stored in %s", fname);
83 TIter iter(folder->GetListOfFolders());
84
85 TH1 *obj = 0;
86 Int_t count = 0;
87 Int_t pad_count = 0;
88 while ((obj = (TH1*)iter()) !=0) {
89
90 // 4 figures per page
91 if((count%4) == 0) {
92 pad_count = 0;
93 ps->NewPage();
94 }
95
96 pad_count++;
97 can->cd(pad_count);
98
99 if(obj->TestBit(TH1::kLogX))
100 gPad->SetLogx(1);
101 else
102 gPad->SetLogx(0);
103
104 if (obj->GetYaxis() && obj->GetZaxis()) {
105 if(logz) gPad->SetLogz();
106 obj->Draw("colz");
107 }
108 else {
109 obj->SetMarkerStyle(24);
110 obj->SetMarkerSize(1.0);
111 obj->Draw();
112 }
113
114 if ((pad_count%4) == 0) {
115 can->Update();
116 }
117
118 //printf("count %d \n",count);
119 count++;
120 }
121 ps->Close();
122}
123
124
125//_____________________________________________________________________________
126Double_t * AliPerformanceObject::CreateLogAxis(Int_t nbins, Double_t xmin, Double_t xmax) {
127 // retun pointer to the array with log axis
128 // it is user responsibility to delete the array
129
130 Double_t logxmin = TMath::Log10(xmin);
131 Double_t logxmax = TMath::Log10(xmax);
132 Double_t binwidth = (logxmax-logxmin)/nbins;
133
134 Double_t *xbins = new Double_t[nbins+1];
135
136 xbins[0] = xmin;
137 for (Int_t i=1;i<=nbins;i++) {
138 xbins[i] = xmin + TMath::Power(10,logxmin+i*binwidth);
139 }
140
141return xbins;
142}
143