]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/TPC/AliTPCClusterHistograms.cxx
adding AliTPCRawHistograms
[u/mrichter/AliRoot.git] / PWG0 / TPC / AliTPCClusterHistograms.cxx
CommitLineData
2d9e89d4 1/* $Id$ */
2
c50f9dc0 3// This class contains a number of histograms for diagnostics of a TPC
4// read out chamber from the reconstructed clusters.
5//
6// TODO:
7//
8//
9//
10
11#include "AliTPCClusterHistograms.h"
12
483b1eb8 13#include <TStyle.h>
2d9e89d4 14#include <TFile.h>
15#include <TCanvas.h>
16#include <TH2F.h>
17#include <TProfile2D.h>
483b1eb8 18#include <TLatex.h>
19
2d9e89d4 20#include <../TPC/AliTPCclusterMI.h>
2d9e89d4 21#include <AliLog.h>
22
2d9e89d4 23
24//____________________________________________________________________
25ClassImp(AliTPCClusterHistograms)
26
27//____________________________________________________________________
28AliTPCClusterHistograms::AliTPCClusterHistograms()
29 : TNamed(),
30 fhQmaxVsRow(0),
31 fhQtotVsRow(0),
32 fhSigmaYVsRow(0),
33 fhSigmaZVsRow(0),
34 fhQmaxProfileYVsRow(0),
35 fhQtotProfileYVsRow(0),
36 fhSigmaYProfileYVsRow(0),
483b1eb8 37 fhSigmaZProfileYVsRow(0),
38 fhQmaxProfileZVsRow(0),
39 fhQtotProfileZVsRow(0),
40 fhSigmaYProfileZVsRow(0),
41 fhSigmaZProfileZVsRow(0),
42 fhQtotVsTime(0),
1d7991a5 43 fhQmaxVsTime(0),
44 fIsIROC(kFALSE),
45 fEdgeSuppression(kFALSE)
2d9e89d4 46{
47 // default constructor
48}
49
50//____________________________________________________________________
1d7991a5 51AliTPCClusterHistograms::AliTPCClusterHistograms(Int_t detector, const Char_t* comment, Int_t timeStart, Int_t timeStop, Bool_t edgeSuppression)
483b1eb8 52 : TNamed(),
2d9e89d4 53 fhQmaxVsRow(0),
54 fhQtotVsRow(0),
55 fhSigmaYVsRow(0),
56 fhSigmaZVsRow(0),
57 fhQmaxProfileYVsRow(0),
58 fhQtotProfileYVsRow(0),
59 fhSigmaYProfileYVsRow(0),
483b1eb8 60 fhSigmaZProfileYVsRow(0),
61 fhQmaxProfileZVsRow(0),
62 fhQtotProfileZVsRow(0),
63 fhSigmaYProfileZVsRow(0),
64 fhSigmaZProfileZVsRow(0),
65 fhQtotVsTime(0),
1d7991a5 66 fhQmaxVsTime(0),
67 fIsIROC(kFALSE),
68 fEdgeSuppression(edgeSuppression)
2d9e89d4 69{
483b1eb8 70 // constructor
c50f9dc0 71
483b1eb8 72 // make name and title
483b1eb8 73 if (detector < 0 || detector >= 72) {
74 AliDebug(AliLog::kError, Form("Detector %d does not exist", detector));
75 return;
76 }
77
1d7991a5 78 TString name(FormDetectorName(detector, edgeSuppression, comment));
2d9e89d4 79
1d7991a5 80 if (detector < 36)
81 fIsIROC = kTRUE;
483b1eb8 82
83 SetName(name);
84 SetTitle(Form("%s (detector %d)",name.Data(), detector));
85
86 fTimeStart = timeStart;
87 fTimeStop = timeStop;
88
89 #define BINNING_Z 250, 0, 250
90
91 Float_t yRange = 45;
92 Int_t nPadRows = 96;
93
1d7991a5 94 if (fIsIROC)
95 {
483b1eb8 96 yRange = 25;
97 nPadRows = 63;
98 }
99
100 // 1 bin for each 0.5 cm
101 Int_t nBinsY = Int_t(4*yRange);
9cc7192c 102
1d7991a5 103 // do not add this hists to the directory
104 Bool_t oldStatus = TH1::AddDirectoryStatus();
105 TH1::AddDirectory(kFALSE);
106
c50f9dc0 107 //defining histograms and profile plots
483b1eb8 108 fhQmaxVsRow = new TH2F("QmaxVsPadRow", "Qmax vs. pad row;Pad row;Qmax", nPadRows+2, -1.5, nPadRows+0.5, 301, -0.5, 300.5);
109 fhQtotVsRow = new TH2F("QtotVsPadRow", "Qtot vs. pad row;Pad row;Qtot", nPadRows+2, -1.5, nPadRows+0.5, 400, 0, 4000);
2d9e89d4 110
483b1eb8 111 fhSigmaYVsRow = new TH2F("SigmaYVsPadRow", "Sigma Y vs. pad row;Pad row;#sigma_{Y}", nPadRows+2, -1.5, nPadRows+0.5, 100, 0, 0.5);
112 fhSigmaZVsRow = new TH2F("SigmaZVsPadRow", "Sigma Z vs. pad row;Pad row;#sigma_{Z}", nPadRows+2, -1.5, nPadRows+0.5, 100, 0, 0.5);
2d9e89d4 113
483b1eb8 114 fhQmaxProfileYVsRow = new TProfile2D("MeanQmaxYVsPadRow","Mean Qmax, y vs pad row;Pad row;y",nPadRows+2, -1.5, nPadRows+0.5, nBinsY, -yRange, yRange);
115 fhQtotProfileYVsRow = new TProfile2D("MeanQtotYVsPadRow","Mean Qtot, y vs pad row;Pad row;y",nPadRows+2, -1.5, nPadRows+0.5, nBinsY, -yRange, yRange);
116 fhSigmaYProfileYVsRow = new TProfile2D("MeanSigmaYVsPadRow","Mean Sigma y, y vs pad row;Pad row;y",nPadRows+2, -1.5, nPadRows+0.5, nBinsY, -yRange, yRange);
117 fhSigmaZProfileYVsRow = new TProfile2D("MeanSigmaYVsPadRow","Mean Sigma y, y vs pad row;Pad row;y",nPadRows+2, -1.5, nPadRows+0.5, nBinsY, -yRange, yRange);
2d9e89d4 118
483b1eb8 119 fhQmaxProfileZVsRow = new TProfile2D("MeanQmaxZVsPadRow","Mean Qmax, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
120 fhQtotProfileZVsRow = new TProfile2D("MeanQtotZVsPadRow","Mean Qtot, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
121 fhSigmaYProfileZVsRow = new TProfile2D("MeanSigmaZVsPadRow","Mean Sigma y, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
122 fhSigmaZProfileZVsRow = new TProfile2D("MeanSigmaZVsPadRow","Mean Sigma y, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
123
124 Int_t nTimeBins = 100;
125
126 fhQtotVsTime = new TProfile("MeanQtotVsTime", "Mean Qtot vs. event time stamp; time; Qtot",nTimeBins, fTimeStart, fTimeStop);
127 fhQmaxVsTime = new TProfile("MeanQmaxVsTime", "Mean Qmax vs. event time stamp; time; Qmax",nTimeBins, fTimeStart, fTimeStop);
128
1d7991a5 129 TH1::AddDirectory(oldStatus);
2d9e89d4 130}
131
132//____________________________________________________________________
133AliTPCClusterHistograms::AliTPCClusterHistograms(const AliTPCClusterHistograms& c) : TNamed(c)
134{
135 // copy constructor
136 ((AliTPCClusterHistograms &)c).Copy(*this);
137}
138
139//____________________________________________________________________
140AliTPCClusterHistograms::~AliTPCClusterHistograms()
141{
142 //
143 // destructor
144 //
145
146 if (fhQmaxVsRow) {
147 delete fhQmaxVsRow;
148 fhQmaxVsRow = 0;
149 }
150 if (fhQtotVsRow) {
151 delete fhQtotVsRow;
152 fhQtotVsRow = 0;
153 }
154 if (fhSigmaYVsRow) {
155 delete fhSigmaYVsRow;
156 fhSigmaYVsRow = 0;
157 }
158 if (fhSigmaZVsRow) {
159 delete fhSigmaZVsRow;
160 fhSigmaZVsRow = 0;
161 }
162 if (fhQmaxProfileYVsRow) {
163 delete fhQmaxProfileYVsRow;
164 fhQmaxProfileYVsRow = 0;
165 }
166 if (fhQtotProfileYVsRow) {
167 delete fhQtotProfileYVsRow;
168 fhQtotProfileYVsRow = 0;
169 }
170 if (fhSigmaYProfileYVsRow) {
171 delete fhSigmaYProfileYVsRow;
172 fhSigmaYProfileYVsRow = 0;
173 }
174 if (fhSigmaZProfileYVsRow) {
175 delete fhSigmaZProfileYVsRow;
176 fhSigmaZProfileYVsRow = 0;
177 }
483b1eb8 178 if (fhQmaxProfileZVsRow) {
179 delete fhQmaxProfileZVsRow;
180 fhQmaxProfileZVsRow = 0;
181 }
182 if (fhQtotProfileZVsRow) {
183 delete fhQtotProfileZVsRow;
184 fhQtotProfileZVsRow = 0;
185 }
186 if (fhSigmaYProfileZVsRow) {
187 delete fhSigmaYProfileZVsRow;
188 fhSigmaYProfileZVsRow = 0;
189 }
190 if (fhSigmaZProfileZVsRow) {
191 delete fhSigmaZProfileZVsRow;
192 fhSigmaZProfileZVsRow = 0;
193 }
2d9e89d4 194
483b1eb8 195 if (fhQtotVsTime) {
196 delete fhQtotVsTime;
197 fhQtotVsTime = 0;
198 }
199 if (fhQmaxVsTime) {
200 delete fhQmaxVsTime;
201 fhQmaxVsTime = 0;
202 }
2d9e89d4 203}
204
205//____________________________________________________________________
206AliTPCClusterHistograms &AliTPCClusterHistograms::operator=(const AliTPCClusterHistograms &c)
207{
208 // assigment operator
209
210 if (this != &c)
211 ((AliTPCClusterHistograms &) c).Copy(*this);
212
213 return *this;
214}
215
1d7991a5 216//____________________________________________________________________
217const char* AliTPCClusterHistograms::FormDetectorName(Int_t detector, Bool_t edgeSuppression, const char* comment)
218{
219 //
220 // creates a readable name from the detector number
221 //
222
223 Int_t sector = detector%18;
224 TString side;
225 TString inout;
226
227 if (detector<18 || ( detector>=36 && detector<54))
228 side.Form("A");
229 else
230 side.Form("B");
231
232 if (detector<36)
233 inout.Form("IROC");
234 else
235 inout.Form("OROC");
236
237 TString name;
238 name.Form("sector_%s%d_%s", side.Data(), sector, inout.Data());
239
240 if (edgeSuppression)
241 name += "_noedge";
242
243 if (comment)
244 name += comment;
245
246 return name;
247}
2d9e89d4 248
249//____________________________________________________________________
250Long64_t AliTPCClusterHistograms::Merge(TCollection* list)
251{
252 // Merge a list of AliTPCClusterHistograms objects with this (needed for
253 // PROOF).
254 // Returns the number of merged objects (including this).
255
256 if (!list)
257 return 0;
258
259 if (list->IsEmpty())
260 return 1;
261
262 TIterator* iter = list->MakeIterator();
263 TObject* obj;
264
265 // collections of measured and generated histograms
266 TList* collectionQmaxVsRow = new TList;
267 TList* collectionQtotVsRow = new TList;
268 TList* collectionSigmaYVsRow = new TList;
269 TList* collectionSigmaZVsRow = new TList;
270
271 TList* collectionQmaxProfileYVsRow = new TList;
272 TList* collectionQtotProfileYVsRow = new TList;
273 TList* collectionSigmaYProfileYVsRow = new TList;
274 TList* collectionSigmaZProfileYVsRow = new TList;
275
483b1eb8 276 TList* collectionQmaxProfileZVsRow = new TList;
277 TList* collectionQtotProfileZVsRow = new TList;
278 TList* collectionSigmaYProfileZVsRow = new TList;
279 TList* collectionSigmaZProfileZVsRow = new TList;
280
281 TList* collectionQtotVsTime = new TList;
282 TList* collectionQmaxVsTime = new TList;
283
2d9e89d4 284 Int_t count = 0;
285 while ((obj = iter->Next())) {
286
287 AliTPCClusterHistograms* entry = dynamic_cast<AliTPCClusterHistograms*> (obj);
288 if (entry == 0)
289 continue;
290
2d9e89d4 291 collectionQmaxVsRow ->Add(entry->fhQmaxVsRow );
292 collectionQtotVsRow ->Add(entry->fhQtotVsRow );
293 collectionSigmaYVsRow ->Add(entry->fhSigmaYVsRow );
294 collectionSigmaZVsRow ->Add(entry->fhSigmaZVsRow );
295
296 collectionQmaxProfileYVsRow ->Add(entry->fhQmaxProfileYVsRow );
297 collectionQtotProfileYVsRow ->Add(entry->fhQtotProfileYVsRow );
298 collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow);
299 collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow);
300
483b1eb8 301 collectionQmaxProfileZVsRow ->Add(entry->fhQmaxProfileZVsRow );
302 collectionQtotProfileZVsRow ->Add(entry->fhQtotProfileZVsRow );
303 collectionSigmaYProfileZVsRow->Add(entry->fhSigmaYProfileZVsRow);
304 collectionSigmaZProfileZVsRow->Add(entry->fhSigmaZProfileZVsRow);
305
306 collectionQtotVsTime->Add(entry->fhQtotVsTime);
307 collectionQmaxVsTime->Add(entry->fhQmaxVsTime);
308
309
2d9e89d4 310 count++;
311 }
312
313 fhQmaxVsRow ->Merge(collectionQmaxVsRow );
314 fhQtotVsRow ->Merge(collectionQtotVsRow );
315 fhSigmaYVsRow ->Merge(collectionSigmaYVsRow );
316 fhSigmaZVsRow ->Merge(collectionSigmaZVsRow );
317
318 fhQmaxProfileYVsRow ->Merge(collectionQmaxProfileYVsRow );
319 fhQtotProfileYVsRow ->Merge(collectionQtotProfileYVsRow );
320 fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow);
321 fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow);
322
483b1eb8 323 fhQmaxProfileZVsRow ->Merge(collectionQmaxProfileZVsRow );
324 fhQtotProfileZVsRow ->Merge(collectionQtotProfileZVsRow );
325 fhSigmaYProfileZVsRow->Merge(collectionSigmaYProfileZVsRow);
326 fhSigmaZProfileZVsRow->Merge(collectionSigmaZProfileZVsRow);
327
328 fhQtotVsTime->Merge(collectionQtotVsTime);
329 fhQmaxVsTime->Merge(collectionQmaxVsTime);
330
2d9e89d4 331 delete collectionQmaxVsRow;
332 delete collectionQtotVsRow;
333 delete collectionSigmaYVsRow;
334 delete collectionSigmaZVsRow;
335
336 delete collectionQmaxProfileYVsRow;
337 delete collectionQtotProfileYVsRow;
338 delete collectionSigmaYProfileYVsRow;
339 delete collectionSigmaZProfileYVsRow;
340
483b1eb8 341 delete collectionQmaxProfileZVsRow;
342 delete collectionQtotProfileZVsRow;
343 delete collectionSigmaYProfileZVsRow;
344 delete collectionSigmaZProfileZVsRow;
345
346 delete collectionQtotVsTime;
347 delete collectionQmaxVsTime;
348
2d9e89d4 349 return count+1;
350}
351
352//____________________________________________________________________
483b1eb8 353void AliTPCClusterHistograms::FillCluster(AliTPCclusterMI* cluster, Int_t time) {
2d9e89d4 354 //
c50f9dc0 355 // Fills the different histograms with the information from the cluster.
2d9e89d4 356 //
357
358 Int_t padRow = cluster->GetRow();
359 Float_t qMax = cluster->GetMax();
360 Float_t qTot = cluster->GetQ();
361 Float_t sigmaY = cluster->GetSigmaY2();
362 Float_t sigmaZ = cluster->GetSigmaZ2();
363 Float_t y = cluster->GetY();
483b1eb8 364 Float_t z = cluster->GetZ();
1d7991a5 365
366 if (fEdgeSuppression)
367 {
368 Float_t limit = 0;
369 if (fIsIROC)
370 {
371 limit = 12 + padRow * (20.0 - 12.0) / 63;
372 }
373 else
374 limit = 16 + padRow * (36.0 - 16.0) / 96;
375
376 if (TMath::Abs(y) > limit)
377 return;
378 }
2d9e89d4 379
380 fhQmaxVsRow ->Fill(padRow, qMax);
381 fhQtotVsRow ->Fill(padRow, qTot);
382
383 fhSigmaYVsRow ->Fill(padRow, sigmaY);
384 fhSigmaZVsRow ->Fill(padRow, sigmaZ);
385
386 fhQmaxProfileYVsRow ->Fill(padRow, y, qMax);
387 fhQtotProfileYVsRow ->Fill(padRow, y, qTot);
388 fhSigmaYProfileYVsRow ->Fill(padRow, y, sigmaY);
389 fhSigmaZProfileYVsRow ->Fill(padRow, y, sigmaZ);
483b1eb8 390
391 fhQmaxProfileZVsRow ->Fill(padRow, z, qMax);
392 fhQtotProfileZVsRow ->Fill(padRow, z, qTot);
393 fhSigmaYProfileZVsRow ->Fill(padRow, z, sigmaY);
394 fhSigmaZProfileZVsRow ->Fill(padRow, z, sigmaZ);
395
396 if (time>0 & fTimeStart>0 & fTimeStop>0 & time>fTimeStart) {
397 //Float_t timeFraction = (time - fTimeStart)/(fTimeStop-fTimeStart);
398
399 fhQtotVsTime->Fill(time,qTot);
400 fhQmaxVsTime->Fill(time,qMax);
401 }
402
2d9e89d4 403}
404
405
406//____________________________________________________________________
407void AliTPCClusterHistograms::SaveHistograms()
408{
409 //
410 // saves the histograms
411 //
412
413 gDirectory->mkdir(fName.Data());
414 gDirectory->cd(fName.Data());
415
416 fhQmaxVsRow ->Write();
417 fhQtotVsRow ->Write();
418
419 fhSigmaYVsRow ->Write();
420 fhSigmaZVsRow ->Write();
421
422 fhQmaxProfileYVsRow ->Write();
423 fhQtotProfileYVsRow ->Write();
424 fhSigmaYProfileYVsRow ->Write();
425 fhSigmaZProfileYVsRow ->Write();
426
483b1eb8 427 fhQmaxProfileZVsRow ->Write();
428 fhQtotProfileZVsRow ->Write();
429 fhSigmaYProfileZVsRow ->Write();
430 fhSigmaZProfileZVsRow ->Write();
431
432 if (fhQtotVsTime->GetEntries()>0)
433 fhQtotVsTime->Write();
434
435 if (fhQmaxVsTime->GetEntries()>0)
436 fhQmaxVsTime->Write();
437
2d9e89d4 438 gDirectory->cd("../");
439
440}
441
483b1eb8 442//____________________________________________________________________
1d7991a5 443TCanvas* AliTPCClusterHistograms::DrawHistograms(const Char_t* /*opt*/) {
c50f9dc0 444 //
445 // Draws some histograms and save the canvas as eps and gif file.
446 //
483b1eb8 447
1d7991a5 448 TCanvas* c = new TCanvas(fName.Data(), fName.Data(), 1200, 1000);
483b1eb8 449
450 gStyle->SetOptStat(0);
451 gStyle->SetOptFit(0);
452
6c3d6245 453 gStyle->SetPadLeftMargin(0.1);
483b1eb8 454
455 c->Divide(3,3);
456
457 c->Draw();
458
459 c->cd(1);
460
461 // this is not really a nice way to do it...
462 c->GetPad(1)->Delete();
463
464 TLatex* name = new TLatex(0.1,0.8,fName.Data());
465 name->SetTextSize(0.02);
466 name->DrawClone();
467
468 c->cd(2);
469 fhQmaxVsRow->Draw("colz");
470
471 c->cd(3);
472 fhQtotVsRow->Draw("colz");
473
474 c->cd(4);
475 fhQmaxProfileYVsRow ->Draw("colz");
476 c->cd(5);
477 fhQtotProfileYVsRow ->Draw("colz");
478 c->cd(6);
479 fhQmaxProfileZVsRow ->Draw("colz");
480 c->cd(7);
481 fhQtotProfileZVsRow ->Draw("colz");
482 c->cd(8);
483 fhSigmaYVsRow ->Draw("colz");
484
485 c->cd(9);
486 fhSigmaZVsRow ->Draw("colz");
487
488 //fhSigmaYProfileYVsRow ->Draw("colz");
489 //fhSigmaZProfileYVsRow ->Draw("colz");
490
491 //fhSigmaYProfileZVsRow ->Draw("colz");
492 //fhSigmaZProfileZVsRow ->Draw("colz");
493 return c;
494}