]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TPC/AliPerformanceObject.cxx
bug fix and small changed in the macros
[u/mrichter/AliRoot.git] / PWG1 / TPC / AliPerformanceObject.cxx
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
36 using namespace std;
37
38 ClassImp(AliPerformanceObject)
39
40 //_____________________________________________________________________________
41 AliPerformanceObject::AliPerformanceObject():
42   TNamed("AliPerformanceObject","AliPerformanceObject"),
43   fAnalysisMode(-1),
44   fHptGenerator(kFALSE),
45   fTriggerClass(0)
46 {
47   // constructor
48 }
49
50 //_____________________________________________________________________________
51 AliPerformanceObject::AliPerformanceObject(const char* name, const char* title):
52   TNamed(name,title),
53   fAnalysisMode(-1),
54   fHptGenerator(kFALSE),
55   fTriggerClass(0)
56 {
57   // constructor
58 }
59
60 //_____________________________________________________________________________
61 AliPerformanceObject::~AliPerformanceObject(){
62   // destructor 
63 }
64
65 //_____________________________________________________________________________
66 void AliPerformanceObject::PrintHisto(Bool_t logz, Char_t * outFileName) {
67   // draw all histograms from the folder 
68   // and store them in the output *.ps file
69  
70   // use this folder
71   TFolder *folder = this->GetAnalysisFolder();
72   if (!folder) {
73      AliDebug(AliLog::kError, "folder not available");
74      return;
75   } 
76
77   TCanvas *can = new TCanvas("can");
78   can->Divide(2,2);
79
80   char fname[256];
81   const char* suffix=".ps"; 
82
83   if(outFileName) sprintf(fname,"%s",outFileName);
84   else sprintf(fname,"%s%s",folder->GetName(),suffix);
85   
86   TPostScript *ps = new TPostScript(fname,112);
87   Printf("Histograms are stored in %s", fname); 
88   TIter iter(folder->GetListOfFolders());
89
90   TH1 *obj = 0;
91   Int_t count = 0;
92   Int_t pad_count = 0;
93   while ((obj = (TH1*)iter()) !=0) {
94
95     // 4 figures per page
96     if((count%4) == 0) {
97       pad_count = 0;
98       ps->NewPage();
99     }
100
101     pad_count++; 
102     can->cd(pad_count);
103     
104     if(obj->TestBit(TH1::kLogX)) 
105        gPad->SetLogx(1);
106     else    
107        gPad->SetLogx(0);
108
109     if (obj->GetYaxis() && obj->GetZaxis()) {
110       if(logz) gPad->SetLogz();
111       obj->Draw("colz");
112     }
113     else { 
114       obj->SetMarkerStyle(24);
115       obj->SetMarkerSize(1.0);
116       obj->Draw();
117     }
118
119     if ((pad_count%4) == 0)  { 
120       can->Update();
121     }
122
123   //printf("count %d \n",count);
124   count++;
125   }
126   ps->Close();
127 }
128  
129
130 //_____________________________________________________________________________
131 Double_t * AliPerformanceObject::CreateLogAxis(Int_t nbins, Double_t xmin, Double_t xmax) {
132   // retun pointer to the array with log axis
133   // it is user responsibility to delete the array
134  
135   Double_t logxmin = TMath::Log10(xmin);
136   Double_t logxmax = TMath::Log10(xmax);
137   Double_t binwidth = (logxmax-logxmin)/nbins;
138   
139   Double_t *xbins =  new Double_t[nbins+1];
140
141   xbins[0] = xmin;
142   for (Int_t i=1;i<=nbins;i++) {
143     xbins[i] = xmin + TMath::Power(10,logxmin+i*binwidth);
144   }
145
146 return xbins;
147 }
148