]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliPerformanceObject.cxx
PreReading of MC information on demand.
[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//_____________________________________________________________________________
3ccf3245 64void AliPerformanceObject::PrintHisto(Bool_t logz, Char_t * outFileName) {
777a0ba6 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";
3ccf3245 80
81 if(outFileName) sprintf(fname,"%s",outFileName);
82 else sprintf(fname,"%s%s",folder->GetName(),suffix);
83
777a0ba6 84 TPostScript *ps = new TPostScript(fname,112);
85 Printf("Histograms are stored in %s", fname);
86 TIter iter(folder->GetListOfFolders());
87
88 TH1 *obj = 0;
89 Int_t count = 0;
90 Int_t pad_count = 0;
91 while ((obj = (TH1*)iter()) !=0) {
92
93 // 4 figures per page
94 if((count%4) == 0) {
95 pad_count = 0;
96 ps->NewPage();
97 }
98
99 pad_count++;
100 can->cd(pad_count);
101
102 if(obj->TestBit(TH1::kLogX))
103 gPad->SetLogx(1);
104 else
105 gPad->SetLogx(0);
106
107 if (obj->GetYaxis() && obj->GetZaxis()) {
108 if(logz) gPad->SetLogz();
109 obj->Draw("colz");
110 }
111 else {
112 obj->SetMarkerStyle(24);
113 obj->SetMarkerSize(1.0);
114 obj->Draw();
115 }
116
117 if ((pad_count%4) == 0) {
118 can->Update();
119 }
120
121 //printf("count %d \n",count);
122 count++;
123 }
124 ps->Close();
125}
126
127
128//_____________________________________________________________________________
129Double_t * AliPerformanceObject::CreateLogAxis(Int_t nbins, Double_t xmin, Double_t xmax) {
130 // retun pointer to the array with log axis
131 // it is user responsibility to delete the array
132
133 Double_t logxmin = TMath::Log10(xmin);
134 Double_t logxmax = TMath::Log10(xmax);
135 Double_t binwidth = (logxmax-logxmin)/nbins;
136
137 Double_t *xbins = new Double_t[nbins+1];
138
139 xbins[0] = xmin;
140 for (Int_t i=1;i<=nbins;i++) {
141 xbins[i] = xmin + TMath::Power(10,logxmin+i*binwidth);
142 }
143
144return xbins;
145}
146