1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
24 #include "TGTextEntry.h"
27 #include "TGListBox.h"
28 #include "TGComboBox.h"
33 #include "TGridResult.h"
34 #include "TEventList.h"
36 #include "AliRunTagCuts.h"
37 #include "AliEventTagCuts.h"
38 #include "AliTagAnalysis.h"
40 #include "AliAnalysisGUI.h"
41 #include "AliAlienBrowser.h"
42 #include "AliTagFrame.h"
43 #include "AliTagAnalysisFrame.h"
45 ClassImp(AliTagAnalysisFrame)
47 //___________________________________________________________________________
48 AliTagAnalysisFrame::AliTagAnalysisFrame(const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI* fAliAnalysisGUI):
49 TGMainFrame(main, w, h, kHorizontalFrame),
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) {
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"
83 const char *tmp[] = {"MultiplicityRange","VOsRange", "NPionRange" };
84 fEventTagCutsName = tmp;
86 // fEventTagCutsName = new TList();
88 // fEventTagCutsName[0] = "NegMultiplicityRange";
89 // fEventTagCutsName[1] = "VOsRange";
90 // fEventTagCutsName[2] = "NPionRange";
92 fVFrame1 = new TGVerticalFrame(this, 200, 150);
93 this->AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
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));
100 BuildLocalGroup(fGroup1);
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));
107 BuildGridGroup(fGroup2);
111 fVFrame2 = new TGVerticalFrame(this, 200, 200);
112 AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight| kLHintsExpandX
113 | kLHintsExpandY, 5,5,5,5));
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));
122 fListBox = new TGListBox(fGroup3);
123 fGroup3->AddFrame(fListBox,
124 new TGLayoutHints(kLHintsTop | kLHintsExpandX |
125 kLHintsExpandY, 5,5,5,5));
127 fAliTagAnalysis = new AliTagAnalysis();
128 fAliRunCuts = new AliRunTagCuts();
129 fAliEventCuts = new AliEventTagCuts();
136 //___________________________________________________________________________
137 AliTagAnalysisFrame::~AliTagAnalysisFrame() {
138 // AliTagAnalysisFrame dctor.
149 delete fAliTagAnalysis;
151 delete fAliEventCuts;
153 delete fAnalysisChain;
158 //___________________________________________________________________________
159 void AliTagAnalysisFrame::AddResult (const char* line) {
160 // Add a new line in the result group box.
162 // fGroup3->AddFrame(new TGLabel(fGroup3, new TGString(line)),
163 // new TGLayoutHints(kLHintsTop, 5,5,5,5));
165 fListBox->AddEntry(line, fListBox->GetNumberOfEntries());
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));
178 fLocalPath = new TGTextEntry(frame, new TGTextBuffer(40));
179 fLocalPath->SetEnabled(false);
180 frame->AddFrame(fLocalPath, new TGLayoutHints(kLHintsTop, 5,5,5,5));
182 fLocalButton = new TGTextButton(frame, "Browse...", 0);
183 frame->AddFrame(fLocalButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
185 fLocalButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "LocalBrowse()");
187 fComboEventTagCut = new TGComboBox(frame, "Select Tag Cuts...", 1);
188 frame->AddFrame(fComboEventTagCut,
189 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
191 for(int i=0; i!=fkNumberOfTags; i++)
192 fComboEventTagCut->AddEntry(fEventTagCutsName[i],i);
194 fComboEventTagCut->Resize(150, 20);
196 fButtonInsert = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
197 frame->AddFrame(fButtonInsert,
198 new TGLayoutHints(kLHintsLeft | kLHintsTop, 5,5,5,5));
200 fButtonInsert->Connect("Clicked()", "AliTagAnalysisFrame", this,
201 "InsertTagCutsRangeLocal()");
203 fButtonRun = new TGTextButton(frame, " Run ", 3);
204 frame->AddFrame(fButtonRun,
205 new TGLayoutHints(kLHintsTop | kLHintsRight, 5,5,5,5));
207 fButtonRun->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunLocal()");
210 //___________________________________________________________________________
211 void AliTagAnalysisFrame::BuildGridGroup (TGCompositeFrame* frame) {
212 // The Grid Group Frame
214 fGridLabel1 = new TGLabel(frame, new TGString("Chain Grid Tag Path"));
215 frame->AddFrame(fGridLabel1, new TGLayoutHints(kLHintsTop, 5,5,5,5));
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));
222 fGridButton = new TGTextButton(frame, "Browse...", 0);
223 frame->AddFrame(fGridButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
225 fGridButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "GridBrowse()");
227 fComboEventTagCut2 = new TGComboBox(frame, "Select Tag Cuts...", 1);
228 frame->AddFrame(fComboEventTagCut2,
229 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
231 for(int i=0; i!=fkNumberOfTags; i++)
232 fComboEventTagCut2->AddEntry(fEventTagCutsName[i],i);
234 fComboEventTagCut2->Resize(150, 20);
236 fButtonInsert2 = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
237 frame->AddFrame(fButtonInsert2,
238 new TGLayoutHints(kLHintsLeft, 5,5,5,5));
240 fButtonInsert2->Connect("Clicked()", "AliTagAnalysisFrame", this,
241 "InsertTagCutsRangeGrid()");
243 fButtonRun2 = new TGTextButton(frame," Run " , 2);
244 frame->AddFrame(fButtonRun2,
245 new TGLayoutHints(kLHintsRight, 5,5,5,5));
247 fButtonRun2->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunGrid()");
251 //___________________________________________________________________________
252 void AliTagAnalysisFrame::LocalBrowse() {
253 // Browse local directories.
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()");
263 fAliEnBrowser->AddItem(0, "/");
265 fAliEnBrowser->GotoDir(gSystem->pwd());
267 fBrowser->MapSubwindows();
269 fBrowser->MapWindow();
272 //___________________________________________________________________________
273 void AliTagAnalysisFrame::GridBrowse() {
274 // Opens a browser for grid directories.
276 if (!fAliAnalysisGUI->IsConnected()){
277 new TGMsgBox(gClient->GetRoot(), this, "Connect",
278 "Please connect to AliEn", 0, kMBOk);
282 fBrowser = new TGTransientFrame(gClient->GetRoot(), fAliAnalysisGUI, 450, 200);
284 fAliEnBrowser = new AliAlienBrowser(fBrowser, 300, 200, this,
285 "AliTagAnalysisFrame", kGridBrowse);
286 fBrowser->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsTop, 5,5,5,5));
288 fBrowserButton = new TGTextButton(fBrowser, " OK ", 0);
289 fBrowser->AddFrame(fBrowserButton, new TGLayoutHints(kLHintsRight, 5,5,5,5));
291 fBrowserButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "OnOKButton()");
293 fAliEnBrowser->AddItem(0, "/");
295 fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory());
297 fBrowser->MapSubwindows();
299 fBrowser->MapWindow();
302 //___________________________________________________________________________
303 void AliTagAnalysisFrame::InsertTagCutsRangeLocal() {
305 InsertTagCutsRange(fComboEventTagCut->GetSelected());
309 //___________________________________________________________________________
310 void AliTagAnalysisFrame::InsertTagCutsRangeGrid() {
312 InsertTagCutsRange(fComboEventTagCut2->GetSelected());
315 //___________________________________________________________________________
316 void AliTagAnalysisFrame::InsertTagCutsRange(Int_t id) {
317 // insert the event tag range
319 // if nth is selected
325 case 0: // SetMultiplicity Range
327 fTagFrame = new AliTagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, fComboEventTagCut->GetTextEntry()->GetText(), fComboEventTagCut->GetSelected(), kRangeMinMax);
329 Int_t min = fTagFrame->GetRangeMin();
330 Int_t max = fTagFrame->GetRangeMax();
332 fAliEventCuts->SetMultiplicityRange(min, max);
334 TString res = TString("Multiplicity Range Min: ");
339 AddResult(res.Data());
345 //___________________________________________________________________________
346 void AliTagAnalysisFrame::RunLocal() {
349 printf("*******************************\n");
350 printf("*** Querying the tags ***\n");
351 printf("*******************************\n");
355 fAliTagAnalysis->ChainLocalTags(fLocalPath->GetText());
358 printf("*******************************\n");
359 printf("*** Getting the Chain ***\n");
360 printf("*******************************\n");
363 fAnalysisChain = new TChain("esdTree");
364 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts);
366 TString res = TString("Number of Accepted Events: ");
367 res += fAnalysisChain->GetEventList()->GetN();
369 AddResult(res.Data());
372 //___________________________________________________________________________
373 void AliTagAnalysisFrame::RunGrid() {
377 // fGroup3->SetCleanup(kDeepCleanup);
379 if (!fAliAnalysisGUI->IsConnected()){
380 new TGMsgBox(gClient->GetRoot(), this, "Connect",
381 "Please connect to AliEn", 0, kMBOk);
387 printf("*******************************\n");
388 printf("*** Querying the tags ***\n");
389 printf("*******************************\n");
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", "", "");
396 // fAliTagAnalysis->ChainLocalTags("../tags");
398 fAliTagAnalysis->ChainGridTags(fTagResult);
400 //////////////////////////////////////////////////////////////////
403 printf("*******************************\n");
404 printf("*** Getting the Chain ***\n");
405 printf("*******************************\n");
408 fAnalysisChain = new TChain("esdTree");
409 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts);
411 TString res = TString("Number of Accepted Events: ");
412 res += fAnalysisChain->GetEventList()->GetN();
414 AddResult(res.Data());
417 //___________________________________________________________________________
418 void AliTagAnalysisFrame::ProcessSelector(const char* selectorfile) {
422 printf("*******************************\n");
423 printf("*** Run Analysis Selector %s\n",selectorfile);
424 printf("*******************************\n");
428 fAnalysisChain->Process(selectorfile);
432 //___________________________________________________________________________
433 void AliTagAnalysisFrame::OnDoubleClick(TGListTreeItem* item, Int_t btn) {
434 // Slot for double clicking.
436 fAliEnBrowser->OnDoubleClick(item, btn);
438 //"/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1");
442 //___________________________________________________________________________
443 void AliTagAnalysisFrame::OnOKButton() {
444 // Slot for OK button in the Transient Frame.
446 if(fAliEnBrowser->GetBrowseType() == kLocalBrowse)
447 fLocalPath->SetText(fAliEnBrowser->GetPath());
448 else if(fAliEnBrowser->GetBrowseType() == kGridBrowse)
449 fGridPath->SetText(fAliEnBrowser->GetPath());
451 TTimer::SingleShot(150, "AliTagAnalysisFrame", fBrowser, "CloseWindow()");