AddStandardMacros();
}
-//__________________________________________________________
+//______________________________________________________
AliEveTRDTrackList::~AliEveTRDTrackList()
{
if (fMacroList != 0)
}
}
-//__________________________________________________________
+//______________________________________________________
Int_t AliEveTRDTrackList::AddMacro(const Char_t* path, const Char_t* nameC)
{
// First check the type of the macro:
// Selection macro?
TFunction* f = gROOT->GetGlobalFunctionWithPrototype(name, "AliTRDtrackV1*", kTRUE);
- if (f != 0x0){
- if (!strcmp(f->GetReturnTypeName(), "Bool_t")){
+ if (f != 0x0)
+ {
+ if (!strcmp(f->GetReturnTypeName(), "Bool_t"))
+ {
// Some additional check (is the parameter EXACTLY of the desired type?)
- if (strstr(f->GetMangledName(), "AliTRDtrackV1mUsP") != 0x0) {
+ if (strstr(f->GetMangledName(), "AliTRDtrackV1mUsP") != 0x0)
+ {
hasCorrectSignature = kTRUE;
isSelectionMacro = kTRUE;
}
}
- } else { // Process macro?
+ }
+ // Process macro?
+ else
+ {
f = gROOT->GetGlobalFunctionWithPrototype(name, "AliTRDtrackV1*, Double_t*&, Int_t&", kTRUE);
- if (f != 0x0) {
- if (!strcmp(f->GetReturnTypeName(), "void")) {
+ if (f != 0x0)
+ {
+ if (!strcmp(f->GetReturnTypeName(), "void"))
+ {
// Some additional check (are the parameters EXACTLY of the desired type?)
if (strstr(f->GetMangledName(), "AliTRDtrackV1mUsP") != 0x0 &&
strstr(f->GetMangledName(), "Double_tmUaNsP") != 0x0 &&
- strstr(f->GetMangledName(), "Int_taNsP") != 0x0){
+ strstr(f->GetMangledName(), "Int_taNsP") != 0x0)
+ {
hasCorrectSignature = kTRUE;
isSelectionMacro = kFALSE;
}
return returnValue;
}
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::AddMacroFast(const Char_t* path, const Char_t* name, Bool_t toSelectionList)
{
Char_t* entry = MakeMacroEntry(path, name);
- if (entry != 0) {
+ if (entry != 0)
+ {
if (toSelectionList) fMacroSelList->Add(new TObjString(entry));
else fMacroList->Add(new TObjString(entry));
printf("#AliEveTRDTrackList: Standard macros: Added macro %s/%s to %s list\n", path, name,
(toSelectionList ? "selection" : "process"));
#endif
- } else {
+ }
+ else
+ {
// Error will always be displayed
printf("#AliEveTRDTrackList: Standard macros: ERROR: Could not add macro %s/%s to %s list\n", path, name,
(toSelectionList ? "selection" : "process"));
}
}
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::AddStandardMacros()
{
// Add your standard macros here, e.g.:
AddMacro("$(ALICE_ROOT)/TRD/qaRec/macros", "chargeDistr.C");
}
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::ApplyProcessMacros(TList* iterator)
{
+ if (iterator->GetEntries() <= 0) return;
+
Char_t name[100];
Char_t path[300];
Char_t pathname[400];
- Char_t cmd[430];
+ Char_t** cmds = new Char_t*[iterator->GetEntries()];
AliEveTRDTrack* track = 0;
AliTRDtrackV1 *trackv1 = 0;
fDataFromMacroList = new TList();
if (fDataTree == 0) fDataTree = new TTreeSRedirector("TRD.TrackListMacroData.root");
+
+ // Collect the commands for each macro and add them to "data-from-list"
+ for (Int_t i = 0; i < iterator->GetEntries(); i++)
+ {
+ memset(name, '\0', sizeof(Char_t) * 100);
+ memset(path, '\0', sizeof(Char_t) * 300);
+ memset(pathname, '\0', sizeof(Char_t) * 400);
+
+ cmds[i] = new Char_t[430];
+ memset(cmds[i], '\0', sizeof(Char_t) * 430);
+
+#ifdef ALIEVETRDTRACKLIST_DEBUG
+ printf("AliEveTRDTrackList: Applying process macro: %s\n", iterator->At(i)->GetTitle());
+#endif
+
+ // Extract path and name -> Make pathname
+ sscanf(iterator->At(i)->GetTitle(), "%s (Path: %s)", name, path);
+
+ // Add to "data-from-list"
+ fDataFromMacroList->Add(new TObjString(name));
+
+ // Delete ")" at the end of path
+ path[strlen(path)] = '\0';
+ path[strlen(path) - 1] = '\0';
+ sprintf(pathname, "%s/%s", path, name);
+ sprintf(cmds[i], ".x %s(automaticTrackV1, results, n);", pathname);
+ }
- // Walk through the list of tracks
- Int_t trackNum = 0;
-
- //Double_t* results = new Double_t[iterator->GetEntries()];
- //for (Int_t i = 0; i < iterator->GetEntries(); i++) results[i] = 0;
- //Double_t result = 0;
-
- for (TEveElement::List_i iter = this->BeginChildren(); iter != this->EndChildren(); ++iter, ++trackNum)
+ // Walk through the list of tracks
+ for (TEveElement::List_i iter = this->BeginChildren(); iter != this->EndChildren(); ++iter)
{
track = dynamic_cast<AliEveTRDTrack*>(*iter);
// Collect data for each macro
for (Int_t i = 0; i < iterator->GetEntries(); i++)
{
- memset(name, '\0', sizeof(Char_t) * 100);
- memset(path, '\0', sizeof(Char_t) * 300);
- memset(pathname, '\0', sizeof(Char_t) * 400);
- memset(cmd, '\0', sizeof(Char_t) * 430);
-
-#ifdef ALIEVETRDTRACKLIST_DEBUG
- // Display this message only once
- if (iter == this->BeginChildren())
- printf("AliEveTRDTrackList: Applying process macro: %s\n", iterator->At(i)->GetTitle());
-#endif
-
- // Extract path and name -> Make pathname
- sscanf(iterator->At(i)->GetTitle(), "%s (Path: %s)", name, path);
- // Delete ")" at the end of path
- path[strlen(path)] = '\0';
- path[strlen(path) - 1] = '\0';
- sprintf(pathname, "%s/%s", path, name);
- sprintf(cmd, ".x %s(automaticTrackV1, results, n);", pathname);
-
- // Add to "data-from-list", but only once!
- if (iter == this->BeginChildren()) fDataFromMacroList->Add(new TObjString(name));
-
- //results[i] += (Double_t)gROOT->ProcessLineSync(cmd);
- //result = (Double_t)gROOT->ProcessLineSync(cmd);
-
- //(*fDataTree) << Form("TrackData%d", i)
- // << Form("Macro%d=", i) << result << "\n";
-
// Create data pointers in CINT, execute the macro and get the data
gROOT->ProcessLineSync("Double_t* results = 0;");
gROOT->ProcessLineSync("Int_t n = 0;");
- gROOT->ProcessLineSync(cmd);
+ gROOT->ProcessLineSync(cmds[i]);
Double_t* results = (Double_t*)gROOT->ProcessLineSync("results;");
Int_t nResults = (Int_t)gROOT->ProcessLineSync("n;");
if (results == 0)
{
- Error("Apply macros", Form("Error reading data from macro \"%s\"", name));
+ Error("Apply macros", Form("Error reading data from macro \"%s\"", iterator->At(i)->GetTitle()));
continue;
}
for (Int_t resInd = 0; resInd < nResults; resInd++)
results = 0;
}
}
-/* for (Int_t i = 0; i < iterator->GetEntries(); i++)
- {
- (*fDataTree) << Form("TrackData") << Form("Macro%d=", i) << results[i] << "\n";
- }
-
- if (results != 0) delete results;
- results = 0;
-*/
delete fDataTree;
fDataTree = 0;
+ if (cmds != 0) delete [] cmds;
+
// Clear root
gROOT->Reset();
// The editor will access this file to display the data
}
-
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::ApplySelectionMacros(TList* iterator)
{
+ if (iterator->GetEntries() <= 0) return;
+
Char_t name[100];
Char_t path[300];
Char_t pathname[400];
gROOT->Reset();
}
-
-//__________________________________________________________
+//______________________________________________________
Char_t* AliEveTRDTrackList::MakeMacroEntry(const Char_t* path, const Char_t* name)
{
Char_t* entry = new Char_t[400];
return entry;
}
-
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::RemoveProcessMacros(TList* iterator)
{
for (Int_t i = 0; i < iterator->GetEntries(); i++)
}
}
-
-//__________________________________________________________
+//______________________________________________________
void AliEveTRDTrackList::RemoveSelectionMacros(TList* iterator)
{
for (Int_t i = 0; i < iterator->GetEntries(); i++)
-#include "TTreeStream.h"
+#include <EveDet/AliEveTRDData.h>
#include <EveDet/AliEveTRDTrackList.h>
#include "AliEveTRDTrackListEditor.h"
-#include <TGFileDialog.h>
-#include <TFile.h>
+#include <AliTRDtrackV1.h>
#include <TGButton.h>
-#include <TGedEditor.h> ////// MAYBE THIS CAN BE REMOVED
-#include <TGTextEntry.h>
-#include <TGTextView.h>
-#include <TGListBox.h>
-#include <TGMsgBox.h>
-#include <TGLabel.h>
-#include <TG3DLine.h>
+#include <TCanvas.h>
+#include <TEveGedEditor.h>
#include <TEveMacro.h>
#include <TEveManager.h>
+#include <TFile.h>
+#include <TG3DLine.h>
+#include <TGFileDialog.h>
+#include <TGLabel.h>
+#include <TGListBox.h>
+#include <TGMsgBox.h>
+#include <TGTab.h>
#include <TObjString.h>
-#include <TSystem.h>
#include <TROOT.h>
-#include <AliTRDtrackV1.h>
-#include <EveDet/AliEveTRDData.h>
+#include <TSystem.h>
+#include <TGTextEntry.h>
+#include <TGTextView.h>
+#include <TTreeStream.h>
+
ClassImp(AliEveTRDTrackListEditor)
UInt_t options, Pixel_t back) :
TGedFrame(p, width, height, options, back),
fM(0),
+ fInitState(0),
fMainFrame(0),
fHistoFrame(0),
fHistoSubFrame(0),
fFileInfo->fFileTypes = (const Char_t**)fFileTypes;
fFileInfo->fFileTypeIdx = 2;
fFileInfo->fMultipleSelection = kTRUE;
-
- // Set focus on "Apply macros" tab
- //fMainFrame->TGWindow::RequestFocus();
- //Update();
}
//______________________________________________________
return;
}
+ Char_t macroName[100];
TTree* t = 0;
- for (Int_t i = 0; i < iterator->GetEntries(); i++) {
+ for (Int_t i = 0; i < iterator->GetEntries(); i++)
+ {
t = (TTree*)file->Get(Form("TrackData%d", i));
- if (t != 0) {
- gEve->AddCanvasTab(Form("Macro%d", i));
+ if (t != 0)
+ {
+ memset(macroName, '\0', sizeof(Char_t) * 100);
+ sscanf(iterator->At(i)->GetTitle(), "%s (Path:%*s)", macroName);
+
+ TCanvas* canvas = (TCanvas*)gROOT->GetListOfCanvases()->TCollection::FindObject(macroName);
+ if (!canvas)
+ {
+ canvas = gEve->AddCanvasTab(macroName);
+ canvas->SetName(macroName);
+ }
+ gPad = canvas;
t->Draw(Form("Macro%d", i), "1");
+ canvas->Update();
delete t;
t = 0;
// ONLY DISPLAY ONE MACRO (the first one possible) -> Remove the next line to display all
- break;
- } else {
+ //break;
+ }
+ else
+ {
Error("Apply macros", Form("No data for macro%d found!", i));
new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Apply macros",
Form("No data for macro%d found!", i), kMBIconExclamation, kMBOk);
iterator = 0;
// Update histogram tab (data has to be reloaded)
- //fHistoFrame->TGWindow::RequestFocus();
- //fGedEditor->TGCompositeFrame::ShowFrame(fHistoFrame);
SetModel(fM);
Update();
-}
+ // Set focus on "Histograms" tab
+ GetGedEditor()->GetTab()->SetTab("Histograms");
+}
//______________________________________________________
void AliEveTRDTrackListEditor::BrowseMacros()
// 1d histogram
if (nHistograms == 1)
{
- gEve->AddCanvasTab(Form("Macro%d", indexOfMacro1));
+ TCanvas* canvas = (TCanvas*)gROOT->GetListOfCanvases()->TCollection::FindObject(fM->fDataFromMacroList->At(indexOfMacro1)->GetName());
+ if (!canvas)
+ {
+ canvas = gEve->AddCanvasTab(fM->fDataFromMacroList->At(indexOfMacro1)->GetName());
+ canvas->SetName(fM->fDataFromMacroList->At(indexOfMacro1)->GetName());
+ }
+ gPad = canvas;
t->Draw(Form("Macro%d", indexOfMacro1), "1");
+ gROOT->SetSelectedPad(canvas);
+ canvas->Update();
break;
}
// 2d histogram
if (nHistograms == 2)
{
- gEve->AddCanvasTab(Form("Macro%d - Macro%d", indexOfMacro1, indexOfMacro2));
+ TCanvas* canvas = (TCanvas*)gROOT->GetListOfCanvases()->TCollection::FindObject(Form("%s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName()));
+ if (!canvas)
+ {
+ canvas = gEve->AddCanvasTab(Form("%s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName()));
+ canvas->SetName(Form("%s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName()));
+ }
+ gPad = canvas;
t->AddFriend(tFriend1);
t->Draw(Form("Macro%d:Macro%d", indexOfMacro1, indexOfMacro2), "1");
+ canvas->Update();
break;
}
break;
}
- gEve->AddCanvasTab(Form("Macro%d - Macro%d - Macro%d", indexOfMacro1, indexOfMacro2, indexOfMacro3));
+ TCanvas* canvas = (TCanvas*)gROOT->GetListOfCanvases()->TCollection::FindObject(Form("%s - %s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro3)->GetName()));
+ if (!canvas)
+ {
+ canvas = gEve->AddCanvasTab(Form("%s - %s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro3)->GetName()));
+ canvas->SetName(Form("%s - %s - %s",
+ fM->fDataFromMacroList->At(indexOfMacro1)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro2)->GetName(),
+ fM->fDataFromMacroList->At(indexOfMacro3)->GetName()));
+ }
+ gPad = canvas;
t->AddFriend(tFriend1);
t->AddFriend(tFriend2);
t->Draw(Form("Macro%d:Macro%d:Macro%d", indexOfMacro1, indexOfMacro2, indexOfMacro3), "1");
+ canvas->Update();
break;
}
iterator = 0;
}
-
//______________________________________________________
void AliEveTRDTrackListEditor::SetModel(TObject* obj)
-{
+{
// Set model object
fM = dynamic_cast<AliEveTRDTrackList*>(obj);
+ if (fM == 0)
+ {
+ Error("SetModel", "Parameter is zero pointer");
+ return;
+ }
+
UpdateMacroList();
- UpdateHistoList();
+ UpdateHistoList();
+
+ // Set focus on "Apply macros" tab, if the editor has just been initialized.
+ // To prevent refocusing on "Style" tab, disable "Style" and during the next call
+ // re-enable "Style"
+ if (fInitState == 0)
+ {
+ GetGedEditor()->GetTab()->SetEnabled(0, kFALSE);
+ GetGedEditor()->GetTab()->SetTab("Apply macros");
+
+ fInitState = 1;
+ }
+ else if (fInitState == 1)
+ {
+ GetGedEditor()->GetTab()->SetEnabled(0, kTRUE);
+ fInitState = 2;
+ }
}
//______________________________________________________
}
}
-
//______________________________________________________
void AliEveTRDTrackListEditor::UpdateMacroList()
{