5 #include <TGNumberEntry.h>
6 #include <TGTextEntry.h>
7 #include <TGComboBox.h>
9 #include <TGFileDialog.h>
10 #include <TGButtonGroup.h>
19 #include <TGListView.h>
20 #include <TGStatusBar.h>
22 #include <TParameter.h>
23 #include <TPaveText.h>
28 ForwardOADBGUIErrorHandler(
Int_t lvl,
Bool_t doAbort,
32 if (!doAbort && lvl >= kWarning) {
33 EMsgBoxIcon msgIcon = kMBIconAsterisk;
35 if (lvl >= kWarning) msgIcon = kMBIconExclamation;
36 if (lvl >= kError) msgIcon = kMBIconStop;
38 new TGMsgBox(gClient->GetRoot(), gClient->GetRoot(),
39 location, msg, msgIcon);
41 DefaultErrorHandler(lvl, doAbort, location, msg);
48 class TGTransientFrame;
51 class TGHorizontalFrame;
55 class TGVerticalFrame;
71 :
fFrame(gClient->GetRoot(), p, 200, 40, kVerticalFrame),
72 fHints(kLHintsExpandX,30,30,30,30),
80 fFrame.SetWindowName(
"Please wait ...");
82 fIncrement.Connect(
"Timeout()",
"ForwardOADBDialog",
this,
"HandleIncr()");
102 fFrame.Resize(width, height);
103 fFrame.SetWMSize(width, height);
104 fFrame.SetWMSizeHints(width, height, width, height, 0, 0);
130 :
fMain(gClient->GetRoot(), 10, 10, kVerticalFrame),
145 TGNumberFormat::kNESReal,
146 TGNumberFormat::kNEANonNegative,
147 TGNumberFormat::kNELLimitMin, 0),
155 TGNumberFormat::kNEANonNegative,
156 TGNumberFormat::kNELLimitMin, 0),
177 fEntryHints(kLHintsExpandX|kLHintsExpandY, 2, 4, 0, 0),
179 fListHints(kLHintsExpandX|kLHintsExpandY, 2, 2, 4, 2),
186 fMain.Connect(
"CloseWindow()",
"ForwardOADBGUI",
this,
"HandleKill()");
187 fMain.DontCallClose();
189 fFileSelect.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleBrowse()");
190 fOpenButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleOpen()");
191 fCloseButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleClose()");
204 fTableSelect.Connect(
"Selected(Int_t)",
"ForwardOADBGUI",
this,
205 "HandleTable(Int_t)");
265 fQueryButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleQuery()");
266 fListButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleList()");
267 fDrawButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleDraw()");
268 fCopyButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandleCopy()");
269 fPDFButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandlePDF()");
270 fPrintButton.Connect(
"Clicked()",
"ForwardOADBGUI",
this,
"HandlePrint()");
287 fList.SetViewMode(kLVDetails);
288 fList.Connect(
"Clicked(TGLVEntry*,Int_t)",
289 "ForwardOADBGUI",
this,
"HandleItem(TGLVEntry*,Int_t)");
290 fList.Connect(
"DoubleClicked(TGLVEntry*,Int_t)",
291 "ForwardOADBGUI",
this,
"HandleItem(TGLVEntry*,Int_t)");
293 "ForwardOADBGUI",
this,
294 "HandleItem(TGFrame*,Int_t)");
295 fList.SetMinWidth(400);
296 fList.SetMinHeight(200);
302 ::SetErrorHandler(ForwardOADBGUIErrorHandler);
306 fMain.SetMinWidth(600);
307 fMain.SetMinHeight(480);
308 fMain.MapSubwindows();
309 fMain.Resize(600, 480);
316 ::SetErrorHandler(::DefaultErrorHandler);
318 Info(
"~ForwardOADBGUI",
"Closing");
321 :
fMain(gClient->GetRoot(), 10, 10, kVerticalFrame),
387 while ((key = next())) {
390 lt.Append(Form(
"%s/%s", t->
GetName(), t->
fTree->GetTitle()));
398 fMain.DeleteWindow();
399 Printf(
"Starting timer");
405 Info(
"HandleDBEntry",
"Selected entry %p", e);
445 while ((key = next())) {
448 if (tables.GetEntries() == 1) tsel = 1;
471 Info(
"HandleOpen",
"Opening DB file %s for tables %s",
475 if (!
fDB->
Open(fn, tn, rw,
true,
true)) {
476 Error(
"HandleOpen",
"Failed to open database");
489 if (
gSystem->Getenv(
"OADB_PATH"))
490 iniDir =
gSystem->ExpandPathName(
"$(OADB_PATH)");
492 iniDir =
gSystem->ExpandPathName(
"$(ALICE_PHYSICS)/OADB");
493 iniDir.Append(
"/PWGLF/FORWARD/CORRECTIONS/data");
494 char* ini =
new char[iniDir.Length()+1];
495 for (
int i = 0; i < iniDir.Length(); i++) ini[i] = iniDir[i];
496 ini[iniDir.Length()] =
'\0';
497 Printf(
"Initial directory: %s (%s)", iniDir.Data(), ini);
499 new TGFileDialog(gClient->GetRoot(), &
fMain, kFDOpen, &fi);
503 Info(
"HandleBrowse",
"New file: %s", nf.Data());
508 TGLVEntry* lve =
new TGLVEntry(&
fListContainer, Form(
"%d", i),
"");
509 if (i < 0) lve->SetUserData(e);
512 lve->SetSubnames(Form(
"%lu", e->
fRunNo),
513 (e->
fSys == 1 ?
"p-p" :
514 e->
fSys == 2 ?
"Pb-Pb" :
515 e->
fSys == 3 ?
"p-Pb" :
516 e->
fSys == 4 ?
"Pb-p" :
"?"),
517 Form(
"%4huGeV",e->
fSNN),
518 Form(
"%+2hdkG", e->
fField),
519 (e->
fMC ?
"MC" :
"Real"),
532 if (table.IsNull()) {
539 Error(
"HandleList",
"No table named %s in DB", table.Data());
548 Int_t n = tree->GetEntries();
549 for (
Int_t i = 0; i < n; i++) {
554 fList.AdjustHeaders();
562 Error(
"SelectedTable",
"No table selected");
569 Info(
"HandleTable",
"Id=%d",
id);
573 fList.AdjustHeaders();
581 Info(
"HandleItem",
"frame=%p", lve);
582 HandleItem(static_cast<TGLVEntry*>(lve), btn);
586 Info(
"HandleItem",
"entry=%p", lve);
588 Warning(
"HandleItem",
"No item");
591 void* data = lve->GetUserData();
599 if (tab.IsNull())
return;
603 t->
fTree->GetEntry(lve->GetUniqueID());
607 Warning(
"HandleItem",
"No entry");
620 Warning(
"HandlePrint",
"No entry selected");
628 Warning(
"HandleDraw",
"No entry selected");
633 Info(
"HandleDraw",
"Will draw object of type %s", o->ClassName());
637 msg = Form(
"%f", pd->GetVal());
641 msg = Form(
"%f", pf->GetVal());
644 if (!gPad) TCanvas::MakeDefCanvas();
646 TPaveText* t =
new TPaveText(.1, .1, .9, .9);
658 if (table.IsNull())
return;
661 Warning(
"HandleCopy",
"No entry selected");
666 Info(
"HandleCopy",
"Will copy object of type %s", o->ClassName());
681 msg = Form(
"Will copy %lu/%hu/%hu/%hd -> %lu/%hu/%hu/%hd (%s,%s) in %s",
682 oldRun, oldSys, oldSNN, oldFld,
683 newRun, newSys, newSNN, newFld,
684 (mc ?
"mc" :
"real"), (sat ?
"satellite" :
"nominal"),
688 new TGMsgBox(gClient->GetRoot(), gClient->GetRoot(),
689 "Confirm copy of OADB entry",
690 msg.Data(), 0, kMBOk|kMBCancel, &ret);
692 if (ret == kMBCancel) {
693 Info(
"HandleCopy",
"%s CANCELLED", msg.Data());
696 Info(
"HandleCopy",
"%s CONFIRMED", msg.Data());
699 oldRun, oldSys, oldSNN, oldFld,
700 newRun, newSys, newSNN, newFld,
713 Warning(
"HandlePrint",
"No entry selected");
719 gROOT->SetBatch(
true);
721 gROOT->SetBatch(
false);
727 const char* opt =
"++g";
728 const char*
fwd =
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
729 gSystem->AddIncludePath(Form(
"-I$ALICE_ROOT/include "
730 "-I$ALICE_PHYSICS/include "
731 "-I%s -I%s/scripts", fwd, fwd));
732 Info(
"CorrDraw",
"Loading SummaryDrawer.C%s", opt);
733 gROOT->LoadMacro(Form(
"%s/scripts/SummaryDrawer.C%s", fwd, opt));
735 Info(
"CorrDraw",
"Loading CorrDrawer.C%s", opt);
736 gROOT->LoadMacro(Form(
"%s/corrs/CorrDrawer.C%s", fwd, opt));
743 if (!gROOT->GetClass(
"CorrDrawer")) {
744 TTimer* t =
new TTimer(Form(
"((ForwardOADBGUI*)%p)->LoadCorrDraw()",
this),
751 TTimer* t =
new TTimer(Form(
"((ForwardOADBGUI*)%p)"
752 "->DoCorrDraw((TObject*)%p,1)",
this, o),
762 TString cmd(Form(
"CorrDrawer cd; cd.Summarize((const %s*)%p,%d);",
763 o->ClassName(), o, summarize));
764 gROOT->ProcessLine(cmd);
772 if (out.IsNull())
return;
775 out.Append(Form(
"_%s", (
fEntry->
fSys == 1 ?
"pp" :
780 out.Append(Form(
"_%c%hukG",
fEntry->
fField >= 0 ?
'p' :
'm',
782 out.Append(Form(
"_%s",
fEntry->
fMC ?
"mc" :
"real"));
798 Info(
"HandleQuery",
"tab=%s runNo=%lu mode=%d sys=%d "
799 "sNN=%d fld=%d mc=%d sat=%d",
800 tab.Data(), run,
mode, sys, sNN, fld, mc, sat);
816 Info(
"HandleQuery",
"tab=%s runNo=%lu mode=%d sys=%d "
817 "sNN=%d fld=%d mc=%d sat=%d",
818 tab.Data(), run, qmode, sys, sNN, fld, mc, sat);
830 if (!e->fData)
return 0;
833 fList.AdjustHeaders();
845 Info(
"CloseMsg",
"Closing message window");
910 const char*
fwd =
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
911 if (!gROOT->GetClass(
"AliOADBForward"))
913 gROOT->Macro(Form(
"%s/scripts/LoadLibs.C", fwd));
923 if (path) gui->
SetStatus(Form(
"Connected to %s", path));
TGMainFrame * ForwardOADBGui(AliOADBForward *db=0, const char *path=0)
AliOADBForward::Entry * fEntry
TGLayoutHints fStatusBarHints
void DoCorrDraw(const TObject *o, Bool_t summarize)
const Char_t * GetName() const
ForwardOADBGUI(const ForwardOADBGUI &)
void Print(Option_t *option="") const
TGHorizontalFrame fSysFrame
TGHorizontalFrame fOpenFrame
TGHorizontalFrame fOptionsFrame
void HandleItem(TGLVEntry *lve, Int_t)
TGLVContainer fListContainer
TGLayoutHints fFrameHints
void SelectedTable(TString &ret) const
ForwardOADBGUI & operator=(const ForwardOADBGUI &)
void Show(const char *msg)
void HandleDBEntry(AliOADBForward::Entry *e)
void HandleEntry(Int_t i, AliOADBForward::Entry *e)
void CorrDraw(const TObject *o, Bool_t summarize)
TGLayoutHints fEntryHints
Table * FindTable(const TString &name, Bool_t quite=false) const
void HandleItem(TGFrame *lve, Int_t btn)
Bool_t CopyEntry(const TString &table, ULong_t oldRunNo, UShort_t oldSys, UShort_t oldSNN, Short_t oldField, ULong_t newRunNo, UShort_t newSys, UShort_t newSNN, Short_t newField, Bool_t mc, Bool_t sat)
TGTextButton fCloseButton
TGHorizontalFrame fRunFrame
void SetStatus(const char *what)
const TMap & GetTables() const
void MakeFileName(TString &out) const
void HandleTable(Int_t id)
TGTextButton fPrintButton
ForwardOADBDialog(TGMainFrame *p)
TGTextButton fQueryButton
ForwardOADBDialog(const ForwardOADBDialog &)
void UseDB(AliOADBForward *db)
void Print(Option_t *option="") const
TGHButtonGroup fCommandFrame
TGHorizontalFrame fTableFrame
ForwardOADBDialog & operator=(const ForwardOADBDialog &)
TGHButtonGroup fOtherFrame
TGVerticalFrame fSelectFrame
Entry * Get(const TString &table, ULong_t run=0, ERunSelectMode mode=kNear, UShort_t sys=0, UShort_t sNN=0, Short_t fld=0, Bool_t mc=false, Bool_t sat=false) const
TGHorizontalFrame fSNNFrame
TGLayoutHints fButtonHints
Bool_t Open(const TString &fileName, const TString &tables="*", Bool_t rw=false, Bool_t verb=false, Bool_t fallback=false)
void MakeMsg(const char *what)
TGHorizontalFrame fFldFrame
TGLayoutHints fLabelHints