]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EVE/AliHLTEveBase.cxx
Merge branch 'devel'
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveBase.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        *
3  * ALICE Experiment at CERN, All rights reserved.                         *
4  *                                                                        *
5  * Primary Authors: Svein Lindal <slindal@fys.uio.no   >                  *
6  *                  for The ALICE HLT Project.                            *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 /// @file   AliHLTEveBase.cxx
18 /// @author Svein Lindal <slindal@fys.uio.no>
19 /// @brief  Base class for the HLT eve display detector elements
20
21
22 #include "AliHLTEveBase.h"
23 #include "AliHLTHOMERBlockDesc.h"
24 //#include "TCollection.h"
25 #include "AliEveHOMERManager.h"
26 #include "TCanvas.h"
27 #include "TEveWindow.h"
28 #include "TEveManager.h"
29 #include "TEveBrowser.h"
30 #include "TH1F.h"
31 #include "TH2F.h"
32
33 ClassImp(AliHLTEveBase);
34
35 AliHLTEveBase::AliHLTEveBase() : 
36   fEventManager(NULL), 
37   fCanvas(NULL),
38   fHistoCount(0)
39 {
40   // Constructor.
41 }
42
43 AliHLTEveBase::~AliHLTEveBase()
44 {
45   //Destructor
46
47   if(fCanvas) 
48     delete fCanvas;
49   fCanvas = NULL;
50
51   fEventManager = NULL;
52 }
53
54
55
56 TCanvas * AliHLTEveBase::CreateCanvas(TString  tabTitle, TString  canvasTitle ) {
57    //See header file for documentation
58
59   TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(fEventManager->GetEveManager()->GetBrowser()->GetTabRight());
60   slot->StartEmbedding();
61   TCanvas * canvas = new TCanvas(canvasTitle.Data(),canvasTitle.Data(), 600, 400);
62   slot->StopEmbedding(tabTitle.Data());
63
64   return canvas;
65 }
66
67 void AliHLTEveBase::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount ) {
68   //See header file for documentation
69    
70   if ( ! block->GetClassName().CompareTo("TObjArray")) {
71     TIter next((TObjArray*)(block->GetTObject()));
72     TObject *object;
73    
74     while (( object = (TObject*) next())) {
75       TH2F* histo = dynamic_cast<TH2F*>(object);
76       if(histo){
77         canvas->cd(++cdCount);
78         histo->Draw("COLZ");
79       } else {
80         TH1F* hist = dynamic_cast<TH1F*>(object);
81         if (hist) {
82           canvas->cd(++cdCount);
83           hist->Draw();
84         } else {
85           cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
86         }
87       }
88     }
89   }
90     
91   else if ( ! block->GetClassName().CompareTo("TH1F")) {
92
93     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
94     ++cdCount;
95     canvas->cd(cdCount);
96     histo->Draw();
97     
98   } 
99   
100   else if ( ! block->GetClassName().CompareTo("TH2F")) {
101     TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
102     if (histo) {
103       ++cdCount;
104       canvas->cd(cdCount);
105       histo->Draw("COLZ");
106     }
107   }
108
109   canvas->cd();
110 }
111
112