-// Author: Benjamin Hess 25/09/2008
+// Author: Benjamin Hess 29/01/2010
/*************************************************************************
- * Copyright (C) 2008, Alexandru Bercuci, Benjamin Hess. *
+ * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess. *
* All rights reserved. *
*************************************************************************/
frbTrack[0] = new TGRadioButton(fbgStyleTrack, "Rieman", 0);
frbTrack[0]->SetToolTipText("Set the track model to \"Rieman\" (i.e. the used fit method)");
- fbgStyleTrack->AddFrame(frbTrack[0]);
frbTrack[1] = new TGRadioButton(fbgStyleTrack, "Kalman", 1);
frbTrack[1]->SetToolTipText("Set the track model to \"Kalman\" (i.e. the used fit method)");
- fbgStyleTrack->AddFrame(frbTrack[1]);
frbTrack[2] = new TGRadioButton(fbgStyleTrack, "Line", 2);
frbTrack[2]->SetToolTipText("Set the track model to \"Line\" (i.e. the used fit method)");
- fbgStyleTrack->AddFrame(frbTrack[2]);
// Style - Color model
fbgStyleColor = new TGButtonGroup(fStyleFrame, "Color model");
frbColor[0] = new TGRadioButton(fbgStyleColor, "PID LQ", 0);
frbColor[0]->SetToolTipText("Set color model to \"PID LQ\" -> 2 dimensional likelihood particle identification");
- fbgStyleColor->AddFrame(frbColor[0]);
frbColor[1] = new TGRadioButton(fbgStyleColor, "PID NN", 1);
frbColor[1]->SetToolTipText("Set color model to \"PID NN\" -> Neural network particle identification");
- fbgStyleColor->AddFrame(frbColor[1]);
frbColor[2] = new TGRadioButton(fbgStyleColor, "ESD Source", 2);
frbColor[2]->SetToolTipText("Set color model to \"ESD Source\" -> By source (TPC track prolongation or TRD stand alone)");
- fbgStyleColor->AddFrame(frbColor[2]);
-
- // Functionality for adding macros
+ // Functionality for adding plugins
fMainFrame = CreateEditorTabSubFrame("Process");
- fLabel1 = new TGLabel(fMainFrame,"Add macro(s):");
+ fLabel1 = new TGLabel(fMainFrame,"Add plugin(s):");
fMainFrame->AddFrame(fLabel1);
fBrowseFrame = new TGHorizontalFrame(fMainFrame);
fBrowseFrame->AddFrame(fbBrowse);
fbNew = new TGTextButton(fBrowseFrame, "New");
- fbNew->SetToolTipText("Start macro creation wizzard");
+ fbNew->SetToolTipText("Start macro creation wizard");
fbNew->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "NewMacros()");
fBrowseFrame->AddFrame(fbNew);
fMainFrame->AddFrame(fBrowseFrame);
fLine1 = new TGHorizontal3DLine(fMainFrame, 194, 8);
fMainFrame->AddFrame(fLine1, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 8, 2));
- fLabel2 = new TGLabel(fMainFrame,"Selection macros:");
+ fLabel2 = new TGLabel(fMainFrame,"Selection plugins:");
fMainFrame->AddFrame(fLabel2);
ftlMacroSelList = new TGListBox(fMainFrame);
fHistoFrame->AddFrame(fLine4, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 8, 2));
fbDrawHisto = new TGTextButton(fHistoFrame, "Draw projections");
- fbDrawHisto->SetToolTipText("Uses the data file created by the last \"Apply selected macro(s)\".\nClick here to display the data histograms of the selected macros.\nSelect multiple macros to create multi-dimensional plots.\nHisto macros cannot be used for multi-dimensional plots!");
+ fbDrawHisto->SetToolTipText("Uses the data file created by the last \"Apply selected plugin(s)\".\nClick here to display the data histograms of the selected macros.\nSelect multiple macros to create multi-dimensional plots.\nHisto macros cannot be used for multi-dimensional plots!");
fbDrawHisto->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "DrawHistos()");
fHistoFrame->AddFrame(fbDrawHisto);
kMBIconExclamation, kMBOk);
break;
case ERROR:
- new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error", "Fail to load the macro (check messages in the terminal)!",
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error", "Failed to load the macro (check messages in the terminal)!",
kMBIconExclamation, kMBOk);
break;
case SIGNATURE_ERROR:
DrawHistos();
}
- if (selIterator != 0) delete selIterator;
- selIterator = 0;
- if (procIterator != 0) delete procIterator;
- procIterator = 0;
+ delete selIterator;
+ delete procIterator;
- if (!success)
- {
+ if (!success) {
new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
"AliEveTRDTrackList::ApplyProcessMacros experienced an error (cf. CINT-output)!",
kMBIconExclamation, kMBOk);
//______________________________________________________
void AliEveTRDTrackListEditor::NewMacros()
{
- // Start the macro creation wizzard.
+ // Start the macro creation wizard.
// thanks to Jacek Otwinowski<J.Otwinowski@GSI.DE> for this suggestion
- AliEveTRDMacroWizzard *wizz = new AliEveTRDMacroWizzard();
+ AliEveTRDMacroWizard *wizz = new AliEveTRDMacroWizard();
wizz->Connect("Create(Char_t*)", "AliEveTRDTrackListEditor", this, "AddMacro(Char_t*)");
}
// accessed (and that it exists) and adds the macro to the macro list via AddMacro(...).
// You can use environment variables in the text field, e.g. "$ALICE_ROOT/Eve/alice-macro/myMacro.C".
+ Char_t bname[AliEveTRDTrackList::fkMaxMacroNameLength]; // allocate buffers
+
if (strlen(fteField->GetText()) != 0)
{
// Expand the pathname
Char_t* name = (Char_t*)strrchr(fteField->GetText(), '/');
// Current path
- if (name == NULL)
- {
- name = new Char_t[AliEveTRDTrackList::fkMaxMacroNameLength];
+ if (!name) {
+ name= bname;
memset(name, '\0', sizeof(Char_t) * AliEveTRDTrackList::fkMaxMacroNameLength);
- sprintf(name, "%s", fteField->GetText());
+ snprintf(name, AliEveTRDTrackList::fkMaxMacroNameLength, "%s", fteField->GetText());
// Add path to textfield -> Path is "./" -> Use length for the name + 2
Char_t pathname[AliEveTRDTrackList::fkMaxMacroNameLength + 2];
memset(pathname, '\0', sizeof(Char_t) * (AliEveTRDTrackList::fkMaxMacroNameLength + 2));
- sprintf(pathname, "./%s", fteField->GetText());
+ snprintf(pathname, AliEveTRDTrackList::fkMaxMacroNameLength + 2, "./%s", fteField->GetText());
fteField->SetText(pathname);
AddMacro(name);
- if (name != 0) delete name;
- name = 0;
}
// Different path
else
{
// Extract path
- Char_t* path = new Char_t[AliEveTRDTrackList::fkMaxMacroPathLength];
+ Char_t path[AliEveTRDTrackList::fkMaxMacroPathLength];
memset(path, '\0', sizeof(Char_t) * AliEveTRDTrackList::fkMaxMacroPathLength);
- strncpy(path, fteField->GetText(), strlen(fteField->GetText()) - strlen(name));
+ snprintf(path, strlen(fteField->GetText()) - strlen(name), "%s", fteField->GetText());
// Ignore the slash "/" in name
AddMacro(name + 1, path);
-
- if (path != 0) delete path;
- path = 0;
- }
+ }
}
else
{
new TMacroData(macro->GetName(), macro->GetPath(), macro->GetType()));
else
{
- Error("AliEveTRDTrackListEditor::InheritMacroList", Form("Failed to inherit the macro \"%s\"!", key));
+ Error("AliEveTRDTrackListEditor::InheritMacroList", Form("Failed to inherit the macro \"%s\"!", key->GetName()));
}
}
{
// Removes the selected macros from the corresponding list.
- TList* iterator = new TList();
-
- ftlMacroList->GetSelectedEntries(iterator);
- fM->RemoveSelectedMacros(iterator);
+ TList iterator;
+ ftlMacroList->GetSelectedEntries(&iterator);
+ fM->RemoveSelectedMacros(&iterator);
- if (iterator != 0) delete iterator;
- iterator = new TList();
- ftlMacroSelList->GetSelectedEntries(iterator);
- fM->RemoveSelectedMacros(iterator);
+ iterator.Clear();
+ ftlMacroSelList->GetSelectedEntries(&iterator);
+ fM->RemoveSelectedMacros(&iterator);
// Selected macros are deleted from the list -> No selected entries left
fM->fMacroListSelected = 0;
-
UpdateMacroList();
+}
+
+//______________________________________________________
+void AliEveTRDTrackListEditor::SaveMacroList(TMap* list)
+{
+ // Saves the provided macro list in an interior list. This list will be used by
+ // InheritMacroList() to restore the data in "list". With this method one is able
+ // to inherit the macro list from track list to track list (i.e. from event to event).
+
+ if (fInheritedMacroList != 0)
+ {
+ fInheritedMacroList->Delete();
+ delete fInheritedMacroList;
+ }
+ fInheritedMacroList = new TMap();
+ fInheritedMacroList->SetOwnerKeyValue(kTRUE, kTRUE);
- if (iterator != 0) delete iterator;
- iterator = 0;
+ TMapIter* iter = (TMapIter*)list->MakeIterator();
+ TObject* key = 0;
+ TMacroData* macro = 0;
+
+ while ((key = iter->Next()) != 0)
+ {
+ macro = (TMacroData*)fM->fMacroList->GetValue(key);
+ if (macro != 0) fInheritedMacroList->Add(new TObjString(key->GetName()),
+ new TMacroData(macro->GetName(), macro->GetPath(), macro->GetType()));
+ else
+ {
+ Error("AliEveTRDTrackListEditor::SaveMacroList", Form("Failed to inherit the macro \"%s\"!", key->GetName()));
+ }
+ }
}
//______________________________________________________
GetGedEditor()->GetTab()->SetTab(fM->GetSelectedTab());
}
-//______________________________________________________
-void AliEveTRDTrackListEditor::SaveMacroList(TMap* list)
-{
- // Saves the provided macro list in an interior list. This list will be used by
- // InheritMacroList() to restore the data in "list". With this method one is able
- // to inherit the macro list from track list to track list (i.e. from event to event).
-
- if (fInheritedMacroList != 0)
- {
- fInheritedMacroList->Delete();
- delete fInheritedMacroList;
- }
- fInheritedMacroList = new TMap();
- fInheritedMacroList->SetOwnerKeyValue(kTRUE, kTRUE);
-
- TMapIter* iter = (TMapIter*)list->MakeIterator();
- TObject* key = 0;
- TMacroData* macro = 0;
-
- while ((key = iter->Next()) != 0)
- {
- macro = (TMacroData*)fM->fMacroList->GetValue(key);
- if (macro != 0) fInheritedMacroList->Add(new TObjString(key->GetName()),
- new TMacroData(macro->GetName(), macro->GetPath(), macro->GetType()));
- else
- {
- Error("AliEveTRDTrackListEditor::SaveMacroList", Form("Failed to inherit the macro \"%s\"!", key));
- }
- }
-}
-
//______________________________________________________
void AliEveTRDTrackListEditor::SetTrackColor(Int_t ind)
{
//______________________________________________________
void AliEveTRDTrackListEditor::UpdateHistoCanvasTab()
{
- // Updates the histogram and the corresponding tab (including titles).
+ // Updates the histogram and the corresponding tab (including titles).
// Update name of the tab (tab has been set to current tab!)
fHistoCanvasName->SetString(fM->GetName());
else
{
Error("AliEveTRDTrackListEditor::UpdateMacroList()",
- Form("Macro \"%s/%s.C\" has neither a selection macro nor a process macro!",
+ Form("Macro \"%s/%s.C\" is neither a selection macro nor a process macro!",
macro->GetPath(), macro->GetName()));
}
}
}
+//______________________________________________________
+//______________________________________________________
+//______________________________________________________
+
+
+/////////////////////////////////////////////////
+ClassImp(AliEveTRDMacroWizard)
/////////////////////////////////////////////////
-ClassImp(AliEveTRDMacroWizzard)
//______________________________________________________
-AliEveTRDMacroWizzard::AliEveTRDMacroWizzard(const TGWindow* p)
+AliEveTRDMacroWizard::AliEveTRDMacroWizard(const TGWindow* p)
:TGMainFrame(p ? p : gClient->GetRoot(), 10, 10, kMainFrame | kVerticalFrame)
,fText(0x0)
,fCombo(0x0)
,fTextEdit(0x0)
+ ,fbCreate(0x0)
+ ,fbCancel(0x0)
{
+ // Creates the macro wizard.
+
const Int_t width = 300;
// horizontal frame
fCombo->Resize(width, fText->GetDefaultHeight());
fFrameType->AddFrame(fCombo, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+ // horizontal frame
+ TGHorizontalFrame *fFrameAction = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
+ fbCancel = new TGTextButton(fFrameAction, "Cancel");
+ fbCancel->SetToolTipText("Exit macro creation wizard");
+ fFrameAction->AddFrame(fbCancel, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+ fbCreate = new TGTextButton(fFrameAction, "Done");
+ fbCreate->SetToolTipText("Use settings to create the macro");
+ fFrameAction->AddFrame(fbCreate, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+
// horizontal frame
TGHorizontalFrame *fFrameText = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
AddFrame(fFrameName, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
AddFrame(fFrameComment, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
AddFrame(fFrameType, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
+ AddFrame(fFrameAction, new TGLayoutHints(kLHintsRight | kLHintsTop | kLHintsExpandX,2,2,2,2));
TGHorizontal3DLine *fLine = new TGHorizontal3DLine(this, 281, 2);
AddFrame(fLine, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
AddFrame(fFrameText, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));
- SetWindowName("TRD Macro Wizzard");
+ SetWindowName("TRD Macro Wizard");
SetMWMHints(kMWMDecorAll,
kMWMFuncAll,
kMWMInputModeless);
MapWindow();
// Do the linking
- fCombo->Connect("Selected(Int_t)", "AliEveTRDMacroWizzard", this, "Create(Int_t)");
+ //fCombo->Connect("Selected(Int_t)", "AliEveTRDMacroWizard", this, "Create(Int_t)");
+ fbCreate->Connect("Clicked()", "AliEveTRDMacroWizard", this, "HandleCreate()");
+ fbCancel->Connect("Clicked()", "AliEveTRDMacroWizard", this, "CloseWindow()");
+
+ // Standard choice
+ fCombo->Select(1, kFALSE);
}
const Char_t *fIncludes =
const Char_t *fMacroTemplate[7] = {
""
," if (!track) return kFALSE;\n"
-" return kFALSE;\n"
," n = 0;\n"
-" r=0x0;\n"
+" r = 0x0;\n"
" if (!track) return;\n"
," if (!track) return 0x0;\n"
-" TH1* h = 0x0;\n"
+" TH1* h = 0x0;\n\n"
+"// Set bins, xmin and xmax here\n"
+" Int_t n = 1;\n"
+" Double_t xmin = 0;\n"
+" Double_t xmax = 100;\n\n"
" if(!(h = (TH1*)gROOT->FindObject(\"h\"))){\n"
" h = new TH1(\"h\", \"Title\", n, xmin, xmax);\n"
" h->GetXaxis()->SetTitle("");\n"
" h->GetYaxis()->SetTitle("");\n"
" } else h->Reset();\n"
-" return h;\n"
," if (!track) return kFALSE;\n"
" if (!track2) return kFALSE;\n"
-" return kFALSE;\n"
," n = 0;\n"
-" r=0x0;\n"
+" r = 0x0;\n"
" if (!track) return;\n"
" if (!track2) return;\n"
," if (!track) return 0x0;\n"
" if (!track2) return 0x0;\n"
-" TH1* h = 0x0;\n"
+" TH1* h = 0x0;\n\n"
+"// Set bins, xmin and xmax here\n"
+" Int_t n = 1;\n"
+" Double_t xmin = 0;\n"
+" Double_t xmax = 100;\n\n"
" if(!(h = (TH1*)gROOT->FindObject(\"h\"))){\n"
" h = new TH1(\"h\", \"Title\", n, xmin, xmax);\n"
" h->GetXaxis()->SetTitle("");\n"
" h->GetYaxis()->SetTitle("");\n"
" } else h->Reset();\n"
-" return h;\n"
};
//______________________________________________________
-void AliEveTRDMacroWizzard::Create(Int_t typ)
+void AliEveTRDMacroWizard::Create(Int_t type)
{
+ // Creates the macro with the selected type (combo box).
+
const Char_t *name = fText->GetText();
if(strcmp(name,"")==0){
AliInfo("Please specify a name for your macro.");
- fCombo->Select(-1);
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ "Please specify a name for your macro.", kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
+ return;
+ }
+
+ // Note: gSystem->AccessPathName(...) returns kTRUE, if the access FAILED!
+ if(!gSystem->AccessPathName(Form("./%s.C", name))){
+ // If there is already a file with this name -> Error
+ AliInfo(Form("A macro \"%s.C\" already exists in the current directory!\nPlease choose another name!", name));
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ Form("A macro \"%s.C\" already exists in the current directory!\nPlease choose another name!", name), kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
return;
}
FILE* fp = 0x0;
if(!(fp = fopen(Form("%s.C", name), "wt"))){
AliInfo("Couldn't create macro file.");
- fCombo->Select(-1);
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ "Couldn't create macro file.", kMBIconExclamation, kMBOk);
+ //fCombo->Select(-1);
return;
}
fprintf(fp, "\n%s\n", fIncludes);
- switch(typ){
+ switch(type){
case AliEveTRDTrackList::kSingleTrackSelect:
fprintf(fp, "Bool_t %s(const AliTRDtrackV1 *track)\n", name);
break;
fprintf(fp, "TH1* %s(const AliTRDtrackV1 *track, const AliTRDtrackV1 *track2)\n", name);
break;
default:
- AliInfo(Form("Unknown typ[%d]", typ));
+ AliInfo(Form("Unknown type[%d]", type));
+ new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
+ Form("Unknown type[%d]", type), kMBIconExclamation, kMBOk);
fclose(fp);
gSystem->Exec(Form("rm -f %s.C", name));
- fCombo->Select(-1);
+ //fCombo->Select(-1);
return;
}
- fprintf(fp, "{\n%s\n", fMacroTemplate[typ]);
+ fprintf(fp, "{\n%s\n", fMacroTemplate[type]);
fprintf(fp, "// add your own code here\n\n\n}\n");
fclose(fp);
- Emit("Create(Int_t)", typ);
+ Emit("Create(Int_t)", type);
Create((Char_t*)name);
CloseWindow();
}
//______________________________________________________
-void AliEveTRDMacroWizzard::Create(Char_t *name)
+void AliEveTRDMacroWizard::Create(Char_t *name)
{
+ // Emits the creation signal.
+
Emit("Create(Char_t*)", Form("%s.C", name));
}
+
+//______________________________________________________
+void AliEveTRDMacroWizard::HandleCreate()
+{
+ // Handles the signal, when the creation button is pressed.
+
+ Create(fCombo->GetSelected());
+}