Draw spd mult histogram in viewer
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveMultCorr.cxx
1 #include "AliHLTEveMultCorr.h"
2 #include "TH1F.h"
3 #include "TH2F.h"
4 #include <iostream>
5 #include <TCanvas.h>
6 #include "AliHLTHOMERBlockDesc.h"
7 #include "TList.h"
8
9 AliHLTEveMultCorr::AliHLTEveMultCorr(const char* name): AliHLTEveBase(name)
10         ,fVzeroMultCanvas(0)
11         ,fZdcMultCanvas(0)
12         ,fTpcMultCanvas(0)
13         ,fCorrCanvas(0)
14         ,fEtCorrCanvas(0)
15         ,fZdcVzeroSpdCorrCanvas(0)
16 {
17
18 }
19
20 AliHLTEveMultCorr::~AliHLTEveMultCorr()
21 {
22 }
23
24 void AliHLTEveMultCorr::ResetElements()
25 {
26
27 }
28
29 void AliHLTEveMultCorr::UpdateElements()
30 {
31     fVzeroMultCanvas->Update();
32     fZdcMultCanvas->Update();
33     fTpcMultCanvas->Update();
34     fCorrCanvas->Update();
35     fEtCorrCanvas->Update();
36     fZdcVzeroSpdCorrCanvas->Update();
37
38 }
39
40 void AliHLTEveMultCorr::ProcessBlock(AliHLTHOMERBlockDesc* block)
41 {
42     TList *hlist = dynamic_cast<TList*>(block->GetTObject());
43     if (hlist)
44     {
45
46         if (hlist->Contains("fVzeroMult")) // These are the correlation histograms
47         {
48             TH1F *oneDf = 0;
49             TH2F *twoDf = 0;
50             int cd = 1;
51
52             //VZERO multiplicity hists
53             if (!fVzeroMultCanvas) 
54             {
55               fVzeroMultCanvas = CreateCanvas("V0 Mult", "V0 Multiplicities");
56               fVzeroMultCanvas->Divide(2, 2);
57             }
58             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fVzeroMult"));
59             AddHistogramToCanvas(oneDf, fVzeroMultCanvas, cd);
60             cd++;
61             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fVzeroMultAC"));
62             AddHistogramToCanvas(twoDf, fVzeroMultCanvas, cd);
63             cd++;
64             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fVzeroFlaggedMult"));
65             AddHistogramToCanvas(oneDf, fVzeroMultCanvas, cd);
66             cd++;
67             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fVzeroFlaggedMultAC"));
68             AddHistogramToCanvas(twoDf, fVzeroMultCanvas, cd);
69
70             cd = 1;
71             //ZDC multiplicity hists
72             if (!fZdcMultCanvas) 
73             {
74               fZdcMultCanvas = CreateCanvas("ZDC Mult", "ZDC Multiplicities");
75               fZdcMultCanvas->Divide(2, 4);
76             }
77             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcEzdc"));
78             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
79             cd++;
80             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcEzn"));
81             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
82             cd++;
83             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcEzp"));
84             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
85             cd++;
86             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcEzem"));
87             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
88             cd++;
89             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcNpart"));
90             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
91             cd++;
92             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fZdcB"));
93             AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
94             cd++;
95             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fZdcEzemEzdc"));
96             AddHistogramToCanvas(twoDf, fZdcMultCanvas, cd);
97
98             cd = 1;
99             // TPC multiplicity
100             if (!fTpcMultCanvas) 
101             {
102               fTpcMultCanvas = CreateCanvas("TPC Mult", "TPC Multiplicities");
103               fTpcMultCanvas->Divide(2, 2);
104             }
105             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fTpcNch2"));
106             AddHistogramToCanvas(oneDf, fTpcMultCanvas, cd);
107             cd++;
108             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fTpcNch3"));
109             AddHistogramToCanvas(oneDf, fTpcMultCanvas, cd);
110             cd++;
111             oneDf = dynamic_cast<TH1F*>(hlist->FindObject("fSpdNClusters"));
112             
113             AddHistogramToCanvas(oneDf, fTpcMultCanvas, cd);
114
115             cd = 1;
116             // Correlations
117             if (!fCorrCanvas) 
118             {
119               fCorrCanvas = CreateCanvas("Correlations", "Multiplicity Correlations");
120               fCorrCanvas->Divide(2, 3);
121             }
122             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzdcNch"));
123             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
124             cd++;
125             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzeroNch"));
126             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
127             cd++;
128             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrSpdTpcNch"));
129             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
130             cd++;
131             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzemNch"));
132             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
133             cd++;
134             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzdcVzero"));
135             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
136             cd++;
137             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzemVzero"));
138             AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
139             
140             cd = 1;
141             // ET Correlations
142             if (!fEtCorrCanvas) 
143             {
144               fEtCorrCanvas = CreateCanvas("E_{T} corr", "E_{T} Correlations");
145               fEtCorrCanvas->Divide(2, 3);
146             }
147             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrZdcTotEvsPhosTotEt"));
148             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
149             cd++;
150             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrZdcTotEvsEmcalTotEt"));
151             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
152             cd++;
153             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrZdcTotEvsTotEt"));
154             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
155             cd++;
156             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzerovsPhosTotEt"));
157             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
158             cd++;
159             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzerovsEmcalTotEt"));
160             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
161             cd++;
162             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzerovsTotEt"));
163             AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
164
165             cd = 1;
166             // ZDC,V0 vs SPD
167             if (!fZdcVzeroSpdCorrCanvas) 
168             {
169               fZdcVzeroSpdCorrCanvas = CreateCanvas("ZDC/V0 vs SPD", "ZDC/V0 vs. SPD");
170               fZdcVzeroSpdCorrCanvas->Divide(2, 3);
171               
172             }
173             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzeroSpd"));
174             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
175             cd++;
176             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzeroASpd"));
177             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
178             cd++;
179             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrVzeroCSpd"));
180             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
181             cd++;
182             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzdcSpd"));
183             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
184             cd++;
185             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzdcASpd"));
186             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
187             cd++;
188             twoDf = dynamic_cast<TH2F*>(hlist->FindObject("fCorrEzdcCSpd"));
189             AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
190         }
191         else
192         {
193             std::cout << "ERROR: This block does not contain what you think it contains!" << std::endl;
194         }
195     }
196     else
197     {
198       std::cout << "ERROR: There is no TList object in the block" << std::endl;
199     }
200
201
202 }
203
204 void AliHLTEveMultCorr::AddHistogramsToCanvas(AliHLTHOMERBlockDesc* /*block*/, TCanvas* /*canvas*/, Int_t& /*cdCount*/)
205 {
206 }
207
208 void AliHLTEveMultCorr::AddHistogramToCanvas(TH1* hist, TCanvas* canvas, Int_t& cdCount)
209 {
210     if (hist)
211     {
212         if (!strcmp(hist->ClassName(), "TH1F"))
213         {
214             canvas->cd(cdCount);
215             TPad * pad = dynamic_cast<TPad*>(canvas->cd(cdCount));
216             pad->SetLogy();
217             dynamic_cast<TH1F*>(hist)->Draw();
218         }
219         else if (!strcmp(hist->ClassName(), "TH2F"))
220         {
221             canvas->cd(cdCount);
222             dynamic_cast<TH2F*>(hist)->Draw("COLZ");
223         }
224         else
225         {
226             std::cout << "I don't want histograms of type " << hist->ClassName() << std::endl;
227         }
228     }
229     else
230     {
231       std::cout << "ERROR (AddHistogramsToCanvas): You gave me a null pointer" << std::endl;
232     }
233 }
234