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