1 /**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
3 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
4 * full copyright notice. *
5 **************************************************************************/
7 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <TGButtonGroup.h>
13 #include <TGNumberEntry.h>
15 #include <TApplication.h>
16 #include <TGComboBox.h>
21 #include <AliCDBManager.h>
22 #include <AliESDEvent.h>
23 #include <AliESDfriendTrack.h>
24 #include <AliGeomManager.h>
25 #include <AliEveEventManager.h>
27 /* Not sure which ConfigCalibTrain.C macro ?
28 * From ANALYSIS or from PWGPP?
30 #include <ANALYSIS/macros/ConfigCalibTrain.C>
33 class ButtonWindow : public TGMainFrame {
50 TGTextEntry *customCutSelection;
51 TGTextEntry *customDrawSelection;
52 TGNumberEntry *nEntries;
53 TGNumberEntry *firstEntry;
59 ClassDef(ButtonWindow, 0)
62 //________________________________________________
64 ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kHorizontalFrame)
68 SetCleanup(kDeepCleanup);
71 TGVerticalFrame *controls = new TGVerticalFrame(this);
72 AddFrame(controls, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 5, 5, 5, 5));
74 // control margins of the text
80 TGHorizontal3DLine *separator = 0;
82 TGGroupFrame *margins = new TGGroupFrame(controls, "Residuals Drawing Options");
83 margins->SetTitlePos(TGGroupFrame::kCenter);
85 //==========================
87 separator = new TGHorizontal3DLine(margins);
89 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
91 label1 = new TGLabel(margins, "Axes");
93 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
95 TGHorizontalFrame *hframe1 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
97 label1 = new TGLabel(hframe1, "X axis: ");
99 option1 = new TGComboBox(hframe1,"Draw option");
100 option1->AddEntry("fX",1);
101 option1->AddEntry("fY",2);
102 option1->AddEntry("fZ",3);
103 option1->AddEntry("fR",4);
104 option1->Resize(120,20);
106 label3 = new TGLabel(hframe1, "Y axis: ");
108 option2 = new TGComboBox(hframe1,"Draw option");
109 option2->AddEntry("fPx",1);
110 option2->AddEntry("fPy",2);
111 option2->AddEntry("fPz",3);
112 option2->AddEntry("fPt",4);
113 option2->AddEntry("fP",5);
114 option2->Resize(120,20);
116 hframe1->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
117 hframe1->AddFrame(option1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
118 hframe1->AddFrame(label3, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
119 hframe1->AddFrame(option2, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
121 margins->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
123 //==========================
125 separator = new TGHorizontal3DLine(margins);
127 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
129 label1 = new TGLabel(margins, "Cut Selection");
131 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
133 //===============================
135 TGHorizontalFrame *hframe3 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
137 label1 = new TGLabel(hframe3, " 1. ");
139 option3 = new TGComboBox(hframe3,"Cut");
140 option3->AddEntry("fPx",1);
141 option3->AddEntry("fPy",2);
142 option3->AddEntry("fPz",3);
143 option3->AddEntry("fPt",4);
144 option3->AddEntry("fP",5);
145 option3->Resize(100,20);
147 option4 = new TGComboBox(hframe3,"-");
148 option4->AddEntry("(no cut)",0);
149 option4->AddEntry("<",1);
150 option4->AddEntry(">",2);
151 option4->Resize(100,20);
153 cut1 = new TGTextEntry(hframe3);
155 hframe3->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
156 hframe3->AddFrame(option3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
157 hframe3->AddFrame(option4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
158 hframe3->AddFrame(cut1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
160 margins->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
162 //=====================================
164 TGHorizontalFrame *hframe4 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
166 label1 = new TGLabel(hframe4, "2. ");
168 option5 = new TGComboBox(hframe4,"Cut");
169 option5->AddEntry("fPx",1);
170 option5->AddEntry("fPy",2);
171 option5->AddEntry("fPz",3);
172 option5->AddEntry("fPt",4);
173 option5->AddEntry("fP",5);
174 option5->Resize(100,20);
176 option6 = new TGComboBox(hframe4,"-");
177 option6->AddEntry("(no cut)",0);
178 option6->AddEntry("<",1);
179 option6->AddEntry(">",2);
180 option6->Resize(100,20);
182 cut2 = new TGTextEntry(hframe4);
183 // cut2 = new TGNumberEntryField(hframe4, 40, 20, kFixedWidth);
185 hframe4->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
186 hframe4->AddFrame(option5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
187 hframe4->AddFrame(option6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
188 hframe4->AddFrame(cut2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
190 margins->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
192 separator = new TGHorizontal3DLine(margins);
194 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
196 label1 = new TGLabel(margins, "Custom Cut Selection");
198 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
200 customCutSelection = new TGTextEntry(margins);
202 margins->AddFrame(customCutSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
204 //========================================
206 separator = new TGHorizontal3DLine(margins);
208 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
210 label1 = new TGLabel(margins, "Draw Selection");
212 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
214 //========================================
216 TGHorizontalFrame *hframe5 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
218 label1 = new TGLabel(hframe5, "1. ");
220 option7 = new TGComboBox(hframe5,"Cut");
221 option7->AddEntry("fPx",1);
222 option7->AddEntry("fPy",2);
223 option7->AddEntry("fPz",3);
224 option7->AddEntry("fPt",4);
225 option7->AddEntry("fP",5);
226 option7->Resize(100,20);
228 option8 = new TGComboBox(hframe5,"-");
229 option8->AddEntry("(no cut)",0);
230 option8->AddEntry("<",1);
231 option8->AddEntry(">",2);
232 option8->Resize(100,20);
234 cut3 = new TGTextEntry(hframe5);
235 // cut3 = new TGNumberEntryField(hframe5, 40, 20, kFixedWidth);
237 hframe5->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
238 hframe5->AddFrame(option7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
239 hframe5->AddFrame(option8, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
240 hframe5->AddFrame(cut3, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
242 margins->AddFrame(hframe5, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
244 //=======================================
246 TGHorizontalFrame *hframe6 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
248 label1 = new TGLabel(hframe6, "2. ");
250 option9 = new TGComboBox(hframe6,"Cut");
251 option9->AddEntry("fPx",1);
252 option9->AddEntry("fPy",2);
253 option9->AddEntry("fPz",3);
254 option9->AddEntry("fPt",4);
255 option9->AddEntry("fP",5);
256 option9->Resize(100,20);
258 option10 = new TGComboBox(hframe6,"-");
259 option10->AddEntry("(no cut)",0);
260 option10->AddEntry("<",1);
261 option10->AddEntry(">",2);
262 option10->Resize(100,20);
264 cut4 = new TGTextEntry(hframe6);
265 // cut4 = new TGNumberEntryField(hframe6, 40, 20, kFixedWidth);
267 hframe6->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
268 hframe6->AddFrame(option9, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
269 hframe6->AddFrame(option10, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
270 hframe6->AddFrame(cut4, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
272 margins->AddFrame(hframe6, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
274 separator = new TGHorizontal3DLine(margins);
276 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
278 label1 = new TGLabel(margins, "Custom Draw Selection");
280 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
282 customDrawSelection = new TGTextEntry(margins);
284 margins->AddFrame(customDrawSelection, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
286 //==========================
288 separator = new TGHorizontal3DLine(margins);
290 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
292 label1 = new TGLabel(margins, "Entries Selection");
294 margins->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
296 //========================================
298 TGHorizontalFrame *hframe7 = new TGHorizontalFrame(margins, 400, 20, kFixedWidth);
300 label1 = new TGLabel(hframe7, "nEntries");
302 nEntries = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
304 label2 = new TGLabel(hframe7, "firstEntry");
306 firstEntry = new TGNumberEntry(hframe7, 40, 20, kFixedWidth);
308 hframe7->AddFrame(label1, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
309 hframe7->AddFrame(nEntries, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
310 hframe7->AddFrame(label2, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
311 hframe7->AddFrame(firstEntry, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
313 margins->AddFrame(hframe7, new TGLayoutHints(kLHintsExpandX, 5, 5, 1, 1));
315 //==========================
317 separator = new TGHorizontal3DLine(margins);
319 margins->AddFrame(separator, new TGLayoutHints(kLHintsExpandX));
321 const TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-16-*-*-*-*-*-*-*");
322 // const TGFont *font = gClient->GetFont("-*-symbol-medium-r-normal-*-16-*-*-*-*-*-*-*");
323 FontStruct_t buttonFont = font->GetFontStruct();
324 ULong_t buttonRedColor;
325 gClient->GetColorByName("red", buttonRedColor);
326 TGTextButton *draw = new TGTextButton(margins,"Draw Residuals");
327 draw->SetTextColor(buttonRedColor);
328 draw->SetFont(buttonFont);
329 draw->Connect("Clicked()", "ButtonWindow", this, "DrawResiduals()");
330 margins->AddFrame(draw, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
332 controls->AddFrame(margins, new TGLayoutHints(kLHintsExpandX));
337 SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0);
338 SetWindowName("Residuals");
342 //______________________________________________________________________________
343 void ButtonWindow::DrawResiduals()
346 TString selection1, selection2, selection3, selection4, selection5, selection6, selection7, selection8, selection9, selection10;
348 switch(option1->GetSelected())
364 switch(option2->GetSelected())
386 switch(option3->GetSelected())
408 switch(option4->GetSelected())
421 switch(option5->GetSelected())
443 switch(option6->GetSelected())
456 switch(option7->GetSelected())
478 switch(option8->GetSelected())
491 switch(option9->GetSelected())
513 switch(option10->GetSelected())
526 TString cutSelectionMerged;// = ("abs(ESDfriend.fTracks[].fTPCOut."+selection3+"[4])"+selection4+cut1->GetText());
527 TString drawSelectionMerged1 = ("track[]."+selection2+"[0]:track[]."+selection1);
528 TString drawSelectionMerged2;// = ("abs(track[]."+selection7+"[0])"+selection8+cut3->GetText());
530 if(customCutSelection->GetText())
531 cutSelectionMerged = customCutSelection->GetText();
533 if(customDrawSelection->GetText())
534 drawSelectionMerged2 = customDrawSelection->GetText();
537 Info("make_residuals::DrawResiduals", "%s abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5", cutSelectionMerged.Data());
538 Info("make_residuals::DrawResiduals", "%s track[].fP[0]:track[].fX", drawSelectionMerged1.Data());
539 Info("make_residuals::DrawResiduals", "%s abs(track[].fP[0])<20", drawSelectionMerged2.Data());
540 Info("make_residuals::DrawResiduals", "nEntries: %f", nEntries->GetNumber());
541 Info("make_residuals::DrawResiduals", "firstEntry: %f", firstEntry->GetNumber());
543 TEveUtil::LoadMacro("$ALICE_ROOT/ANALYSIS/macros/ConfigCalibTrain.C+");
545 AliESDEvent *esd = AliEveEventManager::AssertESD();
547 ConfigCalibTrain(esd->GetRunNumber());
549 /* OBSOLETE CODE - No function members defined
551 AliESDfriendTrack::MakeDebugStreamer(kTRUE);
553 TTreeSRedirector *pcstreamRes = AliESDfriendTrack::GetDebugStreamer();
556 TFile fRes("AliESDfriends.root");
558 TTree *treeRes = (TTree*)fRes.Get("esdFriendTree");
560 TCanvas* cnv = new TCanvas();
563 treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)",cutSelectionMerged," ",nEntries->GetNumber(),firstEntry->GetNumber());
564 // treeRes->Draw("ESDfriend.fTracks[].MakeResidualGraph(1)","abs(ESDfriend.fTracks[].fTPCOut.fP[4])<0.5"," ",nEntries,firstEntry);
566 //delete pcstreamRes;
568 /* OBSOLETE CODE -dump not defined
570 TFile fRes("residual.root");
572 dump.Draw(drawSelectionMerged1,drawSelectionMerged2);
574 // dump.Draw("track[].fP[0]:track[].fX","abs(track[].fP[0])<20");
578 //_____________________________________________________________________________
579 void make_residuals()