2 #if !defined(__CINT__) || defined(__MAKECINT__)
5 #include <TGButtonGroup.h>
8 #include <TGNumberEntry.h>
10 #include <TApplication.h>
11 #include <TGComboBox.h>
16 #include <STEER/CDB/AliCDBManager.h>
17 #include <STEER/ESD/AliESDEvent.h>
18 #include <STEER/ESD/AliESDfriendTrack.h>
19 #include <STEER/STEER/AliGeomManager.h>
20 #include <EVE/EveBase/AliEveEventManager.h>
22 /* Not sure which ConfigCalibTrain.C macro ?
23 * From ANALYSIS or from PWGPP?
25 #include "ANALYSIS/macros/ConfigCalibTrain.C"
28 class ButtonWindow : public TGMainFrame {
45 TGTextEntry *customCutSelection;
46 TGTextEntry *customDrawSelection;
47 TGNumberEntry *nEntries;
48 TGNumberEntry *firstEntry;
54 ClassDef(ButtonWindow, 0)
57 //________________________________________________
59 ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kHorizontalFrame)
63 SetCleanup(kDeepCleanup);
66 TGVerticalFrame *controls = new TGVerticalFrame(this);
67 AddFrame(controls, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 5, 5, 5, 5));
69 // control margins of the text
75 TGHorizontal3DLine *separator = 0;
77 TGGroupFrame *margins = new TGGroupFrame(controls, "Residuals Drawing Options");
78 margins->SetTitlePos(TGGroupFrame::kCenter);
80 //==========================
82 separator = new TGHorizontal3DLine(margins);
84 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
86 label1 = new TGLabel(margins, "Axes");
88 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
90 TGHorizontalFrame *hframe1 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
92 label1 = new TGLabel(hframe1, "X axis: ");
94 option1 = new TGComboBox(hframe1,"Draw option");
95 option1->AddEntry("fX",1);
96 option1->AddEntry("fY",2);
97 option1->AddEntry("fZ",3);
98 option1->AddEntry("fR",4);
99 option1->Resize(120,20);
101 label3 = new TGLabel(hframe1, "Y axis: ");
103 option2 = new TGComboBox(hframe1,"Draw option");
104 option2->AddEntry("fPx",1);
105 option2->AddEntry("fPy",2);
106 option2->AddEntry("fPz",3);
107 option2->AddEntry("fPt",4);
108 option2->AddEntry("fP",5);
109 option2->Resize(120,20);
111 hframe1->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
112 hframe1->AddFrame(option1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
113 hframe1->AddFrame(label3, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
114 hframe1->AddFrame(option2, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
116 margins->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
118 //==========================
120 separator = new TGHorizontal3DLine(margins);
122 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
124 label1 = new TGLabel(margins, "Cut Selection");
126 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
128 //===============================
130 TGHorizontalFrame *hframe3 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
132 label1 = new TGLabel(hframe3, " 1. ");
134 option3 = new TGComboBox(hframe3,"Cut");
135 option3->AddEntry("fPx",1);
136 option3->AddEntry("fPy",2);
137 option3->AddEntry("fPz",3);
138 option3->AddEntry("fPt",4);
139 option3->AddEntry("fP",5);
140 option3->Resize(100,20);
142 option4 = new TGComboBox(hframe3,"-");
143 option4->AddEntry("(no cut)",0);
144 option4->AddEntry("<",1);
145 option4->AddEntry(">",2);
146 option4->Resize(100,20);
148 cut1 = new TGTextEntry(hframe3);
150 hframe3->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
151 hframe3->AddFrame(option3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
152 hframe3->AddFrame(option4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
153 hframe3->AddFrame(cut1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
155 margins->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
157 //=====================================
159 TGHorizontalFrame *hframe4 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
161 label1 = new TGLabel(hframe4, "2. ");
163 option5 = new TGComboBox(hframe4,"Cut");
164 option5->AddEntry("fPx",1);
165 option5->AddEntry("fPy",2);
166 option5->AddEntry("fPz",3);
167 option5->AddEntry("fPt",4);
168 option5->AddEntry("fP",5);
169 option5->Resize(100,20);
171 option6 = new TGComboBox(hframe4,"-");
172 option6->AddEntry("(no cut)",0);
173 option6->AddEntry("<",1);
174 option6->AddEntry(">",2);
175 option6->Resize(100,20);
177 cut2 = new TGTextEntry(hframe4);
178 // cut2 = new TGNumberEntryField(hframe4, 40, 20, kFixedWidth);
180 hframe4->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
181 hframe4->AddFrame(option5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
182 hframe4->AddFrame(option6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
183 hframe4->AddFrame(cut2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
185 margins->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
187 separator = new TGHorizontal3DLine(margins);
189 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
191 label1 = new TGLabel(margins, "Custom Cut Selection");
193 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
195 customCutSelection = new TGTextEntry(margins);
197 margins->AddFrame(customCutSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
199 //========================================
201 separator = new TGHorizontal3DLine(margins);
203 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
205 label1 = new TGLabel(margins, "Draw Selection");
207 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
209 //========================================
211 TGHorizontalFrame *hframe5 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
213 label1 = new TGLabel(hframe5, "1. ");
215 option7 = new TGComboBox(hframe5,"Cut");
216 option7->AddEntry("fPx",1);
217 option7->AddEntry("fPy",2);
218 option7->AddEntry("fPz",3);
219 option7->AddEntry("fPt",4);
220 option7->AddEntry("fP",5);
221 option7->Resize(100,20);
223 option8 = new TGComboBox(hframe5,"-");
224 option8->AddEntry("(no cut)",0);
225 option8->AddEntry("<",1);
226 option8->AddEntry(">",2);
227 option8->Resize(100,20);
229 cut3 = new TGTextEntry(hframe5);
230 // cut3 = new TGNumberEntryField(hframe5, 40, 20, kFixedWidth);
232 hframe5->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
233 hframe5->AddFrame(option7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
234 hframe5->AddFrame(option8, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
235 hframe5->AddFrame(cut3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
237 margins->AddFrame(hframe5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
239 //=======================================
241 TGHorizontalFrame *hframe6 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
243 label1 = new TGLabel(hframe6, "2. ");
245 option9 = new TGComboBox(hframe6,"Cut");
246 option9->AddEntry("fPx",1);
247 option9->AddEntry("fPy",2);
248 option9->AddEntry("fPz",3);
249 option9->AddEntry("fPt",4);
250 option9->AddEntry("fP",5);
251 option9->Resize(100,20);
253 option10 = new TGComboBox(hframe6,"-");
254 option10->AddEntry("(no cut)",0);
255 option10->AddEntry("<",1);
256 option10->AddEntry(">",2);
257 option10->Resize(100,20);
259 cut4 = new TGTextEntry(hframe6);
260 // cut4 = new TGNumberEntryField(hframe6, 40, 20, kFixedWidth);
262 hframe6->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
263 hframe6->AddFrame(option9, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
264 hframe6->AddFrame(option10, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
265 hframe6->AddFrame(cut4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
267 margins->AddFrame(hframe6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
269 separator = new TGHorizontal3DLine(margins);
271 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
273 label1 = new TGLabel(margins, "Custom Draw Selection");
275 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
277 customDrawSelection = new TGTextEntry(margins);
279 margins->AddFrame(customDrawSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
281 //==========================
283 separator = new TGHorizontal3DLine(margins);
285 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
287 label1 = new TGLabel(margins, "Entries Selection");
289 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
291 //========================================
293 TGHorizontalFrame *hframe7 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
295 label1 = new TGLabel(hframe7, "nEntries");
297 nEntries = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
299 label2 = new TGLabel(hframe7, "firstEntry");
301 firstEntry = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
303 hframe7->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
304 hframe7->AddFrame(nEntries, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
305 hframe7->AddFrame(label2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
306 hframe7->AddFrame(firstEntry, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
308 margins->AddFrame(hframe7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
310 //==========================
312 separator = new TGHorizontal3DLine(margins);
314 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
316 const TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-16-*-*-*-*-*-*-*");
317 // const TGFont *font = gClient->GetFont("-*-symbol-medium-r-normal-*-16-*-*-*-*-*-*-*");
318 FontStruct_t buttonFont = font->GetFontStruct();
319 ULong_t buttonRedColor;
320 gClient->GetColorByName("red", buttonRedColor);
321 TGTextButton *draw = new TGTextButton(margins,"Draw Residuals");
322 draw->SetTextColor(buttonRedColor);
323 draw->SetFont(buttonFont);
324 draw->Connect("Clicked()", "ButtonWindow", this, "DrawResiduals()");
325 margins->AddFrame(draw, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
327 controls->AddFrame(margins, new TGLayoutHints(kLHintsExpandX));
332 SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0);
333 SetWindowName("Residuals");
337 //______________________________________________________________________________
338 void ButtonWindow::DrawResiduals()
341 TString selection1, selection2, selection3, selection4, selection5, selection6, selection7, selection8, selection9, selection10;
343 switch(option1->GetSelected())
359 switch(option2->GetSelected())
381 switch(option3->GetSelected())
403 switch(option4->GetSelected())
416 switch(option5->GetSelected())
438 switch(option6->GetSelected())
451 switch(option7->GetSelected())
473 switch(option8->GetSelected())
486 switch(option9->GetSelected())
508 switch(option10->GetSelected())
521 TString cutSelectionMerged;// = ("abs(ESDfriend.fTracks[].fTPCOut."+selection3+"[4])"+selection4+cut1->GetText());
522 TString drawSelectionMerged1 = ("track[]."+selection2+"[0]:track[]."+selection1);
523 TString drawSelectionMerged2;// = ("abs(track[]."+selection7+"[0])"+selection8+cut3->GetText());
525 if(customCutSelection->GetText())
526 cutSelectionMerged = customCutSelection->GetText();
528 if(customDrawSelection->GetText())
529 drawSelectionMerged2 = customDrawSelection->GetText();
532 Info("make_residuals::DrawResiduals", "%s abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5", cutSelectionMerged.Data());
533 Info("make_residuals::DrawResiduals", "%s track[].fP[0]:track[].fX", drawSelectionMerged1.Data());
534 Info("make_residuals::DrawResiduals", "%s abs(track[].fP[0])<20", drawSelectionMerged2.Data());
535 Info("make_residuals::DrawResiduals", "nEntries: %f", nEntries->GetNumber());
536 Info("make_residuals::DrawResiduals", "firstEntry: %f", firstEntry->GetNumber());
538 TEveUtil::LoadMacro("ConfigCalibTrain.C");
540 AliESDEvent *esd = AliEveEventManager::AssertESD();
542 ConfigCalibTrain(esd->GetRunNumber());
544 /* OBSOLETE CODE - No function members defined
546 AliESDfriendTrack::MakeDebugStreamer(kTRUE);
548 TTreeSRedirector *pcstreamRes = AliESDfriendTrack::GetDebugStreamer();
551 TFile fRes("AliESDfriends.root");
553 TTree *treeRes = (TTree*)fRes.Get("esdFriendTree");
555 TCanvas* cnv = new TCanvas();
558 treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)",cutSelectionMerged," ",nEntries->GetNumber(),firstEntry->GetNumber());
559 // treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)","abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5"," ",nEntries,firstEntry);
561 //delete pcstreamRes;
563 /* OBSOLETE CODE -dump not defined
565 TFile fRes("residual.root");
567 dump.Draw(drawSelectionMerged1,drawSelectionMerged2);
569 // dump.Draw("track[].fP[0]:track[].fX","abs(track[].fP[0])<20");
573 //_____________________________________________________________________________
574 void make_residuals()