]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveListAnalyser.h
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveListAnalyser.h
index 52addfeab49f0c9be2d7e17d5fcb721c83765f79..0146f7668d25a39155338482df8898250d4c83ad 100644 (file)
@@ -1,33 +1,33 @@
-// Author: Benjamin Hess   06/11/2009
+// Author: Benjamin Hess   29/01/2010
 
 /*************************************************************************
- * Copyright (C) 2009, Alexandru Bercuci, Benjamin Hess.                 *
+ * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess.            *
  * All rights reserved.                                                  *
  *************************************************************************/
 
-#ifndef AliEveListAnalyser_H
-#define AliEveListAnalyser_H
-
-// TODO: DOCUMENTATION
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
-// AliEveTRDTAnalyseObjectList                                          //
+// AliEveListAnalyser                                                   //
 //                                                                      //
-// An AliEveListAnalyser is, in principal, a TEveElementList    //
-// with some sophisticated features. You can add macros to this list,   //
-// which then can be applied to the list of tracks (these tracks can    //
-// be added to the list in the same way as for the TEveElementList).    //
+// An AliEveListAnalyser is, in principal, a TEveElementList with some  //
+// sophisticated features. You can add macros to this list, which then  //
+// can be applied to the list of analysis objects (these objects can be //
+// added to the list in the same way as for the TEveElementList, but    //
+// also "by clicking" (cf. AliEveListAnaLyserEditor)).                  //
 // In general, please use AddMacro(...) for this purpose.               //
 // Macros that are no longer needed can be removed from the list via    //
-// RemoveSelectedMacros(...).This function takes an iterator of the     //
+// RemoveSelectedMacros(...). This function takes an iterator of the    //
 // list of macros that are to be removed.                               //
-// be removed. An entry looks like:                                     //
+// An entry looks like:                                                 //
 // The data for each macro consists of path, name, type and the command //
 // that will be used to apply the macro. This stuff is stored in a map  //
 // which takes the macro name for the key and the above mentioned data  //
 // in a TGeneralMacroData-object for the value.                         //
 // You can get the macro type via GetMacroType(...).                    //
-// With ApplySTSelectionMacros(...) or ApplyProcessMacros(...)          //
+// To find the type of objects the macro will deal with (corresponds to //
+// "YourObjectType" in the examples below) please use                   //
+// GetMacroObjectType(...).                                             //
+// With ApplySOSelectionMacros(...) or ApplyProcessMacros(...)          //
 // respectively you can apply the macros to the track list via          //
 // iterators (same style like for RemoveSelectedMacros(...)(cf. above)).//
 // Selection macros (de-)select macros according to a selection rule    //
 //                                                                      //
 // Currently, the following macro types are supported:                  //
 // Selection macros:                                                    //
-// Bool_t YourMacro(const YourObjectType*);                              //
-// Bool_t YourMacro(const YourObjectType*, const YourObjectType*);        //
+// Bool_t YourMacro(const YourObjectType*);                             //
+// Bool_t YourMacro(const YourObjectType*, const YourObjectType2*);     //
 //                                                                      //
 // Process macros:                                                      //
-// void YourMacro(const YourObjectType*, Double_t*&, Int_t&);            //
-// void YourMacro(const YourObjectType*, const YourObjectType*,           //
+// void YourMacro(const YourObjectType*, Double_t*&, Int_t&);           //
+// void YourMacro(const YourObjectType*, const YourObjectType2*,        //
 //                Double_t*&, Int_t&);                                  //
-// TH1* YourMacro(const YourObjectType*);                                //
-// TH1* YourMacro(const YourObjectType*, const YourObjectType*);          //
+// TH1* YourMacro(const YourObjectType*);                               //
+// TH1* YourMacro(const YourObjectType*, const YourObjectType2*);       //
 //                                                                      //
 // The macros which take 2 tracks are applied to all track pairs        //
 // (whereby BOTH tracks of the pair have to be selected by the single   //
 // process macros that process only a single track!                     //
 //////////////////////////////////////////////////////////////////////////
 
+#ifndef AliEveListAnalyser_H
+#define AliEveListAnalyser_H
 
-#include <TEveElement.h>
 #include <TClass.h>
-#include <EveDet/AliEveTRDData.h>
+#include <TEveElement.h>
+#include <AliEveTRDData.h>
 
 #define SIGNATURE_ERROR           -1
 #define NOT_EXIST_ERROR           -2
 class AliEveListAnalyserEditor;
 class AliTRDReconstructor;
 class TClass;
+class TEveManager;
+class TEveSelection;
 class TFile;
 class TFunction;
 class TH1;
-class TObjString;
 class TList;
 class TMap;
+class TObjString;
 class TPair;
 class TString;
 class TTreeSRedirector;
 
-// TODO - NEW
-class TGLViewer;
-class TEveManager;
-
 class AliEveListAnalyser: public TEveElementList
 {
   friend class AliEveListAnalyserEditor;
@@ -130,13 +130,17 @@ public:
   virtual ~AliEveListAnalyser();
 
   Int_t AddMacro(const Char_t* path, const Char_t* name, Bool_t forceReload = kFALSE);                      
-  Bool_t AddMacroFast(const Char_t* path, const Char_t* name, AliEveListAnalyserMacroType type, TClass* objectType);     
-  void AddObjectToList(Int_t pointId);   
-  virtual void AddStandardContent();                           
+  Bool_t AddMacroFast(const Char_t* path, const Char_t* name, AliEveListAnalyserMacroType type, TClass* objectType, TClass* objectType2);     
+  Int_t AddPrimSelectedObject(TEveElement* el);
+  //void AddPrimSelectedObjects();
+  void AddSecSelectedSingleObjectToList(Int_t pointId);  
+  virtual void AddStandardContent();                             
   Bool_t ApplyProcessMacros(const TList* selIterator, const TList* procIterator);               
-  void ApplySTSelectionMacros(const TList* iterator);
+  void ApplySOSelectionMacros(const TList* iterator);
   Bool_t GetConnected()             // Returns whether "adding objects by clicking" is enabled or not.
     { return fConnected;  };
+  TClass* GetMacroObjectType(const Char_t* name, Int_t argNum = 1) const;
+
   // Returns the type of the macro of the corresponding entry (i.e. "macro.C (Path: path)"). 
   // If you have only the name and the path, you can simply use MakeMacroEntry.
   // If "UseList" is kTRUE, the type will be looked up in the internal list (very fast). But if this list
@@ -145,9 +149,10 @@ public:
   // predictable, but normally will be kUnknown.
   // "objectType" gives the class/"type of object" of the pointer(s), the macro accepts as a parametre.
   // Note: AddMacro(Fast) will update the internal list and RemoveProcess(/Selection)Macros respectively.
-  AliEveListAnalyserMacroType GetMacroType(const Char_t* name, const Char_t* objectType = "TObject", Bool_t UseList = kTRUE) const; 
+  AliEveListAnalyserMacroType GetMacroType(const Char_t* name, const Char_t* objectType = "TObject", 
+                                           const Char_t* objectType2 = "TObject", Bool_t UseList = kTRUE) const; 
   
-  TClass* GetMacroObjectType(const Char_t* name) const;
+  //void RemovePrimSelectedObjects();
   void RemoveSelectedMacros(const TList* iterator);
   void ResetObjectList();
   Bool_t StartAddingObjects();
@@ -207,9 +212,10 @@ class TGeneralMacroData: public TObject
 public:
   TGeneralMacroData(const Char_t* name, const Char_t* path,                                                        // Constructor
              AliEveListAnalyser::AliEveListAnalyserMacroType type = AliEveListAnalyser::kUnknown,
-             TClass* objectType = TObject::Class()):
+             TClass* objectType = TObject::Class(), TClass* objectType2 = TObject::Class()):
     TObject(),
     fObjectType(0x0),
+    fObjectType2(0x0),
     fIsSelected(kFALSE),
     fType(AliEveListAnalyser::kUnknown)
     
@@ -218,6 +224,7 @@ public:
 
     SetName(name);
     SetObjectType(objectType);
+    SetObjectType2(objectType2);
     SetPath(path);
     SetType(type);
 
@@ -237,11 +244,11 @@ public:
 
       case AliEveListAnalyser::kCorrelObjectSelect:
       case AliEveListAnalyser::kCorrelObjectHisto:
-        SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2);", name, fObjectType->GetName(), fObjectType->GetName()));
+        SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2);", name, fObjectType->GetName(), fObjectType2->GetName()));
         break;
 
       case AliEveListAnalyser::kCorrelObjectAnalyse:
-        SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2, results, n);", name, fObjectType->GetName(), fObjectType->GetName()));
+        SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2, results, n);", name, fObjectType->GetName(), fObjectType2->GetName()));
         break;
 
       default:
@@ -254,13 +261,15 @@ public:
     { return fCmd;  }
   const Char_t* GetName() const               // Returns the macro name (without ".C")
     { return fName;  }
-  TClass* GetObjectType() const               // Returns the object type of the macro parameter
+  TClass* GetObjectType() const               // Returns the object type of the macro parameter (1st pointer)
     { return fObjectType;  }
+  TClass* GetObjectType2() const              // Returns the object type of the macro parameter (2nd pointer)
+    { return fObjectType2;  }
   const Char_t* GetPath() const               // Returns the path of the macro
     { return fPath;  }
   AliEveListAnalyser::AliEveListAnalyserMacroType GetType() const   // Returns the type of the macro
     { return fType;  }
-  Bool_t IsProcessMacro() const             // Returns whether the macro is a process type macro or not
+  Bool_t IsProcessMacro() const               // Returns whether the macro is a process type macro or not
   {
     switch (fType)
     {
@@ -294,26 +303,30 @@ public:
     return kFALSE;
   }
 
-  void SetCmd(const char* newCmd)             // Sets the command that will be used to call this macro
+  void SetCmd(const char* newCmd)               // Sets the command that will be used to call this macro
   { 
     memset(fCmd, '\0', sizeof(Char_t) * MAX_APPLY_COMMAND_LENGTH);
-    sprintf(fCmd, "%s", newCmd);
+    snprintf(fCmd, MAX_APPLY_COMMAND_LENGTH, "%s", newCmd);
   }
-  void SetName(const char* newName)           // Sets the macro name (please use without ".C")
+  void SetName(const char* newName)             // Sets the macro name (please use without ".C")
   { 
     memset(fName, '\0', sizeof(Char_t) * MAX_MACRO_NAME_LENGTH);
-    sprintf(fName, "%s", newName);
+    snprintf(fName, MAX_MACRO_NAME_LENGTH, "%s", newName);
   }
-  void SetObjectType(TClass* newObjectType)     // Sets the object type of the macro parameter
+  void SetObjectType(TClass* newObjectType)     // Sets the object type of the macro parameter (1st pointer)
   { 
     fObjectType = newObjectType;
   }
-  void SetPath(const char* newPath)           // Sets the path of the macro
+  void SetObjectType2(TClass* newObjectType2)   // Sets the object type of the macro parameter (2nd pointer)
+  { 
+    fObjectType2 = newObjectType2;
+  }
+  void SetPath(const char* newPath)             // Sets the path of the macro
   { 
     memset(fPath, '\0', sizeof(Char_t) * MAX_MACRO_PATH_LENGTH);
-    sprintf(fPath, "%s", newPath);
+    snprintf(fPath, MAX_MACRO_PATH_LENGTH, "%s", newPath);
   }
-  void SetSelected(Bool_t selection)          // Sets whether the macro is selected or not
+  void SetSelected(Bool_t selection)            // Sets whether the macro is selected or not
   {
     fIsSelected = selection;
   }
@@ -328,7 +341,8 @@ private:
 
   Char_t fCmd[MAX_APPLY_COMMAND_LENGTH];                  // Command that will be used to call this macro
   Char_t fName[MAX_MACRO_NAME_LENGTH];                    // Macro name (without ".C"!)
-  TClass* fObjectType;                                    // Type of object of the macro parameter
+  TClass* fObjectType;                                    // Type of object of the macro parameter (1st pointer)
+  TClass* fObjectType2;                                   // Type of object of the macro parameter (2nd pointer)
   Char_t fPath[MAX_MACRO_PATH_LENGTH];                    // Path of the macro
   Bool_t fIsSelected;                                     // Is macro selected (e.g. in the editor's list)?
   AliEveListAnalyser::AliEveListAnalyserMacroType fType;  // Type of the macro