]>
Commit | Line | Data |
---|---|---|
39bcd65d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // Class for viewing/visualizing TPC calibration data // | |
20 | // base on TTree functionality for visualization // | |
72d0ab7e | 21 | // // |
22 | // Create a list of AliTPCCalPads, arrange them in an TObjArray. // | |
23 | // Pass this TObjArray to MakeTree and create the calibration Tree // | |
24 | // While craating this tree some statistical information are calculated // | |
25 | // Open the viewer with this Tree: AliTPCCalibViewer v("CalibTree.root") // | |
26 | // Have fun! // | |
27 | // EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0") // | |
28 | // // | |
29 | // If you like to click, we recommand you the // | |
30 | // AliTPCCalibViewerGUI // | |
31 | // // | |
32 | // THE DOCUMENTATION IS STILL NOT COMPLETED !!!! // | |
33 | // // | |
39bcd65d | 34 | /////////////////////////////////////////////////////////////////////////////// |
35 | ||
36 | // | |
37 | // ROOT includes | |
38 | // | |
2811495d | 39 | |
4f3934a1 | 40 | #include <fstream> |
2811495d | 41 | #include <iostream> |
42 | ||
43 | #include <TFile.h> | |
44 | #include <TFriendElement.h> | |
45 | #include <TGraph.h> | |
46 | #include <TKey.h> | |
47 | #include <TPad.h> | |
48 | //#include <TCanvas.h> | |
72d0ab7e | 49 | #include <TH1.h> |
39bcd65d | 50 | #include <TH1F.h> |
2811495d | 51 | #include <TLegend.h> |
52 | #include <TLine.h> | |
53 | #include <TMath.h> | |
39bcd65d | 54 | #include <TObjString.h> |
2811495d | 55 | //#include <TROOT.h> |
56 | #include <TRandom.h> | |
57 | #include <TString.h> | |
58 | #include <TStyle.h> | |
59 | #include <TTreeStream.h> | |
39bcd65d | 60 | |
2811495d | 61 | #include "AliTPCCalibCE.h" |
62 | #include "AliMathBase.h" | |
63 | #include "AliTPCCalPad.h" | |
64 | #include "AliTPCCalROC.h" | |
65 | #include "AliTPCCalibPedestal.h" | |
66 | #include "AliTPCCalibPulser.h" | |
39bcd65d | 67 | |
68 | // | |
69 | // AliRoot includes | |
70 | // | |
71 | #include "AliTPCCalibViewer.h" | |
72 | ||
73 | ClassImp(AliTPCCalibViewer) | |
74 | ||
832bb12c | 75 | |
39bcd65d | 76 | AliTPCCalibViewer::AliTPCCalibViewer() |
77 | :TObject(), | |
78 | fTree(0), | |
79 | fFile(0), | |
a6d2bd0c | 80 | fListOfObjectsToBeDeleted(0), |
832bb12c | 81 | fTreeMustBeDeleted(0), |
82 | fAbbreviation(0), | |
83 | fAppendString(0) | |
39bcd65d | 84 | { |
85 | // | |
86 | // Default constructor | |
87 | // | |
88 | ||
89 | } | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | AliTPCCalibViewer::AliTPCCalibViewer(const AliTPCCalibViewer &c) | |
93 | :TObject(c), | |
94 | fTree(0), | |
95 | fFile(0), | |
a6d2bd0c | 96 | fListOfObjectsToBeDeleted(0), |
832bb12c | 97 | fTreeMustBeDeleted(0), |
98 | fAbbreviation(0), | |
99 | fAppendString(0) | |
39bcd65d | 100 | { |
101 | // | |
102 | // dummy AliTPCCalibViewer copy constructor | |
103 | // not yet working!!! | |
104 | // | |
105 | fTree = c.fTree; | |
a6d2bd0c | 106 | fTreeMustBeDeleted = c.fTreeMustBeDeleted; |
39bcd65d | 107 | //fFile = new TFile(*(c.fFile)); |
108 | fListOfObjectsToBeDeleted = c.fListOfObjectsToBeDeleted; | |
832bb12c | 109 | fAbbreviation = c.fAbbreviation; |
110 | fAppendString = c.fAppendString; | |
39bcd65d | 111 | } |
112 | ||
113 | //_____________________________________________________________________________ | |
2811495d | 114 | AliTPCCalibViewer::AliTPCCalibViewer(TTree *const tree) |
39bcd65d | 115 | :TObject(), |
116 | fTree(0), | |
117 | fFile(0), | |
a6d2bd0c | 118 | fListOfObjectsToBeDeleted(0), |
832bb12c | 119 | fTreeMustBeDeleted(0), |
120 | fAbbreviation(0), | |
121 | fAppendString(0) | |
39bcd65d | 122 | { |
123 | // | |
124 | // Constructor that initializes the calibration viewer | |
125 | // | |
126 | fTree = tree; | |
a6d2bd0c | 127 | fTreeMustBeDeleted = kFALSE; |
39bcd65d | 128 | fListOfObjectsToBeDeleted = new TObjArray(); |
832bb12c | 129 | fAbbreviation = "~"; |
130 | fAppendString = ".fElements"; | |
39bcd65d | 131 | } |
132 | ||
133 | //_____________________________________________________________________________ | |
a6e0ebfe | 134 | AliTPCCalibViewer::AliTPCCalibViewer(const char* fileName, const char* treeName) |
39bcd65d | 135 | :TObject(), |
136 | fTree(0), | |
137 | fFile(0), | |
a6d2bd0c | 138 | fListOfObjectsToBeDeleted(0), |
832bb12c | 139 | fTreeMustBeDeleted(0), |
140 | fAbbreviation(0), | |
141 | fAppendString(0) | |
142 | ||
39bcd65d | 143 | { |
144 | // | |
145 | // Constructor to initialize the calibration viewer | |
146 | // the file 'fileName' contains the tree 'treeName' | |
147 | // | |
148 | fFile = new TFile(fileName, "read"); | |
149 | fTree = (TTree*) fFile->Get(treeName); | |
a6d2bd0c | 150 | fTreeMustBeDeleted = kTRUE; |
39bcd65d | 151 | fListOfObjectsToBeDeleted = new TObjArray(); |
832bb12c | 152 | fAbbreviation = "~"; |
153 | fAppendString = ".fElements"; | |
39bcd65d | 154 | } |
155 | ||
156 | //____________________________________________________________________________ | |
157 | AliTPCCalibViewer & AliTPCCalibViewer::operator =(const AliTPCCalibViewer & param) | |
158 | { | |
159 | // | |
160 | // assignment operator - dummy | |
161 | // not yet working!!! | |
162 | // | |
04420071 | 163 | if (this == ¶m) return (*this); |
164 | ||
39bcd65d | 165 | fTree = param.fTree; |
a6d2bd0c | 166 | fTreeMustBeDeleted = param.fTreeMustBeDeleted; |
39bcd65d | 167 | //fFile = new TFile(*(param.fFile)); |
168 | fListOfObjectsToBeDeleted = param.fListOfObjectsToBeDeleted; | |
832bb12c | 169 | fAbbreviation = param.fAbbreviation; |
170 | fAppendString = param.fAppendString; | |
39bcd65d | 171 | return (*this); |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | AliTPCCalibViewer::~AliTPCCalibViewer() | |
176 | { | |
177 | // | |
178 | // AliTPCCalibViewer destructor | |
a6d2bd0c | 179 | // all objects will be deleted, the file will be closed, the pictures will disappear |
39bcd65d | 180 | // |
a6d2bd0c | 181 | if (fTree && fTreeMustBeDeleted) { |
182 | fTree->SetCacheSize(0); | |
183 | fTree->Delete(); | |
184 | //delete fTree; | |
185 | } | |
39bcd65d | 186 | if (fFile) { |
187 | fFile->Close(); | |
188 | fFile = 0; | |
189 | } | |
190 | ||
191 | for (Int_t i = fListOfObjectsToBeDeleted->GetEntriesFast()-1; i >= 0; i--) { | |
192 | //cout << "Index " << i << " trying to delete the following object: " << fListOfObjectsToBeDeleted->At(i)->GetName() << "..."<< endl; | |
193 | delete fListOfObjectsToBeDeleted->At(i); | |
194 | } | |
195 | delete fListOfObjectsToBeDeleted; | |
196 | } | |
197 | ||
a6d2bd0c | 198 | //_____________________________________________________________________________ |
2773a273 | 199 | void AliTPCCalibViewer::Delete(Option_t* /*option*/) { |
a6d2bd0c | 200 | // |
201 | // Should be called from AliTPCCalibViewerGUI class only. | |
202 | // If you use Delete() do not call the destructor. | |
203 | // All objects (except those contained in fListOfObjectsToBeDeleted) will be deleted, the file will be closed. | |
204 | // | |
205 | ||
a6d2bd0c | 206 | if (fTree && fTreeMustBeDeleted) { |
207 | fTree->SetCacheSize(0); | |
208 | fTree->Delete(); | |
209 | } | |
2773a273 | 210 | delete fFile; |
a6d2bd0c | 211 | delete fListOfObjectsToBeDeleted; |
212 | } | |
213 | ||
8192627b | 214 | |
2811495d | 215 | const char* AliTPCCalibViewer::AddAbbreviations(const Char_t *c, Bool_t printDrawCommand){ |
8192627b | 216 | // Replace all "<variable>" with "<variable><fAbbreviation>" (Adds forgotten "~") |
217 | // but take care on the statistical information, like "CEQmean_Mean" | |
218 | // and also take care on correct given variables, like "CEQmean~" | |
219 | // | |
220 | // For each variable out of "listOfVariables": | |
221 | // - 'Save' correct items: | |
222 | // - form <replaceString>, take <variable>'s first char, add <removeString>, add rest of <variable>, e.g. "C!#EQmean" (<removeString> = "!#") | |
223 | // - For each statistical information in "listOfNormalizationVariables": | |
224 | // - ReplaceAll <variable><statistical_Information> with <replaceString><statistical_Information> | |
225 | // - ReplaceAll <variable><abbreviation> with <replaceString><abbreviation>, e.g. "CEQmean~" -> "C!#EQmean~" | |
226 | // - ReplaceAll <variable><appendStr> with <replaceString><appendStr>, e.g. "CEQmean.fElements" -> "C!#EQmean.fElements" | |
227 | // | |
228 | // - Do actual replacing: | |
229 | // - ReplaceAll <variable> with <variable><fAbbreviation>, e.g. "CEQmean" -> "CEQmean~" | |
230 | // | |
231 | // - Undo saving: | |
232 | // - For each statistical information in "listOfNormalizationVariables": | |
233 | // - ReplaceAll <replaceString><statistical_Information> with <variable><statistical_Information> | |
234 | // - ReplaceAll <replaceString><abbreviation> with <variable><abbreviation>, e.g. "C!#EQmean~" -> "CEQmean~" | |
235 | // - ReplaceAll <replaceString><appendStr> with <variable><appendStr>, e.g. "C!#EQmean.fElements" -> "CEQmean.fElements" | |
236 | // | |
237 | // Now all the missing "~" should be added. | |
238 | ||
239 | TString str(c); | |
240 | TString removeString = "!#"; // very unpropable combination of chars | |
241 | TString replaceString = ""; | |
242 | TString searchString = ""; | |
243 | TString normString = ""; | |
244 | TObjArray *listOfVariables = GetListOfVariables(); | |
245 | listOfVariables->Add(new TObjString("channel")); | |
246 | listOfVariables->Add(new TObjString("gx")); | |
247 | listOfVariables->Add(new TObjString("gy")); | |
248 | listOfVariables->Add(new TObjString("lx")); | |
249 | listOfVariables->Add(new TObjString("ly")); | |
250 | listOfVariables->Add(new TObjString("pad")); | |
251 | listOfVariables->Add(new TObjString("row")); | |
252 | listOfVariables->Add(new TObjString("rpad")); | |
253 | listOfVariables->Add(new TObjString("sector")); | |
254 | TObjArray *listOfNormalizationVariables = GetListOfNormalizationVariables(); | |
255 | Int_t nVariables = listOfVariables->GetEntriesFast(); | |
256 | Int_t nNorm = listOfNormalizationVariables->GetEntriesFast(); | |
257 | ||
258 | Int_t *varLengths = new Int_t[nVariables]; | |
259 | for (Int_t i = 0; i < nVariables; i++) { | |
260 | varLengths[i] = ((TObjString*)listOfVariables->At(i))->String().Length(); | |
261 | } | |
262 | Int_t *normLengths = new Int_t[nNorm]; | |
263 | for (Int_t i = 0; i < nNorm; i++) { | |
264 | normLengths[i] = ((TObjString*)listOfNormalizationVariables->At(i))->String().Length(); | |
265 | // printf("normLengths[%i] (%s) = %i \n", i,((TObjString*)listOfNormalizationVariables->At(i))->String().Data(), normLengths[i]); | |
266 | } | |
267 | Int_t *varSort = new Int_t[nVariables]; | |
268 | TMath::Sort(nVariables, varLengths, varSort, kTRUE); | |
269 | Int_t *normSort = new Int_t[nNorm]; | |
270 | TMath::Sort(nNorm, normLengths, normSort, kTRUE); | |
271 | // for (Int_t i = 0; i<nNorm; i++) printf("normLengths: %i\n", normLengths[normSort[i]]); | |
272 | // for (Int_t i = 0; i<nVariables; i++) printf("varLengths: %i\n", varLengths[varSort[i]]); | |
273 | ||
274 | for (Int_t ivar = 0; ivar < nVariables; ivar++) { | |
275 | // ***** save correct tokens ***** | |
276 | // first get the next variable: | |
277 | searchString = ((TObjString*)listOfVariables->At(varSort[ivar]))->String(); | |
278 | // printf("searchString: %s ++++++++++++++\n", searchString.Data()); | |
279 | // form replaceString: | |
280 | replaceString = ""; | |
281 | for (Int_t i = 0; i < searchString.Length(); i++) { | |
282 | replaceString.Append(searchString[i]); | |
283 | if (i == 0) replaceString.Append(removeString); | |
284 | } | |
285 | // go through normalization: | |
286 | // printf("go through normalization\n"); | |
287 | for (Int_t inorm = 0; inorm < nNorm; inorm++) { | |
288 | // printf(" inorm=%i, nNorm=%i, normSort[inorm]=%i \n", inorm, nNorm, normSort[inorm]); | |
289 | normString = ((TObjString*)listOfNormalizationVariables->At(normSort[inorm]))->String(); | |
290 | // printf(" walking in normalization, i=%i, normString=%s \n", inorm, normString.Data()); | |
291 | str.ReplaceAll(searchString + normString, replaceString + normString); | |
292 | // like: str.ReplaceAll("CEQmean_Mean", "C!EQmean_Mean"); | |
293 | } | |
294 | str.ReplaceAll(searchString + fAbbreviation, replaceString + fAbbreviation); | |
295 | // like: str.ReplaceAll("CEQmean~", "C!EQmean~"); | |
296 | str.ReplaceAll(searchString + fAppendString, replaceString + fAppendString); | |
297 | // like: str.ReplaceAll("CEQmean.fElements", "C!EQmean.fElements"); | |
298 | ||
299 | // ***** add missing extensions ***** | |
300 | str.ReplaceAll(searchString, replaceString + fAbbreviation); | |
301 | // like: str.ReplaceAll("CEQmean", "C!EQmean~"); | |
302 | } | |
303 | ||
304 | // ***** undo saving ***** | |
305 | str.ReplaceAll(removeString, ""); | |
306 | ||
307 | if (printDrawCommand) std::cout << "The string looks now like: " << str.Data() << std::endl; | |
6fefa5ce | 308 | delete [] varLengths; |
309 | delete [] normLengths; | |
4ce766eb | 310 | delete [] varSort; |
311 | delete [] normSort; | |
8192627b | 312 | return str.Data(); |
313 | } | |
314 | ||
315 | ||
316 | ||
317 | ||
39bcd65d | 318 | //_____________________________________________________________________________ |
319 | Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, const char* sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { | |
320 | // | |
321 | // easy drawing of data, use '~' for abbreviation of '.fElements' | |
322 | // example: EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0") | |
323 | // sector: sector-number - only the specified sector will be drwawn | |
324 | // 'A'/'C' or 'a'/'c' - side A/C will be drawn | |
325 | // 'ALL' - whole TPC will be drawn, projected on one side | |
326 | // cuts: specifies cuts | |
327 | // drawOptions: draw options like 'same' | |
328 | // writeDrawCommand: write the command, that is passed to TTree::Draw | |
329 | // | |
72d0ab7e | 330 | |
39bcd65d | 331 | TString drawStr(drawCommand); |
332 | TString sectorStr(sector); | |
333 | sectorStr.ToUpper(); | |
334 | TString cutStr(""); | |
72d0ab7e | 335 | //TString drawOptionsStr("profcolz "); |
8192627b | 336 | Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>"); |
337 | if (dangerousToDraw) { | |
c4607f01 | 338 | Warning("EasyDraw", "The draw string must not contain ':' or '>>'. Using only first variable for drawing!"); |
339 | // return -1; | |
340 | // drawStr.Resize(drawStr.First(">")); | |
341 | drawStr.Resize(drawStr.First(":")); | |
8192627b | 342 | } |
c4607f01 | 343 | |
72d0ab7e | 344 | TString drawOptionsStr(""); |
39bcd65d | 345 | TRandom rnd(0); |
346 | Int_t rndNumber = rnd.Integer(10000); | |
72d0ab7e | 347 | |
348 | if (drawOptions && strcmp(drawOptions, "") != 0) | |
39bcd65d | 349 | drawOptionsStr += drawOptions; |
72d0ab7e | 350 | else |
351 | drawOptionsStr += "profcolz"; | |
39bcd65d | 352 | |
353 | if (sectorStr == "A") { | |
832bb12c | 354 | drawStr += Form(":gy%s:gx%s>>prof", fAppendString.Data(), fAppendString.Data()); |
39bcd65d | 355 | drawStr += rndNumber; |
356 | drawStr += "(330,-250,250,330,-250,250)"; | |
357 | cutStr += "(sector/18)%2==0 "; | |
358 | } | |
359 | else if (sectorStr == "C") { | |
832bb12c | 360 | drawStr += Form(":gy%s:gx%s>>prof", fAppendString.Data(), fAppendString.Data()); |
39bcd65d | 361 | drawStr += rndNumber; |
362 | drawStr += "(330,-250,250,330,-250,250)"; | |
363 | cutStr += "(sector/18)%2==1 "; | |
364 | } | |
365 | else if (sectorStr == "ALL") { | |
832bb12c | 366 | drawStr += Form(":gy%s:gx%s>>prof", fAppendString.Data(), fAppendString.Data()); |
39bcd65d | 367 | drawStr += rndNumber; |
368 | drawStr += "(330,-250,250,330,-250,250)"; | |
369 | } | |
c4607f01 | 370 | else if (sectorStr.Contains("S")) { |
371 | drawStr += Form(":rpad%s:row%s+(sector>35)*63>>prof", fAppendString.Data(), fAppendString.Data()); | |
372 | drawStr += rndNumber; | |
373 | drawStr += "(159,0,159,140,-70,70)"; | |
374 | TString sec=sectorStr; | |
375 | sec.Remove(0,1); | |
376 | cutStr += "sector%36=="+sec+" "; | |
377 | } | |
39bcd65d | 378 | else if (sectorStr.IsDigit()) { |
379 | Int_t isec = sectorStr.Atoi(); | |
832bb12c | 380 | drawStr += Form(":rpad%s:row%s>>prof", fAppendString.Data(), fAppendString.Data()); |
39bcd65d | 381 | drawStr += rndNumber; |
382 | if (isec < 36 && isec >= 0) | |
383 | drawStr += "(63,0,63,108,-54,54)"; | |
384 | else if (isec < 72 && isec >= 36) | |
385 | drawStr += "(96,0,96,140,-70,70)"; | |
386 | else { | |
387 | Error("EasyDraw","The TPC contains only sectors between 0 and 71."); | |
388 | return -1; | |
389 | } | |
390 | cutStr += "(sector=="; | |
391 | cutStr += isec; | |
392 | cutStr += ") "; | |
393 | } | |
394 | ||
395 | if (cuts && cuts[0] != 0) { | |
396 | if (cutStr.Length() != 0) cutStr += "&& "; | |
397 | cutStr += "("; | |
398 | cutStr += cuts; | |
399 | cutStr += ")"; | |
400 | } | |
832bb12c | 401 | drawStr.ReplaceAll(fAbbreviation, fAppendString); |
402 | cutStr.ReplaceAll(fAbbreviation, fAppendString); | |
39bcd65d | 403 | if (writeDrawCommand) std::cout << "fTree->Draw(\"" << drawStr << "\", \"" << cutStr << "\", \"" << drawOptionsStr << "\");" << std::endl; |
832bb12c | 404 | Int_t returnValue = fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data()); |
405 | TString profName("prof"); | |
406 | profName += rndNumber; | |
407 | TObject *obj = gDirectory->Get(profName.Data()); | |
408 | if (obj && obj->InheritsFrom("TH1")) FormatHistoLabels((TH1*)obj); | |
409 | return returnValue; | |
39bcd65d | 410 | } |
411 | ||
72d0ab7e | 412 | |
39bcd65d | 413 | Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, Int_t sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { |
414 | // | |
415 | // easy drawing of data, use '~' for abbreviation of '.fElements' | |
416 | // example: EasyDraw("CETmean~-CETmean_mean", 34, "(CETmean~-CETmean_mean)>0") | |
417 | // sector: sector-number - only the specified sector will be drwawn | |
418 | // cuts: specifies cuts | |
419 | // drawOptions: draw options like 'same' | |
420 | // writeDrawCommand: write the command, that is passed to TTree::Draw | |
421 | // | |
422 | if (sector >= 0 && sector < 72) { | |
df5d3222 | 423 | return EasyDraw(drawCommand, Form("%i", sector), cuts, drawOptions, writeDrawCommand); |
39bcd65d | 424 | } |
425 | Error("EasyDraw","The TPC contains only sectors between 0 and 71."); | |
426 | return -1; | |
427 | } | |
428 | ||
72d0ab7e | 429 | |
39bcd65d | 430 | //_____________________________________________________________________________ |
431 | Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, const char* sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { | |
432 | // | |
433 | // easy drawing of data, use '~' for abbreviation of '.fElements' | |
434 | // example: EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0") | |
435 | // sector: sector-number - the specified sector will be drwawn | |
436 | // 'A'/'C' or 'a'/'c' - side A/C will be drawn | |
437 | // 'ALL' - whole TPC will be drawn, projected on one side | |
438 | // cuts: specifies cuts | |
439 | // drawOptions: draw options like 'same' | |
440 | // writeDrawCommand: write the command, that is passed to TTree::Draw | |
441 | // | |
442 | ||
443 | TString drawStr(drawCommand); | |
444 | TString sectorStr(sector); | |
445 | TString drawOptionsStr(drawOptions); | |
446 | sectorStr.ToUpper(); | |
447 | TString cutStr(""); | |
448 | ||
449 | if (sectorStr == "A") | |
450 | cutStr += "(sector/18)%2==0 "; | |
451 | else if (sectorStr == "C") | |
452 | cutStr += "(sector/18)%2==1 "; | |
453 | else if (sectorStr.IsDigit()) { | |
454 | Int_t isec = sectorStr.Atoi(); | |
455 | if (isec < 0 || isec > 71) { | |
456 | Error("EasyDraw","The TPC contains only sectors between 0 and 71."); | |
457 | return -1; | |
458 | } | |
459 | cutStr += "(sector=="; | |
460 | cutStr += isec; | |
461 | cutStr += ") "; | |
462 | } | |
c4607f01 | 463 | else if (sectorStr.Contains("S")) { |
464 | TString sec=sectorStr; | |
465 | sec.Remove(0,1); | |
466 | cutStr += "sector%36=="+sec+" "; | |
467 | } | |
39bcd65d | 468 | |
469 | if (cuts && cuts[0] != 0) { | |
470 | if (cutStr.Length() != 0) cutStr += "&& "; | |
471 | cutStr += "("; | |
472 | cutStr += cuts; | |
473 | cutStr += ")"; | |
474 | } | |
475 | ||
832bb12c | 476 | drawStr.ReplaceAll(fAbbreviation, fAppendString); |
477 | cutStr.ReplaceAll(fAbbreviation, fAppendString); | |
39bcd65d | 478 | if (writeDrawCommand) std::cout << "fTree->Draw(\"" << drawStr << "\", \"" << cutStr << "\", \"" << drawOptionsStr << "\");" << std::endl; |
832bb12c | 479 | Int_t returnValue = fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data()); |
8192627b | 480 | if (returnValue == -1) return -1; |
832bb12c | 481 | |
8192627b | 482 | TObject *obj = (gPad) ? gPad->GetPrimitive("htemp") : 0; |
832bb12c | 483 | if (!obj) obj = (TH1F*)gDirectory->Get("htemp"); |
484 | if (!obj) obj = gPad->GetPrimitive("tempHist"); | |
485 | if (!obj) obj = (TH1F*)gDirectory->Get("tempHist"); | |
486 | if (!obj) obj = gPad->GetPrimitive("Graph"); | |
487 | if (!obj) obj = (TH1F*)gDirectory->Get("Graph"); | |
488 | if (obj && obj->InheritsFrom("TH1")) FormatHistoLabels((TH1*)obj); | |
489 | return returnValue; | |
39bcd65d | 490 | } |
491 | ||
72d0ab7e | 492 | |
39bcd65d | 493 | Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, Int_t sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const { |
494 | // | |
495 | // easy drawing of data, use '~' for abbreviation of '.fElements' | |
496 | // example: EasyDraw("CETmean~-CETmean_mean", 34, "(CETmean~-CETmean_mean)>0") | |
497 | // sector: sector-number - the specified sector will be drwawn | |
498 | // cuts: specifies cuts | |
499 | // drawOptions: draw options like 'same' | |
500 | // writeDrawCommand: write the command, that is passed to TTree::Draw | |
501 | // | |
502 | ||
503 | if (sector >= 0 && sector < 72) { | |
df5d3222 | 504 | return EasyDraw1D(drawCommand, Form("%i",sector), cuts, drawOptions, writeDrawCommand); |
39bcd65d | 505 | } |
506 | Error("EasyDraw","The TPC contains only sectors between 0 and 71."); | |
507 | return -1; | |
508 | } | |
509 | ||
39bcd65d | 510 | |
832bb12c | 511 | void AliTPCCalibViewer::FormatHistoLabels(TH1 *histo) const { |
512 | // | |
513 | // formats title and axis labels of histo | |
514 | // removes '.fElements' | |
515 | // | |
516 | if (!histo) return; | |
517 | TString replaceString(fAppendString.Data()); | |
518 | TString *str = new TString(histo->GetTitle()); | |
519 | str->ReplaceAll(replaceString, ""); | |
520 | histo->SetTitle(str->Data()); | |
521 | delete str; | |
522 | if (histo->GetXaxis()) { | |
523 | str = new TString(histo->GetXaxis()->GetTitle()); | |
524 | str->ReplaceAll(replaceString, ""); | |
525 | histo->GetXaxis()->SetTitle(str->Data()); | |
526 | delete str; | |
527 | } | |
528 | if (histo->GetYaxis()) { | |
529 | str = new TString(histo->GetYaxis()->GetTitle()); | |
530 | str->ReplaceAll(replaceString, ""); | |
531 | histo->GetYaxis()->SetTitle(str->Data()); | |
532 | delete str; | |
533 | } | |
534 | if (histo->GetZaxis()) { | |
535 | str = new TString(histo->GetZaxis()->GetTitle()); | |
536 | str->ReplaceAll(replaceString, ""); | |
537 | histo->GetZaxis()->SetTitle(str->Data()); | |
538 | delete str; | |
539 | } | |
540 | } | |
541 | ||
542 | ||
72d0ab7e | 543 | Int_t AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, Int_t sector, const char* cuts, const char *sigmas, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { |
544 | // | |
545 | // Easy drawing of data, in principle the same as EasyDraw1D | |
546 | // Difference: A line for the mean / median / LTM is drawn | |
547 | // in 'sigmas' you can specify in which distance to the mean/median/LTM you want to see a line in sigma-units, separated by ';' | |
548 | // example: sigmas = "2; 4; 6;" at Begin_Latex 2 #sigma End_Latex, Begin_Latex 4 #sigma End_Latex and Begin_Latex 6 #sigma End_Latex a line is drawn. | |
549 | // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see? | |
550 | // | |
551 | if (sector >= 0 && sector < 72) { | |
df5d3222 | 552 | return DrawHisto1D(drawCommand, Form("%i", sector), cuts, sigmas, plotMean, plotMedian, plotLTM); |
72d0ab7e | 553 | } |
554 | Error("DrawHisto1D","The TPC contains only sectors between 0 and 71."); | |
555 | return -1; | |
556 | } | |
39bcd65d | 557 | |
72d0ab7e | 558 | |
559 | Int_t AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* sector, const char* cuts, const char *sigmas, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const { | |
560 | // | |
561 | // Easy drawing of data, in principle the same as EasyDraw1D | |
562 | // Difference: A line for the mean / median / LTM is drawn | |
563 | // in 'sigmas' you can specify in which distance to the mean/median/LTM you want to see a line in sigma-units, separated by ';' | |
564 | // example: sigmas = "2; 4; 6;" at Begin_Latex 2 #sigma End_Latex, Begin_Latex 4 #sigma End_Latex and Begin_Latex 6 #sigma End_Latex a line is drawn. | |
565 | // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see? | |
566 | // | |
39bcd65d | 567 | Int_t oldOptStat = gStyle->GetOptStat(); |
568 | gStyle->SetOptStat(0000000); | |
72d0ab7e | 569 | Double_t ltmFraction = 0.8; |
570 | ||
571 | TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); | |
572 | TVectorF nsigma(sigmasTokens->GetEntriesFast()); | |
573 | for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { | |
574 | TString str(((TObjString*)sigmasTokens->At(i))->GetString()); | |
575 | Double_t sig = (str.IsFloat()) ? str.Atof() : 0; | |
576 | nsigma[i] = sig; | |
39bcd65d | 577 | } |
578 | ||
72d0ab7e | 579 | TString drawStr(drawCommand); |
832bb12c | 580 | Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>"); |
581 | if (dangerousToDraw) { | |
582 | Warning("DrawHisto1D", "The draw string must not contain ':' or '>>'."); | |
583 | return -1; | |
584 | } | |
72d0ab7e | 585 | drawStr += " >> tempHist"; |
586 | Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts); | |
587 | TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); | |
588 | // FIXME is this histogram deleted automatically? | |
589 | Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers | |
590 | ||
591 | Double_t mean = TMath::Mean(entries, values); | |
592 | Double_t median = TMath::Median(entries, values); | |
593 | Double_t sigma = TMath::RMS(entries, values); | |
594 | Double_t maxY = htemp->GetMaximum(); | |
595 | ||
72d0ab7e | 596 | TLegend * legend = new TLegend(.7,.7, .99, .99, "Statistical information"); |
832bb12c | 597 | //fListOfObjectsToBeDeleted->Add(legend); |
39bcd65d | 598 | |
39bcd65d | 599 | if (plotMean) { |
72d0ab7e | 600 | // draw Mean |
601 | TLine* line = new TLine(mean, 0, mean, maxY); | |
832bb12c | 602 | //fListOfObjectsToBeDeleted->Add(line); |
39bcd65d | 603 | line->SetLineColor(kRed); |
604 | line->SetLineWidth(2); | |
605 | line->SetLineStyle(1); | |
606 | line->Draw(); | |
df5d3222 | 607 | legend->AddEntry(line, Form("Mean: %f", mean), "l"); |
72d0ab7e | 608 | // draw sigma lines |
39bcd65d | 609 | for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { |
72d0ab7e | 610 | TLine* linePlusSigma = new TLine(mean + nsigma[i] * sigma, 0, mean + nsigma[i] * sigma, maxY); |
832bb12c | 611 | //fListOfObjectsToBeDeleted->Add(linePlusSigma); |
39bcd65d | 612 | linePlusSigma->SetLineColor(kRed); |
72d0ab7e | 613 | linePlusSigma->SetLineStyle(2 + i); |
39bcd65d | 614 | linePlusSigma->Draw(); |
72d0ab7e | 615 | TLine* lineMinusSigma = new TLine(mean - nsigma[i] * sigma, 0, mean - nsigma[i] * sigma, maxY); |
832bb12c | 616 | //fListOfObjectsToBeDeleted->Add(lineMinusSigma); |
39bcd65d | 617 | lineMinusSigma->SetLineColor(kRed); |
72d0ab7e | 618 | lineMinusSigma->SetLineStyle(2 + i); |
39bcd65d | 619 | lineMinusSigma->Draw(); |
df5d3222 | 620 | legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l"); |
39bcd65d | 621 | } |
622 | } | |
39bcd65d | 623 | if (plotMedian) { |
72d0ab7e | 624 | // draw median |
625 | TLine* line = new TLine(median, 0, median, maxY); | |
832bb12c | 626 | //fListOfObjectsToBeDeleted->Add(line); |
39bcd65d | 627 | line->SetLineColor(kBlue); |
628 | line->SetLineWidth(2); | |
629 | line->SetLineStyle(1); | |
630 | line->Draw(); | |
df5d3222 | 631 | legend->AddEntry(line, Form("Median: %f", median), "l"); |
72d0ab7e | 632 | // draw sigma lines |
39bcd65d | 633 | for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { |
72d0ab7e | 634 | TLine* linePlusSigma = new TLine(median + nsigma[i] * sigma, 0, median + nsigma[i]*sigma, maxY); |
832bb12c | 635 | //fListOfObjectsToBeDeleted->Add(linePlusSigma); |
39bcd65d | 636 | linePlusSigma->SetLineColor(kBlue); |
72d0ab7e | 637 | linePlusSigma->SetLineStyle(2 + i); |
39bcd65d | 638 | linePlusSigma->Draw(); |
72d0ab7e | 639 | TLine* lineMinusSigma = new TLine(median - nsigma[i] * sigma, 0, median - nsigma[i]*sigma, maxY); |
832bb12c | 640 | //fListOfObjectsToBeDeleted->Add(lineMinusSigma); |
39bcd65d | 641 | lineMinusSigma->SetLineColor(kBlue); |
72d0ab7e | 642 | lineMinusSigma->SetLineStyle(2 + i); |
39bcd65d | 643 | lineMinusSigma->Draw(); |
df5d3222 | 644 | legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l"); |
39bcd65d | 645 | } |
646 | } | |
39bcd65d | 647 | if (plotLTM) { |
72d0ab7e | 648 | // draw LTM |
649 | Double_t ltmRms = 0; | |
650 | Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); | |
651 | TLine* line = new TLine(ltm, 0, ltm, maxY); | |
832bb12c | 652 | //fListOfObjectsToBeDeleted->Add(line); |
39bcd65d | 653 | line->SetLineColor(kGreen+2); |
654 | line->SetLineWidth(2); | |
655 | line->SetLineStyle(1); | |
656 | line->Draw(); | |
df5d3222 | 657 | legend->AddEntry(line, Form("LTM: %f", ltm), "l"); |
72d0ab7e | 658 | // draw sigma lines |
39bcd65d | 659 | for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { |
72d0ab7e | 660 | TLine* linePlusSigma = new TLine(ltm + nsigma[i] * ltmRms, 0, ltm + nsigma[i] * ltmRms, maxY); |
832bb12c | 661 | //fListOfObjectsToBeDeleted->Add(linePlusSigma); |
39bcd65d | 662 | linePlusSigma->SetLineColor(kGreen+2); |
663 | linePlusSigma->SetLineStyle(2+i); | |
664 | linePlusSigma->Draw(); | |
665 | ||
72d0ab7e | 666 | TLine* lineMinusSigma = new TLine(ltm - nsigma[i] * ltmRms, 0, ltm - nsigma[i] * ltmRms, maxY); |
832bb12c | 667 | //fListOfObjectsToBeDeleted->Add(lineMinusSigma); |
39bcd65d | 668 | lineMinusSigma->SetLineColor(kGreen+2); |
669 | lineMinusSigma->SetLineStyle(2+i); | |
670 | lineMinusSigma->Draw(); | |
df5d3222 | 671 | legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms)), "l"); |
39bcd65d | 672 | } |
673 | } | |
72d0ab7e | 674 | if (!plotMean && !plotMedian && !plotLTM) return -1; |
39bcd65d | 675 | legend->Draw(); |
676 | gStyle->SetOptStat(oldOptStat); | |
72d0ab7e | 677 | return 1; |
39bcd65d | 678 | } |
679 | ||
39bcd65d | 680 | |
72d0ab7e | 681 | Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, Int_t sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, const char *sigmas, Float_t sigmaStep) const { |
682 | // | |
683 | // Creates a histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value | |
684 | // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'array', 'n' specifies the length of the array | |
685 | // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'array', to be specified by the user | |
686 | // 'nbins': number of bins, 'binLow': first bin, 'binUp': last bin | |
687 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) | |
688 | // sigmaStep: the binsize of the generated histogram | |
689 | // Begin_Latex | |
6a1caa6b | 690 | // f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = (#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx + #int_{#mu}^{#mu - t #sigma} f(x, #mu, #sigma) dx) / (#int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx) |
72d0ab7e | 691 | // End_Latex |
692 | // | |
693 | // | |
694 | // Creates a histogram, where you can see, how much of the data are inside sigma-intervals | |
695 | // around the mean/median/LTM | |
696 | // with drawCommand, sector and cuts you specify your input data, see EasyDraw | |
697 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma) | |
698 | // sigmaStep: the binsize of the generated histogram | |
699 | // plotMean/plotMedian/plotLTM: specifies where to put the center | |
700 | // | |
701 | if (sector >= 0 && sector < 72) { | |
df5d3222 | 702 | return SigmaCut(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, pm, sigmas, sigmaStep); |
72d0ab7e | 703 | } |
704 | Error("SigmaCut","The TPC contains only sectors between 0 and 71."); | |
705 | return -1; | |
706 | } | |
707 | ||
708 | ||
709 | Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, const char *sigmas, Float_t sigmaStep) const { | |
710 | // | |
711 | // Creates a histogram, where you can see, how much of the data are inside sigma-intervals | |
712 | // around the mean/median/LTM | |
713 | // with drawCommand, sector and cuts you specify your input data, see EasyDraw | |
714 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma) | |
715 | // sigmaStep: the binsize of the generated histogram | |
716 | // plotMean/plotMedian/plotLTM: specifies where to put the center | |
717 | // | |
718 | ||
719 | Double_t ltmFraction = 0.8; | |
720 | ||
721 | TString drawStr(drawCommand); | |
832bb12c | 722 | Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>"); |
723 | if (dangerousToDraw) { | |
724 | Warning("SigmaCut", "The draw string must not contain ':' or '>>'."); | |
725 | return -1; | |
726 | } | |
72d0ab7e | 727 | drawStr += " >> tempHist"; |
728 | ||
729 | Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); | |
730 | TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); | |
731 | // FIXME is this histogram deleted automatically? | |
732 | Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers | |
733 | ||
734 | Double_t mean = TMath::Mean(entries, values); | |
735 | Double_t median = TMath::Median(entries, values); | |
736 | Double_t sigma = TMath::RMS(entries, values); | |
737 | ||
738 | TLegend * legend = new TLegend(.7,.7, .99, .99, "Cumulative"); | |
832bb12c | 739 | //fListOfObjectsToBeDeleted->Add(legend); |
72d0ab7e | 740 | TH1F *cutHistoMean = 0; |
741 | TH1F *cutHistoMedian = 0; | |
742 | TH1F *cutHistoLTM = 0; | |
743 | ||
744 | TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); | |
745 | TVectorF nsigma(sigmasTokens->GetEntriesFast()); | |
746 | for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { | |
747 | TString str(((TObjString*)sigmasTokens->At(i))->GetString()); | |
748 | Double_t sig = (str.IsFloat()) ? str.Atof() : 0; | |
749 | nsigma[i] = sig; | |
750 | } | |
751 | ||
752 | if (plotMean) { | |
753 | cutHistoMean = AliTPCCalibViewer::SigmaCut(htemp, mean, sigma, sigmaMax, sigmaStep, pm); | |
754 | if (cutHistoMean) { | |
832bb12c | 755 | //fListOfObjectsToBeDeleted->Add(cutHistoMean); |
72d0ab7e | 756 | cutHistoMean->SetLineColor(kRed); |
757 | legend->AddEntry(cutHistoMean, "Mean", "l"); | |
758 | cutHistoMean->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
759 | cutHistoMean->Draw(); | |
760 | DrawLines(cutHistoMean, nsigma, legend, kRed, pm); | |
761 | } // if (cutHistoMean) | |
762 | ||
763 | } | |
764 | if (plotMedian) { | |
765 | cutHistoMedian = AliTPCCalibViewer::SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm); | |
766 | if (cutHistoMedian) { | |
832bb12c | 767 | //fListOfObjectsToBeDeleted->Add(cutHistoMedian); |
72d0ab7e | 768 | cutHistoMedian->SetLineColor(kBlue); |
769 | legend->AddEntry(cutHistoMedian, "Median", "l"); | |
770 | cutHistoMedian->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
771 | if (plotMean && cutHistoMean) cutHistoMedian->Draw("same"); | |
772 | else cutHistoMedian->Draw(); | |
773 | DrawLines(cutHistoMedian, nsigma, legend, kBlue, pm); | |
774 | } // if (cutHistoMedian) | |
775 | } | |
776 | if (plotLTM) { | |
777 | Double_t ltmRms = 0; | |
778 | Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); | |
779 | cutHistoLTM = AliTPCCalibViewer::SigmaCut(htemp, ltm, ltmRms, sigmaMax, sigmaStep, pm); | |
780 | if (cutHistoLTM) { | |
832bb12c | 781 | //fListOfObjectsToBeDeleted->Add(cutHistoLTM); |
72d0ab7e | 782 | cutHistoLTM->SetLineColor(kGreen+2); |
783 | legend->AddEntry(cutHistoLTM, "LTM", "l"); | |
784 | cutHistoLTM->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
94bf739c | 785 | if ((plotMean && cutHistoMean) || (plotMedian && cutHistoMedian)) cutHistoLTM->Draw("same"); |
72d0ab7e | 786 | else cutHistoLTM->Draw(); |
787 | DrawLines(cutHistoLTM, nsigma, legend, kGreen+2, pm); | |
788 | } | |
789 | } | |
790 | if (!plotMean && !plotMedian && !plotLTM) return -1; | |
791 | legend->Draw(); | |
792 | return 1; | |
793 | } | |
794 | ||
832bb12c | 795 | |
2773a273 | 796 | Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector, const char* cuts, Float_t /*sigmaMax*/, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t /*pm*/, const char *sigmas, Float_t /*sigmaStep*/) const { |
4f3934a1 | 797 | // |
798 | // Creates a histogram, where you can see, how much of the data are inside sigma-intervals | |
799 | // around the mean/median/LTM | |
800 | // with drawCommand, sector and cuts you specify your input data, see EasyDraw | |
801 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma) | |
802 | // sigmaStep: the binsize of the generated histogram | |
803 | // plotMean/plotMedian/plotLTM: specifies where to put the center | |
804 | // | |
805 | ||
806 | // Double_t ltmFraction = 0.8; //unused | |
4f3934a1 | 807 | |
808 | TString drawStr(drawCommand); | |
809 | drawStr += " >> tempHist"; | |
810 | ||
811 | Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); | |
812 | TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); | |
813 | TGraph *cutGraphMean = 0; | |
814 | // TGraph *cutGraphMedian = 0; | |
815 | // TGraph *cutGraphLTM = 0; | |
816 | Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers | |
817 | Int_t *index = new Int_t[entries]; | |
818 | Float_t *xarray = new Float_t[entries]; | |
819 | Float_t *yarray = new Float_t[entries]; | |
820 | TMath::Sort(entries, values, index, kFALSE); | |
821 | ||
822 | Double_t mean = TMath::Mean(entries, values); | |
823 | // Double_t median = TMath::Median(entries, values); | |
824 | Double_t sigma = TMath::RMS(entries, values); | |
825 | ||
826 | TLegend * legend = new TLegend(.7,.7, .99, .99, "Cumulative"); | |
832bb12c | 827 | //fListOfObjectsToBeDeleted->Add(legend); |
4f3934a1 | 828 | |
829 | // parse sigmas string | |
830 | TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); | |
831 | TVectorF nsigma(sigmasTokens->GetEntriesFast()); | |
832 | for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { | |
833 | TString str(((TObjString*)sigmasTokens->At(i))->GetString()); | |
834 | Double_t sig = (str.IsFloat()) ? str.Atof() : 0; | |
835 | nsigma[i] = sig; | |
836 | } | |
837 | ||
838 | if (plotMean) { | |
839 | for (Int_t i = 0; i < entries; i++) { | |
840 | xarray[i] = TMath::Abs(values[index[i]] - mean) / sigma; | |
841 | yarray[i] = float(i) / float(entries); | |
842 | } | |
843 | cutGraphMean = new TGraph(entries, xarray, yarray); | |
844 | if (cutGraphMean) { | |
832bb12c | 845 | //fListOfObjectsToBeDeleted->Add(cutGraphMean); |
4f3934a1 | 846 | cutGraphMean->SetLineColor(kRed); |
847 | legend->AddEntry(cutGraphMean, "Mean", "l"); | |
848 | cutGraphMean->SetTitle(Form("%s, Cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
849 | cutGraphMean->Draw("alu"); | |
850 | DrawLines(cutGraphMean, nsigma, legend, kRed, kTRUE); | |
851 | } | |
852 | } | |
df5d3222 | 853 | delete [] index; |
854 | delete [] xarray; | |
855 | delete [] yarray; | |
4f3934a1 | 856 | /* |
857 | if (plotMedian) { | |
858 | cutHistoMedian = AliTPCCalibViewer::SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm); | |
859 | if (cutHistoMedian) { | |
860 | fListOfObjectsToBeDeleted->Add(cutHistoMedian); | |
861 | cutHistoMedian->SetLineColor(kBlue); | |
862 | legend->AddEntry(cutHistoMedian, "Median", "l"); | |
863 | cutHistoMedian->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
864 | if (plotMean && cutHistoMean) cutHistoMedian->Draw("same"); | |
865 | else cutHistoMedian->Draw(); | |
866 | DrawLines(cutHistoMedian, nsigma, legend, kBlue, pm); | |
867 | } // if (cutHistoMedian) | |
868 | } | |
869 | if (plotLTM) { | |
870 | Double_t ltmRms = 0; | |
871 | Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); | |
872 | cutHistoLTM = AliTPCCalibViewer::SigmaCut(htemp, ltm, ltmRms, sigmaMax, sigmaStep, pm); | |
873 | if (cutHistoLTM) { | |
874 | fListOfObjectsToBeDeleted->Add(cutHistoLTM); | |
875 | cutHistoLTM->SetLineColor(kGreen+2); | |
876 | legend->AddEntry(cutHistoLTM, "LTM", "l"); | |
877 | cutHistoLTM->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
878 | if (plotMean && cutHistoMean || plotMedian && cutHistoMedian) cutHistoLTM->Draw("same"); | |
879 | else cutHistoLTM->Draw(); | |
880 | DrawLines(cutHistoLTM, nsigma, legend, kGreen+2, pm); | |
881 | } | |
882 | }*/ | |
883 | if (!plotMean && !plotMedian && !plotLTM) return -1; | |
884 | legend->Draw(); | |
885 | return 1; | |
886 | } | |
887 | ||
72d0ab7e | 888 | |
72d0ab7e | 889 | Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, Int_t sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t sigmaStep) const { |
890 | // | |
891 | // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" | |
892 | // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user | |
893 | // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate | |
894 | // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated | |
895 | // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
896 | // The actual work is done on the array. | |
897 | /* Begin_Latex | |
6a1caa6b | 898 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx |
72d0ab7e | 899 | End_Latex |
900 | */ | |
901 | if (sector >= 0 && sector < 72) { | |
df5d3222 | 902 | return Integrate(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, sigmas, sigmaStep); |
72d0ab7e | 903 | } |
904 | Error("Integrate","The TPC contains only sectors between 0 and 71."); | |
905 | return -1; | |
906 | ||
907 | } | |
908 | ||
909 | ||
4f3934a1 | 910 | Int_t AliTPCCalibViewer::IntegrateOld(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t sigmaStep) const { |
72d0ab7e | 911 | // |
912 | // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" | |
913 | // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user | |
914 | // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate | |
915 | // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated | |
916 | // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
917 | // The actual work is done on the array. | |
918 | /* Begin_Latex | |
6a1caa6b | 919 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx |
72d0ab7e | 920 | End_Latex |
921 | */ | |
922 | ||
923 | Double_t ltmFraction = 0.8; | |
924 | ||
925 | TString drawStr(drawCommand); | |
926 | drawStr += " >> tempHist"; | |
927 | ||
928 | Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); | |
929 | TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); | |
930 | // FIXME is this histogram deleted automatically? | |
931 | Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers | |
932 | ||
933 | Double_t mean = TMath::Mean(entries, values); | |
934 | Double_t median = TMath::Median(entries, values); | |
935 | Double_t sigma = TMath::RMS(entries, values); | |
936 | ||
937 | TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); | |
938 | TVectorF nsigma(sigmasTokens->GetEntriesFast()); | |
939 | for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { | |
940 | TString str(((TObjString*)sigmasTokens->At(i))->GetString()); | |
941 | Double_t sig = (str.IsFloat()) ? str.Atof() : 0; | |
942 | nsigma[i] = sig; | |
943 | } | |
944 | ||
945 | TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram"); | |
832bb12c | 946 | //fListOfObjectsToBeDeleted->Add(legend); |
72d0ab7e | 947 | TH1F *integralHistoMean = 0; |
948 | TH1F *integralHistoMedian = 0; | |
949 | TH1F *integralHistoLTM = 0; | |
950 | ||
951 | if (plotMean) { | |
952 | integralHistoMean = AliTPCCalibViewer::Integrate(htemp, mean, sigma, sigmaMax, sigmaStep); | |
953 | if (integralHistoMean) { | |
832bb12c | 954 | //fListOfObjectsToBeDeleted->Add(integralHistoMean); |
72d0ab7e | 955 | integralHistoMean->SetLineColor(kRed); |
956 | legend->AddEntry(integralHistoMean, "Mean", "l"); | |
957 | integralHistoMean->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
958 | integralHistoMean->Draw(); | |
959 | DrawLines(integralHistoMean, nsigma, legend, kRed, kTRUE); | |
39bcd65d | 960 | } |
72d0ab7e | 961 | } |
962 | if (plotMedian) { | |
963 | integralHistoMedian = AliTPCCalibViewer::Integrate(htemp, median, sigma, sigmaMax, sigmaStep); | |
964 | if (integralHistoMedian) { | |
832bb12c | 965 | //fListOfObjectsToBeDeleted->Add(integralHistoMedian); |
72d0ab7e | 966 | integralHistoMedian->SetLineColor(kBlue); |
967 | legend->AddEntry(integralHistoMedian, "Median", "l"); | |
968 | integralHistoMedian->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
969 | if (plotMean && integralHistoMean) integralHistoMedian->Draw("same"); | |
970 | else integralHistoMedian->Draw(); | |
971 | DrawLines(integralHistoMedian, nsigma, legend, kBlue, kTRUE); | |
39bcd65d | 972 | } |
72d0ab7e | 973 | } |
974 | if (plotLTM) { | |
975 | Double_t ltmRms = 0; | |
976 | Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); | |
977 | integralHistoLTM = AliTPCCalibViewer::Integrate(htemp, ltm, ltmRms, sigmaMax, sigmaStep); | |
978 | if (integralHistoLTM) { | |
832bb12c | 979 | //fListOfObjectsToBeDeleted->Add(integralHistoLTM); |
72d0ab7e | 980 | integralHistoLTM->SetLineColor(kGreen+2); |
981 | legend->AddEntry(integralHistoLTM, "LTM", "l"); | |
982 | integralHistoLTM->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
94bf739c | 983 | if ((plotMean && integralHistoMean) || (plotMedian && integralHistoMedian)) integralHistoLTM->Draw("same"); |
72d0ab7e | 984 | else integralHistoLTM->Draw(); |
985 | DrawLines(integralHistoLTM, nsigma, legend, kGreen+2, kTRUE); | |
39bcd65d | 986 | } |
987 | } | |
72d0ab7e | 988 | if (!plotMean && !plotMedian && !plotLTM) return -1; |
989 | legend->Draw(); | |
990 | return 1; | |
991 | } | |
992 | ||
993 | ||
2773a273 | 994 | Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector, const char* cuts, Float_t /*sigmaMax*/, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t /*sigmaStep*/) const { |
4f3934a1 | 995 | // |
996 | // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" | |
997 | // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user | |
998 | // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate | |
999 | // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated | |
1000 | // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
1001 | // The actual work is done on the array. | |
1002 | /* Begin_Latex | |
6a1caa6b | 1003 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx |
4f3934a1 | 1004 | End_Latex |
1005 | */ | |
1006 | ||
1007 | Double_t ltmFraction = 0.8; | |
4f3934a1 | 1008 | |
1009 | TString drawStr(drawCommand); | |
832bb12c | 1010 | Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>"); |
1011 | if (dangerousToDraw) { | |
1012 | Warning("Integrate", "The draw string must not contain ':' or '>>'."); | |
1013 | return -1; | |
1014 | } | |
4f3934a1 | 1015 | drawStr += " >> tempHist"; |
1016 | ||
1017 | Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff"); | |
1018 | TH1F *htemp = (TH1F*)gDirectory->Get("tempHist"); | |
1019 | TGraph *integralGraphMean = 0; | |
1020 | TGraph *integralGraphMedian = 0; | |
1021 | TGraph *integralGraphLTM = 0; | |
1022 | Double_t *values = fTree->GetV1(); // value is the array containing 'entries' numbers | |
1023 | Int_t *index = new Int_t[entries]; | |
1024 | Float_t *xarray = new Float_t[entries]; | |
1025 | Float_t *yarray = new Float_t[entries]; | |
1026 | TMath::Sort(entries, values, index, kFALSE); | |
1027 | ||
1028 | Double_t mean = TMath::Mean(entries, values); | |
1029 | Double_t median = TMath::Median(entries, values); | |
1030 | Double_t sigma = TMath::RMS(entries, values); | |
1031 | ||
1032 | // parse sigmas string | |
1033 | TObjArray *sigmasTokens = TString(sigmas).Tokenize(";"); | |
1034 | TVectorF nsigma(sigmasTokens->GetEntriesFast()); | |
1035 | for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) { | |
1036 | TString str(((TObjString*)sigmasTokens->At(i))->GetString()); | |
1037 | Double_t sig = (str.IsFloat()) ? str.Atof() : 0; | |
1038 | nsigma[i] = sig; | |
1039 | } | |
1040 | ||
1041 | TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram"); | |
832bb12c | 1042 | //fListOfObjectsToBeDeleted->Add(legend); |
4f3934a1 | 1043 | |
1044 | if (plotMean) { | |
1045 | for (Int_t i = 0; i < entries; i++) { | |
1046 | xarray[i] = (values[index[i]] - mean) / sigma; | |
1047 | yarray[i] = float(i) / float(entries); | |
1048 | } | |
1049 | integralGraphMean = new TGraph(entries, xarray, yarray); | |
1050 | if (integralGraphMean) { | |
832bb12c | 1051 | //fListOfObjectsToBeDeleted->Add(integralGraphMean); |
4f3934a1 | 1052 | integralGraphMean->SetLineColor(kRed); |
1053 | legend->AddEntry(integralGraphMean, "Mean", "l"); | |
1054 | integralGraphMean->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
1055 | integralGraphMean->Draw("alu"); | |
1056 | DrawLines(integralGraphMean, nsigma, legend, kRed, kTRUE); | |
1057 | } | |
1058 | } | |
1059 | if (plotMedian) { | |
1060 | for (Int_t i = 0; i < entries; i++) { | |
1061 | xarray[i] = (values[index[i]] - median) / sigma; | |
1062 | yarray[i] = float(i) / float(entries); | |
1063 | } | |
1064 | integralGraphMedian = new TGraph(entries, xarray, yarray); | |
1065 | if (integralGraphMedian) { | |
832bb12c | 1066 | //fListOfObjectsToBeDeleted->Add(integralGraphMedian); |
4f3934a1 | 1067 | integralGraphMedian->SetLineColor(kBlue); |
1068 | legend->AddEntry(integralGraphMedian, "Median", "l"); | |
1069 | integralGraphMedian->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
1070 | if (plotMean && integralGraphMean) integralGraphMedian->Draw("samelu"); | |
1071 | else integralGraphMedian->Draw("alu"); | |
1072 | DrawLines(integralGraphMedian, nsigma, legend, kBlue, kTRUE); | |
1073 | } | |
1074 | } | |
1075 | if (plotLTM) { | |
1076 | Double_t ltmRms = 0; | |
1077 | Double_t ltm = GetLTM(entries, values, <mRms, ltmFraction); | |
1078 | for (Int_t i = 0; i < entries; i++) { | |
1079 | xarray[i] = (values[index[i]] - ltm) / ltmRms; | |
1080 | yarray[i] = float(i) / float(entries); | |
1081 | } | |
1082 | integralGraphLTM = new TGraph(entries, xarray, yarray); | |
1083 | if (integralGraphLTM) { | |
832bb12c | 1084 | //fListOfObjectsToBeDeleted->Add(integralGraphLTM); |
4f3934a1 | 1085 | integralGraphLTM->SetLineColor(kGreen+2); |
1086 | legend->AddEntry(integralGraphLTM, "LTM", "l"); | |
1087 | integralGraphLTM->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle())); | |
94bf739c | 1088 | if ((plotMean && integralGraphMean) || (plotMedian && integralGraphMedian)) integralGraphLTM->Draw("samelu"); |
4f3934a1 | 1089 | else integralGraphLTM->Draw("alu"); |
1090 | DrawLines(integralGraphLTM, nsigma, legend, kGreen+2, kTRUE); | |
1091 | } | |
1092 | } | |
df5d3222 | 1093 | delete [] index; |
1094 | delete [] xarray; | |
1095 | delete [] yarray; | |
1096 | ||
4f3934a1 | 1097 | if (!plotMean && !plotMedian && !plotLTM) return -1; |
1098 | legend->Draw(); | |
1099 | return entries; | |
1100 | } | |
1101 | ||
1102 | ||
72d0ab7e | 1103 | void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const { |
1104 | // | |
1105 | // Private function for SigmaCut(...) and Integrate(...) | |
1106 | // Draws lines into the given histogram, specified by "nsigma", the lines are addeed to the legend | |
1107 | // | |
39bcd65d | 1108 | |
72d0ab7e | 1109 | // start to draw the lines, loop over requested sigmas |
72d0ab7e | 1110 | for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { |
1111 | if (!pm) { | |
1112 | Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]); | |
1113 | TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin)); | |
832bb12c | 1114 | //fListOfObjectsToBeDeleted->Add(lineUp); |
72d0ab7e | 1115 | lineUp->SetLineColor(color); |
1116 | lineUp->SetLineStyle(2 + i); | |
1117 | lineUp->Draw(); | |
1118 | TLine* lineLeft = new TLine(nsigma[i], histogram->GetBinContent(bin), 0, histogram->GetBinContent(bin)); | |
832bb12c | 1119 | //fListOfObjectsToBeDeleted->Add(lineLeft); |
72d0ab7e | 1120 | lineLeft->SetLineColor(color); |
1121 | lineLeft->SetLineStyle(2 + i); | |
1122 | lineLeft->Draw(); | |
df5d3222 | 1123 | legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l"); |
72d0ab7e | 1124 | } |
1125 | else { // if (pm) | |
1126 | Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]); | |
1127 | TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin)); | |
832bb12c | 1128 | //fListOfObjectsToBeDeleted->Add(lineUp1); |
72d0ab7e | 1129 | lineUp1->SetLineColor(color); |
1130 | lineUp1->SetLineStyle(2 + i); | |
1131 | lineUp1->Draw(); | |
1132 | TLine* lineLeft1 = new TLine(nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin)); | |
832bb12c | 1133 | //fListOfObjectsToBeDeleted->Add(lineLeft1); |
72d0ab7e | 1134 | lineLeft1->SetLineColor(color); |
1135 | lineLeft1->SetLineStyle(2 + i); | |
1136 | lineLeft1->Draw(); | |
df5d3222 | 1137 | legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l"); |
72d0ab7e | 1138 | bin = histogram->GetXaxis()->FindBin(-nsigma[i]); |
1139 | TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], histogram->GetBinContent(bin)); | |
832bb12c | 1140 | //fListOfObjectsToBeDeleted->Add(lineUp2); |
72d0ab7e | 1141 | lineUp2->SetLineColor(color); |
1142 | lineUp2->SetLineStyle(2 + i); | |
1143 | lineUp2->Draw(); | |
1144 | TLine* lineLeft2 = new TLine(-nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin)); | |
832bb12c | 1145 | //fListOfObjectsToBeDeleted->Add(lineLeft2); |
72d0ab7e | 1146 | lineLeft2->SetLineColor(color); |
1147 | lineLeft2->SetLineStyle(2 + i); | |
1148 | lineLeft2->Draw(); | |
df5d3222 | 1149 | legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l"); |
72d0ab7e | 1150 | } |
1151 | } // for (Int_t i = 0; i < nsigma.GetNoElements(); i++) | |
1152 | } | |
1153 | ||
1154 | ||
4f3934a1 | 1155 | void AliTPCCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const { |
1156 | // | |
1157 | // Private function for SigmaCut(...) and Integrate(...) | |
1158 | // Draws lines into the given histogram, specified by "nsigma", the lines are addeed to the legend | |
1159 | // | |
1160 | ||
1161 | // start to draw the lines, loop over requested sigmas | |
4f3934a1 | 1162 | for (Int_t i = 0; i < nsigma.GetNoElements(); i++) { |
1163 | if (!pm) { | |
1164 | TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i])); | |
832bb12c | 1165 | //fListOfObjectsToBeDeleted->Add(lineUp); |
4f3934a1 | 1166 | lineUp->SetLineColor(color); |
1167 | lineUp->SetLineStyle(2 + i); | |
1168 | lineUp->Draw(); | |
1169 | TLine* lineLeft = new TLine(nsigma[i], graph->Eval(nsigma[i]), 0, graph->Eval(nsigma[i])); | |
832bb12c | 1170 | //fListOfObjectsToBeDeleted->Add(lineLeft); |
4f3934a1 | 1171 | lineLeft->SetLineColor(color); |
1172 | lineLeft->SetLineStyle(2 + i); | |
1173 | lineLeft->Draw(); | |
df5d3222 | 1174 | legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l"); |
4f3934a1 | 1175 | } |
1176 | else { // if (pm) | |
1177 | TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i])); | |
832bb12c | 1178 | //fListOfObjectsToBeDeleted->Add(lineUp1); |
4f3934a1 | 1179 | lineUp1->SetLineColor(color); |
1180 | lineUp1->SetLineStyle(2 + i); | |
1181 | lineUp1->Draw(); | |
1182 | TLine* lineLeft1 = new TLine(nsigma[i], graph->Eval(nsigma[i]), graph->GetHistogram()->GetXaxis()->GetBinLowEdge(0), graph->Eval(nsigma[i])); | |
832bb12c | 1183 | //fListOfObjectsToBeDeleted->Add(lineLeft1); |
4f3934a1 | 1184 | lineLeft1->SetLineColor(color); |
1185 | lineLeft1->SetLineStyle(2 + i); | |
1186 | lineLeft1->Draw(); | |
df5d3222 | 1187 | legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l"); |
4f3934a1 | 1188 | TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], graph->Eval(-nsigma[i])); |
832bb12c | 1189 | //fListOfObjectsToBeDeleted->Add(lineUp2); |
4f3934a1 | 1190 | lineUp2->SetLineColor(color); |
1191 | lineUp2->SetLineStyle(2 + i); | |
1192 | lineUp2->Draw(); | |
1193 | TLine* lineLeft2 = new TLine(-nsigma[i], graph->Eval(-nsigma[i]), graph->GetHistogram()->GetXaxis()->GetBinLowEdge(0), graph->Eval(-nsigma[i])); | |
832bb12c | 1194 | //fListOfObjectsToBeDeleted->Add(lineLeft2); |
4f3934a1 | 1195 | lineLeft2->SetLineColor(color); |
1196 | lineLeft2->SetLineStyle(2 + i); | |
1197 | lineLeft2->Draw(); | |
df5d3222 | 1198 | legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], graph->Eval(-nsigma[i])), "l"); |
4f3934a1 | 1199 | } |
1200 | } // for (Int_t i = 0; i < nsigma.GetNoElements(); i++) | |
1201 | } | |
1202 | ||
72d0ab7e | 1203 | |
1204 | ||
1205 | ||
1206 | ||
1207 | ///////////////// | |
1208 | // Array tools // | |
1209 | ///////////////// | |
1210 | ||
1211 | ||
1212 | Int_t AliTPCCalibViewer::GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp){ | |
1213 | // Returns the 'bin' for 'value' | |
1214 | // The interval between 'binLow' and 'binUp' is divided into 'nbins' equidistant bins | |
1215 | // avoid index out of bounds error: 'if (bin < binLow) bin = binLow' and vice versa | |
1216 | /* Begin_Latex | |
1217 | GetBin(value) = #frac{nbins - 1}{binUp - binLow} #upoint (value - binLow) +1 | |
1218 | End_Latex | |
1219 | */ | |
1220 | ||
1221 | Int_t bin = TMath::Nint( (Float_t)(value - binLow) / (Float_t)(binUp - binLow) * (nbins-1) ) + 1; | |
1222 | // avoid index out of bounds: | |
1223 | if (value < binLow) bin = 0; | |
1224 | if (value > binUp) bin = nbins + 1; | |
1225 | return bin; | |
39bcd65d | 1226 | |
72d0ab7e | 1227 | } |
39bcd65d | 1228 | |
72d0ab7e | 1229 | |
2811495d | 1230 | Double_t AliTPCCalibViewer::GetLTM(Int_t n, const Double_t *const array, Double_t *const sigma, Double_t fraction){ |
72d0ab7e | 1231 | // |
1232 | // returns the LTM and sigma | |
1233 | // | |
1234 | Double_t *ddata = new Double_t[n]; | |
1235 | Double_t mean = 0, lsigma = 0; | |
1236 | UInt_t nPoints = 0; | |
1237 | for (UInt_t i = 0; i < (UInt_t)n; i++) { | |
1238 | ddata[nPoints]= array[nPoints]; | |
1239 | nPoints++; | |
1240 | } | |
1241 | Int_t hh = TMath::Min(TMath::Nint(fraction * nPoints), Int_t(n)); | |
1242 | AliMathBase::EvaluateUni(nPoints, ddata, mean, lsigma, hh); | |
1243 | if (sigma) *sigma = lsigma; | |
1244 | delete [] ddata; | |
1245 | return mean; | |
39bcd65d | 1246 | } |
1247 | ||
1248 | ||
2811495d | 1249 | TH1F* AliTPCCalibViewer::SigmaCut(TH1F *const histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm) { |
72d0ab7e | 1250 | // |
1251 | // Creates a cumulative histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value | |
1252 | // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'histogram' | |
1253 | // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'histogram', to be specified by the user | |
1254 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) | |
1255 | // sigmaStep: the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
1256 | // pm: Decide weather Begin_Latex t > 0 End_Latex (first case) or Begin_Latex t End_Latex arbitrary (secound case) | |
1257 | // The actual work is done on the array. | |
1258 | /* Begin_Latex | |
6a1caa6b | 1259 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = (#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx + #int_{#mu}^{#mu - t #sigma} f(x, #mu, #sigma) dx) / (#int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx), for t > 0 |
72d0ab7e | 1260 | or |
6a1caa6b | 1261 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx |
72d0ab7e | 1262 | End_Latex |
6a1caa6b | 1263 | Begin_Macro(source) |
72d0ab7e | 1264 | { |
1265 | Float_t mean = 0; | |
1266 | Float_t sigma = 1.5; | |
1267 | Float_t sigmaMax = 4; | |
1268 | gROOT->SetStyle("Plain"); | |
6a1caa6b | 1269 | TH1F *distribution = new TH1F("Distrib1", "Distribution f(x, #mu, #sigma)", 1000,-5,5); |
72d0ab7e | 1270 | TRandom rand(23); |
1271 | for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma)); | |
1272 | Float_t *ar = distribution->GetArray(); | |
1273 | ||
6a1caa6b | 1274 | TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer1", "", 350, 350); |
72d0ab7e | 1275 | macro_example_canvas->Divide(0,3); |
1276 | TVirtualPad *pad1 = macro_example_canvas->cd(1); | |
1277 | pad1->SetGridy(); | |
1278 | pad1->SetGridx(); | |
1279 | distribution->Draw(); | |
1280 | TVirtualPad *pad2 = macro_example_canvas->cd(2); | |
1281 | pad2->SetGridy(); | |
1282 | pad2->SetGridx(); | |
1283 | ||
1284 | TH1F *shist = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax); | |
1285 | shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)"); | |
1286 | shist->Draw(); | |
1287 | TVirtualPad *pad3 = macro_example_canvas->cd(3); | |
1288 | pad3->SetGridy(); | |
1289 | pad3->SetGridx(); | |
1290 | TH1F *shistPM = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax, -1, kTRUE); | |
1291 | shistPM->Draw(); | |
1292 | return macro_example_canvas; | |
1293 | } | |
6a1caa6b | 1294 | End_Macro |
72d0ab7e | 1295 | */ |
1296 | ||
1297 | Float_t *array = histogram->GetArray(); | |
1298 | Int_t nbins = histogram->GetXaxis()->GetNbins(); | |
1299 | Float_t binLow = histogram->GetXaxis()->GetXmin(); | |
1300 | Float_t binUp = histogram->GetXaxis()->GetXmax(); | |
1301 | return AliTPCCalibViewer::SigmaCut(nbins, array, mean, sigma, nbins, binLow, binUp, sigmaMax, sigmaStep, pm); | |
1302 | } | |
1303 | ||
1304 | ||
2811495d | 1305 | TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, const Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm){ |
72d0ab7e | 1306 | // |
1307 | // Creates a histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value | |
1308 | // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'array', 'n' specifies the length of the array | |
1309 | // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in 'array', to be specified by the user | |
1310 | // 'nbins': number of bins, 'binLow': first bin, 'binUp': last bin | |
1311 | // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex) | |
1312 | // sigmaStep: the binsize of the generated histogram | |
1313 | // Here the actual work is done. | |
1314 | ||
1315 | if (sigma == 0) return 0; | |
1316 | Float_t binWidth = (binUp-binLow)/(nbins - 1); | |
1317 | if (sigmaStep <= 0) sigmaStep = binWidth; | |
1318 | Int_t kbins = (Int_t)(sigmaMax * sigma / sigmaStep) + 1; // + 1 due to overflow bin in histograms | |
1319 | if (pm) kbins = 2 * (Int_t)(sigmaMax * sigma / sigmaStep) + 1; | |
1320 | Float_t kbinLow = !pm ? 0 : -sigmaMax; | |
1321 | Float_t kbinUp = sigmaMax; | |
1322 | TH1F *hist = new TH1F("sigmaCutHisto","Cumulative; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); | |
1323 | hist->SetDirectory(0); | |
1324 | hist->Reset(); | |
1325 | ||
1326 | // calculate normalization | |
1327 | Double_t normalization = 0; | |
1328 | for (Int_t i = 0; i <= n; i++) { | |
1329 | normalization += array[i]; | |
1330 | } | |
1331 | ||
1332 | // given units: units from given histogram | |
1333 | // sigma units: in units of sigma | |
1334 | // iDelta: integrate in interval (mean +- iDelta), given units | |
1335 | // x: ofset from mean for integration, given units | |
1336 | // hist: needs | |
1337 | ||
1338 | // printf("nbins: %i, binLow: %f, binUp: %f \n", nbins, binLow, binUp); | |
1339 | // fill histogram | |
1340 | for (Float_t iDelta = 0; iDelta <= sigmaMax * sigma; iDelta += sigmaStep) { | |
1341 | // integrate array | |
1342 | Double_t valueP = array[GetBin(mean, nbins, binLow, binUp)]; | |
1343 | Double_t valueM = array[GetBin(mean-binWidth, nbins, binLow, binUp)]; | |
1344 | // add bin of mean value only once to the histogram | |
1345 | // printf("++ adding bins: "); | |
1346 | for (Float_t x = binWidth; x <= iDelta; x += binWidth) { | |
1347 | valueP += (mean + x <= binUp) ? array[GetBin(mean + x, nbins, binLow, binUp)] : 0; | |
1348 | valueM += (mean-binWidth - x >= binLow) ? array[GetBin(mean-binWidth - x, nbins, binLow, binUp)] : 0; | |
1349 | // printf("%i, ", GetBin(mean + x, nbins, binLow, binUp)); | |
1350 | } | |
1351 | // printf("\n"); | |
1352 | if (valueP / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", valueP, normalization); | |
1353 | if (valueP / normalization > 100) return hist; | |
1354 | if (valueM / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", valueM, normalization); | |
1355 | if (valueM / normalization > 100) return hist; | |
1356 | valueP = (valueP / normalization); | |
1357 | valueM = (valueM / normalization); | |
1358 | if (pm) { | |
1359 | Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); | |
1360 | hist->SetBinContent(bin, valueP); | |
1361 | bin = GetBin(-iDelta/sigma, kbins, kbinLow, kbinUp); | |
1362 | hist->SetBinContent(bin, valueM); | |
1363 | } | |
1364 | else { // if (!pm) | |
1365 | Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); | |
1366 | hist->SetBinContent(bin, valueP + valueM); | |
1367 | // printf(" first integration bin: %i, last integration bin in + direction: %i \n", GetBin(mean+binWidth, nbins, binLow, binUp), GetBin(iDelta, nbins, binLow, binUp)); | |
1368 | // printf(" first integration bin: %i, last integration bin in - direction: %i \n", GetBin(mean+binWidth, nbins, binLow, binUp), GetBin(-iDelta, nbins, binLow, binUp)); | |
1369 | // printf(" value: %f, normalization: %f, iDelta: %f, Bin: %i \n", valueP+valueM, normalization, iDelta, bin); | |
1370 | } | |
1371 | } | |
1372 | //hist->SetMaximum(0.7); | |
1373 | if (!pm) hist->SetMaximum(1.2); | |
1374 | return hist; | |
1375 | } | |
1376 | ||
1377 | ||
2773a273 | 1378 | TH1F* AliTPCCalibViewer::SigmaCut(Int_t /*n*/, const Double_t */*array*/, Double_t /*mean*/, Double_t /*sigma*/, Int_t /*nbins*/, const Double_t */*xbins*/, Double_t /*sigmaMax*/){ |
72d0ab7e | 1379 | // |
1380 | // SigmaCut for variable binsize | |
1381 | // NOT YET IMPLEMENTED !!! | |
1382 | // | |
1383 | printf("SigmaCut with variable binsize, Not yet implemented\n"); | |
72d0ab7e | 1384 | |
1385 | return 0; | |
1386 | } | |
1387 | ||
1388 | ||
2811495d | 1389 | TH1F* AliTPCCalibViewer::Integrate(TH1F *const histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){ |
72d0ab7e | 1390 | // |
1391 | // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" | |
1392 | // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user | |
1393 | // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate | |
1394 | // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated | |
1395 | // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
1396 | // The actual work is done on the array. | |
1397 | /* Begin_Latex | |
6a1caa6b | 1398 | f(x, #mu, #sigma) #Rightarrow S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx |
72d0ab7e | 1399 | End_Latex |
6a1caa6b | 1400 | Begin_Macro(source) |
72d0ab7e | 1401 | { |
1402 | Float_t mean = 0; | |
1403 | Float_t sigma = 1.5; | |
1404 | Float_t sigmaMax = 4; | |
1405 | gROOT->SetStyle("Plain"); | |
6a1caa6b | 1406 | TH1F *distribution = new TH1F("Distrib2", "Distribution f(x, #mu, #sigma)", 1000,-5,5); |
72d0ab7e | 1407 | TRandom rand(23); |
1408 | for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma)); | |
1409 | Float_t *ar = distribution->GetArray(); | |
1410 | ||
6a1caa6b | 1411 | TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer2", "", 350, 350); |
72d0ab7e | 1412 | macro_example_canvas->Divide(0,2); |
1413 | TVirtualPad *pad1 = macro_example_canvas->cd(1); | |
1414 | pad1->SetGridy(); | |
1415 | pad1->SetGridx(); | |
1416 | distribution->Draw(); | |
1417 | TVirtualPad *pad2 = macro_example_canvas->cd(2); | |
1418 | pad2->SetGridy(); | |
1419 | pad2->SetGridx(); | |
1420 | TH1F *shist = AliTPCCalibViewer::Integrate(distribution, mean, sigma, sigmaMax); | |
1421 | shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)"); | |
1422 | shist->Draw(); | |
1423 | ||
7072d276 | 1424 | return macro_example_canvas_Integrate; |
72d0ab7e | 1425 | } |
6a1caa6b | 1426 | End_Macro |
72d0ab7e | 1427 | */ |
1428 | ||
1429 | ||
1430 | Float_t *array = histogram->GetArray(); | |
1431 | Int_t nbins = histogram->GetXaxis()->GetNbins(); | |
1432 | Float_t binLow = histogram->GetXaxis()->GetXmin(); | |
1433 | Float_t binUp = histogram->GetXaxis()->GetXmax(); | |
1434 | return AliTPCCalibViewer::Integrate(nbins, array, nbins, binLow, binUp, mean, sigma, sigmaMax, sigmaStep); | |
1435 | } | |
1436 | ||
1437 | ||
2811495d | 1438 | TH1F* AliTPCCalibViewer::Integrate(Int_t n, const Float_t *const array, Int_t nbins, Float_t binLow, Float_t binUp, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){ |
72d0ab7e | 1439 | // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram" |
1440 | // "mean" and "sigma" are Begin_Latex #mu End_Latex and Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user | |
1441 | // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate | |
1442 | // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated | |
1443 | // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used | |
1444 | // Here the actual work is done. | |
1445 | ||
1446 | Bool_t givenUnits = kTRUE; | |
1447 | if (sigma != 0 && sigmaMax != 0) givenUnits = kFALSE; | |
1448 | if (givenUnits) { | |
1449 | sigma = 1; | |
1450 | sigmaMax = (binUp - binLow) / 2.; | |
1451 | } | |
1452 | ||
1453 | Float_t binWidth = (binUp-binLow)/(nbins - 1); | |
1454 | if (sigmaStep <= 0) sigmaStep = binWidth; | |
1455 | Int_t kbins = (Int_t)(sigmaMax * sigma / sigmaStep) + 1; // + 1 due to overflow bin in histograms | |
1456 | Float_t kbinLow = givenUnits ? binLow : -sigmaMax; | |
1457 | Float_t kbinUp = givenUnits ? binUp : sigmaMax; | |
1458 | TH1F *hist = 0; | |
1459 | if (givenUnits) hist = new TH1F("integratedHisto","Integrated Histogram; Given x; Fraction of included data", kbins, kbinLow, kbinUp); | |
1460 | if (!givenUnits) hist = new TH1F("integratedHisto","Integrated Histogram; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); | |
1461 | hist->SetDirectory(0); | |
1462 | hist->Reset(); | |
1463 | ||
1464 | // calculate normalization | |
1465 | // printf("calculating normalization, integrating from bin 1 to %i \n", n); | |
1466 | Double_t normalization = 0; | |
1467 | for (Int_t i = 1; i <= n; i++) { | |
1468 | normalization += array[i]; | |
1469 | } | |
1470 | // printf("normalization: %f \n", normalization); | |
1471 | ||
1472 | // given units: units from given histogram | |
1473 | // sigma units: in units of sigma | |
1474 | // iDelta: integrate in interval (mean +- iDelta), given units | |
1475 | // x: ofset from mean for integration, given units | |
1476 | // hist: needs | |
1477 | ||
1478 | // fill histogram | |
1479 | for (Float_t iDelta = mean - sigmaMax * sigma; iDelta <= mean + sigmaMax * sigma; iDelta += sigmaStep) { | |
1480 | // integrate array | |
1481 | Double_t value = 0; | |
1482 | for (Float_t x = mean - sigmaMax * sigma; x <= iDelta; x += binWidth) { | |
1483 | value += (x <= binUp && x >= binLow) ? array[GetBin(x, nbins, binLow, binUp)] : 0; | |
1484 | } | |
1485 | if (value / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail +++ \n", value, normalization); | |
1486 | if (value / normalization > 100) return hist; | |
1487 | Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp); | |
1488 | // printf("first integration bin: %i, last integration bin: %i \n", GetBin(mean - sigmaMax * sigma, nbins, binLow, binUp), GetBin(iDelta, nbins, binLow, binUp)); | |
1489 | // printf("value: %f, normalization: %f, normalized value: %f, iDelta: %f, Bin: %i \n", value, normalization, value/normalization, iDelta, bin); | |
1490 | value = (value / normalization); | |
1491 | hist->SetBinContent(bin, value); | |
1492 | } | |
1493 | return hist; | |
1494 | } | |
1495 | ||
1496 | ||
1497 | ||
1498 | ||
1499 | ||
1500 | //////////////////////// | |
1501 | // end of Array tools // | |
1502 | //////////////////////// | |
1503 | ||
1504 | ||
1505 | ||
39bcd65d | 1506 | //_____________________________________________________________________________ |
a6e0ebfe | 1507 | AliTPCCalPad* AliTPCCalibViewer::GetCalPadOld(const char* desiredData, const char* cuts, const char* calPadName) const { |
39bcd65d | 1508 | // |
1509 | // creates a AliTPCCalPad out of the 'desiredData' | |
1510 | // the functionality of EasyDraw1D is used | |
1511 | // calPadName specifies the name of the created AliTPCCalPad | |
1512 | // - this takes a while - | |
1513 | // | |
1514 | TString drawStr(desiredData); | |
832bb12c | 1515 | drawStr.Append(":channel"); |
1516 | drawStr.Append(fAbbreviation); | |
39bcd65d | 1517 | AliTPCCalPad * createdCalPad = new AliTPCCalPad(calPadName, calPadName); |
1518 | Int_t entries = 0; | |
1519 | for (Int_t sec = 0; sec < 72; sec++) { | |
ac7becc3 | 1520 | AliTPCCalROC * roc = createdCalPad->GetCalROC(sec); |
39bcd65d | 1521 | entries = EasyDraw1D(drawStr.Data(), (Int_t)sec, cuts, "goff"); |
a6d2bd0c | 1522 | if (entries == -1) return 0; |
ac7becc3 | 1523 | const Double_t *pchannel = fTree->GetV2(); |
1524 | const Double_t *pvalue = fTree->GetV1(); | |
39bcd65d | 1525 | for (Int_t i = 0; i < entries; i++) |
ac7becc3 | 1526 | roc->SetValue((UInt_t)(pchannel[i]), (Float_t)(pvalue[i])); |
1527 | } | |
1528 | return createdCalPad; | |
1529 | } | |
1530 | ||
1531 | ||
1532 | //_____________________________________________________________________________ | |
a6e0ebfe | 1533 | AliTPCCalPad* AliTPCCalibViewer::GetCalPad(const char* desiredData, const char* cuts, const char* calPadName) const { |
ac7becc3 | 1534 | // |
1535 | // creates a AliTPCCalPad out of the 'desiredData' | |
1536 | // the functionality of EasyDraw1D is used | |
1537 | // calPadName specifies the name of the created AliTPCCalPad | |
1538 | // - this takes a while - | |
1539 | // | |
1540 | TString drawStr(desiredData); | |
1541 | drawStr.Append(":channel.fElements:sector"); | |
1542 | AliTPCCalPad * createdCalPad = new AliTPCCalPad(calPadName, calPadName); | |
1543 | // | |
1544 | Int_t entries = fTree->Draw(drawStr, cuts,"goff"); | |
1545 | const Double_t *pvalue = fTree->GetV1(); | |
1546 | const Double_t *pchannel = fTree->GetV2(); | |
1547 | const Double_t *psector = fTree->GetV3(); | |
1548 | ||
1549 | for (Int_t ientry=0; ientry<entries; ientry++){ | |
1550 | Int_t sector= TMath::Nint(psector[ientry]); | |
1551 | AliTPCCalROC * roc = createdCalPad->GetCalROC(sector); | |
1552 | if (roc) roc->SetValue((UInt_t)(pchannel[ientry]), (Float_t)(pvalue[ientry])); | |
39bcd65d | 1553 | } |
ac7becc3 | 1554 | |
1555 | // for (Int_t sec = 0; sec < 72; sec++) { | |
1556 | // AliTPCCalROC * roc = createdCalPad->GetCalROC(sec); | |
1557 | // entries = EasyDraw1D(drawStr.Data(), (Int_t)sec, cuts, "goff"); | |
1558 | // if (entries == -1) return 0; | |
1559 | // for (Int_t i = 0; i < entries; i++) | |
1560 | // roc->SetValue((UInt_t)(pchannel[i]), (Float_t)(pvalue[i])); | |
1561 | // } | |
39bcd65d | 1562 | return createdCalPad; |
1563 | } | |
1564 | ||
1565 | //_____________________________________________________________________________ | |
f78da5ae | 1566 | AliTPCCalROC* AliTPCCalibViewer::GetCalROC(const char* desiredData, UInt_t sector, const char* cuts) const { |
39bcd65d | 1567 | // |
1568 | // creates a AliTPCCalROC out of the desiredData | |
1569 | // the functionality of EasyDraw1D is used | |
1570 | // sector specifies the sector of the created AliTPCCalROC | |
1571 | // | |
1572 | TString drawStr(desiredData); | |
8192627b | 1573 | drawStr.Append(":channel"); |
1574 | drawStr.Append(fAbbreviation); | |
39bcd65d | 1575 | Int_t entries = EasyDraw1D(drawStr.Data(), (Int_t)sector, cuts, "goff"); |
a6d2bd0c | 1576 | if (entries == -1) return 0; |
39bcd65d | 1577 | AliTPCCalROC * createdROC = new AliTPCCalROC(sector); |
1578 | for (Int_t i = 0; i < entries; i++) | |
1579 | createdROC->SetValue((UInt_t)(fTree->GetV2()[i]), fTree->GetV1()[i]); | |
1580 | return createdROC; | |
1581 | } | |
1582 | ||
1583 | ||
1584 | TObjArray* AliTPCCalibViewer::GetListOfVariables(Bool_t printList) { | |
1585 | // | |
1586 | // scan the tree - produces a list of available variables in the tree | |
1587 | // printList: print the list to the screen, after the scan is done | |
1588 | // | |
1589 | TObjArray* arr = new TObjArray(); | |
1590 | TObjString* str = 0; | |
596afefb | 1591 | if (!fTree) return 0; |
39bcd65d | 1592 | Int_t nentries = fTree->GetListOfBranches()->GetEntries(); |
1593 | for (Int_t i = 0; i < nentries; i++) { | |
1594 | str = new TObjString(fTree->GetListOfBranches()->At(i)->GetName()); | |
1595 | str->String().ReplaceAll("_Median", ""); | |
1596 | str->String().ReplaceAll("_Mean", ""); | |
1597 | str->String().ReplaceAll("_RMS", ""); | |
1598 | str->String().ReplaceAll("_LTM", ""); | |
1599 | str->String().ReplaceAll("_OutlierCutted", ""); | |
1600 | str->String().ReplaceAll(".", ""); | |
1601 | if (!arr->FindObject(str) && | |
1602 | !(str->String() == "channel" || str->String() == "gx" || str->String() == "gy" || | |
1603 | str->String() == "lx" || str->String() == "ly" || str->String() == "pad" || | |
1604 | str->String() == "row" || str->String() == "rpad" || str->String() == "sector" )) | |
1605 | arr->Add(str); | |
1606 | } | |
832bb12c | 1607 | |
1608 | // loop over all friends (if there are some) and add them to the list | |
1609 | if (fTree->GetListOfFriends()) { | |
1610 | for (Int_t ifriend = 0; ifriend < fTree->GetListOfFriends()->GetEntries(); ifriend++){ | |
1611 | // printf("iterating through friendlist, currently at %i\n", ifriend); | |
1612 | // printf("working with %s\n", fTree->GetListOfFriends()->At(ifriend)->ClassName()); | |
1613 | if (TString(fTree->GetListOfFriends()->At(ifriend)->ClassName()) != "TFriendElement") continue; // no friendElement found | |
1614 | TFriendElement *friendElement = (TFriendElement*)fTree->GetListOfFriends()->At(ifriend); | |
1615 | if (friendElement->GetTree() == 0) continue; // no tree found in friendElement | |
1616 | // printf("friend found \n"); | |
1617 | for (Int_t i = 0; i < friendElement->GetTree()->GetListOfBranches()->GetEntries(); i++) { | |
1618 | // printf("iterating through friendelement entries, currently at %i\n", i); | |
1619 | str = new TObjString(friendElement->GetTree()->GetListOfBranches()->At(i)->GetName()); | |
1620 | str->String().ReplaceAll("_Median", ""); | |
1621 | str->String().ReplaceAll("_Mean", ""); | |
1622 | str->String().ReplaceAll("_RMS", ""); | |
1623 | str->String().ReplaceAll("_LTM", ""); | |
1624 | str->String().ReplaceAll("_OutlierCutted", ""); | |
1625 | str->String().ReplaceAll(".", ""); | |
1626 | if (!(str->String() == "channel" || str->String() == "gx" || str->String() == "gy" || | |
1627 | str->String() == "lx" || str->String() == "ly" || str->String() == "pad" || | |
1628 | str->String() == "row" || str->String() == "rpad" || str->String() == "sector" )){ | |
1629 | // insert "<friendName>." at the beginning: (<friendName> is per default "R") | |
1630 | str->String().Insert(0, "."); | |
1631 | str->String().Insert(0, friendElement->GetName()); | |
1632 | if (!arr->FindObject(str)) arr->Add(str); | |
1633 | // printf("added string %s \n", str->String().Data()); | |
1634 | } | |
1635 | } | |
1636 | } | |
1637 | } // if (fTree->GetListOfFriends()) | |
1638 | ||
39bcd65d | 1639 | arr->Sort(); |
832bb12c | 1640 | // ((TFriendElement*)gui->GetViewer()->GetTree()->GetListOfFriends()->At(0))->GetTree()->GetListOfBranches()->At(0)->GetName() |
1641 | // ((TFriendElement*)gui->GetViewer()->GetTree()->GetListOfFriends()->At(0))->GetTree()->GetListOfBranches() | |
1642 | ||
39bcd65d | 1643 | |
1644 | if (printList) { | |
1645 | TIterator* iter = arr->MakeIterator(); | |
1646 | iter->Reset(); | |
1647 | TObjString* currentStr = 0; | |
1648 | while ( (currentStr = (TObjString*)(iter->Next())) ) { | |
1649 | std::cout << currentStr->GetString().Data() << std::endl; | |
1650 | } | |
1651 | delete iter; | |
1652 | } | |
1653 | return arr; | |
1654 | } | |
1655 | ||
1656 | ||
72d0ab7e | 1657 | TObjArray* AliTPCCalibViewer::GetListOfNormalizationVariables(Bool_t printList) const{ |
39bcd65d | 1658 | // |
1659 | // produces a list of available variables for normalization in the tree | |
1660 | // printList: print the list to the screen, after the scan is done | |
1661 | // | |
1662 | TObjArray* arr = new TObjArray(); | |
1663 | arr->Add(new TObjString("_Mean")); | |
1664 | arr->Add(new TObjString("_Mean_OutlierCutted")); | |
1665 | arr->Add(new TObjString("_Median")); | |
1666 | arr->Add(new TObjString("_Median_OutlierCutted")); | |
1667 | arr->Add(new TObjString("_LTM")); | |
1668 | arr->Add(new TObjString("_LTM_OutlierCutted")); | |
832bb12c | 1669 | arr->Add(new TObjString(Form("LFitIntern_4_8%s", fAppendString.Data()))); |
1670 | arr->Add(new TObjString(Form("GFitIntern_Lin%s", fAppendString.Data()))); | |
1671 | arr->Add(new TObjString(Form("GFitIntern_Par%s", fAppendString.Data()))); | |
a6d2bd0c | 1672 | arr->Add(new TObjString("FitLinLocal")); |
1673 | arr->Add(new TObjString("FitLinGlobal")); | |
72d0ab7e | 1674 | arr->Add(new TObjString("FitParLocal")); |
1675 | arr->Add(new TObjString("FitParGlobal")); | |
39bcd65d | 1676 | |
1677 | if (printList) { | |
1678 | TIterator* iter = arr->MakeIterator(); | |
1679 | iter->Reset(); | |
1680 | TObjString* currentStr = 0; | |
1681 | while ((currentStr = (TObjString*)(iter->Next()))) { | |
1682 | std::cout << currentStr->GetString().Data() << std::endl; | |
1683 | } | |
1684 | delete iter; | |
1685 | } | |
1686 | return arr; | |
1687 | } | |
1688 | ||
1689 | ||
1690 | TFriendElement* AliTPCCalibViewer::AddReferenceTree(const char* filename, const char* treename, const char* refname){ | |
1691 | // | |
1692 | // add a reference tree to the current tree | |
1693 | // by default the treename is 'calPads' and the reference treename is 'R' | |
1694 | // | |
1695 | TFile *file = new TFile(filename); | |
1696 | fListOfObjectsToBeDeleted->Add(file); | |
1697 | TTree * tree = (TTree*)file->Get(treename); | |
1698 | return AddFriend(tree, refname); | |
1699 | } | |
1700 | ||
1701 | ||
1702 | TObjArray* AliTPCCalibViewer::GetArrayOfCalPads(){ | |
1703 | // | |
1704 | // Returns a TObjArray with all AliTPCCalPads that are stored in the tree | |
1705 | // - this takes a while - | |
1706 | // | |
1707 | TObjArray *listOfCalPads = GetListOfVariables(); | |
1708 | TObjArray *calPadsArray = new TObjArray(); | |
1709 | Int_t numberOfCalPads = listOfCalPads->GetEntries(); | |
1710 | for (Int_t i = 0; i < numberOfCalPads; i++) { | |
832bb12c | 1711 | std::cout << "Creating calPad " << (i+1) << " of " << numberOfCalPads << "\r" << std::flush; |
39bcd65d | 1712 | char* calPadName = (char*)((TObjString*)(listOfCalPads->At(i)))->GetString().Data(); |
1713 | TString drawCommand = ((TObjString*)(listOfCalPads->At(i)))->GetString(); | |
832bb12c | 1714 | drawCommand.Append(fAbbreviation.Data()); |
39bcd65d | 1715 | AliTPCCalPad* calPad = GetCalPad(drawCommand.Data(), "", calPadName); |
1716 | calPadsArray->Add(calPad); | |
1717 | } | |
1718 | std::cout << std::endl; | |
1719 | listOfCalPads->Delete(); | |
1720 | delete listOfCalPads; | |
1721 | return calPadsArray; | |
1722 | } | |
1723 | ||
1724 | ||
a6d2bd0c | 1725 | TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, const char* cuts, Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix){ |
1726 | // | |
1727 | // fit an arbitrary function, specified by formula into the data, specified by drawCommand and cuts | |
1728 | // returns chi2, fitParam and covMatrix | |
1729 | // returns TString with fitted formula | |
1730 | // | |
1731 | ||
1732 | TString formulaStr(formula); | |
1733 | TString drawStr(drawCommand); | |
1734 | TString cutStr(cuts); | |
1735 | ||
1736 | // abbreviations: | |
832bb12c | 1737 | drawStr.ReplaceAll(fAbbreviation, fAppendString); |
1738 | cutStr.ReplaceAll(fAbbreviation, fAppendString); | |
1739 | formulaStr.ReplaceAll(fAbbreviation, fAppendString); | |
a6d2bd0c | 1740 | |
832bb12c | 1741 | formulaStr.ReplaceAll("++", fAbbreviation); |
1742 | TObjArray* formulaTokens = formulaStr.Tokenize(fAbbreviation.Data()); | |
a6d2bd0c | 1743 | Int_t dim = formulaTokens->GetEntriesFast(); |
1744 | ||
1745 | fitParam.ResizeTo(dim); | |
1746 | covMatrix.ResizeTo(dim,dim); | |
1747 | ||
1748 | TLinearFitter* fitter = new TLinearFitter(dim+1, Form("hyp%d",dim)); | |
1749 | fitter->StoreData(kTRUE); | |
1750 | fitter->ClearPoints(); | |
1751 | ||
1752 | Int_t entries = Draw(drawStr.Data(), cutStr.Data(), "goff"); | |
1753 | if (entries == -1) return new TString("An ERROR has occured during fitting!"); | |
1754 | Double_t **values = new Double_t*[dim+1] ; | |
1755 | ||
1756 | for (Int_t i = 0; i < dim + 1; i++){ | |
1757 | Int_t centries = 0; | |
1758 | if (i < dim) centries = fTree->Draw(((TObjString*)formulaTokens->At(i))->GetName(), cutStr.Data(), "goff"); | |
1759 | else centries = fTree->Draw(drawStr.Data(), cutStr.Data(), "goff"); | |
1760 | ||
c60053f6 | 1761 | if (entries != centries) { |
1762 | delete [] values; | |
1763 | return new TString("An ERROR has occured during fitting!"); | |
1764 | } | |
a6d2bd0c | 1765 | values[i] = new Double_t[entries]; |
1766 | memcpy(values[i], fTree->GetV1(), entries*sizeof(Double_t)); | |
1767 | } | |
1768 | ||
1769 | // add points to the fitter | |
1770 | for (Int_t i = 0; i < entries; i++){ | |
1771 | Double_t x[1000]; | |
1772 | for (Int_t j=0; j<dim;j++) x[j]=values[j][i]; | |
1773 | fitter->AddPoint(x, values[dim][i], 1); | |
1774 | } | |
1775 | ||
1776 | fitter->Eval(); | |
1777 | fitter->GetParameters(fitParam); | |
1778 | fitter->GetCovarianceMatrix(covMatrix); | |
1779 | chi2 = fitter->GetChisquare(); | |
df5d3222 | 1780 | // chi2 = chi2; |
a6d2bd0c | 1781 | |
7390f655 | 1782 | TString *preturnFormula = new TString(Form("( %e+",fitParam[0])), &returnFormula = *preturnFormula; |
a6d2bd0c | 1783 | |
1784 | for (Int_t iparam = 0; iparam < dim; iparam++) { | |
7390f655 | 1785 | returnFormula.Append(Form("%s*(%e)",((TObjString*)formulaTokens->At(iparam))->GetName(),fitParam[iparam+1])); |
a6d2bd0c | 1786 | if (iparam < dim-1) returnFormula.Append("+"); |
1787 | } | |
1788 | returnFormula.Append(" )"); | |
1789 | delete formulaTokens; | |
1790 | delete fitter; | |
c60053f6 | 1791 | for (Int_t i = 0; i < dim + 1; i++){ |
1792 | delete [] values[i]; | |
1793 | } | |
1794 | delete [] values; | |
a6d2bd0c | 1795 | return preturnFormula; |
1796 | } | |
1797 | ||
1798 | ||
2811495d | 1799 | void AliTPCCalibViewer::MakeTreeWithObjects(const char *fileName, const TObjArray *const array, const char * mapFileName) { |
39bcd65d | 1800 | // |
1801 | // Write tree with all available information | |
1802 | // im mapFileName is speciefied, the Map information are also written to the tree | |
1803 | // AliTPCCalPad-Objects are written directly to the tree, so that they can be accessd later on | |
1804 | // (does not work!!!) | |
1805 | // | |
1806 | AliTPCROC* tpcROCinstance = AliTPCROC::Instance(); | |
1807 | ||
1808 | TObjArray* mapIROCs = 0; | |
1809 | TObjArray* mapOROCs = 0; | |
1810 | TVectorF *mapIROCArray = 0; | |
1811 | TVectorF *mapOROCArray = 0; | |
1812 | Int_t mapEntries = 0; | |
1813 | TString* mapNames = 0; | |
1814 | ||
1815 | if (mapFileName) { | |
1816 | TFile mapFile(mapFileName, "read"); | |
1817 | ||
1818 | TList* listOfROCs = mapFile.GetListOfKeys(); | |
1819 | mapEntries = listOfROCs->GetEntries()/2; | |
1820 | mapIROCs = new TObjArray(mapEntries*2); | |
1821 | mapOROCs = new TObjArray(mapEntries*2); | |
1822 | mapIROCArray = new TVectorF[mapEntries]; | |
1823 | mapOROCArray = new TVectorF[mapEntries]; | |
1824 | ||
1825 | mapNames = new TString[mapEntries]; | |
1826 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
72d0ab7e | 1827 | TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); |
1828 | rocName.Remove(rocName.Length()-4, 4); | |
1829 | mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue); | |
1830 | mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue); | |
1831 | mapNames[ivalue].Append(rocName); | |
39bcd65d | 1832 | } |
1833 | ||
1834 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
1835 | mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0)); | |
1836 | mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36)); | |
1837 | ||
1838 | for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++) | |
1839 | (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel); | |
1840 | for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++) | |
1841 | (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel); | |
1842 | } | |
1843 | ||
1844 | } // if (mapFileName) | |
1845 | ||
1846 | TTreeSRedirector cstream(fileName); | |
1847 | Int_t arrayEntries = array->GetEntries(); | |
1848 | ||
1849 | // Read names of AliTPCCalPads and save them in names[] | |
1850 | TString* names = new TString[arrayEntries]; | |
1851 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) | |
1852 | names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName()); | |
1853 | ||
1854 | for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) { | |
1855 | ||
1856 | TVectorF *vectorArray = new TVectorF[arrayEntries]; | |
1857 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) | |
1858 | vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); | |
1859 | ||
1860 | ||
1861 | // | |
1862 | // fill vectors of variable per pad | |
1863 | // | |
1864 | TVectorF *posArray = new TVectorF[8]; | |
1865 | for (Int_t ivalue = 0; ivalue < 8; ivalue++) | |
1866 | posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); | |
1867 | ||
1868 | Float_t posG[3] = {0}; | |
1869 | Float_t posL[3] = {0}; | |
1870 | Int_t ichannel = 0; | |
1871 | for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) { | |
1872 | for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) { | |
1873 | tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL); | |
1874 | tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG); | |
1875 | posArray[0][ichannel] = irow; | |
1876 | posArray[1][ichannel] = ipad; | |
1877 | posArray[2][ichannel] = posL[0]; | |
1878 | posArray[3][ichannel] = posL[1]; | |
1879 | posArray[4][ichannel] = posG[0]; | |
1880 | posArray[5][ichannel] = posG[1]; | |
1881 | posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2); | |
1882 | posArray[7][ichannel] = ichannel; | |
1883 | ||
1884 | // loop over array containing AliTPCCalPads | |
1885 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { | |
1886 | AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); | |
1887 | AliTPCCalROC* calROC = calPad->GetCalROC(isector); | |
1888 | if (calROC) | |
1889 | (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad); | |
1890 | else | |
1891 | (vectorArray[ivalue])[ichannel] = 0; | |
1892 | } | |
1893 | ichannel++; | |
1894 | } | |
1895 | } | |
1896 | AliTPCCalROC dummyROC(0); | |
1897 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { | |
1898 | AliTPCCalROC *roc = ((AliTPCCalPad*)array->At(ivalue))->GetCalROC(isector); | |
1899 | if (!roc) roc = &dummyROC; | |
1900 | cstream << "calPads" << | |
1901 | (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue]; | |
1902 | cstream << "calPads" << | |
1903 | (Char_t*)((names[ivalue] + "Pad.=").Data()) << roc; | |
1904 | } | |
1905 | ||
1906 | if (mapFileName) { | |
1907 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
1908 | if (isector < 36) | |
1909 | cstream << "calPads" << | |
1910 | (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue]; | |
1911 | else | |
1912 | cstream << "calPads" << | |
1913 | (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue]; | |
1914 | } | |
1915 | } | |
1916 | ||
1917 | cstream << "calPads" << | |
1918 | "sector=" << isector; | |
1919 | ||
1920 | cstream << "calPads" << | |
1921 | "row.=" << &posArray[0] << | |
1922 | "pad.=" << &posArray[1] << | |
1923 | "lx.=" << &posArray[2] << | |
1924 | "ly.=" << &posArray[3] << | |
1925 | "gx.=" << &posArray[4] << | |
1926 | "gy.=" << &posArray[5] << | |
1927 | "rpad.=" << &posArray[6] << | |
1928 | "channel.=" << &posArray[7]; | |
1929 | ||
1930 | cstream << "calPads" << | |
1931 | "\n"; | |
1932 | ||
1933 | delete[] posArray; | |
1934 | delete[] vectorArray; | |
1935 | } //for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) | |
1936 | ||
1937 | delete[] names; | |
1938 | if (mapFileName) { | |
1939 | delete mapIROCs; | |
1940 | delete mapOROCs; | |
1941 | delete[] mapIROCArray; | |
1942 | delete[] mapOROCArray; | |
1943 | delete[] mapNames; | |
1944 | } | |
1945 | } | |
1946 | ||
72d0ab7e | 1947 | |
2811495d | 1948 | void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad *const outlierPad, Float_t ltmFraction) { |
39bcd65d | 1949 | // |
1950 | // Write a tree with all available information | |
72d0ab7e | 1951 | // if mapFileName is speciefied, the Map information are also written to the tree |
39bcd65d | 1952 | // pads specified in outlierPad are not used for calculating statistics |
72d0ab7e | 1953 | // The following statistical information on the basis of a ROC are calculated: |
1954 | // "_Median", "_Mean", "_LTM", "_RMS_LTM" | |
1955 | // "_Median_OutlierCutted", "_Mean_OutlierCutted", "_RMS_OutlierCutted", "_LTM_OutlierCutted", "_RMS_LTM_OutlierCutted" | |
1956 | // The following position variables are available: | |
1957 | // "row", "pad", "lx", "ly", "gx", "gy", "rpad", "channel" | |
1958 | // | |
1959 | // The tree out of this function is the basis for the AliTPCCalibViewer and the AliTPCCalibViewerGUI. | |
1960 | ||
7390f655 | 1961 | AliTPCROC* tpcROCinstance = AliTPCROC::Instance(); |
39bcd65d | 1962 | |
7390f655 | 1963 | TObjArray* mapIROCs = 0; |
1964 | TObjArray* mapOROCs = 0; | |
1965 | TVectorF *mapIROCArray = 0; | |
1966 | TVectorF *mapOROCArray = 0; | |
1967 | Int_t mapEntries = 0; | |
1968 | TString* mapNames = 0; | |
1969 | ||
1970 | if (mapFileName) { | |
1971 | TFile mapFile(mapFileName, "read"); | |
1972 | ||
1973 | TList* listOfROCs = mapFile.GetListOfKeys(); | |
1974 | mapEntries = listOfROCs->GetEntries()/2; | |
1975 | mapIROCs = new TObjArray(mapEntries*2); | |
1976 | mapOROCs = new TObjArray(mapEntries*2); | |
1977 | mapIROCArray = new TVectorF[mapEntries]; | |
1978 | mapOROCArray = new TVectorF[mapEntries]; | |
1979 | ||
1980 | mapNames = new TString[mapEntries]; | |
1981 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
1982 | TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName()); | |
1983 | rocName.Remove(rocName.Length()-4, 4); | |
1984 | mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue); | |
1985 | mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue); | |
1986 | mapNames[ivalue].Append(rocName); | |
1987 | } | |
1988 | ||
1989 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
1990 | mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0)); | |
1991 | mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36)); | |
39bcd65d | 1992 | |
7390f655 | 1993 | for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++) |
1994 | (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel); | |
1995 | for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++) | |
1996 | (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel); | |
1997 | } | |
1998 | ||
1999 | } // if (mapFileName) | |
39bcd65d | 2000 | |
7390f655 | 2001 | TTreeSRedirector cstream(fileName); |
2002 | Int_t arrayEntries = 0; | |
2003 | if (array) arrayEntries = array->GetEntries(); | |
2004 | ||
2005 | TString* names = new TString[arrayEntries]; | |
2006 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) | |
2007 | names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName()); | |
2008 | ||
2009 | for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) { | |
39bcd65d | 2010 | // |
2011 | // get statistic for given sector | |
2012 | // | |
7390f655 | 2013 | TVectorF median(arrayEntries); |
2014 | TVectorF mean(arrayEntries); | |
2015 | TVectorF rms(arrayEntries); | |
2016 | TVectorF ltm(arrayEntries); | |
2017 | TVectorF ltmrms(arrayEntries); | |
2018 | TVectorF medianWithOut(arrayEntries); | |
2019 | TVectorF meanWithOut(arrayEntries); | |
2020 | TVectorF rmsWithOut(arrayEntries); | |
2021 | TVectorF ltmWithOut(arrayEntries); | |
2022 | TVectorF ltmrmsWithOut(arrayEntries); | |
2023 | ||
2024 | TVectorF *vectorArray = new TVectorF[arrayEntries]; | |
2025 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++){ | |
2026 | vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); | |
2027 | vectorArray[ivalue].SetUniqueID(array->UncheckedAt(ivalue)->GetUniqueID()); | |
2028 | // printf("UniqueID: %d\n",vectorArray[ivalue].GetUniqueID()); | |
2029 | } | |
2030 | ||
2031 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { | |
2032 | AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); | |
2033 | AliTPCCalROC* calROC = calPad->GetCalROC(isector); | |
2034 | AliTPCCalROC* outlierROC = 0; | |
2035 | if (outlierPad) outlierROC = outlierPad->GetCalROC(isector); | |
2036 | if (calROC) { | |
2037 | median[ivalue] = calROC->GetMedian(); | |
2038 | mean[ivalue] = calROC->GetMean(); | |
2039 | rms[ivalue] = calROC->GetRMS(); | |
2040 | Double_t ltmrmsValue = 0; | |
2041 | ltm[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction); | |
2042 | ltmrms[ivalue] = ltmrmsValue; | |
2043 | if (outlierROC) { | |
2044 | medianWithOut[ivalue] = calROC->GetMedian(outlierROC); | |
2045 | meanWithOut[ivalue] = calROC->GetMean(outlierROC); | |
2046 | rmsWithOut[ivalue] = calROC->GetRMS(outlierROC); | |
2047 | ltmrmsValue = 0; | |
2048 | ltmWithOut[ivalue] = calROC->GetLTM(<mrmsValue, ltmFraction, outlierROC); | |
2049 | ltmrmsWithOut[ivalue] = ltmrmsValue; | |
2050 | } | |
39bcd65d | 2051 | } |
7390f655 | 2052 | else { |
2053 | median[ivalue] = 0.; | |
2054 | mean[ivalue] = 0.; | |
2055 | rms[ivalue] = 0.; | |
2056 | ltm[ivalue] = 0.; | |
2057 | ltmrms[ivalue] = 0.; | |
2058 | medianWithOut[ivalue] = 0.; | |
2059 | meanWithOut[ivalue] = 0.; | |
2060 | rmsWithOut[ivalue] = 0.; | |
2061 | ltmWithOut[ivalue] = 0.; | |
2062 | ltmrmsWithOut[ivalue] = 0.; | |
2063 | } | |
2064 | } | |
2065 | ||
39bcd65d | 2066 | // |
2067 | // fill vectors of variable per pad | |
2068 | // | |
7390f655 | 2069 | TVectorF *posArray = new TVectorF[8]; |
2070 | for (Int_t ivalue = 0; ivalue < 8; ivalue++) | |
2071 | posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector)); | |
2072 | ||
2073 | Float_t posG[3] = {0}; | |
2074 | Float_t posL[3] = {0}; | |
2075 | Int_t ichannel = 0; | |
2076 | for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) { | |
2077 | for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) { | |
2078 | tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL); | |
2079 | tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG); | |
2080 | posArray[0][ichannel] = irow; | |
2081 | posArray[1][ichannel] = ipad; | |
2082 | posArray[2][ichannel] = posL[0]; | |
2083 | posArray[3][ichannel] = posL[1]; | |
2084 | posArray[4][ichannel] = posG[0]; | |
2085 | posArray[5][ichannel] = posG[1]; | |
2086 | posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2); | |
2087 | posArray[7][ichannel] = ichannel; | |
2088 | ||
39bcd65d | 2089 | // loop over array containing AliTPCCalPads |
7390f655 | 2090 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { |
2091 | AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue); | |
2092 | AliTPCCalROC* calROC = calPad->GetCalROC(isector); | |
2093 | if (calROC) | |
39bcd65d | 2094 | (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad); |
7390f655 | 2095 | else |
2096 | (vectorArray[ivalue])[ichannel] = 0; | |
2097 | } | |
2098 | ichannel++; | |
39bcd65d | 2099 | } |
7390f655 | 2100 | } |
2101 | ||
2102 | cstream << "calPads" << | |
2103 | "sector=" << isector; | |
2104 | ||
2105 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { | |
39bcd65d | 2106 | cstream << "calPads" << |
7390f655 | 2107 | (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] << |
2108 | (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] << | |
2109 | (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] << | |
2110 | (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] << | |
2111 | (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue]; | |
2112 | if (outlierPad) { | |
2113 | cstream << "calPads" << | |
2114 | (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] << | |
2115 | (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] << | |
2116 | (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] << | |
2117 | (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] << | |
2118 | (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue]; | |
39bcd65d | 2119 | } |
7390f655 | 2120 | //timestamp and run, if given in title |
2121 | /* TString title(((AliTPCCalPad*) array->At(ivalue))->GetTitle()); | |
2122 | TObjArray *arrtitle=title.Tokenize(","); | |
2123 | Int_t run=-1; | |
2124 | UInt_t time=0; | |
2125 | TIter next(arrtitle); | |
2126 | TObject *o=0; | |
2127 | while ( (o=next()) ){ | |
2128 | TString &entry=((TObjString*)o)->GetString(); | |
2129 | entry.Remove(TString::kBoth,' '); | |
2130 | entry.Remove(TString::kBoth,'\t'); | |
2131 | if (entry.BeginsWith("Run:")) { | |
2132 | run=entry(4,entry.Length()).Atoi(); | |
2133 | } else if (entry.BeginsWith("Time:")) { | |
2134 | time=entry(6,entry.Length()).Atoi(); | |
2135 | } | |
39bcd65d | 2136 | } |
7390f655 | 2137 | delete arrtitle;*/ |
2138 | ||
2139 | } | |
2140 | ||
2141 | for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) { | |
2142 | cstream << "calPads" << | |
2143 | (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue]; | |
2144 | } | |
2145 | ||
2146 | if (mapFileName) { | |
2147 | for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) { | |
39bcd65d | 2148 | if (isector < 36) |
7390f655 | 2149 | cstream << "calPads" << |
2150 | (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue]; | |
39bcd65d | 2151 | else |
7390f655 | 2152 | cstream << "calPads" << |
2153 | (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue]; | |
39bcd65d | 2154 | } |
7390f655 | 2155 | } |
2156 | ||
2157 | cstream << "calPads" << | |
2158 | "row.=" << &posArray[0] << | |
2159 | "pad.=" << &posArray[1] << | |
2160 | "lx.=" << &posArray[2] << | |
2161 | "ly.=" << &posArray[3] << | |
2162 | "gx.=" << &posArray[4] << | |
2163 | "gy.=" << &posArray[5] << | |
2164 | "rpad.=" << &posArray[6] << | |
2165 | "channel.=" << &posArray[7]; | |
2166 | ||
2167 | cstream << "calPads" << | |
2168 | "\n"; | |
2169 | ||
2170 | delete[] posArray; | |
2171 | delete[] vectorArray; | |
2172 | } | |
2173 | ||
2174 | ||
2175 | delete[] names; | |
2176 | if (mapFileName) { | |
2177 | delete mapIROCs; | |
2178 | delete mapOROCs; | |
2179 | delete[] mapIROCArray; | |
2180 | delete[] mapOROCArray; | |
2181 | delete[] mapNames; | |
2182 | } | |
39bcd65d | 2183 | } |
2184 | ||
4f3934a1 | 2185 | |
2186 | void AliTPCCalibViewer::MakeTree(const char *outPutFileName, const Char_t *inputFileName, AliTPCCalPad *outlierPad, Float_t ltmFraction, const char *mapFileName ){ | |
2187 | // | |
2188 | // Function to create a calibration Tree with all available information. | |
2189 | // See also documentation to MakeTree | |
2190 | // the file "inputFileName" must be in the following format (see also CreateObjectList): | |
2191 | // (each colum separated by tabs, "dependingOnType" can have 2 or 3 colums) | |
2192 | // | |
2193 | // type path dependingOnType | |
2194 | // | |
2195 | // type == "CE": | |
2196 | // dependingOnType = CETmean CEQmean CETrms | |
2197 | // | |
2198 | // type == "Pulser": | |
2199 | // dependingOnType = PulserTmean PulsterQmean PulserTrms | |
2200 | // | |
2201 | // type == "Pedestals": | |
2202 | // dependingOnType = Pedestals Noise | |
2203 | // | |
2204 | // type == "CalPad": | |
2205 | // dependingOnType = NameInFile NameToWriteToFile | |
2206 | // | |
2207 | // | |
2208 | TObjArray objArray; | |
2209 | CreateObjectList(inputFileName, &objArray); | |
2210 | MakeTree(outPutFileName, &objArray, mapFileName, outlierPad, ltmFraction); | |
2211 | } | |
2212 | ||
832bb12c | 2213 | |
4f3934a1 | 2214 | void AliTPCCalibViewer::CreateObjectList(const Char_t *filename, TObjArray *calibObjects){ |
2215 | // | |
2216 | // Function to create a TObjArray out of a given file | |
2217 | // the file must be in the following format: | |
2218 | // (each colum separated by tabs, "dependingOnType" can have 2 or 3 colums) | |
2219 | // | |
2220 | // | |
2221 | // type path dependingOnType | |
2222 | // | |
2223 | // type == "CE": | |
2224 | // dependingOnType = CETmean CEQmean CETrms | |
2225 | // | |
2226 | // type == "Pulser": | |
2227 | // dependingOnType = PulserTmean PulsterQmean PulserTrms | |
2228 | // | |
2229 | // type == "Pedestals": | |
2230 | // dependingOnType = Pedestals Noise | |
2231 | // | |
2232 | // type == "CalPad": | |
2233 | // dependingOnType = NameInFile NameToWriteToFile | |
2234 | // | |
2235 | // | |
2236 | // | |
2237 | if ( calibObjects == 0x0 ) return; | |
2238 | ifstream in; | |
2239 | in.open(filename); | |
2240 | if ( !in.is_open() ){ | |
2241 | fprintf(stderr,"Error: cannot open list file '%s'", filename); | |
2242 | return; | |
2243 | } | |
2244 | ||
2245 | AliTPCCalPad *calPad=0x0; | |
2246 | ||
2247 | TString sFile; | |
2248 | sFile.ReadFile(in); | |
2249 | in.close(); | |
2250 | ||
2251 | TObjArray *arrFileLine = sFile.Tokenize("\n"); | |
2252 | TIter nextLine(arrFileLine); | |
2253 | ||
2254 | TObjString *sObjLine = 0x0; | |
2255 | while ( (sObjLine = (TObjString*)nextLine()) ){ | |
2256 | TString sLine(sObjLine->GetString()); | |
2257 | ||
2258 | TObjArray *arrCol = sLine.Tokenize("\t"); | |
2259 | Int_t nCols = arrCol->GetEntriesFast(); | |
2260 | ||
2261 | TObjString *sObjType = (TObjString*)(arrCol->At(0)); | |
2262 | TObjString *sObjFileName = (TObjString*)(arrCol->At(1)); | |
2263 | TObjString *sObjName = 0x0; | |
2264 | ||
2265 | if ( !sObjType || !sObjFileName ) continue; | |
2266 | TString sType(sObjType->GetString()); | |
2267 | TString sFileName(sObjFileName->GetString()); | |
2268 | printf("Type %s, opening %s \n", sType.Data(), sFileName.Data()); | |
2269 | TFile *fIn = TFile::Open(sFileName); | |
2270 | if ( !fIn ){ | |
2271 | fprintf(stderr,"File not found: '%s'", sFileName.Data()); | |
2272 | continue; | |
2273 | } | |
2274 | ||
2275 | if ( sType == "CE" ){ // next three colums are the names for CETmean, CEQmean and CETrms | |
2276 | AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE"); | |
2277 | calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0()); | |
2278 | if (nCols > 2) { // check, if the name is provided | |
2279 | sObjName = (TObjString*)(arrCol->At(2)); | |
2280 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2281 | } | |
2282 | else calPad->SetNameTitle("CETmean","CETmean"); | |
2283 | calibObjects->Add(calPad); | |
2284 | ||
2285 | calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ()); | |
2286 | if (nCols > 3) { // check, if the name is provided | |
2287 | sObjName = (TObjString*)(arrCol->At(3)); | |
2288 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2289 | } | |
2290 | else calPad->SetNameTitle("CEQmean","CEQmean"); | |
2291 | calibObjects->Add(calPad); | |
2292 | ||
2293 | calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS()); | |
2294 | if (nCols > 4) { // check, if the name is provided | |
2295 | sObjName = (TObjString*)(arrCol->At(4)); | |
2296 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2297 | } | |
2298 | else calPad->SetNameTitle("CETrms","CETrms"); | |
2299 | calibObjects->Add(calPad); | |
2300 | ||
2301 | } else if ( sType == "Pulser") { | |
2302 | AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser"); | |
2303 | ||
2304 | calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0()); | |
2305 | if (nCols > 2) { | |
2306 | sObjName = (TObjString*)(arrCol->At(2)); | |
2307 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2308 | } | |
2309 | else calPad->SetNameTitle("PulserTmean","PulserTmean"); | |
2310 | calibObjects->Add(calPad); | |
2311 | ||
2312 | calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ()); | |
2313 | if (nCols > 3) { | |
2314 | sObjName = (TObjString*)(arrCol->At(3)); | |
2315 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2316 | } | |
2317 | else calPad->SetNameTitle("PulserQmean","PulserQmean"); | |
2318 | calibObjects->Add(calPad); | |
2319 | ||
2320 | calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS()); | |
2321 | if (nCols > 4) { | |
2322 | sObjName = (TObjString*)(arrCol->At(4)); | |
2323 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2324 | } | |
2325 | else calPad->SetNameTitle("PulserTrms","PulserTrms"); | |
2326 | calibObjects->Add(calPad); | |
2327 | ||
2328 | } else if ( sType == "Pedestals") { | |
2329 | AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal"); | |
2330 | ||
2331 | calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal()); | |
2332 | if (nCols > 2) { | |
2333 | sObjName = (TObjString*)(arrCol->At(2)); | |
2334 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2335 | } | |
2336 | else calPad->SetNameTitle("Pedestals","Pedestals"); | |
2337 | calibObjects->Add(calPad); | |
2338 | ||
2339 | calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS()); | |
2340 | if (nCols > 3) { | |
2341 | sObjName = (TObjString*)(arrCol->At(3)); | |
2342 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2343 | } | |
2344 | else calPad->SetNameTitle("Noise","Noise"); | |
2345 | calibObjects->Add(calPad); | |
2346 | ||
2347 | } else if ( sType == "CalPad") { | |
2348 | if (nCols > 2) sObjName = (TObjString*)(arrCol->At(2)); | |
2349 | else continue; | |
2350 | calPad = new AliTPCCalPad(*(AliTPCCalPad*)fIn->Get(sObjName->GetString().Data())); | |
2351 | if (nCols > 3) { | |
2352 | sObjName = (TObjString*)(arrCol->At(3)); | |
2353 | calPad->SetNameTitle(sObjName->GetString().Data(), sObjName->GetString().Data()); | |
2354 | } | |
2355 | calibObjects->Add(calPad); | |
2356 | } else { | |
2357 | fprintf(stderr,"Undefined Type: '%s'",sType.Data()); | |
2358 | } | |
2359 | delete fIn; | |
2360 | } | |
2361 | } | |
2362 | ||
2363 | ||
2364 |