]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/TPC/AliTPCRawHistograms.cxx
adding AliTPCRawHistograms
[u/mrichter/AliRoot.git] / PWG0 / TPC / AliTPCRawHistograms.cxx
1 /* $Id$ */
2
3 // This class contains a number of histograms for diagnostics of a TPC
4 // read out chamber from the raw data
5 //
6 // TODO:
7 //  
8 //
9 //
10
11 #include "AliTPCRawHistograms.h"
12
13 #include <TStyle.h>
14 #include <TFile.h>
15 #include <TCanvas.h>
16 #include <TH3F.h>
17 #include <TH1F.h>
18 #include <TLatex.h>
19 #include <TNtuple.h>
20
21 #include <AliTPCRawStream.h>
22 #include <AliLog.h>
23
24
25 //____________________________________________________________________
26 ClassImp(AliTPCRawHistograms)
27
28 //____________________________________________________________________
29 AliTPCRawHistograms::AliTPCRawHistograms() 
30   : TNamed(),
31     fhDigits(0),
32     fhSignal(0)
33 {
34   // default constructor
35 }
36
37 //____________________________________________________________________
38 AliTPCRawHistograms::AliTPCRawHistograms(Int_t detector, const Char_t* /* comment */, Int_t timeStart, Int_t timeStop)
39   : TNamed(),
40     fhDigits(0),
41     fhSignal(0),
42     fDigitTree(0)
43 {
44   // constructor 
45   
46   // make name and title
47   if (detector < 0 || detector >= 72) {
48     AliDebug(AliLog::kError, Form("Detector %d does not exist", detector));
49     return;
50   }
51       
52   Int_t sector = detector%18;
53   TString side;
54   TString inout;
55   if (detector<18 || ( detector>=36 && detector<54))
56     side.Form("A");
57   else 
58     side.Form("B");
59   
60   if (detector<36)
61     inout.Form("IROC");
62   else 
63     inout.Form("OROC");
64
65   TString name;
66   name.Form("sector_%s%d_%s", side.Data(), sector, inout.Data());
67   
68   SetName(name);
69   SetTitle(Form("%s (detector %d)",name.Data(), detector));
70
71   fTimeStart = timeStart;
72   fTimeStop  = timeStop;
73   
74   Float_t yRange   = 45;
75   Int_t nPadRows   = 96;
76   
77   if (TString(name).Contains("IROC")) {
78     yRange = 25;
79     nPadRows = 63;
80   }
81   
82   // 1 bin for each 0.5 cm
83   Int_t nBinsY = Int_t(4*yRange);
84
85   // TODO do NOT attach to the directory!
86   fhDigits = new TH3F("fhDigits", Form("signal distribution;row;pad;time", name.Data()), nPadRows, -0.5, -0.5 + nPadRows, 120, -0.5, 119.5, 100, 0, 1200);
87   fhSignal = new TH1F("fhSignal", "fhSignal", 200, 0, 2000);
88   
89   fDigitTree = new TNtuple("fDigitTree", "fDigitTree", "row:pad:time:signal");
90 }
91
92 //____________________________________________________________________
93 AliTPCRawHistograms::AliTPCRawHistograms(const AliTPCRawHistograms& c) : TNamed(c)
94 {
95   // copy constructor
96
97   ((AliTPCRawHistograms &)c).Copy(*this);
98 }
99
100 //____________________________________________________________________
101 AliTPCRawHistograms::~AliTPCRawHistograms()
102 {
103   //
104   // destructor
105   //
106
107 }
108
109 //____________________________________________________________________
110 AliTPCRawHistograms &AliTPCRawHistograms::operator=(const AliTPCRawHistograms &c)
111 {
112   // assigment operator
113
114   if (this != &c)
115     ((AliTPCRawHistograms &) c).Copy(*this);
116
117   return *this;
118 }
119
120
121 //____________________________________________________________________
122 Long64_t AliTPCRawHistograms::Merge(TCollection* list)
123 {
124   // Merge a list of AliTPCRawHistograms 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    Int_t count = 0;
138
139 /*
140   // collections of measured and generated histograms
141   TList* collectionQmaxVsRow     = new TList;
142   TList* collectionQtotVsRow     = new TList;
143   TList* collectionSigmaYVsRow   = new TList;
144   TList* collectionSigmaZVsRow   = new TList;
145                                         
146   TList* collectionQmaxProfileYVsRow    = new TList;
147   TList* collectionQtotProfileYVsRow    = new TList;
148   TList* collectionSigmaYProfileYVsRow  = new TList;
149   TList* collectionSigmaZProfileYVsRow  = new TList;
150
151   TList* collectionQmaxProfileZVsRow    = new TList;
152   TList* collectionQtotProfileZVsRow    = new TList;
153   TList* collectionSigmaYProfileZVsRow  = new TList;
154   TList* collectionSigmaZProfileZVsRow  = new TList;
155
156   TList* collectionQtotVsTime  = new TList;
157   TList* collectionQmaxVsTime  = new TList;
158
159    while ((obj = iter->Next())) {
160     
161      AliTPCRawHistograms* entry = dynamic_cast<AliTPCRawHistograms*> (obj);
162      if (entry == 0) 
163        continue;
164
165      collectionQmaxVsRow          ->Add(entry->fhQmaxVsRow         );
166      collectionQtotVsRow          ->Add(entry->fhQtotVsRow         );
167      collectionSigmaYVsRow        ->Add(entry->fhSigmaYVsRow       );
168      collectionSigmaZVsRow        ->Add(entry->fhSigmaZVsRow       );
169                                                                            
170      collectionQmaxProfileYVsRow  ->Add(entry->fhQmaxProfileYVsRow );
171      collectionQtotProfileYVsRow  ->Add(entry->fhQtotProfileYVsRow );
172      collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow);
173      collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow);
174
175      collectionQmaxProfileZVsRow  ->Add(entry->fhQmaxProfileZVsRow );
176      collectionQtotProfileZVsRow  ->Add(entry->fhQtotProfileZVsRow );
177      collectionSigmaYProfileZVsRow->Add(entry->fhSigmaYProfileZVsRow);
178      collectionSigmaZProfileZVsRow->Add(entry->fhSigmaZProfileZVsRow);
179
180      collectionQtotVsTime->Add(entry->fhQtotVsTime);
181      collectionQmaxVsTime->Add(entry->fhQmaxVsTime);
182
183
184      count++;
185    }
186
187    fhQmaxVsRow          ->Merge(collectionQmaxVsRow       );       
188    fhQtotVsRow          ->Merge(collectionQtotVsRow       );       
189    fhSigmaYVsRow        ->Merge(collectionSigmaYVsRow     );       
190    fhSigmaZVsRow        ->Merge(collectionSigmaZVsRow     );       
191                                                                      
192    fhQmaxProfileYVsRow  ->Merge(collectionQmaxProfileYVsRow  ); 
193    fhQtotProfileYVsRow  ->Merge(collectionQtotProfileYVsRow  );
194    fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow);
195    fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow);
196
197    fhQmaxProfileZVsRow  ->Merge(collectionQmaxProfileZVsRow  ); 
198    fhQtotProfileZVsRow  ->Merge(collectionQtotProfileZVsRow  );
199    fhSigmaYProfileZVsRow->Merge(collectionSigmaYProfileZVsRow);
200    fhSigmaZProfileZVsRow->Merge(collectionSigmaZProfileZVsRow);
201
202    fhQtotVsTime->Merge(collectionQtotVsTime);
203    fhQmaxVsTime->Merge(collectionQmaxVsTime);
204
205    delete collectionQmaxVsRow;          
206    delete collectionQtotVsRow;  
207    delete collectionSigmaYVsRow;          
208    delete collectionSigmaZVsRow;          
209                                   
210    delete collectionQmaxProfileYVsRow;  
211    delete collectionQtotProfileYVsRow;  
212    delete collectionSigmaYProfileYVsRow;
213    delete collectionSigmaZProfileYVsRow;
214
215    delete collectionQmaxProfileZVsRow;  
216    delete collectionQtotProfileZVsRow;  
217    delete collectionSigmaYProfileZVsRow;
218    delete collectionSigmaZProfileZVsRow;
219
220    delete collectionQtotVsTime;
221    delete collectionQmaxVsTime;*/
222
223   return count+1;
224 }
225
226 //____________________________________________________________________
227 void AliTPCRawHistograms::FillDigit(AliTPCRawStream* rawStream, Int_t time) 
228 {
229   //
230   // Fills the different histograms with the information from a raw digit
231   //
232   
233   Int_t signal = rawStream->GetSignal();
234   Int_t row = rawStream->GetRow();
235   Int_t pad = rawStream->GetPad();
236   Int_t timeBin = rawStream->GetTime();
237
238   if (signal > 120)
239     fhDigits->Fill(row, pad, timeBin, signal);
240     
241   fhSignal->Fill(signal);
242   
243   //fDigitTree->Fill(row, pad, timeBin, signal);
244 }
245
246 //____________________________________________________________________
247 void AliTPCRawHistograms::SaveHistograms()
248 {
249   //
250   // saves the histograms
251   //
252
253   gDirectory->mkdir(fName.Data());
254   gDirectory->cd(fName.Data());
255
256   fhDigits           ->Write();
257   fhSignal           ->Write();
258   fDigitTree->Write();
259                         
260   gDirectory->cd("../");
261 }
262
263 //____________________________________________________________________
264 TCanvas* AliTPCRawHistograms::DrawHistograms(const Char_t* opt) {
265   //
266   // Draws some histograms and save the canvas as eps and gif file.
267   //  
268
269   TCanvas* c = new TCanvas(Form("plots_%s",fName.Data()), fName.Data(), 1200, 1000);
270
271   gStyle->SetOptStat(0);
272   gStyle->SetOptFit(0);
273
274   gStyle->SetPadLeftMargin(0.05);
275
276   c->Divide(3,3);
277
278   c->Draw();  
279
280   c->cd(1);
281   
282   // this is not really a nice way to do it...
283   c->GetPad(1)->Delete();
284   
285   TLatex* name = new TLatex(0.1,0.8,fName.Data());
286   name->SetTextSize(0.02);
287   name->DrawClone();
288
289   c->cd(2);
290   fhDigits->Draw();
291
292   c->cd(3);
293   fhSignal->Draw();         
294                         
295   return c;
296 }