added AliTPCClusterHistograms
[u/mrichter/AliRoot.git] / PWG0 / TPC / AliTPCClusterHistograms.cxx
1 /* $Id$ */
2
3
4 #include <TFile.h>
5 #include <TCanvas.h>
6 #include <TH2F.h>
7 #include <TProfile2D.h>
8
9 #include <../TPC/AliTPCclusterMI.h>
10
11 #include <AliLog.h>
12
13 #include "AliTPCClusterHistograms.h"
14
15 //____________________________________________________________________
16 ClassImp(AliTPCClusterHistograms)
17
18 //____________________________________________________________________
19 AliTPCClusterHistograms::AliTPCClusterHistograms() 
20   : TNamed(),
21   fhQmaxVsRow(0),          
22   fhQtotVsRow(0),          
23   fhSigmaYVsRow(0),        
24   fhSigmaZVsRow(0),                             
25   fhQmaxProfileYVsRow(0), 
26   fhQtotProfileYVsRow(0),
27   fhSigmaYProfileYVsRow(0),
28   fhSigmaZProfileYVsRow(0)
29 {
30   // default constructor
31 }
32
33 //____________________________________________________________________
34 AliTPCClusterHistograms::AliTPCClusterHistograms(const Char_t* name, const Char_t* title) 
35   : TNamed(name, title),
36   fhQmaxVsRow(0),          
37   fhQtotVsRow(0),          
38   fhSigmaYVsRow(0),        
39   fhSigmaZVsRow(0),                             
40   fhQmaxProfileYVsRow(0), 
41   fhQtotProfileYVsRow(0),
42   fhSigmaYProfileYVsRow(0),
43   fhSigmaZProfileYVsRow(0)
44 {
45   // constructor initializing tnamed
46
47   fhQmaxVsRow  = new TH2F("QmaxVsPadRow", "Qmax vs. pad row;Pad row;Qmax", 91, -0.5, 90.5, 301, -0.5, 300.5);
48   fhQtotVsRow  = new TH2F("QtotVsPadRow", "Qtot vs. pad row;Pad row;Qtot", 91, -0.5, 90.5, 100,  0,  1000);
49   
50   fhSigmaYVsRow = new TH2F("SigmaYVsPadRow", "Sigma Y vs. pad row;Pad row;#sigma_{Y}", 91, -0.5, 90.5, 100,  0,  0.5);
51   fhSigmaZVsRow = new TH2F("SigmaZVsPadRow", "Sigma Z vs. pad row;Pad row;#sigma_{Z}", 91, -0.5, 90.5, 100,  0,  0.5);
52   
53   fhQmaxProfileYVsRow = new TProfile2D("QmaxMeanYVsPadRow","Mean Qmax, y vs pad row;Pad row;y",91,-0.5,90.5,100,-30,30);
54   fhQtotProfileYVsRow = new TProfile2D("QtotMeanYVsPadRow","Mean Qtot, y vs pad row;Pad row;y",91,-0.5,90.5,100,-30,30);
55   fhSigmaYProfileYVsRow = new TProfile2D("SigmaYMeanYVsPadRow","Mean Sigma y, x vs pad row;Pad row;y",91,-0.5,90.5,100,-30,30);
56   fhSigmaZProfileYVsRow = new TProfile2D("SigmaZMeanYVsPadRow","Mean Sigma y, x vs pad row;Pad row;y",91,-0.5,90.5,100,-30,30);
57
58 }
59
60 //____________________________________________________________________
61 AliTPCClusterHistograms::AliTPCClusterHistograms(const AliTPCClusterHistograms& c) : TNamed(c)
62 {
63   // copy constructor
64   ((AliTPCClusterHistograms &)c).Copy(*this);
65 }
66
67 //____________________________________________________________________
68 AliTPCClusterHistograms::~AliTPCClusterHistograms()
69 {
70   //
71   // destructor
72   //
73
74   if (fhQmaxVsRow) {
75     delete fhQmaxVsRow;
76     fhQmaxVsRow = 0;
77   }
78   if (fhQtotVsRow) {
79     delete fhQtotVsRow;
80     fhQtotVsRow = 0; 
81   }
82   if (fhSigmaYVsRow) {
83     delete fhSigmaYVsRow;
84     fhSigmaYVsRow = 0;
85   } 
86   if (fhSigmaZVsRow) {
87     delete fhSigmaZVsRow;
88     fhSigmaZVsRow = 0; 
89   }
90   if (fhQmaxProfileYVsRow) {
91     delete fhQmaxProfileYVsRow;
92     fhQmaxProfileYVsRow = 0;
93   }
94   if (fhQtotProfileYVsRow) {
95     delete fhQtotProfileYVsRow;
96     fhQtotProfileYVsRow = 0;
97   }
98   if (fhSigmaYProfileYVsRow) {
99     delete fhSigmaYProfileYVsRow;
100     fhSigmaYProfileYVsRow = 0;
101   }
102   if (fhSigmaZProfileYVsRow) {
103     delete fhSigmaZProfileYVsRow;
104     fhSigmaZProfileYVsRow = 0;
105   }
106
107 }
108
109 //____________________________________________________________________
110 AliTPCClusterHistograms &AliTPCClusterHistograms::operator=(const AliTPCClusterHistograms &c)
111 {
112   // assigment operator
113
114   if (this != &c)
115     ((AliTPCClusterHistograms &) c).Copy(*this);
116
117   return *this;
118 }
119
120
121 //____________________________________________________________________
122 Long64_t AliTPCClusterHistograms::Merge(TCollection* list)
123 {
124   // Merge a list of AliTPCClusterHistograms objects with this (needed for
125   // PROOF). 
126   // Returns the number of merged objects (including this).
127
128   if (!list)
129     return 0;
130   
131   if (list->IsEmpty())
132     return 1;
133
134   TIterator* iter = list->MakeIterator();
135   TObject* obj;
136
137   // collections of measured and generated histograms
138   TList* collectionQmaxVsRow     = new TList;
139   TList* collectionQtotVsRow     = new TList;
140   TList* collectionSigmaYVsRow   = new TList;
141   TList* collectionSigmaZVsRow   = new TList;
142                                         
143   TList* collectionQmaxProfileYVsRow    = new TList;
144   TList* collectionQtotProfileYVsRow    = new TList;
145   TList* collectionSigmaYProfileYVsRow  = new TList;
146   TList* collectionSigmaZProfileYVsRow  = new TList;
147
148    Int_t count = 0;
149    while ((obj = iter->Next())) {
150     
151      AliTPCClusterHistograms* entry = dynamic_cast<AliTPCClusterHistograms*> (obj);
152      if (entry == 0) 
153        continue;
154
155
156      collectionQmaxVsRow          ->Add(entry->fhQmaxVsRow         );
157      collectionQtotVsRow          ->Add(entry->fhQtotVsRow         );
158      collectionSigmaYVsRow        ->Add(entry->fhSigmaYVsRow       );
159      collectionSigmaZVsRow        ->Add(entry->fhSigmaZVsRow       );
160                                                                            
161      collectionQmaxProfileYVsRow  ->Add(entry->fhQmaxProfileYVsRow );
162      collectionQtotProfileYVsRow  ->Add(entry->fhQtotProfileYVsRow );
163      collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow);
164      collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow);
165
166      count++;
167    }
168
169    fhQmaxVsRow          ->Merge(collectionQmaxVsRow       );       
170    fhQtotVsRow          ->Merge(collectionQtotVsRow       );       
171    fhSigmaYVsRow        ->Merge(collectionSigmaYVsRow     );       
172    fhSigmaZVsRow        ->Merge(collectionSigmaZVsRow     );       
173                                                                      
174    fhQmaxProfileYVsRow  ->Merge(collectionQmaxProfileYVsRow  ); 
175    fhQtotProfileYVsRow  ->Merge(collectionQtotProfileYVsRow  );
176    fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow);
177    fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow);
178
179    delete collectionQmaxVsRow;          
180    delete collectionQtotVsRow;  
181    delete collectionSigmaYVsRow;          
182    delete collectionSigmaZVsRow;          
183                                   
184    delete collectionQmaxProfileYVsRow;  
185    delete collectionQtotProfileYVsRow;  
186    delete collectionSigmaYProfileYVsRow;
187    delete collectionSigmaZProfileYVsRow;
188
189   return count+1;
190 }
191
192 //____________________________________________________________________
193 void AliTPCClusterHistograms::FillCluster(AliTPCclusterMI* cluster) {
194   //
195   //
196   //
197
198   Int_t padRow =   cluster->GetRow(); 
199   Float_t qMax =   cluster->GetMax();
200   Float_t qTot =   cluster->GetQ();
201   Float_t sigmaY = cluster->GetSigmaY2();
202   Float_t sigmaZ = cluster->GetSigmaZ2();
203   Float_t y      = cluster->GetY();
204
205   fhQmaxVsRow           ->Fill(padRow, qMax);
206   fhQtotVsRow           ->Fill(padRow, qTot);
207                         
208   fhSigmaYVsRow         ->Fill(padRow, sigmaY);
209   fhSigmaZVsRow         ->Fill(padRow, sigmaZ);
210                         
211   fhQmaxProfileYVsRow   ->Fill(padRow, y, qMax);
212   fhQtotProfileYVsRow   ->Fill(padRow, y, qTot); 
213   fhSigmaYProfileYVsRow ->Fill(padRow, y, sigmaY);
214   fhSigmaZProfileYVsRow ->Fill(padRow, y, sigmaZ);
215 }
216
217
218 //____________________________________________________________________
219 void AliTPCClusterHistograms::SaveHistograms()
220 {
221   //
222   // saves the histograms
223   //
224
225   gDirectory->mkdir(fName.Data());
226   gDirectory->cd(fName.Data());
227
228   fhQmaxVsRow           ->Write();
229   fhQtotVsRow           ->Write();
230                         
231   fhSigmaYVsRow         ->Write();
232   fhSigmaZVsRow         ->Write();
233                         
234   fhQmaxProfileYVsRow   ->Write();
235   fhQtotProfileYVsRow   ->Write();
236   fhSigmaYProfileYVsRow ->Write();
237   fhSigmaZProfileYVsRow ->Write();
238
239   gDirectory->cd("../");
240
241 }
242