]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/make_residuals.C
Coverity
[u/mrichter/AliRoot.git] / EVE / alice-macros / make_residuals.C
CommitLineData
6aafad45 1#include <TGButton.h>
2#include <TGButtonGroup.h>
3#include <TGLabel.h>
4#include <TGNumberEntry.h>
5#include <TG3DLine.h>
6#include <TApplication.h>
7#include <TGComboBox.h>
8#include <TLatex.h>
9
10
11class ButtonWindow : public TGMainFrame {
12
13protected:
14 TGComboBox *option1;
15 TGComboBox *option2;
16 TGComboBox *option3;
17 TGComboBox *option4;
18 TGComboBox *option5;
19 TGComboBox *option6;
20 TGComboBox *option7;
21 TGComboBox *option8;
22 TGComboBox *option9;
23 TGComboBox *option10;
24 TGTextEntry *cut1;
25 TGTextEntry *cut2;
26 TGTextEntry *cut3;
27 TGTextEntry *cut4;
28 TGTextEntry *customCutSelection;
29 TGTextEntry *customDrawSelection;
30 TGNumberEntry *nEntries;
31 TGNumberEntry *firstEntry;
32
33public:
34 ButtonWindow();
35 void DrawResiduals();
36
37 ClassDef(ButtonWindow, 0)
38};
39
40//________________________________________________
41
42ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kHorizontalFrame)
43{
44 // Main test window.
45
46 SetCleanup(kDeepCleanup);
47
48 // Controls on right
49 TGVerticalFrame *controls = new TGVerticalFrame(this);
50 AddFrame(controls, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 5, 5, 5, 5));
51
52 // control margins of the text
53
54 TGLabel *label1 = 0;
55 TGLabel *label2 = 0;
56 TGLabel *label3 = 0;
57 TGLabel *label4 = 0;
58 TGLabel *label5 = 0;
59 TGLabel *label6 = 0;
60 TGHorizontal3DLine *separator = 0;
61
62 TGGroupFrame *margins = new TGGroupFrame(controls, "Residuals Drawing Options");
63 margins->SetTitlePos(TGGroupFrame::kCenter);
64
65//==========================
66
67 separator = new TGHorizontal3DLine(margins);
68
69 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
70
71 label1 = new TGLabel(margins, "Axes");
72
73 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
74
75 TGHorizontalFrame *hframe1 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
76
77 label1 = new TGLabel(hframe1, "X axis: ");
78
79 option1 = new TGComboBox(hframe1,"Draw option");
80 option1->AddEntry("fX",1);
81 option1->AddEntry("fY",2);
82 option1->AddEntry("fZ",3);
83 option1->AddEntry("fR",4);
84 option1->Resize(120,20);
85
86 label3 = new TGLabel(hframe1, "Y axis: ");
87
88 option2 = new TGComboBox(hframe1,"Draw option");
89 option2->AddEntry("fPx",1);
90 option2->AddEntry("fPy",2);
91 option2->AddEntry("fPz",3);
92 option2->AddEntry("fPt",4);
93 option2->AddEntry("fP",5);
94 option2->Resize(120,20);
95
96 hframe1->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
97 hframe1->AddFrame(option1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
98 hframe1->AddFrame(label3, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
99 hframe1->AddFrame(option2, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
100
101 margins->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
102
103//==========================
104
105 separator = new TGHorizontal3DLine(margins);
106
107 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
108
109 label1 = new TGLabel(margins, "Cut Selection");
110
111 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
112
113//===============================
114
115 TGHorizontalFrame *hframe3 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
116
117 label1 = new TGLabel(hframe3, " 1. ");
118
119 option3 = new TGComboBox(hframe3,"Cut");
120 option3->AddEntry("fPx",1);
121 option3->AddEntry("fPy",2);
122 option3->AddEntry("fPz",3);
123 option3->AddEntry("fPt",4);
124 option3->AddEntry("fP",5);
125 option3->Resize(100,20);
126
127 option4 = new TGComboBox(hframe3,"-");
128 option4->AddEntry("(no cut)",0);
129 option4->AddEntry("<",1);
130 option4->AddEntry(">",2);
131 option4->Resize(100,20);
132
133 cut1 = new TGTextEntry(hframe3);
134
135 hframe3->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
136 hframe3->AddFrame(option3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
137 hframe3->AddFrame(option4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
138 hframe3->AddFrame(cut1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
139
140 margins->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
141
142//=====================================
143
144 TGHorizontalFrame *hframe4 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
145
146 label1 = new TGLabel(hframe4, "2. ");
147
148 option5 = new TGComboBox(hframe4,"Cut");
149 option5->AddEntry("fPx",1);
150 option5->AddEntry("fPy",2);
151 option5->AddEntry("fPz",3);
152 option5->AddEntry("fPt",4);
153 option5->AddEntry("fP",5);
154 option5->Resize(100,20);
155
156 option6 = new TGComboBox(hframe4,"-");
157 option6->AddEntry("(no cut)",0);
158 option6->AddEntry("<",1);
159 option6->AddEntry(">",2);
160 option6->Resize(100,20);
161
162 cut2 = new TGTextEntry(hframe4);
163// cut2 = new TGNumberEntryField(hframe4, 40, 20, kFixedWidth);
164
165 hframe4->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
166 hframe4->AddFrame(option5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
167 hframe4->AddFrame(option6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
168 hframe4->AddFrame(cut2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
169
170 margins->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
171
172 separator = new TGHorizontal3DLine(margins);
173
174 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
175
176 label1 = new TGLabel(margins, "Custom Cut Selection");
177
178 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
179
180 customCutSelection = new TGTextEntry(margins);
181
182 margins->AddFrame(customCutSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
183
184//========================================
185
186 separator = new TGHorizontal3DLine(margins);
187
188 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
189
190 label1 = new TGLabel(margins, "Draw Selection");
191
192 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
193
194//========================================
195
196 TGHorizontalFrame *hframe5 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
197
198 label1 = new TGLabel(hframe5, "1. ");
199
200 option7 = new TGComboBox(hframe5,"Cut");
201 option7->AddEntry("fPx",1);
202 option7->AddEntry("fPy",2);
203 option7->AddEntry("fPz",3);
204 option7->AddEntry("fPt",4);
205 option7->AddEntry("fP",5);
206 option7->Resize(100,20);
207
208 option8 = new TGComboBox(hframe5,"-");
209 option8->AddEntry("(no cut)",0);
210 option8->AddEntry("<",1);
211 option8->AddEntry(">",2);
212 option8->Resize(100,20);
213
214 cut3 = new TGTextEntry(hframe5);
215// cut3 = new TGNumberEntryField(hframe5, 40, 20, kFixedWidth);
216
217 hframe5->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
218 hframe5->AddFrame(option7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
219 hframe5->AddFrame(option8, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
220 hframe5->AddFrame(cut3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
221
222 margins->AddFrame(hframe5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
223
224//=======================================
225
226 TGHorizontalFrame *hframe6 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
227
228 label1 = new TGLabel(hframe6, "2. ");
229
230 option9 = new TGComboBox(hframe6,"Cut");
231 option9->AddEntry("fPx",1);
232 option9->AddEntry("fPy",2);
233 option9->AddEntry("fPz",3);
234 option9->AddEntry("fPt",4);
235 option9->AddEntry("fP",5);
236 option9->Resize(100,20);
237
238 option10 = new TGComboBox(hframe6,"-");
239 option10->AddEntry("(no cut)",0);
240 option10->AddEntry("<",1);
241 option10->AddEntry(">",2);
242 option10->Resize(100,20);
243
244 cut4 = new TGTextEntry(hframe6);
245// cut4 = new TGNumberEntryField(hframe6, 40, 20, kFixedWidth);
246
247 hframe6->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
248 hframe6->AddFrame(option9, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
249 hframe6->AddFrame(option10, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
250 hframe6->AddFrame(cut4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
251
252 margins->AddFrame(hframe6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
253
254 separator = new TGHorizontal3DLine(margins);
255
256 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
257
258 label1 = new TGLabel(margins, "Custom Draw Selection");
259
260 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
261
262 customDrawSelection = new TGTextEntry(margins);
263
264 margins->AddFrame(customDrawSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
265
266//==========================
267
268 separator = new TGHorizontal3DLine(margins);
269
270 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
271
272 label1 = new TGLabel(margins, "Entries Selection");
273
274 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
275
276//========================================
277
278 TGHorizontalFrame *hframe7 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
279
280 label1 = new TGLabel(hframe7, "nEntries");
281
282 nEntries = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
283
284 label2 = new TGLabel(hframe7, "firstEntry");
285
286 firstEntry = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
287
288 hframe7->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
289 hframe7->AddFrame(nEntries, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
290 hframe7->AddFrame(label2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
291 hframe7->AddFrame(firstEntry, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
292
293 margins->AddFrame(hframe7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
294
295//==========================
296
297 separator = new TGHorizontal3DLine(margins);
298
299 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
300
301 const TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-16-*-*-*-*-*-*-*");
302// const TGFont *font = gClient->GetFont("-*-symbol-medium-r-normal-*-16-*-*-*-*-*-*-*");
303 FontStruct_t buttonFont = font->GetFontStruct();
304 ULong_t buttonRedColor;
305 gClient->GetColorByName("red", buttonRedColor);
306 TGTextButton *draw = new TGTextButton(margins,"Draw Residuals");
307 draw->SetTextColor(buttonRedColor);
308 draw->SetFont(buttonFont);
309 draw->Connect("Clicked()", "ButtonWindow", this, "DrawResiduals()");
310 margins->AddFrame(draw, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
311
312 controls->AddFrame(margins, new TGLayoutHints(kLHintsExpandX));
313
314 MapSubwindows();
315 Resize();
316
317 SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0);
318 SetWindowName("Residuals");
319 MapRaised();
320}
321
322//______________________________________________________________________________
323void ButtonWindow::DrawResiduals()
324{
325
326 TString selection1, selection2, selection3, selection4, selection5 selection6, selection7, selection8, selection9, selection10;
327
328 switch(option1->GetSelected())
329 {
330 case 1:
331 selection1 = "fX";
332 break;
333 case 2:
334 selection1 = "fY";
335 break;
336 case 3:
337 selection1 = "fZ";
338 break;
339 default:
340 selection1 = "fX";
341 break;
342 }
343
344 switch(option2->GetSelected())
345 {
346 case 1:
347 selection2 = "fPx";
348 break;
349 case 2:
350 selection2 = "fPy";
351 break;
352 case 3:
353 selection2 = "fPz";
354 break;
355 case 4:
356 selection2 = "fPt";
357 break;
358 case 5:
359 selection2 = "fP";
360 break;
361 default:
362 selection2 = "fP";
363 break;
364 }
365
366 switch(option3->GetSelected())
367 {
368 case 1:
369 selection3 = "fPx";
370 break;
371 case 2:
372 selection3 = "fPy";
373 break;
374 case 3:
375 selection3 = "fPz";
376 break;
377 case 4:
378 selection3 = "fPt";
379 break;
380 case 5:
381 selection3 = "fP";
382 break;
383 default:
384 selection3 = "fP";
385 break;
386 }
387
388 switch(option4->GetSelected())
389 {
390 case 1:
391 selection4 = "<";
392 break;
393 case 2:
394 selection4 = ">";
395 break;
396 default:
397 selection4 = "<";
398 break;
399 }
400
401 switch(option5->GetSelected())
402 {
403 case 1:
404 selection5 = "fPx";
405 break;
406 case 2:
407 selection5 = "fPy";
408 break;
409 case 3:
410 selection5 = "fPz";
411 break;
412 case 4:
413 selection5 = "fPt";
414 break;
415 case 5:
416 selection5 = "fP";
417 break;
418 default:
419 selection5 = "fP";
420 break;
421 }
422
423 switch(option6->GetSelected())
424 {
425 case 1:
426 selection6 = "<";
427 break;
428 case 2:
429 selection6 = ">";
430 break;
431 default:
432 selection6 = "<";
433 break;
434 }
435
436 switch(option7->GetSelected())
437 {
438 case 1:
439 selection7 = "fPx";
440 break;
441 case 2:
442 selection7 = "fPy";
443 break;
444 case 3:
445 selection7 = "fPz";
446 break;
447 case 4:
448 selection7 = "fPt";
449 break;
450 case 5:
451 selection7 = "fP";
452 break;
453 default:
454 selection7 = "fP";
455 break;
456 }
457
458 switch(option8->GetSelected())
459 {
460 case 1:
461 selection8 = "<";
462 break;
463 case 2:
464 selection8 = ">";
465 break;
466 default:
467 selection8 = "<";
468 break;
469 }
470
471 switch(option9->GetSelected())
472 {
473 case 1:
474 selection9 = "fPx";
475 break;
476 case 2:
477 selection9 = "fPy";
478 break;
479 case 3:
480 selection9 = "fPz";
481 break;
482 case 4:
483 selection9 = "fPt";
484 break;
485 case 5:
486 selection9 = "fP";
487 break;
488 default:
489 selection3 = "fP";
490 break;
491 }
492
493 switch(option10->GetSelected())
494 {
495 case 1:
496 selection10 = "<";
497 break;
498 case 2:
499 selection10 = ">";
500 break;
501 default:
502 selection10 = "<";
503 break;
504 }
505
506 TString cutSelectionMerged;// = ("abs(ESDfriend.fTracks[].fTPCOut."+selection3+"[4])"+selection4+cut1->GetText());
507 TString drawSelectionMerged1 = ("track[]."+selection2+"[0]:track[]."+selection1);
508 TString drawSelectionMerged2;// = ("abs(track[]."+selection7+"[0])"+selection8+cut3->GetText());
509
510 if(customCutSelection->GetText())
511 cutSelectionMerged = customCutSelection->GetText();
512
513 if(customDrawSelection->GetText())
514 drawSelectionMerged2 = customDrawSelection->GetText();
515
516
517 cout << cutSelectionMerged << endl;
518 cout << "abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5" <<endl;
519
520 cout << drawSelectionMerged1 << endl;
521 cout << "track[].fP[0]:track[].fX" << endl;
522
523 cout << drawSelectionMerged2 << endl;
524 cout << "abs(track[].fP[0])<20" << endl;
525
526 cout << "nEntries: " << nEntries->GetNumber() << endl;
527 cout << "firstEntry: " << firstEntry->GetNumber() << endl;
528
529
530 TEveUtil::LoadMacro("ConfigCalibTrain.C");
531
532 AliESDEvent *esd = AliEveEventManager::AssertESD();
533
534 ConfigCalibTrain(esd->GetRunNumber());
535
536 AliESDfriendTrack::MakeDebugStreamer(kTRUE);
537
538 TTreeSRedirector *pcstreamRes = AliESDfriendTrack::GetDebugStreamer();
539
540 TFile fRes("AliESDfriends.root");
541
542 TTree *treeRes = (TTree*)fRes.Get("esdFriendTree");
543
544 TCanvas* cnv = new TCanvas();
545
546 treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)",cutSelectionMerged," ",nEntries->GetNumber(),firstEntry->GetNumber());
547// treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)","abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5"," ",nEntries,firstEntry);
548
549 delete pcstreamRes;
550
551 TFile fRes("residual.root");
552
553 dump.Draw(drawSelectionMerged1,drawSelectionMerged2);
554
555// dump.Draw("track[].fP[0]:track[].fX","abs(track[].fP[0])<20");
556
557
558
559}
560
561//_____________________________________________________________________________
562void make_residuals()
563{
564
565 new ButtonWindow();
566
567}