]>
Commit | Line | Data |
---|---|---|
c1869a7c | 1 | // Author: Benjamin Hess 29/01/2010 |
2670605d | 2 | |
3 | /************************************************************************* | |
c1869a7c | 4 | * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess. * |
2670605d | 5 | * All rights reserved. * |
6 | *************************************************************************/ | |
16db6074 | 7 | |
2ef0687e | 8 | #ifndef AliEveTRDTrackList_H |
9 | #define AliEveTRDTrackList_H | |
10 | ||
16db6074 | 11 | ////////////////////////////////////////////////////////////////////////// |
12 | // // | |
13 | // AliEveTRDTrackList // | |
14 | // // | |
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 // | |
ce239ca6 | 21 | // RemoveSelectedMacros(...). This function takes an iterator of the // |
38a30030 | 22 | // list of macros that are to be removed. // |
ce239ca6 | 23 | // An entry looks like: // |
38a30030 | 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(...). // | |
2670605d | 29 | // With ApplySTSelectionMacros(...) or ApplyProcessMacros(...) // |
16db6074 | 30 | // respectively you can apply the macros to the track list via // |
38a30030 | 31 | // iterators (same style like for RemoveSelectedMacros(...)(cf. above)).// |
16db6074 | 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. // | |
40 | // // | |
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*); // | |
45 | // // | |
46 | // Process macros: // | |
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*); // | |
52 | // // | |
38a30030 | 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! // | |
16db6074 | 59 | ////////////////////////////////////////////////////////////////////////// |
60 | ||
61 | ||
2ef0687e | 62 | #include <TEveElement.h> |
ecbbe371 | 63 | #include <EveDet/AliEveTRDData.h> |
2ef0687e | 64 | |
caaf90d2 | 65 | #define SIGNATURE_ERROR -1 |
66 | #define NOT_EXIST_ERROR -2 | |
db16b708 | 67 | #define ERROR -3 |
caaf90d2 | 68 | #define WARNING 0 |
69 | #define SUCCESS 1 | |
70 | ||
4f6473f6 | 71 | #define MAX_MACRO_NAME_LENGTH 100 |
72 | #define MAX_MACRO_PATH_LENGTH 300 | |
e007877e | 73 | #define MAX_APPLY_COMMAND_LENGTH 120 |
4f6473f6 | 74 | |
8bdeb570 | 75 | #define UNSETBIT(n,i) ((n) &= ~BIT(i)) |
76 | ||
caaf90d2 | 77 | class AliEveTRDTrack; |
38a30030 | 78 | class AliEveTRDTrackListEditor; |
8bdeb570 | 79 | class AliTRDReconstructor; |
caaf90d2 | 80 | class TFile; |
81 | class TFunction; | |
c413e8d4 | 82 | class TH1; |
83 | class TObjString; | |
caaf90d2 | 84 | class TList; |
8bdeb570 | 85 | class TMap; |
38a30030 | 86 | class TPair; |
caaf90d2 | 87 | class TTreeSRedirector; |
2ef0687e | 88 | |
89 | class AliEveTRDTrackList: public TEveElementList | |
90 | { | |
91 | friend class AliEveTRDTrackListEditor; | |
92 | ||
93 | public: | |
38a30030 | 94 | |
4f6473f6 | 95 | enum |
96 | { | |
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 | |
105 | }; | |
106 | ||
2670605d | 107 | // Macro types |
8bdeb570 | 108 | enum AliEveTRDTrackListMacroType |
109 | { | |
e007877e | 110 | kUnknown = 0, |
111 | kSingleTrackSelect = 1, | |
112 | kSingleTrackAnalyse = 2, | |
113 | kSingleTrackHisto = 3, | |
114 | kCorrelTrackSelect = 4, | |
115 | kCorrelTrackAnalyse = 5, | |
116 | kCorrelTrackHisto = 6 | |
8bdeb570 | 117 | }; |
e007877e | 118 | |
8bdeb570 | 119 | |
2ef0687e | 120 | AliEveTRDTrackList(const Text_t* n = "AliEveTRDTrackList", const Text_t* t = "", Bool_t doColor = kFALSE); |
caaf90d2 | 121 | virtual ~AliEveTRDTrackList(); |
122 | ||
38a30030 | 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); | |
db16b708 | 125 | virtual void AddStandardContent(); |
2670605d | 126 | Bool_t ApplyProcessMacros(const TList* selIterator, const TList* procIterator); |
127 | void ApplySTSelectionMacros(const TList* iterator); | |
16db6074 | 128 | |
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. | |
2670605d | 135 | // Note: AddMacro(Fast) will update the internal list and RemoveProcess(/Selection)Macros respectively. |
38a30030 | 136 | AliEveTRDTrackListMacroType GetMacroType(const Char_t* name, Bool_t UseList = kTRUE) const; |
137 | void RemoveSelectedMacros(const TList* iterator); | |
4f6473f6 | 138 | |
139 | protected: | |
38a30030 | 140 | AliEveTRDTrackListEditor* fEditor; // Pointer to the editor of this list |
141 | ||
8bdeb570 | 142 | TList* fDataFromMacroList; // List of macros that currently have data for histograms |
143 | ||
38a30030 | 144 | TMap* fMacroList; // Stores the names, paths, types and commands of all macros added to this list |
4f6473f6 | 145 | |
146 | TTreeSRedirector *fDataTree; // Tree containing data for histograms | |
147 | ||
8bdeb570 | 148 | Int_t fHistoDataSelected; // Stores the selection for the data of the histograms |
38a30030 | 149 | Int_t fMacroListSelected; // Stores the selection of the macro list |
4f6473f6 | 150 | |
8bdeb570 | 151 | Char_t fSelectedTab; // Holds the index of the selected tab |
152 | UChar_t fSelectedStyle; // Holds the selected track style | |
4f6473f6 | 153 | |
2670605d | 154 | Char_t GetSelectedTab() const // Gets the selected tab |
4f6473f6 | 155 | { return fSelectedTab; } |
156 | ||
2670605d | 157 | UChar_t GetSelectedTrackStyle() const // Gets the selected track style |
ecbbe371 | 158 | { return fSelectedStyle; } |
8bdeb570 | 159 | |
2670605d | 160 | Bool_t HistoDataIsSelected(Int_t index) const // Is entry in list selected? |
4f6473f6 | 161 | { return TESTBIT(fHistoDataSelected, index); } |
162 | ||
2670605d | 163 | Bool_t MacroListIsSelected(Int_t index) const // Is entry in list selected? |
4f6473f6 | 164 | { return TESTBIT(fMacroListSelected, index); } |
165 | ||
4f6473f6 | 166 | void SetHistoDataSelection(Int_t index, Bool_t set) // Set selection of entry in list |
8bdeb570 | 167 | { if (set) SETBIT(fHistoDataSelected, index); else UNSETBIT(fHistoDataSelected, index); } |
4f6473f6 | 168 | |
169 | void SetMacroListSelection(Int_t index, Bool_t set) // Set selection of entry in list | |
8bdeb570 | 170 | { if (set) SETBIT(fMacroListSelected, index); else UNSETBIT(fMacroListSelected, index); } |
4f6473f6 | 171 | |
8bdeb570 | 172 | void SetSelectedTab(Int_t index) // Sets the selected tab |
4f6473f6 | 173 | { fSelectedTab = (Char_t)index; } |
174 | ||
8bdeb570 | 175 | void SetSelectedTrackStyle(UChar_t index) // Sets the selected track style |
ecbbe371 | 176 | { fSelectedStyle = index; } |
177 | ||
38a30030 | 178 | void UpdateTrackStyle(AliEveTRDTrack::AliEveTRDTrackState s, UChar_t ss = 0); |
ecbbe371 | 179 | |
2ef0687e | 180 | private: |
181 | AliEveTRDTrackList(const AliEveTRDTrackList&); // Not implemented | |
caaf90d2 | 182 | AliEveTRDTrackList& operator=(const AliEveTRDTrackList&); // Not implemented |
2ef0687e | 183 | |
3f797131 | 184 | ClassDef(AliEveTRDTrackList, 0); // Class containing a list of tracks |
2ef0687e | 185 | }; |
186 | ||
38a30030 | 187 | ////////////////////////////////////////////////////////////////////////// |
188 | // // | |
189 | // TMacroData // | |
190 | // // | |
191 | // Stores macro data which will be used by AliEveTRDTrackList. // | |
192 | // // | |
193 | ////////////////////////////////////////////////////////////////////////// | |
194 | ||
195 | class TMacroData: public TObject | |
196 | { | |
197 | public: | |
198 | TMacroData(const Char_t* name, const Char_t* path, // Constructor | |
199 | AliEveTRDTrackList::AliEveTRDTrackListMacroType type = AliEveTRDTrackList::kUnknown): | |
200 | TObject(), | |
201 | fIsSelected(kFALSE), | |
202 | fType(AliEveTRDTrackList::kUnknown) | |
203 | { | |
204 | // The command is automatically set via type. | |
205 | ||
206 | SetName(name); | |
207 | SetPath(path); | |
208 | SetType(type); | |
209 | ||
210 | // Register the commands for each type here | |
211 | switch (type) | |
212 | { | |
213 | case AliEveTRDTrackList::kSingleTrackSelect: | |
214 | case AliEveTRDTrackList::kSingleTrackHisto: | |
215 | SetCmd(Form("%s(automaticTrackV1_1);", name)); | |
216 | break; | |
217 | ||
218 | case AliEveTRDTrackList::kSingleTrackAnalyse: | |
219 | SetCmd(Form("%s(automaticTrackV1_1, results, n);", name)); | |
220 | break; | |
221 | ||
222 | case AliEveTRDTrackList::kCorrelTrackSelect: | |
223 | case AliEveTRDTrackList::kCorrelTrackHisto: | |
224 | SetCmd(Form("%s(automaticTrackV1_1, automaticTrackV1_2);", name)); | |
225 | break; | |
226 | ||
227 | case AliEveTRDTrackList::kCorrelTrackAnalyse: | |
228 | SetCmd(Form("%s(automaticTrackV1_1, automaticTrackV1_2, results, n);", name)); | |
229 | break; | |
230 | ||
231 | default: | |
232 | SetCmd(""); | |
233 | break; | |
234 | } | |
235 | } | |
236 | ||
237 | const Char_t* GetCmd() const // Returns the command that will be used to call this macro | |
238 | { return fCmd; } | |
239 | const Char_t* GetName() const // Returns the macro name (without ".C") | |
240 | { return fName; } | |
241 | const Char_t* GetPath() const // Returns the path of the macro | |
242 | { return fPath; } | |
243 | AliEveTRDTrackList::AliEveTRDTrackListMacroType GetType() const // Returns the type of the macro | |
244 | { return fType; } | |
245 | Bool_t IsProcessMacro() const // Returns whether the macro is a process type macro or not | |
246 | { | |
247 | switch (fType) | |
248 | { | |
249 | case AliEveTRDTrackList::kSingleTrackAnalyse: | |
250 | case AliEveTRDTrackList::kSingleTrackHisto: | |
251 | case AliEveTRDTrackList::kCorrelTrackAnalyse: | |
252 | case AliEveTRDTrackList::kCorrelTrackHisto: | |
253 | return kTRUE; | |
254 | break; | |
255 | default: | |
256 | break; | |
257 | } | |
258 | ||
259 | return kFALSE; | |
260 | } | |
261 | ||
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 | |
265 | { | |
266 | switch (fType) | |
267 | { | |
268 | case AliEveTRDTrackList::kSingleTrackSelect: | |
269 | case AliEveTRDTrackList::kCorrelTrackSelect: | |
270 | return kTRUE; | |
271 | break; | |
272 | default: | |
273 | break; | |
274 | } | |
275 | ||
276 | return kFALSE; | |
277 | } | |
278 | ||
279 | void SetCmd(const char* newCmd) // Sets the command that will be used to call this macro | |
280 | { | |
281 | memset(fCmd, '\0', sizeof(Char_t) * MAX_APPLY_COMMAND_LENGTH); | |
90ae0503 | 282 | snprintf(fCmd, MAX_APPLY_COMMAND_LENGTH, "%s", newCmd); |
38a30030 | 283 | } |
284 | void SetName(const char* newName) // Sets the macro name (please use without ".C") | |
285 | { | |
286 | memset(fName, '\0', sizeof(Char_t) * MAX_MACRO_NAME_LENGTH); | |
90ae0503 | 287 | snprintf(fName, MAX_MACRO_NAME_LENGTH, "%s", newName); |
38a30030 | 288 | } |
289 | void SetPath(const char* newPath) // Sets the path of the macro | |
290 | { | |
291 | memset(fPath, '\0', sizeof(Char_t) * MAX_MACRO_PATH_LENGTH); | |
90ae0503 | 292 | snprintf(fPath, MAX_MACRO_PATH_LENGTH, "%s", newPath); |
38a30030 | 293 | } |
294 | void SetSelected(Bool_t selection) // Sets whether the macro is selected or not | |
295 | { | |
296 | fIsSelected = selection; | |
297 | } | |
298 | void SetType(AliEveTRDTrackList::AliEveTRDTrackListMacroType newType) // Sets the type of the macro | |
299 | { | |
300 | fType = newType; | |
301 | } | |
302 | ||
303 | private: | |
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 | |
309 | }; | |
310 | ||
2ef0687e | 311 | #endif |