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