new analysis classes, not yet in build system
[u/mrichter/AliRoot.git] / HLT / JET / analysis / AliHLTJETAnalysisMerge.cxx
1 //-*- Mode: C++ -*-
2 // $Id: AliHLTJETAnalysisMerge.cxx  $
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 /** @file   AliHLTJETAnalysisMerge.cxx
20     @author Jochen Thaeder
21     @date   
22     @brief  Container merging analysis objects
23 */
24
25 // see header file for class documentation
26 // or
27 // refer to README to build package
28 // or
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31 #if __GNUC__>= 3
32    using namespace std;
33 #endif
34
35 #include "TCanvas.h"
36 #include "TH2F.h"
37
38 #include "AliHLTJETJets.h"
39
40 #include "AliHLTJETAnalysisMerge.h"
41 #include "AliHLTJETAnalysisJets.h"
42
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTJETAnalysisMerge)
45
46 /*
47  * ---------------------------------------------------------------------------------
48  *                            Constructor / Destructor
49  * ---------------------------------------------------------------------------------
50  */
51
52 //##################################################################################
53 AliHLTJETAnalysisMerge::AliHLTJETAnalysisMerge() :
54   fCanvasArray(NULL),
55   fAnalysisJetsArray(NULL) {
56   // see header file for class documentation
57   // or
58   // refer to README to build package
59   // or
60   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61   
62 }
63
64 //##################################################################################
65 AliHLTJETAnalysisMerge::~AliHLTJETAnalysisMerge() {
66   // see header file for class documentation
67
68   if ( fCanvasArray ) {
69     fCanvasArray->Clear();
70     delete fCanvasArray;
71   }
72   fCanvasArray = NULL;
73
74   if ( fAnalysisJetsArray ) {
75     fAnalysisJetsArray->Clear();
76     delete fAnalysisJetsArray;
77   }
78   fAnalysisJetsArray = NULL;
79 }
80
81 /*
82  * ---------------------------------------------------------------------------------
83  *                                   Initialize / Reset
84  * ---------------------------------------------------------------------------------
85  */
86
87 //##################################################################################
88 Int_t AliHLTJETAnalysisMerge::Initialize() {
89   // see header file for class documentation  
90
91   Int_t iResult = 0;
92
93   fCanvasArray = new TObjArray();
94   fCanvasArray->SetOwner();
95
96   fAnalysisJetsArray = new TObjArray();
97
98   return iResult;
99 }
100
101 /*
102  * ---------------------------------------------------------------------------------
103  *                                Setter - public
104  * ---------------------------------------------------------------------------------
105  */
106
107 //##################################################################################
108 void AliHLTJETAnalysisMerge::AddJets( AliHLTJETAnalysisJets* jets ) {
109   // see header file for class documentation  
110
111   fAnalysisJetsArray->Add( jets );
112
113   return;
114 }
115
116 /*
117  * ---------------------------------------------------------------------------------
118  *                             Output - private
119  * ---------------------------------------------------------------------------------
120  */
121
122 //##################################################################################
123 void AliHLTJETAnalysisMerge::CreateCanvas() {
124   // see header file for class documentation  
125
126   CreateCanvasSpectra();
127
128   CreateCanvasDelta();
129   
130   CreateCanvasMatched();
131
132   return;
133 }
134
135 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
136 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
137 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
138 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
139 ///                                                                                                              ///
140 //////                                               PRIVATE                                                  //////
141 ///                                                                                                              ///
142 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
143 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
144 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
145 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
146
147 /*
148  * ---------------------------------------------------------------------------------
149  *                             Output - private
150  * ---------------------------------------------------------------------------------
151  */
152
153 //##################################################################################
154 void AliHLTJETAnalysisMerge::CreateCanvasSpectra() {
155   // see header file for class documentation  
156
157   TString canvasName = "JetSpectra";
158   
159   AliHLTJETAnalysisJets* jets = 
160     reinterpret_cast<AliHLTJETAnalysisJets*>((*fAnalysisJetsArray)[fAnalysisJetsArray->GetLast()]);     
161   
162   // -- Spectra E_t
163   // ----------------
164   TCanvas* canvas = AddCanvas( Form("E_{t} ")+canvasName, 3, 3 );
165
166   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
167                                               AliHLTJETAnalysisBase::kSpectraRecoAll),kTRUE, kFALSE);
168   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
169                                               AliHLTJETAnalysisBase::kSpectraRecoMatched),kTRUE, kFALSE);
170   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
171                                               AliHLTJETAnalysisBase::kSpectraRecoUnmatched),kTRUE, kFALSE);
172
173   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
174                                               AliHLTJETAnalysisBase::kSpectraRecoLeadAll),kTRUE, kFALSE);
175   DrawHistogram(canvas, 5, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
176                                               AliHLTJETAnalysisBase::kSpectraRecoLeadMatched),kTRUE, kFALSE);
177   DrawHistogram(canvas, 6, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
178                                               AliHLTJETAnalysisBase::kSpectraRecoLeadUnmatched),kTRUE, kFALSE);
179
180   DrawHistogram(canvas, 7, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
181                                               AliHLTJETAnalysisBase::kSpectraPythiaAll),kTRUE, kFALSE);
182   DrawHistogram(canvas, 8, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
183                                               AliHLTJETAnalysisBase::kSpectraPythiaMatched),kTRUE, kFALSE);
184   DrawHistogram(canvas, 9, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEt, 
185                                               AliHLTJETAnalysisBase::kSpectraPythiaUnmatched),kTRUE, kFALSE);
186   
187   // -- Spectra eta
188   // ----------------
189   canvas = AddCanvas( Form("#eta ")+canvasName, 3, 3 );
190
191   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
192                                               AliHLTJETAnalysisBase::kSpectraRecoAll),kTRUE, kFALSE);
193   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
194                                               AliHLTJETAnalysisBase::kSpectraRecoMatched),kTRUE, kFALSE);
195   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
196                                               AliHLTJETAnalysisBase::kSpectraRecoUnmatched),kTRUE, kFALSE);
197
198   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
199                                               AliHLTJETAnalysisBase::kSpectraRecoLeadAll),kTRUE, kFALSE);
200   DrawHistogram(canvas, 5, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
201                                               AliHLTJETAnalysisBase::kSpectraRecoLeadMatched),kTRUE, kFALSE);
202   DrawHistogram(canvas, 6, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
203                                               AliHLTJETAnalysisBase::kSpectraRecoLeadUnmatched),kTRUE, kFALSE);
204
205   DrawHistogram(canvas, 7, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
206                                               AliHLTJETAnalysisBase::kSpectraPythiaAll),kTRUE, kFALSE);
207   DrawHistogram(canvas, 8, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
208                                               AliHLTJETAnalysisBase::kSpectraPythiaMatched),kTRUE, kFALSE);
209   DrawHistogram(canvas, 9, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraEta, 
210                                               AliHLTJETAnalysisBase::kSpectraPythiaUnmatched),kTRUE, kFALSE);
211
212   // -- Spectra phi
213   // ----------------
214   canvas = AddCanvas( Form("#phi ")+canvasName, 3, 3);
215   
216   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
217                                               AliHLTJETAnalysisBase::kSpectraRecoAll),kTRUE, kFALSE);
218   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
219                                               AliHLTJETAnalysisBase::kSpectraRecoMatched),kTRUE, kFALSE);
220   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
221                                               AliHLTJETAnalysisBase::kSpectraRecoUnmatched),kTRUE, kFALSE);
222
223   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
224                                               AliHLTJETAnalysisBase::kSpectraRecoLeadAll),kTRUE, kFALSE);
225   DrawHistogram(canvas, 5, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
226                                               AliHLTJETAnalysisBase::kSpectraRecoLeadMatched),kTRUE, kFALSE);
227   DrawHistogram(canvas, 6, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
228                                               AliHLTJETAnalysisBase::kSpectraRecoLeadUnmatched),kTRUE, kFALSE);
229
230   DrawHistogram(canvas, 7, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
231                                               AliHLTJETAnalysisBase::kSpectraPythiaAll),kTRUE, kFALSE);
232   DrawHistogram(canvas, 8, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
233                                               AliHLTJETAnalysisBase::kSpectraPythiaMatched),kTRUE, kFALSE);
234   DrawHistogram(canvas, 9, jets->GetHistogram(AliHLTJETAnalysisBase::kHistSpectraPhi, 
235                                               AliHLTJETAnalysisBase::kSpectraPythiaUnmatched),kTRUE, kFALSE);
236
237   return;
238 }
239
240 //##################################################################################
241 void AliHLTJETAnalysisMerge::CreateCanvasDelta() {
242   // see header file for class documentation  
243
244   TString canvasName = "JetDelta";
245   
246   AliHLTJETAnalysisJets* jets = 
247     reinterpret_cast<AliHLTJETAnalysisJets*>((*fAnalysisJetsArray)[fAnalysisJetsArray->GetLast()]);     
248   
249   // -- Delta E_t
250   // --------------
251   TCanvas* canvas = AddCanvas( Form("#DeltaE_{t} ")+canvasName, 2, 2 );
252
253   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEt, 
254                                               AliHLTJETAnalysisBase::kDeltaAll),kTRUE, kFALSE);
255   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEt, 
256                                               AliHLTJETAnalysisBase::kDeltaMatchedAll),kTRUE, kFALSE);
257   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEt, 
258                                               AliHLTJETAnalysisBase::kDeltaLead),kTRUE, kFALSE);
259   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEt, 
260                                               AliHLTJETAnalysisBase::kDeltaMatchedLead),kTRUE, kFALSE);
261
262   // -- Delta Eta
263   // --------------
264   canvas = AddCanvas( Form("#Delta#eta} ")+canvasName, 2, 2 );
265
266   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEta, 
267                                               AliHLTJETAnalysisBase::kDeltaAll),kTRUE, kFALSE);
268   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEta, 
269                                               AliHLTJETAnalysisBase::kDeltaMatchedAll),kTRUE, kFALSE);
270   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEta, 
271                                               AliHLTJETAnalysisBase::kDeltaLead),kTRUE, kFALSE);
272   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaEta, 
273                                               AliHLTJETAnalysisBase::kDeltaMatchedLead),kTRUE, kFALSE);
274
275   // -- Delta Phi
276   // --------------
277   canvas = AddCanvas( Form("#Delta#phi ")+canvasName, 2, 2 );
278
279   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaPhi, 
280                                               AliHLTJETAnalysisBase::kDeltaAll),kTRUE, kFALSE);
281   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaPhi, 
282                                               AliHLTJETAnalysisBase::kDeltaMatchedAll),kTRUE, kFALSE);
283   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaPhi, 
284                                               AliHLTJETAnalysisBase::kDeltaLead),kTRUE, kFALSE);
285   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistDeltaPhi, 
286                                               AliHLTJETAnalysisBase::kDeltaMatchedLead),kTRUE, kFALSE);
287
288   // -- Delta Eta Delta Phi
289   // ------------------------
290   canvas = AddCanvas( Form("#Delta#eta#Delta#phi ")+canvasName, 2, 2 );
291
292   DrawHistogram(canvas, 1, jets->GetHistogram( AliHLTJETAnalysisBase::kHistDeltaEtaDeltaPhi, 
293                                                AliHLTJETAnalysisBase::kDeltaAll ),kTRUE, kFALSE);
294   DrawHistogram(canvas, 2, jets->GetHistogram( AliHLTJETAnalysisBase::kHistDeltaEtaDeltaPhi, 
295                                                AliHLTJETAnalysisBase::kDeltaMatchedAll ),kTRUE, kFALSE);
296   DrawHistogram(canvas, 3, jets->GetHistogram( AliHLTJETAnalysisBase::kHistDeltaEtaDeltaPhi, 
297                                                AliHLTJETAnalysisBase::kDeltaLead ),kTRUE, kFALSE);
298   DrawHistogram(canvas, 4, jets->GetHistogram( AliHLTJETAnalysisBase::kHistDeltaEtaDeltaPhi, 
299                                                AliHLTJETAnalysisBase::kDeltaMatchedLead ),kTRUE, kFALSE);
300
301   return;
302 }
303
304 //##################################################################################
305 void AliHLTJETAnalysisMerge::CreateCanvasMatched() {
306   // see header file for class documentation  
307
308   TString canvasName = "JetMatched";
309   
310   AliHLTJETAnalysisJets* jets = 
311     reinterpret_cast<AliHLTJETAnalysisJets*>((*fAnalysisJetsArray)[fAnalysisJetsArray->GetLast()]);     
312   
313   // -- Resolutions
314   // ----------------
315   TCanvas* canvas = AddCanvas( Form("Correlations + Resolutions")+canvasName, 2, 3 );
316
317   DrawHistogram(canvas, 1, jets->GetHistogram(AliHLTJETAnalysisBase::kHistCorrelationsJetEt, 
318                                               AliHLTJETAnalysisBase::kPlotAll),kTRUE, kFALSE);
319   DrawHistogram(canvas, 2, jets->GetHistogram(AliHLTJETAnalysisBase::kHistCorrelationsJetEt, 
320                                               AliHLTJETAnalysisBase::kPlotLead),kTRUE, kFALSE);
321
322   DrawHistogram(canvas, 3, jets->GetHistogram(AliHLTJETAnalysisBase::kHistResolutionsJetEt,
323                                               AliHLTJETAnalysisBase::kPlotAll),kTRUE, kFALSE);
324   DrawHistogram(canvas, 4, jets->GetHistogram(AliHLTJETAnalysisBase::kHistResolutionsJetEt, 
325                                               AliHLTJETAnalysisBase::kPlotLead),kTRUE, kFALSE);
326
327   DrawHistogram(canvas, 5, jets->GetHistogram(AliHLTJETAnalysisBase::kHistResolutionsDiJetEt, 
328                                               AliHLTJETAnalysisBase::kPlotAll),kTRUE, kFALSE);
329   DrawHistogram(canvas, 6, jets->GetHistogram(AliHLTJETAnalysisBase::kHistResolutionsDiJetEt, 
330                                               AliHLTJETAnalysisBase::kPlotLead),kTRUE, kFALSE);
331
332   return;
333 }
334
335 /*
336  * ---------------------------------------------------------------------------------
337  *                               Helper - private
338  * ---------------------------------------------------------------------------------
339  */
340
341 //##################################################################################
342 TCanvas* AliHLTJETAnalysisMerge::AddCanvas( TString name, Int_t divideX=1, Int_t divideY=1 ) {
343   // see header file for class documentation
344
345   fCanvasArray->Add (new TCanvas(name, name, 10, 10, 1400, 800));
346   reinterpret_cast<TCanvas*>((*fCanvasArray)[fCanvasArray->GetLast()])->Divide(divideX,divideY);
347   
348   return reinterpret_cast<TCanvas*>((*fCanvasArray)[fCanvasArray->GetLast()]);
349 }
350
351 //##################################################################################
352 void AliHLTJETAnalysisMerge::DrawHistogram( TCanvas* canvas, Int_t idx, TH1* hist, 
353                                             Bool_t bScale=kFALSE, Bool_t bLogY=kFALSE) {
354   // see header file for class documentation
355
356   if ( hist == NULL )
357     return;
358
359   TVirtualPad* pad = canvas->cd(idx);
360   
361   if ( bScale ) 
362     hist->Scale( 1./hist->GetBinWidth(0) );
363   
364   if ( bLogY && hist->GetEntries() != 0 )
365     pad->SetLogy();
366   
367   pad->SetGridy();
368   pad->SetGridx();
369   
370   if ( !strcmp(hist->ClassName(),"TH2F") )
371     hist->Draw("COLZ");
372   else 
373     hist->Draw("");
374   
375   return;
376 }