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 "AliLHCTagCuts.h"
38 #include "AliDetectorTagCuts.h"
39 #include "AliEventTagCuts.h"
40 #include "AliTagAnalysis.h"
42 #include "AliAnalysisGUI.h"
43 #include "AliAlienBrowser.h"
44 #include "AliTagFrame.h"
45 #include "AliTagAnalysisFrame.h"
47 ClassImp(AliTagAnalysisFrame)
49 //___________________________________________________________________________
50 AliTagAnalysisFrame::AliTagAnalysisFrame(const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI* fAliAnalysisGUI):
51 TGMainFrame(main, w, h, kHorizontalFrame),
53 fVFrame1(0), fVFrame2(0),
54 fGroup1(0), fGroup2(0), fGroup3(0),
55 fAliAnalysisGUI(fAliAnalysisGUI),
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) {
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"
85 const char *tmp[] = {"MultiplicityRange","VOsRange", "NPionRange" };
86 fEventTagCutsName = tmp;
88 // fEventTagCutsName = new TList();
90 // fEventTagCutsName[0] = "NegMultiplicityRange";
91 // fEventTagCutsName[1] = "VOsRange";
92 // fEventTagCutsName[2] = "NPionRange";
94 fVFrame1 = new TGVerticalFrame(this, 200, 150);
95 this->AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
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));
102 BuildLocalGroup(fGroup1);
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));
109 BuildGridGroup(fGroup2);
113 fVFrame2 = new TGVerticalFrame(this, 200, 200);
114 AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight| kLHintsExpandX
115 | kLHintsExpandY, 5,5,5,5));
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));
124 fListBox = new TGListBox(fGroup3);
125 fGroup3->AddFrame(fListBox,
126 new TGLayoutHints(kLHintsTop | kLHintsExpandX |
127 kLHintsExpandY, 5,5,5,5));
129 fAliTagAnalysis = new AliTagAnalysis();
130 fAliRunCuts = new AliRunTagCuts();
131 fAliLHCCuts = new AliLHCTagCuts();
132 fAliDetectorCuts = new AliDetectorTagCuts();
133 fAliEventCuts = new AliEventTagCuts();
140 //___________________________________________________________________________
141 AliTagAnalysisFrame::~AliTagAnalysisFrame() {
142 // AliTagAnalysisFrame dctor.
153 delete fAliTagAnalysis;
156 delete fAliDetectorCuts;
157 delete fAliEventCuts;
159 delete fAnalysisChain;
164 //___________________________________________________________________________
165 void AliTagAnalysisFrame::AddResult (const char* line) {
166 // Add a new line in the result group box.
168 // fGroup3->AddFrame(new TGLabel(fGroup3, new TGString(line)),
169 // new TGLayoutHints(kLHintsTop, 5,5,5,5));
171 fListBox->AddEntry(line, fListBox->GetNumberOfEntries());
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));
184 fLocalPath = new TGTextEntry(frame, new TGTextBuffer(40));
185 fLocalPath->SetEnabled(false);
186 frame->AddFrame(fLocalPath, new TGLayoutHints(kLHintsTop, 5,5,5,5));
188 fLocalButton = new TGTextButton(frame, "Browse...", 0);
189 frame->AddFrame(fLocalButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
191 fLocalButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "LocalBrowse()");
193 fComboEventTagCut = new TGComboBox(frame, "Select Tag Cuts...", 1);
194 frame->AddFrame(fComboEventTagCut,
195 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
197 for(int i=0; i!=fkNumberOfTags; i++)
198 fComboEventTagCut->AddEntry(fEventTagCutsName[i],i);
200 fComboEventTagCut->Resize(150, 20);
202 fButtonInsert = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
203 frame->AddFrame(fButtonInsert,
204 new TGLayoutHints(kLHintsLeft | kLHintsTop, 5,5,5,5));
206 fButtonInsert->Connect("Clicked()", "AliTagAnalysisFrame", this,
207 "InsertTagCutsRangeLocal()");
209 fButtonRun = new TGTextButton(frame, " Run ", 3);
210 frame->AddFrame(fButtonRun,
211 new TGLayoutHints(kLHintsTop | kLHintsRight, 5,5,5,5));
213 fButtonRun->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunLocal()");
216 //___________________________________________________________________________
217 void AliTagAnalysisFrame::BuildGridGroup (TGCompositeFrame* frame) {
218 // The Grid Group Frame
220 fGridLabel1 = new TGLabel(frame, new TGString("Chain Grid Tag Path"));
221 frame->AddFrame(fGridLabel1, new TGLayoutHints(kLHintsTop, 5,5,5,5));
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));
228 fGridButton = new TGTextButton(frame, "Browse...", 0);
229 frame->AddFrame(fGridButton, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
231 fGridButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "GridBrowse()");
233 fComboEventTagCut2 = new TGComboBox(frame, "Select Tag Cuts...", 1);
234 frame->AddFrame(fComboEventTagCut2,
235 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5,5,5,5));
237 for(int i=0; i!=fkNumberOfTags; i++)
238 fComboEventTagCut2->AddEntry(fEventTagCutsName[i],i);
240 fComboEventTagCut2->Resize(150, 20);
242 fButtonInsert2 = new TGTextButton(frame, "Insert Tag Cuts Range", 2);
243 frame->AddFrame(fButtonInsert2,
244 new TGLayoutHints(kLHintsLeft, 5,5,5,5));
246 fButtonInsert2->Connect("Clicked()", "AliTagAnalysisFrame", this,
247 "InsertTagCutsRangeGrid()");
249 fButtonRun2 = new TGTextButton(frame," Run " , 2);
250 frame->AddFrame(fButtonRun2,
251 new TGLayoutHints(kLHintsRight, 5,5,5,5));
253 fButtonRun2->Connect("Clicked()", "AliTagAnalysisFrame", this, "RunGrid()");
257 //___________________________________________________________________________
258 void AliTagAnalysisFrame::LocalBrowse() {
259 // Browse local directories.
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()");
269 fAliEnBrowser->AddItem(0, "/");
271 fAliEnBrowser->GotoDir(gSystem->pwd());
273 fBrowser->MapSubwindows();
275 fBrowser->MapWindow();
278 //___________________________________________________________________________
279 void AliTagAnalysisFrame::GridBrowse() {
280 // Opens a browser for grid directories.
282 if (!fAliAnalysisGUI->IsConnected()){
283 new TGMsgBox(gClient->GetRoot(), this, "Connect",
284 "Please connect to AliEn", 0, kMBOk);
288 fBrowser = new TGTransientFrame(gClient->GetRoot(), fAliAnalysisGUI, 450, 200);
290 fAliEnBrowser = new AliAlienBrowser(fBrowser, 300, 200, this,
291 "AliTagAnalysisFrame", kGridBrowse);
292 fBrowser->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsTop, 5,5,5,5));
294 fBrowserButton = new TGTextButton(fBrowser, " OK ", 0);
295 fBrowser->AddFrame(fBrowserButton, new TGLayoutHints(kLHintsRight, 5,5,5,5));
297 fBrowserButton->Connect("Clicked()", "AliTagAnalysisFrame", this, "OnOKButton()");
299 fAliEnBrowser->AddItem(0, "/");
301 fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory());
303 fBrowser->MapSubwindows();
305 fBrowser->MapWindow();
308 //___________________________________________________________________________
309 void AliTagAnalysisFrame::InsertTagCutsRangeLocal() {
311 InsertTagCutsRange(fComboEventTagCut->GetSelected());
315 //___________________________________________________________________________
316 void AliTagAnalysisFrame::InsertTagCutsRangeGrid() {
318 InsertTagCutsRange(fComboEventTagCut2->GetSelected());
321 //___________________________________________________________________________
322 void AliTagAnalysisFrame::InsertTagCutsRange(Int_t id) {
323 // insert the event tag range
325 // if nth is selected
331 case 0: // SetMultiplicity Range
333 fTagFrame = new AliTagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, fComboEventTagCut->GetTextEntry()->GetText(), fComboEventTagCut->GetSelected(), kRangeMinMax);
335 Int_t min = fTagFrame->GetRangeMin();
336 Int_t max = fTagFrame->GetRangeMax();
338 fAliEventCuts->SetMultiplicityRange(min, max);
340 TString res = TString("Multiplicity Range Min: ");
345 AddResult(res.Data());
351 //___________________________________________________________________________
352 void AliTagAnalysisFrame::RunLocal() {
355 printf("*******************************\n");
356 printf("*** Querying the tags ***\n");
357 printf("*******************************\n");
361 fAliTagAnalysis->ChainLocalTags(fLocalPath->GetText());
364 printf("*******************************\n");
365 printf("*** Getting the Chain ***\n");
366 printf("*******************************\n");
369 fAnalysisChain = new TChain("esdTree");
370 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliLHCCuts,fAliDetectorCuts,fAliEventCuts);
372 TString res = TString("Number of Accepted Events: ");
373 res += fAnalysisChain->GetEventList()->GetN();
375 AddResult(res.Data());
378 //___________________________________________________________________________
379 void AliTagAnalysisFrame::RunGrid() {
383 // fGroup3->SetCleanup(kDeepCleanup);
385 if (!fAliAnalysisGUI->IsConnected()){
386 new TGMsgBox(gClient->GetRoot(), this, "Connect",
387 "Please connect to AliEn", 0, kMBOk);
393 printf("*******************************\n");
394 printf("*** Querying the tags ***\n");
395 printf("*******************************\n");
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", "", "");
402 // fAliTagAnalysis->ChainLocalTags("../tags");
404 fAliTagAnalysis->ChainGridTags(fTagResult);
406 //////////////////////////////////////////////////////////////////
409 printf("*******************************\n");
410 printf("*** Getting the Chain ***\n");
411 printf("*******************************\n");
414 fAnalysisChain = new TChain("esdTree");
415 fAnalysisChain = fAliTagAnalysis->QueryTags(fAliRunCuts,fAliLHCCuts,fAliDetectorCuts,fAliEventCuts);
417 TString res = TString("Number of Accepted Events: ");
418 res += fAnalysisChain->GetEventList()->GetN();
420 AddResult(res.Data());
423 //___________________________________________________________________________
424 void AliTagAnalysisFrame::ProcessSelector(const char* selectorfile) {
428 printf("*******************************\n");
429 printf("*** Run Analysis Selector %s\n",selectorfile);
430 printf("*******************************\n");
434 fAnalysisChain->Process(selectorfile);
438 //___________________________________________________________________________
439 void AliTagAnalysisFrame::OnDoubleClick(TGListTreeItem* item, Int_t btn) {
440 // Slot for double clicking.
442 fAliEnBrowser->OnDoubleClick(item, btn);
444 //"/alice/cern.ch/user/p/pchrista/PDC06/Tags/pp/1");
448 //___________________________________________________________________________
449 void AliTagAnalysisFrame::OnOKButton() {
450 // Slot for OK button in the Transient Frame.
452 if(fAliEnBrowser->GetBrowseType() == kLocalBrowse)
453 fLocalPath->SetText(fAliEnBrowser->GetPath());
454 else if(fAliEnBrowser->GetBrowseType() == kGridBrowse)
455 fGridPath->SetText(fAliEnBrowser->GetPath());
457 TTimer::SingleShot(150, "AliTagAnalysisFrame", fBrowser, "CloseWindow()");