]>
Commit | Line | Data |
---|---|---|
7afe0204 | 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 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // AliTagAnalysisFrame class | |
20 | // The class that deals with the event tag tab of the GUI | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
22 | //----------------------------------------------------------------- | |
23 | ||
24 | #include "TGTextEntry.h" | |
25 | #include "TGLabel.h" | |
26 | #include "TGMsgBox.h" | |
27 | #include "TGListBox.h" | |
28 | #include "TGComboBox.h" | |
29 | ||
30 | #include "TSystem.h" | |
31 | #include "TChain.h" | |
32 | #include "TGrid.h" | |
33 | #include "TGridResult.h" | |
34 | #include "TEventList.h" | |
35 | ||
36 | #include "AliRunTagCuts.h" | |
37 | #include "AliEventTagCuts.h" | |
38 | #include "AliTagAnalysis.h" | |
39 | ||
40 | #include "AliAnalysisGUI.h" | |
41 | #include "AliAlienBrowser.h" | |
42 | #include "AliTagFrame.h" | |
43 | #include "AliTagAnalysisFrame.h" | |
44 | ||
45 | ClassImp(AliTagAnalysisFrame) | |
46 | ||
47 | //___________________________________________________________________________ | |
a313abd0 | 48 | AliTagAnalysisFrame::AliTagAnalysisFrame(const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI* fAliAnalysisGUI): |
49 | TGMainFrame(main, w, h, kHorizontalFrame), | |
50 | fkNumberOfTags(3), | |
51 | fVFrame1(0), fVFrame2(0), | |
52 | fGroup1(0), fGroup2(0), fGroup3(0), | |
53 | fAliAnalysisGUI(fAliAnalysisGUI), | |
54 | fTagFrame(0), fAliEnBrowser(0), | |
55 | fLocalLabel1(0), fLocalPath(0), | |
56 | fLocalButton(0), fButtonInsert(0), fButtonRun(0), | |
57 | fComboEventTagCut(0), fGridLabel1(0), | |
58 | fGridPath(0), fGridButton(0), fButtonInsert2(0), fButtonRun2(0), | |
59 | fComboEventTagCut2(0), fTagResult(0), | |
60 | fAnalysisChain(0), fListBox(0), | |
61 | fBrowser(NULL), fBrowserButton(NULL), | |
62 | fAliTagAnalysis(0), fAliRunCuts(0), | |
63 | fAliEventCuts(0), fEventTagCutsName(0) { | |
7afe0204 | 64 | // Constructor. |
65 | ||
66 | /* | |
67 | // lazy initialization to fEventTagCutsName | |
68 | const char *tmp[] ={ "Vx", "Vy", "Vz", "Participants", "Impact parameter", "Primary vertex", | |
69 | "ZDC - neutron 1", "ZDC - proton 1", "ZDC - neutron 2", "ZDC - proton 2", | |
70 | "ZDC EM", "TO VertexZ", | |
71 | "Multiplicity", "Positive Multiplicity", "Negative Multiplicity", | |
72 | "Neutral Multiplicity", "VO", "Cascades", "Kinks", | |
73 | "Jet Energy", "Hard Photons Candidates", "Neutral Energy", | |
74 | "Charged above 1 GeV", "Charged above 3 GeV", "Charged above 10 GeV", | |
75 | "Muons above 1 GeV", "Muons above 3 GeV", "Muons above 10 GeV", | |
76 | "Electron above 1 GeV", "Electron above 3 GeV", "Electron above 10 GeV", | |
77 | "Electrons range", "Muons range", "Pions range", "Kaons range", | |
78 | "Protons range", "Lambda range", "Photons range", "PiOs range", | |
79 | "Neutrons range", "KaonOs range" | |
80 | }; | |
81 | */ | |
82 | ||
83 | const char *tmp[] = {"MultiplicityRange","VOsRange", "NPionRange" }; | |
84 | fEventTagCutsName = tmp; | |
85 | ||
86 | // fEventTagCutsName = new TList(); | |
87 | ||
88 | // fEventTagCutsName[0] = "NegMultiplicityRange"; | |
89 | // fEventTagCutsName[1] = "VOsRange"; | |
90 | // fEventTagCutsName[2] = "NPionRange"; | |
91 | ||
92 | fVFrame1 = new TGVerticalFrame(this, 200, 150); | |
93 | this->AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5)); | |
94 | ||
95 | // Local Group | |
96 | fGroup1 = new TGGroupFrame(fVFrame1, "Local", kVerticalFrame); | |
97 | fGroup1->SetTitlePos(TGGroupFrame::kLeft); // left aligned | |
98 | fVFrame1->AddFrame(fGroup1, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
99 | ||
100 | BuildLocalGroup(fGroup1); | |
101 | ||
102 | // Grid Group | |
103 | fGroup2 = new TGGroupFrame(fVFrame1, "Grid", kVerticalFrame); | |
104 | fGroup2->SetTitlePos(TGGroupFrame::kLeft); // left aligned | |
105 | fVFrame1->AddFrame(fGroup2, new TGLayoutHints(kLHintsBottom, 5,5,5,5)); | |
106 | ||
107 | BuildGridGroup(fGroup2); | |
108 | ||
109 | // Vertical Frame 2 | |
110 | ||
111 | fVFrame2 = new TGVerticalFrame(this, 200, 200); | |
112 | AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight| kLHintsExpandX | |
113 | | kLHintsExpandY, 5,5,5,5)); | |
114 | ||
115 | fGroup3 = new TGGroupFrame(fVFrame2, "Results", | |
116 | kVerticalFrame | kFitWidth | kFitHeight); | |
117 | fGroup3->SetTitlePos(TGGroupFrame::kLeft); // left aligned | |
118 | fVFrame2->AddFrame(fGroup3, | |
119 | new TGLayoutHints(kLHintsTop | kLHintsExpandX | |
120 | | kLHintsExpandY, 5,5,5,5)); | |
121 | ||
122 | fListBox = new TGListBox(fGroup3); | |
123 | fGroup3->AddFrame(fListBox, | |
124 | new TGLayoutHints(kLHintsTop | kLHintsExpandX | | |
125 | kLHintsExpandY, 5,5,5,5)); | |
126 | ||
127 | fAliTagAnalysis = new AliTagAnalysis(); | |
128 | fAliRunCuts = new AliRunTagCuts(); | |
129 | fAliEventCuts = new AliEventTagCuts(); | |
130 | ||
131 | MapSubwindows(); | |
132 | Resize(); | |
133 | MapWindow(); | |
134 | } | |
135 | ||
136 | //___________________________________________________________________________ | |
137 | AliTagAnalysisFrame::~AliTagAnalysisFrame() { | |
138 | // AliTagAnalysisFrame dctor. | |
139 | ||
140 | delete fGroup1; | |
141 | delete fLocalLabel1; | |
142 | delete fLocalPath; | |
143 | delete fLocalButton; | |
144 | delete fGroup2; | |
145 | delete fGridLabel1; | |
146 | delete fGridPath; | |
147 | delete fGridButton; | |
148 | ||
149 | delete fAliTagAnalysis; | |
150 | delete fAliRunCuts; | |
151 | delete fAliEventCuts; | |
152 | delete fTagResult; | |
153 | delete fAnalysisChain; | |
154 | ||
155 | delete fTagFrame; | |
156 | } | |
157 | ||
158 | //___________________________________________________________________________ | |
159 | void AliTagAnalysisFrame::AddResult (const char* line) { | |
160 | // Add a new line in the result group box. | |
161 | ||
162 | // fGroup3->AddFrame(new TGLabel(fGroup3, new TGString(line)), | |
163 | // new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
164 | ||
165 | fListBox->AddEntry(line, fListBox->GetNumberOfEntries()); | |
166 | ||
167 | MapSubwindows(); | |
168 | Resize(); | |
169 | MapWindow(); | |
170 | } | |
171 | ||
172 | //___________________________________________________________________________ | |
173 | void AliTagAnalysisFrame::BuildLocalGroup (TGCompositeFrame* frame) { | |
174 | // The Local Group Frame | |
175 | fLocalLabel1 = new TGLabel(frame, new TGString("Chain Local Tag Path")); | |
176 | frame->AddFrame(fLocalLabel1, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
177 | ||
178 | fLocalPath = new TGTextEntry(frame, new TGTextBuffer(40)); | |
179 | fLocalPath->SetEnabled(false); | |
180 | frame->AddFrame(fLocalPath, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
181 | ||
182 | fLocalButton = new TGTextButton(frame, "Browse...", 0); | |
183 | frame->AddFrame(fLocalButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5)); | |
184 | ||
185 | fLocalButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "LocalBrowse()"); | |
186 | ||
187 | fComboEventTagCut = new TGComboBox(frame, "Select Tag Cuts...", 1); | |
188 | frame->AddFrame(fComboEventTagCut, | |
189 | new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5)); | |
190 | ||
191 | for(int i=0; i!=fkNumberOfTags; i++) | |
192 | fComboEventTagCut->AddEntry(fEventTagCutsName[i],i); | |
193 | ||
194 | fComboEventTagCut->Resize(150, 20); | |
195 | ||
196 | fButtonInsert = new TGTextButton(frame, "Insert Tag Cuts Range", 2); | |
197 | frame->AddFrame(fButtonInsert, | |
198 | new TGLayoutHints(kLHintsLeft | kLHintsTop, 5,5,5,5)); | |
199 | ||
200 | fButtonInsert->Connect("Clicked()", "AliTagAnalysisFrame", this, | |
201 | "InsertTagCutsRangeLocal()"); | |
202 | ||
203 | fButtonRun = new TGTextButton(frame, " Run ", 3); | |
204 | frame->AddFrame(fButtonRun, | |
205 | new TGLayoutHints(kLHintsTop | kLHintsRight, 5,5,5,5)); | |
206 | ||
207 | fButtonRun->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunLocal()"); | |
208 | } | |
209 | ||
210 | //___________________________________________________________________________ | |
211 | void AliTagAnalysisFrame::BuildGridGroup (TGCompositeFrame* frame) { | |
212 | // The Grid Group Frame | |
213 | ||
214 | fGridLabel1 = new TGLabel(frame, new TGString("Chain Grid Tag Path")); | |
215 | frame->AddFrame(fGridLabel1, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
216 | ||
217 | fGridPath = new TGTextEntry(frame, new TGTextBuffer(40)); | |
218 | fGridPath->SetEnabled(false); | |
219 | // fGridPath->SetText("/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1"); | |
220 | frame->AddFrame(fGridPath, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
221 | ||
222 | fGridButton = new TGTextButton(frame, "Browse...", 0); | |
223 | frame->AddFrame(fGridButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5)); | |
224 | ||
225 | fGridButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "GridBrowse()"); | |
226 | ||
227 | fComboEventTagCut2 = new TGComboBox(frame, "Select Tag Cuts...", 1); | |
228 | frame->AddFrame(fComboEventTagCut2, | |
229 | new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5)); | |
230 | ||
231 | for(int i=0; i!=fkNumberOfTags; i++) | |
232 | fComboEventTagCut2->AddEntry(fEventTagCutsName[i],i); | |
233 | ||
234 | fComboEventTagCut2->Resize(150, 20); | |
235 | ||
236 | fButtonInsert2 = new TGTextButton(frame, "Insert Tag Cuts Range", 2); | |
237 | frame->AddFrame(fButtonInsert2, | |
238 | new TGLayoutHints(kLHintsLeft, 5,5,5,5)); | |
239 | ||
240 | fButtonInsert2->Connect("Clicked()", "AliTagAnalysisFrame", this, | |
241 | "InsertTagCutsRangeGrid()"); | |
242 | ||
243 | fButtonRun2 = new TGTextButton(frame," Run " , 2); | |
244 | frame->AddFrame(fButtonRun2, | |
245 | new TGLayoutHints(kLHintsRight, 5,5,5,5)); | |
246 | ||
247 | fButtonRun2->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunGrid()"); | |
248 | ||
249 | } | |
250 | ||
251 | //___________________________________________________________________________ | |
252 | void AliTagAnalysisFrame::LocalBrowse() { | |
253 | // Browse local directories. | |
254 | ||
255 | fBrowser = new TGTransientFrame(gClient->GetRoot(), fAliAnalysisGUI, 450, 200); | |
256 | fAliEnBrowser = new AliAlienBrowser(fBrowser, 300, 200, this, | |
257 | "AliTagAnalysisFrame", kLocalBrowse); | |
258 | fBrowser->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
259 | fBrowserButton = new TGTextButton(fBrowser, " OK ", 0); | |
260 | fBrowser->AddFrame(fBrowserButton, new TGLayoutHints(kLHintsRight, 5,5,5,5)); | |
261 | fBrowserButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "OnOKButton()"); | |
262 | ||
263 | fAliEnBrowser->AddItem(0, "/"); | |
264 | ||
265 | fAliEnBrowser->GotoDir(gSystem->pwd()); | |
266 | ||
267 | fBrowser->MapSubwindows(); | |
268 | fBrowser->Resize(); | |
269 | fBrowser->MapWindow(); | |
270 | } | |
271 | ||
272 | //___________________________________________________________________________ | |
273 | void AliTagAnalysisFrame::GridBrowse() { | |
274 | // Opens a browser for grid directories. | |
275 | ||
276 | if (!fAliAnalysisGUI->IsConnected()){ | |
277 | new TGMsgBox(gClient->GetRoot(), this, "Connect", | |
278 | "Please connect to AliEn", 0, kMBOk); | |
279 | return; | |
280 | } | |
281 | ||
282 | fBrowser = new TGTransientFrame(gClient->GetRoot(), fAliAnalysisGUI, 450, 200); | |
283 | ||
284 | fAliEnBrowser = new AliAlienBrowser(fBrowser, 300, 200, this, | |
285 | "AliTagAnalysisFrame", kGridBrowse); | |
286 | fBrowser->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsTop, 5,5,5,5)); | |
287 | ||
288 | fBrowserButton = new TGTextButton(fBrowser, " OK ", 0); | |
289 | fBrowser->AddFrame(fBrowserButton, new TGLayoutHints(kLHintsRight, 5,5,5,5)); | |
290 | ||
291 | fBrowserButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "OnOKButton()"); | |
292 | ||
293 | fAliEnBrowser->AddItem(0, "/"); | |
294 | ||
295 | fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory()); | |
296 | ||
297 | fBrowser->MapSubwindows(); | |
298 | fBrowser->Resize(); | |
299 | fBrowser->MapWindow(); | |
300 | } | |
301 | ||
302 | //___________________________________________________________________________ | |
303 | void AliTagAnalysisFrame::InsertTagCutsRangeLocal() { | |
304 | // slot | |
305 | InsertTagCutsRange(fComboEventTagCut->GetSelected()); | |
306 | } | |
307 | ||
308 | ||
309 | //___________________________________________________________________________ | |
310 | void AliTagAnalysisFrame::InsertTagCutsRangeGrid() { | |
311 | // slot | |
312 | InsertTagCutsRange(fComboEventTagCut2->GetSelected()); | |
313 | } | |
314 | ||
315 | //___________________________________________________________________________ | |
316 | void AliTagAnalysisFrame::InsertTagCutsRange(Int_t id) { | |
317 | // insert the event tag range | |
318 | ||
319 | // if nth is selected | |
320 | if(id == -1) | |
321 | return; | |
322 | ||
323 | ||
324 | switch(id){ | |
325 | case 0: // SetMultiplicity Range | |
326 | ||
327 | fTagFrame = new AliTagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, fComboEventTagCut->GetTextEntry()->GetText(), fComboEventTagCut->GetSelected(), kRangeMinMax); | |
328 | ||
329 | Int_t min = fTagFrame->GetRangeMin(); | |
330 | Int_t max = fTagFrame->GetRangeMax(); | |
331 | ||
332 | fAliEventCuts->SetMultiplicityRange(min, max); | |
333 | ||
334 | TString res = TString("Multiplicity Range Min: "); | |
335 | res += min; | |
336 | res += " Max: "; | |
337 | res += max; | |
338 | ||
339 | AddResult(res.Data()); | |
340 | ||
341 | break; | |
342 | } | |
343 | } | |
344 | ||
345 | //___________________________________________________________________________ | |
346 | void AliTagAnalysisFrame::RunLocal() { | |
347 | // Run local query | |
348 | #ifdef GUIDEBUG | |
349 | printf("*******************************\n"); | |
350 | printf("*** Querying the tags ***\n"); | |
351 | printf("*******************************\n"); | |
352 | #endif | |
353 | ||
354 | //local tags | |
355 | fAliTagAnalysis->ChainLocalTags(fLocalPath->GetText()); | |
356 | ||
357 | #ifdef GUIDEBUG | |
358 | printf("*******************************\n"); | |
359 | printf("*** Getting the Chain ***\n"); | |
360 | printf("*******************************\n"); | |
361 | #endif | |
362 | ||
363 | fAnalysisChain = new TChain("esdTree"); | |
364 | fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts); | |
365 | ||
366 | TString res = TString("Number of Accepted Events: "); | |
367 | res += fAnalysisChain->GetEventList()->GetN(); | |
368 | ||
369 | AddResult(res.Data()); | |
370 | } | |
371 | ||
372 | //___________________________________________________________________________ | |
373 | void AliTagAnalysisFrame::RunGrid() { | |
374 | // Run Grid query | |
375 | ||
376 | ||
377 | // fGroup3->SetCleanup(kDeepCleanup); | |
378 | ||
379 | if (!fAliAnalysisGUI->IsConnected()){ | |
380 | new TGMsgBox(gClient->GetRoot(), this, "Connect", | |
381 | "Please connect to AliEn", 0, kMBOk); | |
382 | return; | |
383 | } | |
384 | ||
385 | ||
386 | #ifdef GUIDEBUG | |
387 | printf("*******************************\n"); | |
388 | printf("*** Querying the tags ***\n"); | |
389 | printf("*******************************\n"); | |
390 | #endif | |
391 | ||
392 | ||
393 | // TGridResult* TagResult = gGrid->Query("/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1","*tag.root","",""); | |
394 | fTagResult = gGrid->Query(fGridPath->GetText(), "*tag.root", "", ""); | |
395 | ||
396 | // fAliTagAnalysis->ChainLocalTags("../tags"); | |
397 | ||
398 | fAliTagAnalysis->ChainGridTags(fTagResult); | |
399 | ||
400 | ////////////////////////////////////////////////////////////////// | |
401 | //Get the chain | |
402 | #ifdef GUIDEBUG | |
403 | printf("*******************************\n"); | |
404 | printf("*** Getting the Chain ***\n"); | |
405 | printf("*******************************\n"); | |
406 | #endif | |
407 | ||
408 | fAnalysisChain = new TChain("esdTree"); | |
409 | fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts); | |
410 | ||
411 | TString res = TString("Number of Accepted Events: "); | |
412 | res += fAnalysisChain->GetEventList()->GetN(); | |
413 | ||
414 | AddResult(res.Data()); | |
415 | } | |
416 | ||
417 | //___________________________________________________________________________ | |
418 | void AliTagAnalysisFrame::ProcessSelector(const char* selectorfile) { | |
419 | // Process selector | |
420 | ||
421 | #ifdef GUIDEBUG | |
422 | printf("*******************************\n"); | |
423 | printf("*** Run Analysis Selector %s\n",selectorfile); | |
424 | printf("*******************************\n"); | |
425 | ||
426 | #endif | |
427 | ||
428 | fAnalysisChain->Process(selectorfile); | |
429 | } | |
430 | ||
431 | ||
432 | //___________________________________________________________________________ | |
433 | void AliTagAnalysisFrame::OnDoubleClick(TGListTreeItem* item, Int_t btn) { | |
434 | // Slot for double clicking. | |
435 | ||
436 | fAliEnBrowser->OnDoubleClick(item, btn); | |
437 | ||
438 | //"/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1"); | |
439 | ||
440 | } | |
441 | ||
442 | //___________________________________________________________________________ | |
443 | void AliTagAnalysisFrame::OnOKButton() { | |
444 | // Slot for OK button in the Transient Frame. | |
445 | ||
446 | if(fAliEnBrowser->GetBrowseType() == kLocalBrowse) | |
447 | fLocalPath->SetText(fAliEnBrowser->GetPath()); | |
448 | else if(fAliEnBrowser->GetBrowseType() == kGridBrowse) | |
449 | fGridPath->SetText(fAliEnBrowser->GetPath()); | |
450 | ||
451 | TTimer::SingleShot(150, "AliTagAnalysisFrame", fBrowser, "CloseWindow()"); | |
452 | } |