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