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): TGMainFrame(main, w, h, kHorizontalFrame), fkNumberOfTags(3),fAliAnalysisGUI(fAliAnalysisGUI), fAliEnBrowser(NULL), fBrowser(NULL), fBrowserButton(NULL) {
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"
68 const char *tmp[] = {"MultiplicityRange","VOsRange", "NPionRange" };
69 fEventTagCutsName = tmp;
71 // fEventTagCutsName = new TList();
73 // fEventTagCutsName[0] = "NegMultiplicityRange";
74 // fEventTagCutsName[1] = "VOsRange";
75 // fEventTagCutsName[2] = "NPionRange";
77 fVFrame1 = new TGVerticalFrame(this, 200, 150);
78 this->AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
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));
85 BuildLocalGroup(fGroup1);
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));
92 BuildGridGroup(fGroup2);
96 fVFrame2 = new TGVerticalFrame(this, 200, 200);
97 AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight| kLHintsExpandX
98 | kLHintsExpandY, 5,5,5,5));
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));
107 fListBox = new TGListBox(fGroup3);
108 fGroup3->AddFrame(fListBox,
109 new TGLayoutHints(kLHintsTop | kLHintsExpandX |
110 kLHintsExpandY, 5,5,5,5));
112 fAliTagAnalysis = new AliTagAnalysis();
113 fAliRunCuts = new AliRunTagCuts();
114 fAliEventCuts = new AliEventTagCuts();
121 //___________________________________________________________________________
122 AliTagAnalysisFrame::~AliTagAnalysisFrame() {
123 // AliTagAnalysisFrame dctor.
134 delete fAliTagAnalysis;
136 delete fAliEventCuts;
138 delete fAnalysisChain;
143 //___________________________________________________________________________
144 void AliTagAnalysisFrame::AddResult (const char* line) {
145 // Add a new line in the result group box.
147 // fGroup3->AddFrame(new TGLabel(fGroup3, new TGString(line)),
148 // new TGLayoutHints(kLHintsTop, 5,5,5,5));
150 fListBox->AddEntry(line, fListBox->GetNumberOfEntries());
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));
163 fLocalPath = new TGTextEntry(frame, new TGTextBuffer(40));
164 fLocalPath->SetEnabled(false);
165 frame->AddFrame(fLocalPath, new TGLayoutHints(kLHintsTop, 5,5,5,5));
167 fLocalButton = new TGTextButton(frame, "Browse...", 0);
168 frame->AddFrame(fLocalButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
170 fLocalButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "LocalBrowse()");
172 fComboEventTagCut = new TGComboBox(frame, "Select Tag Cuts...", 1);
173 frame->AddFrame(fComboEventTagCut,
174 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
176 for(int i=0; i!=fkNumberOfTags; i++)
177 fComboEventTagCut->AddEntry(fEventTagCutsName[i],i);
179 fComboEventTagCut->Resize(150, 20);
181 fButtonInsert = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
182 frame->AddFrame(fButtonInsert,
183 new TGLayoutHints(kLHintsLeft | kLHintsTop, 5,5,5,5));
185 fButtonInsert->Connect("Clicked()", "AliTagAnalysisFrame", this,
186 "InsertTagCutsRangeLocal()");
188 fButtonRun = new TGTextButton(frame, " Run ", 3);
189 frame->AddFrame(fButtonRun,
190 new TGLayoutHints(kLHintsTop | kLHintsRight, 5,5,5,5));
192 fButtonRun->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunLocal()");
195 //___________________________________________________________________________
196 void AliTagAnalysisFrame::BuildGridGroup (TGCompositeFrame* frame) {
197 // The Grid Group Frame
199 fGridLabel1 = new TGLabel(frame, new TGString("Chain Grid Tag Path"));
200 frame->AddFrame(fGridLabel1, new TGLayoutHints(kLHintsTop, 5,5,5,5));
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));
207 fGridButton = new TGTextButton(frame, "Browse...", 0);
208 frame->AddFrame(fGridButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
210 fGridButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "GridBrowse()");
212 fComboEventTagCut2 = new TGComboBox(frame, "Select Tag Cuts...", 1);
213 frame->AddFrame(fComboEventTagCut2,
214 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
216 for(int i=0; i!=fkNumberOfTags; i++)
217 fComboEventTagCut2->AddEntry(fEventTagCutsName[i],i);
219 fComboEventTagCut2->Resize(150, 20);
221 fButtonInsert2 = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
222 frame->AddFrame(fButtonInsert2,
223 new TGLayoutHints(kLHintsLeft, 5,5,5,5));
225 fButtonInsert2->Connect("Clicked()", "AliTagAnalysisFrame", this,
226 "InsertTagCutsRangeGrid()");
228 fButtonRun2 = new TGTextButton(frame," Run " , 2);
229 frame->AddFrame(fButtonRun2,
230 new TGLayoutHints(kLHintsRight, 5,5,5,5));
232 fButtonRun2->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunGrid()");
236 //___________________________________________________________________________
237 void AliTagAnalysisFrame::LocalBrowse() {
238 // Browse local directories.
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()");
248 fAliEnBrowser->AddItem(0, "/");
250 fAliEnBrowser->GotoDir(gSystem->pwd());
252 fBrowser->MapSubwindows();
254 fBrowser->MapWindow();
257 //___________________________________________________________________________
258 void AliTagAnalysisFrame::GridBrowse() {
259 // Opens a browser for grid directories.
261 if (!fAliAnalysisGUI->IsConnected()){
262 new TGMsgBox(gClient->GetRoot(), this, "Connect",
263 "Please connect to AliEn", 0, kMBOk);
267 fBrowser = new TGTransientFrame(gClient->GetRoot(), fAliAnalysisGUI, 450, 200);
269 fAliEnBrowser = new AliAlienBrowser(fBrowser, 300, 200, this,
270 "AliTagAnalysisFrame", kGridBrowse);
271 fBrowser->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsTop, 5,5,5,5));
273 fBrowserButton = new TGTextButton(fBrowser, " OK ", 0);
274 fBrowser->AddFrame(fBrowserButton, new TGLayoutHints(kLHintsRight, 5,5,5,5));
276 fBrowserButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "OnOKButton()");
278 fAliEnBrowser->AddItem(0, "/");
280 fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory());
282 fBrowser->MapSubwindows();
284 fBrowser->MapWindow();
287 //___________________________________________________________________________
288 void AliTagAnalysisFrame::InsertTagCutsRangeLocal() {
290 InsertTagCutsRange(fComboEventTagCut->GetSelected());
294 //___________________________________________________________________________
295 void AliTagAnalysisFrame::InsertTagCutsRangeGrid() {
297 InsertTagCutsRange(fComboEventTagCut2->GetSelected());
300 //___________________________________________________________________________
301 void AliTagAnalysisFrame::InsertTagCutsRange(Int_t id) {
302 // insert the event tag range
304 // if nth is selected
310 case 0: // SetMultiplicity Range
312 fTagFrame = new AliTagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, fComboEventTagCut->GetTextEntry()->GetText(), fComboEventTagCut->GetSelected(), kRangeMinMax);
314 Int_t min = fTagFrame->GetRangeMin();
315 Int_t max = fTagFrame->GetRangeMax();
317 fAliEventCuts->SetMultiplicityRange(min, max);
319 TString res = TString("Multiplicity Range Min: ");
324 AddResult(res.Data());
330 //___________________________________________________________________________
331 void AliTagAnalysisFrame::RunLocal() {
334 printf("*******************************\n");
335 printf("*** Querying the tags ***\n");
336 printf("*******************************\n");
340 fAliTagAnalysis->ChainLocalTags(fLocalPath->GetText());
343 printf("*******************************\n");
344 printf("*** Getting the Chain ***\n");
345 printf("*******************************\n");
348 fAnalysisChain = new TChain("esdTree");
349 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts);
351 TString res = TString("Number of Accepted Events: ");
352 res += fAnalysisChain->GetEventList()->GetN();
354 AddResult(res.Data());
357 //___________________________________________________________________________
358 void AliTagAnalysisFrame::RunGrid() {
362 // fGroup3->SetCleanup(kDeepCleanup);
364 if (!fAliAnalysisGUI->IsConnected()){
365 new TGMsgBox(gClient->GetRoot(), this, "Connect",
366 "Please connect to AliEn", 0, kMBOk);
372 printf("*******************************\n");
373 printf("*** Querying the tags ***\n");
374 printf("*******************************\n");
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", "", "");
381 // fAliTagAnalysis->ChainLocalTags("../tags");
383 fAliTagAnalysis->ChainGridTags(fTagResult);
385 //////////////////////////////////////////////////////////////////
388 printf("*******************************\n");
389 printf("*** Getting the Chain ***\n");
390 printf("*******************************\n");
393 fAnalysisChain = new TChain("esdTree");
394 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliEventCuts);
396 TString res = TString("Number of Accepted Events: ");
397 res += fAnalysisChain->GetEventList()->GetN();
399 AddResult(res.Data());
402 //___________________________________________________________________________
403 void AliTagAnalysisFrame::ProcessSelector(const char* selectorfile) {
407 printf("*******************************\n");
408 printf("*** Run Analysis Selector %s\n",selectorfile);
409 printf("*******************************\n");
413 fAnalysisChain->Process(selectorfile);
417 //___________________________________________________________________________
418 void AliTagAnalysisFrame::OnDoubleClick(TGListTreeItem* item, Int_t btn) {
419 // Slot for double clicking.
421 fAliEnBrowser->OnDoubleClick(item, btn);
423 //"/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1");
427 //___________________________________________________________________________
428 void AliTagAnalysisFrame::OnOKButton() {
429 // Slot for OK button in the Transient Frame.
431 if(fAliEnBrowser->GetBrowseType() == kLocalBrowse)
432 fLocalPath->SetText(fAliEnBrowser->GetPath());
433 else if(fAliEnBrowser->GetBrowseType() == kGridBrowse)
434 fGridPath->SetText(fAliEnBrowser->GetPath());
436 TTimer::SingleShot(150, "AliTagAnalysisFrame", fBrowser, "CloseWindow()");