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