]>
Commit | Line | Data |
---|---|---|
1d7991a5 | 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 | ||
899625a7 | 82 | // do not add this hists to the directory |
83 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
84 | TH1::AddDirectory(kFALSE); | |
1d7991a5 | 85 | |
899625a7 | 86 | fhDigits = new TH3F("fhDigits", Form("signal distribution;row;pad;time", name.Data()), nPadRows, -0.5, -0.5 + nPadRows, 150, -0.5, 149.5, 100, 0, 1200); |
1d7991a5 | 87 | fhSignal = new TH1F("fhSignal", "fhSignal", 200, 0, 2000); |
88 | ||
89 | fDigitTree = new TNtuple("fDigitTree", "fDigitTree", "row:pad:time:signal"); | |
899625a7 | 90 | |
91 | TH1::AddDirectory(oldStatus); | |
1d7991a5 | 92 | } |
93 | ||
94 | //____________________________________________________________________ | |
95 | AliTPCRawHistograms::AliTPCRawHistograms(const AliTPCRawHistograms& c) : TNamed(c) | |
96 | { | |
97 | // copy constructor | |
98 | ||
99 | ((AliTPCRawHistograms &)c).Copy(*this); | |
100 | } | |
101 | ||
102 | //____________________________________________________________________ | |
103 | AliTPCRawHistograms::~AliTPCRawHistograms() | |
104 | { | |
105 | // | |
106 | // destructor | |
107 | // | |
108 | ||
109 | } | |
110 | ||
111 | //____________________________________________________________________ | |
112 | AliTPCRawHistograms &AliTPCRawHistograms::operator=(const AliTPCRawHistograms &c) | |
113 | { | |
114 | // assigment operator | |
115 | ||
116 | if (this != &c) | |
117 | ((AliTPCRawHistograms &) c).Copy(*this); | |
118 | ||
119 | return *this; | |
120 | } | |
121 | ||
122 | ||
123 | //____________________________________________________________________ | |
124 | Long64_t AliTPCRawHistograms::Merge(TCollection* list) | |
125 | { | |
126 | // Merge a list of AliTPCRawHistograms objects with this (needed for | |
127 | // PROOF). | |
128 | // Returns the number of merged objects (including this). | |
129 | ||
130 | if (!list) | |
131 | return 0; | |
132 | ||
133 | if (list->IsEmpty()) | |
134 | return 1; | |
135 | ||
136 | TIterator* iter = list->MakeIterator(); | |
137 | TObject* obj; | |
138 | ||
139 | Int_t count = 0; | |
140 | ||
141 | /* | |
142 | // collections of measured and generated histograms | |
143 | TList* collectionQmaxVsRow = new TList; | |
144 | TList* collectionQtotVsRow = new TList; | |
145 | TList* collectionSigmaYVsRow = new TList; | |
146 | TList* collectionSigmaZVsRow = new TList; | |
147 | ||
148 | TList* collectionQmaxProfileYVsRow = new TList; | |
149 | TList* collectionQtotProfileYVsRow = new TList; | |
150 | TList* collectionSigmaYProfileYVsRow = new TList; | |
151 | TList* collectionSigmaZProfileYVsRow = new TList; | |
152 | ||
153 | TList* collectionQmaxProfileZVsRow = new TList; | |
154 | TList* collectionQtotProfileZVsRow = new TList; | |
155 | TList* collectionSigmaYProfileZVsRow = new TList; | |
156 | TList* collectionSigmaZProfileZVsRow = new TList; | |
157 | ||
158 | TList* collectionQtotVsTime = new TList; | |
159 | TList* collectionQmaxVsTime = new TList; | |
160 | ||
161 | while ((obj = iter->Next())) { | |
162 | ||
163 | AliTPCRawHistograms* entry = dynamic_cast<AliTPCRawHistograms*> (obj); | |
164 | if (entry == 0) | |
165 | continue; | |
166 | ||
167 | collectionQmaxVsRow ->Add(entry->fhQmaxVsRow ); | |
168 | collectionQtotVsRow ->Add(entry->fhQtotVsRow ); | |
169 | collectionSigmaYVsRow ->Add(entry->fhSigmaYVsRow ); | |
170 | collectionSigmaZVsRow ->Add(entry->fhSigmaZVsRow ); | |
171 | ||
172 | collectionQmaxProfileYVsRow ->Add(entry->fhQmaxProfileYVsRow ); | |
173 | collectionQtotProfileYVsRow ->Add(entry->fhQtotProfileYVsRow ); | |
174 | collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow); | |
175 | collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow); | |
176 | ||
177 | collectionQmaxProfileZVsRow ->Add(entry->fhQmaxProfileZVsRow ); | |
178 | collectionQtotProfileZVsRow ->Add(entry->fhQtotProfileZVsRow ); | |
179 | collectionSigmaYProfileZVsRow->Add(entry->fhSigmaYProfileZVsRow); | |
180 | collectionSigmaZProfileZVsRow->Add(entry->fhSigmaZProfileZVsRow); | |
181 | ||
182 | collectionQtotVsTime->Add(entry->fhQtotVsTime); | |
183 | collectionQmaxVsTime->Add(entry->fhQmaxVsTime); | |
184 | ||
185 | ||
186 | count++; | |
187 | } | |
188 | ||
189 | fhQmaxVsRow ->Merge(collectionQmaxVsRow ); | |
190 | fhQtotVsRow ->Merge(collectionQtotVsRow ); | |
191 | fhSigmaYVsRow ->Merge(collectionSigmaYVsRow ); | |
192 | fhSigmaZVsRow ->Merge(collectionSigmaZVsRow ); | |
193 | ||
194 | fhQmaxProfileYVsRow ->Merge(collectionQmaxProfileYVsRow ); | |
195 | fhQtotProfileYVsRow ->Merge(collectionQtotProfileYVsRow ); | |
196 | fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow); | |
197 | fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow); | |
198 | ||
199 | fhQmaxProfileZVsRow ->Merge(collectionQmaxProfileZVsRow ); | |
200 | fhQtotProfileZVsRow ->Merge(collectionQtotProfileZVsRow ); | |
201 | fhSigmaYProfileZVsRow->Merge(collectionSigmaYProfileZVsRow); | |
202 | fhSigmaZProfileZVsRow->Merge(collectionSigmaZProfileZVsRow); | |
203 | ||
204 | fhQtotVsTime->Merge(collectionQtotVsTime); | |
205 | fhQmaxVsTime->Merge(collectionQmaxVsTime); | |
206 | ||
207 | delete collectionQmaxVsRow; | |
208 | delete collectionQtotVsRow; | |
209 | delete collectionSigmaYVsRow; | |
210 | delete collectionSigmaZVsRow; | |
211 | ||
212 | delete collectionQmaxProfileYVsRow; | |
213 | delete collectionQtotProfileYVsRow; | |
214 | delete collectionSigmaYProfileYVsRow; | |
215 | delete collectionSigmaZProfileYVsRow; | |
216 | ||
217 | delete collectionQmaxProfileZVsRow; | |
218 | delete collectionQtotProfileZVsRow; | |
219 | delete collectionSigmaYProfileZVsRow; | |
220 | delete collectionSigmaZProfileZVsRow; | |
221 | ||
222 | delete collectionQtotVsTime; | |
223 | delete collectionQmaxVsTime;*/ | |
224 | ||
225 | return count+1; | |
226 | } | |
227 | ||
228 | //____________________________________________________________________ | |
899625a7 | 229 | void AliTPCRawHistograms::FillDigit(AliTPCRawStream* rawStream, Int_t /*time*/) |
1d7991a5 | 230 | { |
231 | // | |
232 | // Fills the different histograms with the information from a raw digit | |
233 | // | |
234 | ||
235 | Int_t signal = rawStream->GetSignal(); | |
236 | Int_t row = rawStream->GetRow(); | |
237 | Int_t pad = rawStream->GetPad(); | |
238 | Int_t timeBin = rawStream->GetTime(); | |
239 | ||
240 | if (signal > 120) | |
241 | fhDigits->Fill(row, pad, timeBin, signal); | |
242 | ||
243 | fhSignal->Fill(signal); | |
244 | ||
899625a7 | 245 | fDigitTree->Fill(row, pad, timeBin, signal); |
1d7991a5 | 246 | } |
247 | ||
248 | //____________________________________________________________________ | |
249 | void AliTPCRawHistograms::SaveHistograms() | |
250 | { | |
251 | // | |
252 | // saves the histograms | |
253 | // | |
254 | ||
255 | gDirectory->mkdir(fName.Data()); | |
256 | gDirectory->cd(fName.Data()); | |
257 | ||
258 | fhDigits ->Write(); | |
259 | fhSignal ->Write(); | |
260 | fDigitTree->Write(); | |
261 | ||
262 | gDirectory->cd("../"); | |
263 | } | |
264 | ||
265 | //____________________________________________________________________ | |
899625a7 | 266 | TCanvas* AliTPCRawHistograms::DrawHistograms(const Char_t* /*opt*/) { |
1d7991a5 | 267 | // |
268 | // Draws some histograms and save the canvas as eps and gif file. | |
269 | // | |
270 | ||
271 | TCanvas* c = new TCanvas(Form("plots_%s",fName.Data()), fName.Data(), 1200, 1000); | |
272 | ||
273 | gStyle->SetOptStat(0); | |
274 | gStyle->SetOptFit(0); | |
275 | ||
276 | gStyle->SetPadLeftMargin(0.05); | |
277 | ||
278 | c->Divide(3,3); | |
279 | ||
280 | c->Draw(); | |
281 | ||
282 | c->cd(1); | |
283 | ||
284 | // this is not really a nice way to do it... | |
285 | c->GetPad(1)->Delete(); | |
286 | ||
287 | TLatex* name = new TLatex(0.1,0.8,fName.Data()); | |
288 | name->SetTextSize(0.02); | |
289 | name->DrawClone(); | |
290 | ||
291 | c->cd(2); | |
292 | fhDigits->Draw(); | |
293 | ||
294 | c->cd(3); | |
295 | fhSignal->Draw(); | |
296 | ||
297 | return c; | |
298 | } |