]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveTRDTrackListEditor.cxx
Cosmetically sanitize ITS visualization code.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTRDTrackListEditor.cxx
index d76da89b86f431984e5eea0275dd290785b92e1a..2ab5bb8da3319b904829b1bb7fbf63ef725737c7 100644 (file)
@@ -1,3 +1,25 @@
+// Author: Benjamin Hess   25/09/2008
+
+/*************************************************************************
+ * Copyright (C) 2008, Alexandru Bercuci, Benjamin Hess.                 *
+ * All rights reserved.                                                  *
+ *************************************************************************/
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// AliEveTRDTrackListEditor                                             //
+//                                                                      //
+// The AliEveTRDTrackListEditor provides the graphical functionality    //
+// for the AliEveTRDTrackList. It creates the tabs and canvases, when   //
+// they are needed and, as well, frees allocated memory on destruction  //
+// (or if new events are loaded and thus some tabs are closed).         //
+// The function DrawHistos() accesses the temporary file created by the //
+// AliEveTRDTrackList and draws the desired data (the file will be      //
+// created within the call of ApplyMacros()). Have a look at this       //
+// function to learn more about the structure of the file and how to    //
+// access the data.                                                     //
+//////////////////////////////////////////////////////////////////////////
+
 #include <EveDet/AliEveTRDData.h>
 #include <EveDet/AliEveTRDTrackList.h>
 #include "AliEveTRDTrackListEditor.h"
 #include <TGListBox.h>
 #include <TGMsgBox.h>
 #include <TGTab.h>
+#include <TMap.h>
 #include <TObjString.h>
 #include <TROOT.h>
 #include <TSystem.h>
 #include <TGTextEntry.h>
+#include <TGTextEdit.h>
+#include <TGComboBox.h>
 #include <TGTextView.h>
 #include <TH1.h>
 #include <TTreeStream.h>
@@ -39,6 +64,7 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fM(0),
   fHistoCanvas(0),
   fHistoCanvasName(0),
+  fInheritedMacroList(0),
   fInheritSettings(kFALSE),
   fStyleFrame(0),
   fMainFrame(0),
@@ -50,6 +76,7 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   frbColor(new TGRadioButton*[3]),
   frbTrack(new TGRadioButton*[3]),
   fbBrowse(0),
+  fbNew(0),
   fbApplyMacros(0),
   fbRemoveMacros(0),
   fbDrawHisto(0),
@@ -62,6 +89,8 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fLine1(0), fLine2(0), fLine3(0), fLine4(0), fLine5(0),
   fCheckButtons(0)
 {
+  // Creates the AliEveTRDTrackListEditor.
+
   // Style stuff
   fLine5 = new TGHorizontal3DLine(this, 194, 8);
   AddFrame(fLine5, new TGLayoutHints(kLHintsLeft  | kLHintsTop, 2, 2, 8, 8));
@@ -75,13 +104,13 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fStyleFrame->AddFrame(fbgStyleTrack);
 
   frbTrack[0] = new TGRadioButton(fbgStyleTrack, "Rieman", 0);
-  frbTrack[0]->SetToolTipText("Set the track model to \"Rieman\"");
+  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\"");
+  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\"");
+  frbTrack[2]->SetToolTipText("Set the track model to \"Line\" (i.e. the used fit method)");
   fbgStyleTrack->AddFrame(frbTrack[2]);  
 
   // Style - Color model
@@ -91,18 +120,18 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fStyleFrame->AddFrame(fbgStyleColor);
 
   frbColor[0] = new TGRadioButton(fbgStyleColor, "PID LQ", 0);
-  frbColor[0]->SetToolTipText("Set color model to \"PID LQ\"");
+  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\"");
+  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\"");
+  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  
-  fMainFrame = CreateEditorTabSubFrame("Apply macros");
+  fMainFrame = CreateEditorTabSubFrame("Process");
    
   fLabel1 = new TGLabel(fMainFrame,"Add macro(s):");
   fMainFrame->AddFrame(fLabel1);
@@ -117,6 +146,11 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fbBrowse->SetToolTipText("Browse the macro you want to add");
   fbBrowse->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "BrowseMacros()");
   fBrowseFrame->AddFrame(fbBrowse);
+  
+  fbNew = new TGTextButton(fBrowseFrame, "New");
+  fbNew->SetToolTipText("Start macro creation wizzard");
+  fbNew->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "NewMacros()");
+  fBrowseFrame->AddFrame(fbNew);
   fMainFrame->AddFrame(fBrowseFrame);
 
   fLine1 = new TGHorizontal3DLine(fMainFrame, 194, 8);
@@ -131,7 +165,7 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
 
   fLine2 = new TGHorizontal3DLine(fMainFrame, 194, 8);
   fMainFrame->AddFrame(fLine2, new TGLayoutHints(kLHintsLeft  | kLHintsTop, 2, 2, 8, 2));
-  fLabel3 = new TGLabel(fMainFrame,"Process macros:");
+  fLabel3 = new TGLabel(fMainFrame,"Process plugins:");
   fMainFrame->AddFrame(fLabel3);
 
   ftlMacroList = new TGListBox(fMainFrame);
@@ -142,21 +176,21 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fLine3 = new TGHorizontal3DLine(fMainFrame, 194, 8);
   fMainFrame->AddFrame(fLine3, new TGLayoutHints(kLHintsLeft  | kLHintsTop, 2, 2, 8, 2));  
 
-  fbApplyMacros = new TGTextButton(fMainFrame, "Apply selected macro(s)");
-  fbApplyMacros->SetToolTipText("Apply all selected macros to the tracklist -> A data file will be generated");
+  fbApplyMacros = new TGTextButton(fMainFrame, "Apply plugin(s)");
+  fbApplyMacros->SetToolTipText("Apply all selected macros/class functins to the list of tracks -> A data file will be generated");
   fbApplyMacros->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "ApplyMacros()");
   fbApplyMacros->SetRightMargin(12);
   fMainFrame->AddFrame(fbApplyMacros);
 
-  fbRemoveMacros = new TGTextButton(fMainFrame, "Remove selected macro(s)");
-  fbRemoveMacros->SetToolTipText("Remove the selected macro(s) from the list(s)");
+  fbRemoveMacros = new TGTextButton(fMainFrame, "Remove plugin(s)");
+  fbRemoveMacros->SetToolTipText("Remove the selected macros/class functions from the list(s)");
   fbRemoveMacros->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "RemoveMacros()");
   fMainFrame->AddFrame(fbRemoveMacros);
 
   // Stuff for displaying histograms
-  fHistoFrame = CreateEditorTabSubFrame("Histograms");  
+  fHistoFrame = CreateEditorTabSubFrame("Results");  
   fHistoFrame->SetMapSubwindows(kTRUE);
-  fLabel4 = new TGLabel(fHistoFrame,"Data from applied macros:");
+  fLabel4 = new TGLabel(fHistoFrame,"Data from plugins:");
   fHistoFrame->AddFrame(fLabel4);
 
   fHistoSubFrame = new TGVerticalFrame(fHistoFrame);
@@ -167,8 +201,8 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
   fLine4 = new TGHorizontal3DLine(fHistoFrame, 194, 8);
   fHistoFrame->AddFrame(fLine4, new TGLayoutHints(kLHintsLeft  | kLHintsTop, 2, 2, 8, 2));  
 
-  fbDrawHisto = new TGTextButton(fHistoFrame, "Draw histogram");
-  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 correlated, multi-dimensional plots.\nHisto macros cannot be correlated!");
+  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->Connect("Clicked()", "AliEveTRDTrackListEditor", this, "DrawHistos()");
   fHistoFrame->AddFrame(fbDrawHisto);
 
@@ -192,19 +226,21 @@ AliEveTRDTrackListEditor::AliEveTRDTrackListEditor(const TGWindow* p, Int_t widt
 
   // Handle the signal "Selected(Int_t ind)"
   ftlMacroList->Connect("Selected(Int_t)", "AliEveTRDTrackListEditor", this, "UpdateMacroListSelection(Int_t)");
-  ftlMacroSelList->Connect("Selected(Int_t)", "AliEveTRDTrackListEditor", this, "UpdateMacroSelListSelection(Int_t)");
+  ftlMacroSelList->Connect("Selected(Int_t)", "AliEveTRDTrackListEditor", this, "UpdateMacroListSelection(Int_t)");
 
   // Handle the signal "NewEventLoaded"
-  gAliEveEvent->Connect("NewEventLoaded()", "AliEveTRDTrackListEditor", this, "HandleNewEventLoaded()");
+  AliEveEventManager::GetMaster()->Connect("NewEventLoaded()", "AliEveTRDTrackListEditor", this, "HandleNewEventLoaded()");
 
   // Handle the signal "Selected" (another tab has been selected)
-  GetGedEditor()->GetTab()->Connect("Selected(Int_t)", "AliEveTRDTrackListEditor", 
-                                    this, "HandleTabChangedToIndex(Int_t)");
+  GetGedEditor()->GetTab()->Connect("Selected(Int_t)", "AliEveTRDTrackListEditor", this, "HandleTabChangedToIndex(Int_t)");
 }
 
 //______________________________________________________
 AliEveTRDTrackListEditor::~AliEveTRDTrackListEditor()
 {
+  // Destructor: Closes all tabs created by this object and
+  // frees the corresponding memory.
+
   if (fFileTypes != 0)
   {
     delete [] fFileTypes;
@@ -224,11 +260,19 @@ AliEveTRDTrackListEditor::~AliEveTRDTrackListEditor()
     delete fHistoCanvasName;
     fHistoCanvasName = 0;
   }
+  if (fInheritedMacroList != 0)
+  {
+    fInheritedMacroList->Delete();
+    delete fInheritedMacroList;
+    fInheritedMacroList = 0;
+  }
 }
 
 //______________________________________________________
-void AliEveTRDTrackListEditor::AddMacro(const Char_t* path, const Char_t* name)
+void AliEveTRDTrackListEditor::AddMacro(const Char_t* name, const Char_t* path)
 {
+  // Adds the macro path/name to the macro list. A warning is provided, if there is
+  // something wrong, e.g. if the macro does not have the correct signature.
   Int_t result = fM->AddMacro(path, name);
 
   switch (result)
@@ -240,9 +284,13 @@ void AliEveTRDTrackListEditor::AddMacro(const Char_t* path, const Char_t* name)
     new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Warning", "Macro is already in list (won't be added again)!",
                  kMBIconExclamation, kMBOk);
     break;
+  case ERROR:
+    new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error", "Fail to load the macro (check messages in the terminal)!",
+                 kMBIconExclamation, kMBOk);
+    break;
   case SIGNATURE_ERROR:
     new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error", 
-                 "Macro has not the signature of...\n...a selection macro: Bool_t YourMacro(const AliTRDtrackV1*)\n...a process macro (type 1): void YourMacro(const AliTRDtrackV1*, Double_t*&, Int_t&)\n...a process macro (type2): TH1* YourMacro(const AliTRDtrackV1*)", 
+                 "Macro has not the signature of...\n...a single track selection macro: Bool_t YourMacro(const AliTRDtrackV1*)\n...a correlated tracks selection macro: Bool_t YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*)\n...a single track analyse macro: void YourMacro(const AliTRDtrackV1*, Double_t*&, Int_t&)\n...a correlated tracks analyse macro: void YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*, Double_t*&, Int_t&)\n...a single track histo macro: TH1* YourMacro(const AliTRDtrackV1*)\n...a correlated tracks histo macro: TH1* YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*)", 
                  kMBIconExclamation, kMBOk);
     break;               
   case NOT_EXIST_ERROR:
@@ -260,22 +308,22 @@ void AliEveTRDTrackListEditor::AddMacro(const Char_t* path, const Char_t* name)
 //______________________________________________________
 void AliEveTRDTrackListEditor::ApplyMacros()
 {
+  // Applies the selected macros and updates the view.
+
   Bool_t success = kFALSE;
 
-  // First apply the selection macros
-  TList* iterator = new TList();
-  ftlMacroSelList->GetSelectedEntries(iterator);
-  fM->ApplySelectionMacros(iterator);
+  // First apply the single track selection macros
+  TList* selIterator = new TList();
+  ftlMacroSelList->GetSelectedEntries(selIterator);
+  fM->ApplySTSelectionMacros(selIterator);
   
   // Update view
   gEve->Redraw3D();
 
-  if (iterator != 0) delete iterator;  
-
   // Now apply the process macros
-  iterator = new TList();
-  ftlMacroList->GetSelectedEntries(iterator);
-  success = fM->ApplyProcessMacros(iterator);
+  TList* procIterator = new TList();
+  ftlMacroList->GetSelectedEntries(procIterator);
+  success = fM->ApplyProcessMacros(selIterator, procIterator);
 
   // Update histogram tab (data has to be reloaded)
   SetModel(fM);
@@ -283,16 +331,18 @@ void AliEveTRDTrackListEditor::ApplyMacros()
 
   // AlieveTRDTrackList::ApplyProcessMacros() automatically selects a macro -> Draw the histogram for it,
   // if a process macro has been applied
-  if (success && iterator->GetEntries() > 0) 
+  if (success && procIterator->GetEntries() > 0) 
   {
     // Set focus on "Histograms" tab
-    GetGedEditor()->GetTab()->SetTab("Histograms");
+    GetGedEditor()->GetTab()->SetTab("Results");
 
     DrawHistos();
   }
 
-  if (iterator != 0)  delete iterator;  
-  iterator = 0;  
+  if (selIterator != 0) delete selIterator;
+  selIterator = 0;  
+  if (procIterator != 0)  delete procIterator;  
+  procIterator = 0;  
   
   if (!success)
   {
@@ -302,9 +352,23 @@ void AliEveTRDTrackListEditor::ApplyMacros()
   }
 }
 
+//______________________________________________________
+void AliEveTRDTrackListEditor::NewMacros()
+{
+  // Start the macro creation wizzard.
+  // thanks to Jacek Otwinowski<J.Otwinowski@GSI.DE> for this suggestion
+
+  AliEveTRDMacroWizzard *wizz = new AliEveTRDMacroWizzard();
+  wizz->Connect("Create(Char_t*)", "AliEveTRDTrackListEditor", this, "AddMacro(Char_t*)");
+}
+
+
 //______________________________________________________
 void AliEveTRDTrackListEditor::BrowseMacros()
 {
+  // Creates a file-dialog. The selected files will be added to the macro list
+  // via AddMacro(...).
+
   new TGFileDialog(gClient->GetRoot(), GetMainFrame(), kFDOpen, fFileInfo);
   
   if (fFileInfo->fIniDir != 0 && fFileInfo->fFileNamesList != 0)
@@ -317,11 +381,11 @@ void AliEveTRDTrackListEditor::BrowseMacros()
     while (iter != 0)
     {
       // NOTE: fileInfo->fFileNamesList will be changed by that, too!
-      name = strrchr(iter->GetName(), '/');
+      name = (Char_t*)strrchr(iter->GetName(), '/');
       // Delete '"' at the end
       name[strlen(name)] = '\0';
               
-      AddMacro(fFileInfo->fIniDir, name + 1); 
+      AddMacro(name + 1, fFileInfo->fIniDir); 
       iter = (TObjString*)fFileInfo->fFileNamesList->After(iter);
     }
   }
@@ -335,6 +399,8 @@ void AliEveTRDTrackListEditor::BrowseMacros()
 //______________________________________________________
 void AliEveTRDTrackListEditor::CloseTabs()
 {
+  // Closes + deletes the tabs created by this object
+
   if (fHistoCanvas != 0)
   {
     // Close the created tab, if it exists
@@ -354,6 +420,9 @@ void AliEveTRDTrackListEditor::CloseTabs()
 //______________________________________________________
 void AliEveTRDTrackListEditor::DrawHistos()
 {
+  // Accesses the temporary data file created by the last call of ApplyMacros() and draws
+  // histograms according to the selection in the "Histograms"-tab.
   Int_t nHistograms = GetNSelectedHistograms();
   if (nHistograms <= 0)
   {
@@ -386,7 +455,7 @@ void AliEveTRDTrackListEditor::DrawHistos()
         {
           // Histo macros cannot(!) be correlated!
           new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Draw histograms", 
-                       "Process macros of type 2 (return value \"TH1*\") cannot be correlated with other macros", 
+                       "Histo macros (return value \"TH1*\") cannot be combined with other macros", 
                        kMBIconExclamation, kMBOk);
           return;        
         }
@@ -447,10 +516,10 @@ void AliEveTRDTrackListEditor::DrawHistos()
     }
     else
     {
-      Error("Draw histograms", Form("No data for histo macro \"%s\" found!", 
+      Error("Draw histograms", Form("No data for histo macro \"%s\" found!\nMaybe no tracks have been selected.", 
                                     fM->fDataFromMacroList->At(indexOfHistoMacro)->GetName()));
       new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Draw histograms", 
-                   Form("No data for histo macro \"%s\" found!", 
+                   Form("No data for histo macro \"%s\" found!\nMaybe no tracks have been selected.", 
                         fM->fDataFromMacroList->At(indexOfHistoMacro)->GetName()), kMBIconExclamation, kMBOk);
     }
 
@@ -458,7 +527,7 @@ void AliEveTRDTrackListEditor::DrawHistos()
     i = fM->fDataFromMacroList->GetEntries();
   }
 
-  // Load the trees in succession and remember the entries -> Plot the process macros of type 1
+  // Load the trees in succession and remember the entries -> Plot the analyse macros
   for ( ; i < fM->fDataFromMacroList->GetEntries(); i++)
   {
     if (fCheckButtons[i]->TGButton::GetState() == kButtonDown)
@@ -468,14 +537,15 @@ void AliEveTRDTrackListEditor::DrawHistos()
         indexOfMacro1 = i;
         if (!(t = (TTree*)file->Get(Form("TrackData%d", i))))
         { 
-          Error("Draw histograms", Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()));
+          Error("Draw histograms", Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                                        fM->fDataFromMacroList->At(i)->GetName()));
           new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Draw histograms", 
-                       Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()),
-                            kMBIconExclamation, kMBOk);
+                       Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                            fM->fDataFromMacroList->At(i)->GetName()), kMBIconExclamation, kMBOk);
           break;   
         }
 
-        // 1d histogram - macro of type 1   
+        // 1d histogram
         if (nHistograms == 1) 
         {
           SetDrawingToHistoCanvasTab();
@@ -494,9 +564,11 @@ void AliEveTRDTrackListEditor::DrawHistos()
         indexOfMacro2 = i;
         if (!(tFriend1 = (TTree*)file->Get(Form("TrackData%d", i))))
         { 
-          Error("Draw histograms", Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()));
+          Error("Draw histograms", Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                                        fM->fDataFromMacroList->At(i)->GetName()));
           new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Draw histograms", 
-                       Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()),
+                       Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                            fM->fDataFromMacroList->At(i)->GetName()),
                             kMBIconExclamation, kMBOk);
           break;   
         }
@@ -525,10 +597,11 @@ void AliEveTRDTrackListEditor::DrawHistos()
         indexOfMacro3 = i;
         if (!(tFriend2 = (TTree*)file->Get(Form("TrackData%d", i))))
         { 
-          Error("Draw histograms", Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()));
+          Error("Draw histograms", Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                                        fM->fDataFromMacroList->At(i)->GetName()));
           new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error - Draw histograms", 
-                       Form("No data for macro \"%s\" found!", fM->fDataFromMacroList->At(i)->GetName()),
-                            kMBIconExclamation, kMBOk);
+                       Form("No data for macro \"%s\" found!\nMaybe no tracks have been selected.", 
+                            fM->fDataFromMacroList->At(i)->GetName()), kMBIconExclamation, kMBOk);
           break;   
         }
 
@@ -565,8 +638,10 @@ void AliEveTRDTrackListEditor::DrawHistos()
 }
 
 //______________________________________________________
-Int_t AliEveTRDTrackListEditor::GetNSelectedHistograms()
+Int_t AliEveTRDTrackListEditor::GetNSelectedHistograms() const
 {
+  // Returns the number of selected macros (or rather: of their selected data) in the "Histograms"-tab
+
   Int_t count = 0;
   
   for (Int_t i = 0; i < fM->fDataFromMacroList->GetEntries(); i++)
@@ -580,6 +655,10 @@ Int_t AliEveTRDTrackListEditor::GetNSelectedHistograms()
 //______________________________________________________
 void AliEveTRDTrackListEditor::HandleMacroPathSet()
 {
+  // Takes the input of the text field (adding a macro), checks if the macro can be
+  // 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".
+
   if (strlen(fteField->GetText()) != 0)
   {  
     // Expand the pathname
@@ -597,7 +676,7 @@ void AliEveTRDTrackListEditor::HandleMacroPathSet()
       fclose(fp);
 
       // Extract filename
-      Char_t* name = strrchr(fteField->GetText(), '/');
+      Char_t* name = (Char_t*)strrchr(fteField->GetText(), '/');
 
       // Current path
       if (name == NULL)
@@ -612,7 +691,7 @@ void AliEveTRDTrackListEditor::HandleMacroPathSet()
         sprintf(pathname, "./%s", fteField->GetText());
         fteField->SetText(pathname);
 
-        AddMacro(".", name);  
+        AddMacro(name);  
         if (name != 0)  delete name;
         name = 0;
       }
@@ -625,7 +704,7 @@ void AliEveTRDTrackListEditor::HandleMacroPathSet()
         strncpy(path, fteField->GetText(), strlen(fteField->GetText()) - strlen(name));
         
         // Ignore the slash "/" in name
-        AddMacro(path, name + 1);  
+        AddMacro(name + 1, path);  
   
         if (path != 0)  delete path;
         path = 0;
@@ -642,6 +721,10 @@ void AliEveTRDTrackListEditor::HandleMacroPathSet()
 //______________________________________________________
 void AliEveTRDTrackListEditor::HandleNewEventLoaded()
 {
+  // Closes the tabs created by this object and sets a flag that will
+  // cause the function SetModel() to inherit the macro lists + style
+  // for the next AliEveTRDTrackList from the current one.
+
   // Inherit the macro list and track style for the next track list!
   fInheritSettings = kTRUE;
 
@@ -652,34 +735,52 @@ void AliEveTRDTrackListEditor::HandleNewEventLoaded()
 //______________________________________________________
 void AliEveTRDTrackListEditor::HandleTabChangedToIndex(Int_t index)
 {
+  // Saves the current tab in the current AliEveTRDTrackList.
+
   fM->SetSelectedTab(index);
 }
 
 //______________________________________________________
 void AliEveTRDTrackListEditor::InheritMacroList()
 {
-  // The old macro lists are stored in the corresponding list boxes -> add them to the track list
-    
-  // Selection macros
-  fM->fMacroSelList->Delete();
-  for (Int_t i = 0; i < ftlMacroSelList->GetNumberOfEntries(); i++)
-  {
-    fM->AddMacroFast(ftlMacroSelList->GetEntry(i)->GetTitle(), AliEveTRDTrackList::kSelectionMacro);
-  }
+  // The old macro list is possibly stored in the corresponding interior map. This function will 
+  // use this interior map to move the data from the interior map to the newly loaded AliEveTRDTrackList. 
+  // Then the interior map will be cleaned up. With this, the settings will be inherited from the previously 
+  // loaded AliEveTRDTrackList.
+
+  if (fInheritedMacroList == 0)  return;
 
-  // Process macros
+  // Clear list  
   fM->fMacroList->Delete();
-  for (Int_t i = 0; i < ftlMacroList->GetNumberOfEntries(); i++)
+
+  // Store data from interior list in the track list's map
+  TMapIter* iter = (TMapIter*)fInheritedMacroList->MakeIterator();
+  
+  TObject* key = 0;
+  TMacroData* macro = 0;
+  
+  while ((key = iter->Next()) != 0)
   {
-    fM->AddMacroFast(ftlMacroList->GetEntry(i)->GetTitle(), fM->GetMacroType(ftlMacroList->GetEntry(i)->GetTitle(),
-                                                                             kFALSE));
+    macro = (TMacroData*)fInheritedMacroList->GetValue(key);
+    if (macro != 0)  fM->fMacroList->Add(new TObjString(key->GetName()), 
+                                         new TMacroData(macro->GetName(), macro->GetPath(), macro->GetType()));
+    else
+    {
+      Error("AliEveTRDTrackListEditor::InheritMacroList", Form("Failed to inherit the macro \"%s\"!", key));
+    }
   }
+  
+  fInheritedMacroList->Delete();
+  delete fInheritedMacroList;
+  fInheritedMacroList = 0;
 }
 
 //______________________________________________________
 void AliEveTRDTrackListEditor::InheritStyle()
 {
-  // The old styles are stored in the corresponding button groups -> set them in track list
+  // The old styles are stored in the corresponding button groups. This function will replace
+  // the style settings of the newly loaded AliEveTRDTrackList with the old styles. With this, the settings
+  // will be inherited from the previously loaded AliEveTRDTrackList.
 
   for (Int_t ind = 0; ind < 3; ind++)
   {
@@ -702,20 +803,21 @@ void AliEveTRDTrackListEditor::InheritStyle()
 //______________________________________________________
 void AliEveTRDTrackListEditor::RemoveMacros()
 {
+  // Removes the selected macros from the corresponding list.
+
   TList* iterator = new TList();
   
   ftlMacroList->GetSelectedEntries(iterator);
-  fM->RemoveProcessMacros(iterator);
+  fM->RemoveSelectedMacros(iterator);
 
   if (iterator != 0)  delete iterator;
 
   iterator = new TList();
   ftlMacroSelList->GetSelectedEntries(iterator);
-  fM->RemoveSelectionMacros(iterator);
+  fM->RemoveSelectedMacros(iterator);
 
   // Selected macros are deleted from the list -> No selected entries left
   fM->fMacroListSelected = 0;
-  fM->fMacroSelListSelected = 0;
 
   UpdateMacroList();
 
@@ -726,6 +828,9 @@ void AliEveTRDTrackListEditor::RemoveMacros()
 //______________________________________________________
 void AliEveTRDTrackListEditor::SetDrawingToHistoCanvasTab()
 {
+  // Sets gPad to the tab with the name of the current AliEveTRDTrackList. If this tab does
+  // not exist, it will be created. Otherwise, it is re-used.
+
   // If the tab with the canvas has been closed, the canvas will be deleted.
   // So, if there is no tab, set the canvas pointer to zero and recreate it in a new tab.
   if (fHistoCanvas != 0) 
@@ -747,7 +852,9 @@ void AliEveTRDTrackListEditor::SetDrawingToHistoCanvasTab()
 //______________________________________________________
 void AliEveTRDTrackListEditor::SetModel(TObject* obj)
 {  
-  // Set model object
+  // Sets the model object, updates the related data in the GUI and
+  // inherits settings (cf. Inherit*(...)), if the flag fInheritSettings is set to kTRUE.
+
   fM = dynamic_cast<AliEveTRDTrackList*>(obj);
 
   if (fM == 0) 
@@ -756,6 +863,9 @@ void AliEveTRDTrackListEditor::SetModel(TObject* obj)
     return;
   }
 
+  // Provide a pointer to this editor
+  fM->fEditor = this;
+
   // If macro list + track style shall be inherited from previously loaded track list, do so
   if (fInheritSettings)
   {
@@ -792,20 +902,54 @@ void AliEveTRDTrackListEditor::SetModel(TObject* obj)
   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)
 {
+  // Sets the color model for the tracks, updates the tracks with this model and
+  // redraws the scene.
+
   switch(ind)
   { 
-  case AliTRDReconstructor::kLQPID:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kPID, AliTRDReconstructor::kLQPID);
-    break;
-  case AliTRDReconstructor::kNNPID:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kPID, AliTRDReconstructor::kNNPID);
-    break;
-  default:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kSource);
-    break;
+    case AliTRDpidUtil::kLQ:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kPID, AliTRDpidUtil::kLQ);
+      break;
+    case AliTRDpidUtil::kNN:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kPID, AliTRDpidUtil::kNN);
+      break;
+    default:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kSource);
+      break;
   }
 
   gEve->Redraw3D();
@@ -814,17 +958,20 @@ void AliEveTRDTrackListEditor::SetTrackColor(Int_t ind)
 //______________________________________________________
 void AliEveTRDTrackListEditor::SetTrackModel(Int_t ind)
 {
+  // Sets the track model for the tracks, updates the tracks with this model and
+  // redraws the scene.
+
   switch(ind)
   { 
-  case AliEveTRDTrack::kRieman:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kTrackModel, AliEveTRDTrack::kRieman);
-    break;
-  case AliEveTRDTrack::kKalman:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kTrackModel, AliEveTRDTrack::kKalman);
-    break;
-  default:
-    fM->UpdateTrackStyle(AliEveTRDTrack::kTrackCosmics);
-    break;
+    case AliEveTRDTrack::kRieman:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kTrackModel, AliEveTRDTrack::kRieman);
+      break;
+    case AliEveTRDTrack::kKalman:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kTrackModel, AliEveTRDTrack::kKalman);
+      break;
+    default:
+      fM->UpdateTrackStyle(AliEveTRDTrack::kTrackCosmics);
+      break;
   }
 
   gEve->Redraw3D();
@@ -833,6 +980,10 @@ void AliEveTRDTrackListEditor::SetTrackModel(Int_t ind)
 //______________________________________________________
 void AliEveTRDTrackListEditor::UpdateDataFromMacroListSelection()
 {
+  // Saves the current selection in the "Histograms"-tab to the current
+  // AliEveTRDTrackList. This means that the selection is updated and won't
+  // get lost, if another editor is loaded in Eve.
+
   for (Int_t i = 0; i < fM->fDataFromMacroList->GetEntries(); i++)
   {
     fM->SetHistoDataSelection(i, fCheckButtons[i]->IsOn());
@@ -842,6 +993,8 @@ void AliEveTRDTrackListEditor::UpdateDataFromMacroListSelection()
 //______________________________________________________
 void AliEveTRDTrackListEditor::UpdateHistoCanvasTab()
 {
+   // 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());  
 
@@ -858,6 +1011,9 @@ void AliEveTRDTrackListEditor::UpdateHistoCanvasTab()
 //______________________________________________________
 void AliEveTRDTrackListEditor::UpdateHistoList()
 {
+  // Reloads (updates) the buttons in the "Histograms"-tab via
+  // the current AliEveTRDTrackList (data).
+
   fHistoSubFrame->TGCompositeFrame::Cleanup();
   
   // Set buttons for histograms
@@ -882,57 +1038,261 @@ void AliEveTRDTrackListEditor::UpdateHistoList()
 //______________________________________________________
 void AliEveTRDTrackListEditor::UpdateMacroList()
 {
+  // Reloads (updates) the macro list (selection AND process macros) via
+  // the current AliEveTRDTrackList (data).
+
   ftlMacroList->RemoveAll();
-  TObjString* iter = (TObjString*)fM->fMacroList->First();
+  ftlMacroSelList->RemoveAll();
+   
+  TMapIter* iter = (TMapIter*)fM->fMacroList->MakeIterator();
+  TObject* key = 0;
+  TMacroData* macro = 0;
 
   Int_t ind = 0;
-  while (iter != 0)
+  while ((key = iter->Next()) != 0)
   {
-    ftlMacroList->AddEntry(iter->GetName(), ind++);
-    iter = (TObjString*)fM->fMacroList->After(iter);
+    macro = (TMacroData*)fM->fMacroList->GetValue(key);
+    if (macro != 0)
+    {
+      if (macro->IsProcessMacro())
+      {
+        ftlMacroList->AddEntry(macro->GetName(), ind);
+        // Select, what has been selected before
+        ftlMacroList->Select(ind, fM->MacroListIsSelected(ind));
+        ind++;
+      }
+      else if (macro->IsSelectionMacro())
+      {
+        ftlMacroSelList->AddEntry(macro->GetName(), ind);
+        // Select, what has been selected before
+        ftlMacroSelList->Select(ind, fM->MacroListIsSelected(ind));
+        ind++;
+      }
+      else
+      {
+        Error("AliEveTRDTrackListEditor::UpdateMacroList()", 
+              Form("Macro \"%s/%s.C\" has neither a selection macro nor a process macro!",
+                   macro->GetPath(), macro->GetName()));                                        
+      }
+    }
+    else
+    {
+      Error("AliEveTRDTrackListEditor::UpdateMacroList()", 
+              Form("Macro list is corrupted: Macro \"%s\" not found!", key->GetName()));            
+    }     
   }
 
-  ftlMacroList->SortByName();
+  ftlMacroList->SortByName(); 
+  ftlMacroSelList->SortByName(); 
+}
 
-  // Select, what has been selected before
-  for (Int_t i = 0; i < fM->fMacroList->GetEntries(); i++)
-  {
-    ftlMacroList->Select(i, fM->MacroListIsSelected(i));
-  }
+//______________________________________________________
+void AliEveTRDTrackListEditor::UpdateMacroListSelection(Int_t ind)
+{
+  // Saves the current selection in the macro listS to the current
+  // AliEveTRDTrackList. This means that the selection is updated and won't
+  // get lost, if another editor is loaded in Eve.
+  // NOTE: The indices in BOTH lists will be unique!
 
+  // Toggle selected item
+  fM->SetMacroListSelection(ind, !fM->MacroListIsSelected(ind));
+}
 
 
-  ftlMacroSelList->RemoveAll();
-  iter = (TObjString*)fM->fMacroSelList->First();
+/////////////////////////////////////////////////
+ClassImp(AliEveTRDMacroWizzard)
 
-  ind = 0;
-  while (iter != 0)
-  {
-    ftlMacroSelList->AddEntry(iter->GetName(), ind++);
-    iter = (TObjString*)fM->fMacroSelList->After(iter);
+//______________________________________________________
+AliEveTRDMacroWizzard::AliEveTRDMacroWizzard(const TGWindow* p)
+  :TGMainFrame(p ? p : gClient->GetRoot(), 10, 10, kMainFrame | kVerticalFrame)
+  ,fText(0x0)
+  ,fCombo(0x0)
+  ,fTextEdit(0x0)
+{
+  const Int_t width = 300;
+
+  // horizontal frame
+  TGHorizontalFrame *fFrameName = new TGHorizontalFrame(this, 10, 10, kHorizontalFrame);
+  TGLabel *fLabel = new TGLabel(fFrameName, "Name*");
+  fLabel->SetTextJustify(36);
+  fLabel->SetMargins(0,0,0,0);
+  fLabel->SetWrapLength(-1);
+  fFrameName->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+
+  fText = new TGTextEntry(fFrameName);
+  fText->SetMaxLength(255);
+  fText->SetAlignment(kTextLeft);
+  fText->SetText("");
+  fText->Resize(width, fText->GetDefaultHeight());
+  fFrameName->AddFrame(fText, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+
+
+  // horizontal frame
+  TGHorizontalFrame *fFrameComment = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
+  fLabel = new TGLabel(fFrameComment, "Comment");
+  fLabel->SetTextJustify(36);
+  fLabel->SetMargins(0,0,0,0);
+  fLabel->SetWrapLength(-1);
+  fFrameComment->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+
+  fTextEdit = new TGTextEdit(fFrameComment, width, 5*fText->GetDefaultHeight());
+  fFrameComment->AddFrame(fTextEdit, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+
+  // horizontal frame
+  TGHorizontalFrame *fFrameType = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
+  fLabel = new TGLabel(fFrameType, "Type*");
+  fLabel->SetTextJustify(36);
+  fLabel->SetMargins(0,0,0,0);
+  fLabel->SetWrapLength(-1);
+  fFrameType->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+
+  fCombo = new TGComboBox(fFrameType, -1, kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
+  fCombo->AddEntry("Single Track Selection", AliEveTRDTrackList::kSingleTrackSelect);
+  fCombo->AddEntry("Pair Tracks Selection", AliEveTRDTrackList::kCorrelTrackSelect);
+  fCombo->AddEntry("Single Track Analyse", AliEveTRDTrackList::kSingleTrackAnalyse);
+  fCombo->AddEntry("Single Track Histo", AliEveTRDTrackList::kSingleTrackHisto);
+  fCombo->AddEntry("Pair Tracks Analyse", AliEveTRDTrackList::kCorrelTrackAnalyse);
+  fCombo->AddEntry("Pair Tracks Histo", AliEveTRDTrackList::kCorrelTrackHisto);
+  fCombo->Select(-1);
+  fCombo->Resize(width, fText->GetDefaultHeight());
+  fFrameType->AddFrame(fCombo, new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2));
+
+
+  // horizontal frame
+  TGHorizontalFrame *fFrameText = new TGHorizontalFrame(this,10,10,kHorizontalFrame);
+  fLabel = new TGLabel(fFrameText, "(*) Mandatory fields");
+  fLabel->SetTextJustify(36);
+  fLabel->SetMargins(0,0,0,0);
+  fLabel->SetWrapLength(-1);
+  fFrameText->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+
+  // put things together  
+  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));
+
+  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");
+  SetMWMHints(kMWMDecorAll,
+              kMWMFuncAll,
+              kMWMInputModeless);
+  MapSubwindows();
+
+  Resize(GetDefaultSize());
+  MapWindow();
+
+  // Do the linking
+  fCombo->Connect("Selected(Int_t)", "AliEveTRDMacroWizzard", this, "Create(Int_t)");
+}  
+
+const Char_t *fIncludes = 
+"#if !defined(__CINT__) || defined(__MAKECINT__)\n"
+"#include <TROOT.h>\n"
+"#include <TH1.h>\n"
+"#include <TRD/AliTRDgeometry.h>\n"
+"#include <TRD/AliTRDcluster.h>\n"
+"#include <TRD/AliTRDseedV1.h>\n"
+"#include <TRD/AliTRDtrackV1.h>\n"
+"#endif\n";
+
+const Char_t *fMacroTemplate[7] = {
+""
+,"  if (!track) return kFALSE;\n"
+
+,"  n = 0;\n"
+"  r=0x0;\n"
+"  if (!track) return;\n"
+
+,"  if (!track) return 0x0;\n"
+"  TH1* h = 0x0;\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"
+
+,"  if (!track) return kFALSE;\n"
+"  if (!track2) return kFALSE;\n"
+
+,"  n = 0;\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"
+"  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"
+};
+//______________________________________________________
+void AliEveTRDMacroWizzard::Create(Int_t typ)
+{
+  const Char_t *name = fText->GetText();
+  if(strcmp(name,"")==0){
+    AliInfo("Please specify a name for your macro.");
+    fCombo->Select(-1);
+    return;
   }
 
-  ftlMacroSelList->SortByName(); 
+  FILE* fp = 0x0;
+  if(!(fp = fopen(Form("%s.C", name), "wt"))){
+    AliInfo("Couldn't create macro file.");
+    fCombo->Select(-1);
+    return;
+  }
 
-  // Select, what has been selected before
-  for (Int_t i = 0; i < fM->fMacroSelList->GetEntries(); i++)
-  {
-    ftlMacroSelList->Select(i, fM->MacroSelListIsSelected(i));
+  TGText *comment = fTextEdit->GetText();
+  Char_t *line = 0x0; Int_t iline = 0;
+  while((line = comment->GetLine(TGLongPosition(0,iline++), 200))) fprintf(fp, "// %s\n", line);
+
+  fprintf(fp, "\n%s\n", fIncludes);
+
+  switch(typ){
+  case AliEveTRDTrackList::kSingleTrackSelect:
+    fprintf(fp, "Bool_t %s(const AliTRDtrackV1 *track)\n", name);
+    break;
+  case AliEveTRDTrackList::kCorrelTrackSelect:
+    fprintf(fp, "Bool_t %s(const AliTRDtrackV1 *track, const AliTRDtrackV1 *track2)\n", name);
+    break;
+  case AliEveTRDTrackList::kSingleTrackAnalyse:
+    fprintf(fp, "void %s(const AliTRDtrackV1 *track, Double_t*& r, Int_t& n)\n", name);
+    break;
+  case AliEveTRDTrackList::kSingleTrackHisto:
+    fprintf(fp, "TH1* %s(const AliTRDtrackV1 *track)\n", name);
+    break;
+  case AliEveTRDTrackList::kCorrelTrackAnalyse:
+    fprintf(fp, "void %s(const AliTRDtrackV1 *track, const AliTRDtrackV1 *track2, Double_t*& r, Int_t& n)\n", name);
+    break;
+  case AliEveTRDTrackList::kCorrelTrackHisto:
+    fprintf(fp, "TH1* %s(const AliTRDtrackV1 *track, const AliTRDtrackV1 *track2)\n", name);
+    break;
+  default:
+    AliInfo(Form("Unknown typ[%d]", typ));
+    fclose(fp);
+    gSystem->Exec(Form("rm -f %s.C", name));
+    fCombo->Select(-1);
+    return;
   }
-}
+  
+  fprintf(fp, "{\n%s\n", fMacroTemplate[typ]);
+  fprintf(fp, "// add your own code here\n\n\n}\n");
+  fclose(fp);
 
-//______________________________________________________
-void AliEveTRDTrackListEditor::UpdateMacroListSelection(Int_t ind)
-{
-  // Toggle selected item
-  fM->SetMacroListSelection(ind, !fM->MacroListIsSelected(ind));
+  Emit("Create(Int_t)", typ);
+  Create((Char_t*)name);
+  CloseWindow();
 }
 
 //______________________________________________________
-void AliEveTRDTrackListEditor::UpdateMacroSelListSelection(Int_t ind)
+void AliEveTRDMacroWizzard::Create(Char_t *name)
 {
-  // Toggle selected item
-  fM->SetMacroSelListSelection(ind, !fM->MacroSelListIsSelected(ind));
+  Emit("Create(Char_t*)", Form("%s.C", name));
 }