Coverity fixes
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveMultCorr.cxx
CommitLineData
2127802b 1#include "AliHLTEveMultCorr.h"
2#include "TH1F.h"
3#include "TH2F.h"
4#include <iostream>
5#include <TCanvas.h>
6#include "AliHLTHOMERBlockDesc.h"
0ff4c5eb 7#include "AliHLTEveHistoMerger.h"
2127802b 8#include "TList.h"
0ff4c5eb 9#include "AliLog.h"
2127802b 10
11AliHLTEveMultCorr::AliHLTEveMultCorr(const char* name): AliHLTEveBase(name)
12 ,fVzeroMultCanvas(0)
13 ,fZdcMultCanvas(0)
0ff4c5eb 14 ,fTrackMultCanvas(0)
2127802b 15 ,fCorrCanvas(0)
16 ,fEtCorrCanvas(0)
17 ,fZdcVzeroSpdCorrCanvas(0)
0ff4c5eb 18 ,fMerger(0)
19 ,fMyList(0)
2127802b 20{
0ff4c5eb 21 fMerger = new AliHLTEveHistoMerger();
2127802b 22}
23
24AliHLTEveMultCorr::~AliHLTEveMultCorr()
25{
0ff4c5eb 26 if(fMerger)
27 {
28 delete fMerger;
29 }
30 if(fMyList)
31 {
32 delete fMyList;
33 }
2127802b 34}
35
36void AliHLTEveMultCorr::ResetElements()
37{
38
39}
40
41void AliHLTEveMultCorr::UpdateElements()
42{
43 fVzeroMultCanvas->Update();
44 fZdcMultCanvas->Update();
0ff4c5eb 45 fTrackMultCanvas->Update();
2127802b 46 fCorrCanvas->Update();
47 fEtCorrCanvas->Update();
48 fZdcVzeroSpdCorrCanvas->Update();
49
50}
51
52void AliHLTEveMultCorr::ProcessBlock(AliHLTHOMERBlockDesc* block)
53{
0ff4c5eb 54 TString msg;
55
2127802b 56 TList *hlist = dynamic_cast<TList*>(block->GetTObject());
040245b5 57 if(!hlist)
0ff4c5eb 58 {
59 hlist = dynamic_cast<TList*>(fMerger->Process(hlist, block->GetSpecification()));
60 }
61 else
62 {
63 if(fMyList)
64 {
65 delete fMyList;
66 fMyList = 0;
67 }
68 fMyList = dynamic_cast<TList*>(hlist->Clone());
69 hlist = fMyList;
70 }
2127802b 71 if (hlist)
72 {
73
74 if (hlist->Contains("fVzeroMult")) // These are the correlation histograms
75 {
76 TH1F *oneDf = 0;
77 TH2F *twoDf = 0;
78 int cd = 1;
79
80 //VZERO multiplicity hists
81 if (!fVzeroMultCanvas)
82 {
0ff4c5eb 83 fVzeroMultCanvas = CreateCanvas("V0 M", "V0 Multiplicities");
2127802b 84 fVzeroMultCanvas->Divide(2, 2);
85 }
0ff4c5eb 86 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fVzeroMult"));
2127802b 87 AddHistogramToCanvas(oneDf, fVzeroMultCanvas, cd);
88 cd++;
0ff4c5eb 89 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fVzeroMultAC"));
2127802b 90 AddHistogramToCanvas(twoDf, fVzeroMultCanvas, cd);
91 cd++;
0ff4c5eb 92 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fVzeroFlaggedMult"));
2127802b 93 AddHistogramToCanvas(oneDf, fVzeroMultCanvas, cd);
94 cd++;
0ff4c5eb 95 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fVzeroFlaggedMultAC"));
2127802b 96 AddHistogramToCanvas(twoDf, fVzeroMultCanvas, cd);
97
98 cd = 1;
99 //ZDC multiplicity hists
100 if (!fZdcMultCanvas)
101 {
0ff4c5eb 102 fZdcMultCanvas = CreateCanvas("ZDC M", "ZDC Multiplicities");
103 fZdcMultCanvas->Divide(3, 3);
2127802b 104 }
0ff4c5eb 105 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcEzdc"));
2127802b 106 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
107 cd++;
0ff4c5eb 108 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcEzn"));
2127802b 109 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
110 cd++;
0ff4c5eb 111 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcEzp"));
2127802b 112 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
113 cd++;
0ff4c5eb 114 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcEzem"));
2127802b 115 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
116 cd++;
0ff4c5eb 117 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcNpart"));
2127802b 118 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
119 cd++;
0ff4c5eb 120 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fZdcB"));
2127802b 121 AddHistogramToCanvas(oneDf, fZdcMultCanvas, cd);
122 cd++;
0ff4c5eb 123 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fZdcEzemEzdc"));
2127802b 124 AddHistogramToCanvas(twoDf, fZdcMultCanvas, cd);
125
126 cd = 1;
127 // TPC multiplicity
0ff4c5eb 128 if (!fTrackMultCanvas)
2127802b 129 {
0ff4c5eb 130 fTrackMultCanvas = CreateCanvas("Track M", "Track Multiplicities");
131 fTrackMultCanvas->Divide(2, 2);
2127802b 132 }
0ff4c5eb 133 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fTpcNch2"));
134 AddHistogramToCanvas(oneDf, fTrackMultCanvas, cd);
2127802b 135 cd++;
0ff4c5eb 136 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fTpcNch3"));
137 AddHistogramToCanvas(oneDf, fTrackMultCanvas, cd);
9e34efc3 138 cd++;
0ff4c5eb 139 oneDf = dynamic_cast<TH1F*>(FindHistogram(hlist, "fSpdNClusters"));
9e34efc3 140
0ff4c5eb 141 AddHistogramToCanvas(oneDf, fTrackMultCanvas, cd);
2127802b 142
143 cd = 1;
144 // Correlations
145 if (!fCorrCanvas)
146 {
0ff4c5eb 147 fCorrCanvas = CreateCanvas("Corr", "Multiplicity Correlations");
148 fCorrCanvas->Divide(3, 2);
2127802b 149 }
0ff4c5eb 150 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzdcNch"));
2127802b 151 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
152 cd++;
0ff4c5eb 153 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzeroNch"));
2127802b 154 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
155 cd++;
0ff4c5eb 156 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrSpdTpcNch"));
2127802b 157 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
158 cd++;
0ff4c5eb 159 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzemNch"));
2127802b 160 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
161 cd++;
0ff4c5eb 162 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzdcVzero"));
2127802b 163 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
164 cd++;
0ff4c5eb 165 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzemVzero"));
2127802b 166 AddHistogramToCanvas(twoDf, fCorrCanvas, cd);
167
168 cd = 1;
169 // ET Correlations
170 if (!fEtCorrCanvas)
171 {
0ff4c5eb 172 fEtCorrCanvas = CreateCanvas("ET", "E_{T} Correlations");
173 fEtCorrCanvas->Divide(3, 2);
2127802b 174 }
0ff4c5eb 175 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrZdcTotEvsPhosTotEt"));
2127802b 176 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
177 cd++;
0ff4c5eb 178 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrZdcTotEvsEmcalTotEt"));
2127802b 179 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
180 cd++;
0ff4c5eb 181 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrZdcTotEvsTotEt"));
2127802b 182 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
183 cd++;
0ff4c5eb 184 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzerovsPhosTotEt"));
2127802b 185 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
186 cd++;
0ff4c5eb 187 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzerovsEmcalTotEt"));
2127802b 188 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
189 cd++;
0ff4c5eb 190 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzerovsTotEt"));
2127802b 191 AddHistogramToCanvas(twoDf, fEtCorrCanvas, cd);
192
193 cd = 1;
194 // ZDC,V0 vs SPD
195 if (!fZdcVzeroSpdCorrCanvas)
196 {
197 fZdcVzeroSpdCorrCanvas = CreateCanvas("ZDC/V0 vs SPD", "ZDC/V0 vs. SPD");
0ff4c5eb 198 fZdcVzeroSpdCorrCanvas->Divide(3, 2);
2127802b 199
200 }
0ff4c5eb 201 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzeroSpd"));
2127802b 202 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
203 cd++;
0ff4c5eb 204 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzeroASpd"));
2127802b 205 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
206 cd++;
0ff4c5eb 207 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrVzeroCSpd"));
2127802b 208 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
209 cd++;
0ff4c5eb 210 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzdcSpd"));
2127802b 211 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
212 cd++;
0ff4c5eb 213 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzdcASpd"));
2127802b 214 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
215 cd++;
0ff4c5eb 216 twoDf = dynamic_cast<TH2F*>(FindHistogram(hlist, "fCorrEzdcCSpd"));
2127802b 217 AddHistogramToCanvas(twoDf, fZdcVzeroSpdCorrCanvas, cd);
218 }
219 else
220 {
0ff4c5eb 221 AliWarning("This block does not contain what you think it contains!");
2127802b 222 }
223 }
224 else
225 {
0ff4c5eb 226 AliWarning("There is no TList object in the block");
2127802b 227 }
228
229
230}
231
232void AliHLTEveMultCorr::AddHistogramsToCanvas(AliHLTHOMERBlockDesc* /*block*/, TCanvas* /*canvas*/, Int_t& /*cdCount*/)
233{
234}
235
0ff4c5eb 236void AliHLTEveMultCorr::AddHistogramToCanvas(TH1* hist, TCanvas* canvas, Int_t& cdCount, Bool_t zoom)
2127802b 237{
0ff4c5eb 238
239 TString msg;
2127802b 240 if (hist)
241 {
242 if (!strcmp(hist->ClassName(), "TH1F"))
243 {
244 canvas->cd(cdCount);
9e34efc3 245 TPad * pad = dynamic_cast<TPad*>(canvas->cd(cdCount));
040245b5 246 if(pad) pad->SetLogy();
0ff4c5eb 247 if(zoom)
248 {
249 TH1F *h = dynamic_cast<TH1F*>(hist);
040245b5 250 if(h) h->GetXaxis()->SetRange(0, h->GetMaximumBin() + h->GetMaximumBin()*0.2);
0ff4c5eb 251 }
2127802b 252 dynamic_cast<TH1F*>(hist)->Draw();
253 }
254 else if (!strcmp(hist->ClassName(), "TH2F"))
255 {
256 canvas->cd(cdCount);
0ff4c5eb 257 if(zoom)
258 {
259 TH2F *h = dynamic_cast<TH2F*>(hist);
040245b5 260 if(h)
261 {
262 h->GetXaxis()->SetRange(0, h->GetMaximumBin() + h->GetMaximumBin()*0.2);
263 h->GetYaxis()->SetRange(0, h->GetMaximumBin() + h->GetMaximumBin()*0.2);
264 }
0ff4c5eb 265 }
2127802b 266 dynamic_cast<TH2F*>(hist)->Draw("COLZ");
267 }
268 else
0ff4c5eb 269 {
270 msg.Form("I don't want histograms of type %s", hist->ClassName());
271 AliWarning(msg.Data());
2127802b 272 }
273 }
274 else
275 {
0ff4c5eb 276 AliWarning("You gave me a null pointer!");
2127802b 277 }
278}
279
0ff4c5eb 280TH1* AliHLTEveMultCorr::FindHistogram(TCollection* coll, const char* name)
281{
282 TString msg;
283 TH1 *hist = dynamic_cast<TH1*>(coll->FindObject(name));
284 if(!hist)
285 {
286 msg.Form("Could not find object %s", name);
287 AliWarning(msg);
288 }
289 return hist;
290}