1 // Author: Benjamin Hess 29/01/2010
3 /*************************************************************************
4 * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess. *
5 * All rights reserved. *
6 *************************************************************************/
8 #ifndef AliEveTRDTrackList_H
9 #define AliEveTRDTrackList_H
11 //////////////////////////////////////////////////////////////////////////
13 // AliEveTRDTrackList //
15 // An AliEveTRDTrackList is, in principal, a TEveElementList with some //
16 // sophisticated features. You can add macros to this list, which then //
17 // can be applied to the list of tracks (these tracks can be added to //
18 // the list in the same way as for the TEveElementList). In general, //
19 // please use AddMacro(...) for this purpose. //
20 // Macros that are no longer needed can be removed from the list via //
21 // RemoveSelectedMacros(...). This function takes an iterator of the //
22 // list of macros that are to be removed. //
23 // An entry looks like: //
24 // The data for each macro consists of path, name, type and the command //
25 // that will be used to apply the macro. This stuff is stored in a map //
26 // which takes the macro name for the key and the above mentioned data //
27 // in a TMacroData-object for the value. //
28 // You can get the macro type via GetMacroType(...). //
29 // With ApplySTSelectionMacros(...) or ApplyProcessMacros(...) //
30 // respectively you can apply the macros to the track list via //
31 // iterators (same style like for RemoveSelectedMacros(...)(cf. above)).//
32 // Selection macros (de-)select macros according to a selection rule //
33 // by setting the rnr-state of the tracks. //
34 // If multiple selection macros are applied, a track is selected, if //
35 // all selection macros select the track. //
36 // Process macros create data or histograms, which will be stored in //
37 // a temporary file. The editor of this class will access this file //
38 // and draw all the stuff within it's DrawHistos() function. The file //
39 // will be deleted by the destructor. //
41 // Currently, the following macro types are supported: //
42 // Selection macros: //
43 // Bool_t YourMacro(const AliTRDtrackV1*); //
44 // Bool_t YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*); //
47 // void YourMacro(const AliTRDtrackV1*, Double_t*&, Int_t&); //
48 // void YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*, //
49 // Double_t*&, Int_t&); //
50 // TH1* YourMacro(const AliTRDtrackV1*); //
51 // TH1* YourMacro(const AliTRDtrackV1*, const AliTRDtrackV1*); //
53 // The macros which take 2 tracks are applied to all track pairs //
54 // (whereby BOTH tracks of the pair have to be selected by the single //
55 // track selection macros and have to be unequal, otherwise they will //
56 // be skipped) that have been selected by ALL correlated tracks //
57 // selection macros. The selection macros with 2 tracks do NOT affect //
58 // process macros that process only a single track! //
59 //////////////////////////////////////////////////////////////////////////
62 #include <TEveElement.h>
63 #include <EveDet/AliEveTRDData.h>
65 #define SIGNATURE_ERROR -1
66 #define NOT_EXIST_ERROR -2
71 #define MAX_MACRO_NAME_LENGTH 100
72 #define MAX_MACRO_PATH_LENGTH 300
73 #define MAX_APPLY_COMMAND_LENGTH 120
75 #define UNSETBIT(n,i) ((n) &= ~BIT(i))
78 class AliEveTRDTrackListEditor;
79 class AliTRDReconstructor;
87 class TTreeSRedirector;
89 class AliEveTRDTrackList: public TEveElementList
91 friend class AliEveTRDTrackListEditor;
97 // Maximum length (number of characters) for a macro name:
98 fkMaxMacroNameLength = MAX_MACRO_NAME_LENGTH,
99 // Maximum length (number of characters) for a macro path:
100 fkMaxMacroPathLength = MAX_MACRO_PATH_LENGTH,
101 // Maximum length (number of characters) for a macro pathname:
102 fkMaxMacroPathNameLength = MAX_MACRO_NAME_LENGTH + MAX_MACRO_PATH_LENGTH,
103 // Maximum length (number of characters) for "apply macro" commands in addition to the length of the name, path...
104 fkMaxApplyCommandLength = MAX_APPLY_COMMAND_LENGTH
108 enum AliEveTRDTrackListMacroType
111 kSingleTrackSelect = 1,
112 kSingleTrackAnalyse = 2,
113 kSingleTrackHisto = 3,
114 kCorrelTrackSelect = 4,
115 kCorrelTrackAnalyse = 5,
116 kCorrelTrackHisto = 6
120 AliEveTRDTrackList(const Text_t* n = "AliEveTRDTrackList", const Text_t* t = "", Bool_t doColor = kFALSE);
121 virtual ~AliEveTRDTrackList();
123 Int_t AddMacro(const Char_t* path, const Char_t* name, Bool_t forceReload = kFALSE);
124 Bool_t AddMacroFast(const Char_t* path, const Char_t* name, AliEveTRDTrackListMacroType type);
125 virtual void AddStandardContent();
126 Bool_t ApplyProcessMacros(const TList* selIterator, const TList* procIterator);
127 void ApplySTSelectionMacros(const TList* iterator);
129 // Returns the type of the macro of the corresponding entry (i.e. "macro.C (Path: path)").
130 // If you have only the name and the path, you can simply use MakeMacroEntry.
131 // If "UseList" is kTRUE, the type will be looked up in the internal list (very fast). But if this list
132 // does not exist, you have to use kFALSE for this parameter. Then the type will be determined by the
133 // prototype! NOTE: It is assumed that the macro has been compiled! If not, the return value is not
134 // predictable, but normally will be kUnknown.
135 // Note: AddMacro(Fast) will update the internal list and RemoveProcess(/Selection)Macros respectively.
136 AliEveTRDTrackListMacroType GetMacroType(const Char_t* name, Bool_t UseList = kTRUE) const;
137 void RemoveSelectedMacros(const TList* iterator);
140 AliEveTRDTrackListEditor* fEditor; // Pointer to the editor of this list
142 TList* fDataFromMacroList; // List of macros that currently have data for histograms
144 TMap* fMacroList; // Stores the names, paths, types and commands of all macros added to this list
146 TTreeSRedirector *fDataTree; // Tree containing data for histograms
148 Int_t fHistoDataSelected; // Stores the selection for the data of the histograms
149 Int_t fMacroListSelected; // Stores the selection of the macro list
151 Char_t fSelectedTab; // Holds the index of the selected tab
152 UChar_t fSelectedStyle; // Holds the selected track style
154 Char_t GetSelectedTab() const // Gets the selected tab
155 { return fSelectedTab; }
157 UChar_t GetSelectedTrackStyle() const // Gets the selected track style
158 { return fSelectedStyle; }
160 Bool_t HistoDataIsSelected(Int_t index) const // Is entry in list selected?
161 { return TESTBIT(fHistoDataSelected, index); }
163 Bool_t MacroListIsSelected(Int_t index) const // Is entry in list selected?
164 { return TESTBIT(fMacroListSelected, index); }
166 void SetHistoDataSelection(Int_t index, Bool_t set) // Set selection of entry in list
167 { if (set) SETBIT(fHistoDataSelected, index); else UNSETBIT(fHistoDataSelected, index); }
169 void SetMacroListSelection(Int_t index, Bool_t set) // Set selection of entry in list
170 { if (set) SETBIT(fMacroListSelected, index); else UNSETBIT(fMacroListSelected, index); }
172 void SetSelectedTab(Int_t index) // Sets the selected tab
173 { fSelectedTab = (Char_t)index; }
175 void SetSelectedTrackStyle(UChar_t index) // Sets the selected track style
176 { fSelectedStyle = index; }
178 void UpdateTrackStyle(AliEveTRDTrack::AliEveTRDTrackState s, UChar_t ss = 0);
181 AliEveTRDTrackList(const AliEveTRDTrackList&); // Not implemented
182 AliEveTRDTrackList& operator=(const AliEveTRDTrackList&); // Not implemented
184 ClassDef(AliEveTRDTrackList, 0); // Class containing a list of tracks
187 //////////////////////////////////////////////////////////////////////////
191 // Stores macro data which will be used by AliEveTRDTrackList. //
193 //////////////////////////////////////////////////////////////////////////
195 class TMacroData: public TObject
198 TMacroData(const Char_t* name, const Char_t* path, // Constructor
199 AliEveTRDTrackList::AliEveTRDTrackListMacroType type = AliEveTRDTrackList::kUnknown):
202 fType(AliEveTRDTrackList::kUnknown)
204 // The command is automatically set via type.
210 // Register the commands for each type here
213 case AliEveTRDTrackList::kSingleTrackSelect:
214 case AliEveTRDTrackList::kSingleTrackHisto:
215 SetCmd(Form("%s(automaticTrackV1_1);", name));
218 case AliEveTRDTrackList::kSingleTrackAnalyse:
219 SetCmd(Form("%s(automaticTrackV1_1, results, n);", name));
222 case AliEveTRDTrackList::kCorrelTrackSelect:
223 case AliEveTRDTrackList::kCorrelTrackHisto:
224 SetCmd(Form("%s(automaticTrackV1_1, automaticTrackV1_2);", name));
227 case AliEveTRDTrackList::kCorrelTrackAnalyse:
228 SetCmd(Form("%s(automaticTrackV1_1, automaticTrackV1_2, results, n);", name));
237 const Char_t* GetCmd() const // Returns the command that will be used to call this macro
239 const Char_t* GetName() const // Returns the macro name (without ".C")
241 const Char_t* GetPath() const // Returns the path of the macro
243 AliEveTRDTrackList::AliEveTRDTrackListMacroType GetType() const // Returns the type of the macro
245 Bool_t IsProcessMacro() const // Returns whether the macro is a process type macro or not
249 case AliEveTRDTrackList::kSingleTrackAnalyse:
250 case AliEveTRDTrackList::kSingleTrackHisto:
251 case AliEveTRDTrackList::kCorrelTrackAnalyse:
252 case AliEveTRDTrackList::kCorrelTrackHisto:
262 Bool_t IsSelected() const // Returns whether the macro is selected or not
263 { return fIsSelected; }
264 Bool_t IsSelectionMacro() const // Returns whether the macro is a selection type macro or not
268 case AliEveTRDTrackList::kSingleTrackSelect:
269 case AliEveTRDTrackList::kCorrelTrackSelect:
279 void SetCmd(const char* newCmd) // Sets the command that will be used to call this macro
281 memset(fCmd, '\0', sizeof(Char_t) * MAX_APPLY_COMMAND_LENGTH);
282 snprintf(fCmd, MAX_APPLY_COMMAND_LENGTH, "%s", newCmd);
284 void SetName(const char* newName) // Sets the macro name (please use without ".C")
286 memset(fName, '\0', sizeof(Char_t) * MAX_MACRO_NAME_LENGTH);
287 snprintf(fName, MAX_MACRO_NAME_LENGTH, "%s", newName);
289 void SetPath(const char* newPath) // Sets the path of the macro
291 memset(fPath, '\0', sizeof(Char_t) * MAX_MACRO_PATH_LENGTH);
292 snprintf(fPath, MAX_MACRO_PATH_LENGTH, "%s", newPath);
294 void SetSelected(Bool_t selection) // Sets whether the macro is selected or not
296 fIsSelected = selection;
298 void SetType(AliEveTRDTrackList::AliEveTRDTrackListMacroType newType) // Sets the type of the macro
304 Char_t fCmd[MAX_APPLY_COMMAND_LENGTH]; // Command that will be used to call this macro
305 Char_t fName[MAX_MACRO_NAME_LENGTH]; // Macro name (without ".C"!)
306 Char_t fPath[MAX_MACRO_PATH_LENGTH]; // Path of the macro
307 Bool_t fIsSelected; // Is macro selected (e.g. in the editor's list)?
308 AliEveTRDTrackList::AliEveTRDTrackListMacroType fType; // Type of the macro