]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveListAnalyser.h
initialization for Coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveListAnalyser.h
CommitLineData
004e0620 1// Author: Benjamin Hess 29/01/2010
00dc25ef 2
3/*************************************************************************
ce239ca6 4 * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess. *
00dc25ef 5 * All rights reserved. *
6 *************************************************************************/
7
00dc25ef 8//////////////////////////////////////////////////////////////////////////
9// //
ce239ca6 10// AliEveListAnalyser //
00dc25ef 11// //
ce239ca6 12// An AliEveListAnalyser is, in principal, a TEveElementList with some //
13// sophisticated features. You can add macros to this list, which then //
14// can be applied to the list of analysis objects (these objects can be //
15// added to the list in the same way as for the TEveElementList, but //
16// also "by clicking" (cf. AliEveListAnaLyserEditor)). //
00dc25ef 17// In general, please use AddMacro(...) for this purpose. //
18// Macros that are no longer needed can be removed from the list via //
ce239ca6 19// RemoveSelectedMacros(...). This function takes an iterator of the //
00dc25ef 20// list of macros that are to be removed. //
ce239ca6 21// An entry looks like: //
00dc25ef 22// The data for each macro consists of path, name, type and the command //
23// that will be used to apply the macro. This stuff is stored in a map //
24// which takes the macro name for the key and the above mentioned data //
25// in a TGeneralMacroData-object for the value. //
26// You can get the macro type via GetMacroType(...). //
ce239ca6 27// To find the type of objects the macro will deal with (corresponds to //
28// "YourObjectType" in the examples below) please use //
29// GetMacroObjectType(...). //
004e0620 30// With ApplySOSelectionMacros(...) or ApplyProcessMacros(...) //
00dc25ef 31// respectively you can apply the macros to the track list via //
32// iterators (same style like for RemoveSelectedMacros(...)(cf. above)).//
33// Selection macros (de-)select macros according to a selection rule //
34// by setting the rnr-state of the tracks. //
35// If multiple selection macros are applied, a track is selected, if //
36// all selection macros select the track. //
37// Process macros create data or histograms, which will be stored in //
38// a temporary file. The editor of this class will access this file //
39// and draw all the stuff within it's DrawHistos() function. The file //
40// will be deleted by the destructor. //
41// //
42// Currently, the following macro types are supported: //
43// Selection macros: //
ce239ca6 44// Bool_t YourMacro(const YourObjectType*); //
004e0620 45// Bool_t YourMacro(const YourObjectType*, const YourObjectType2*); //
00dc25ef 46// //
47// Process macros: //
ce239ca6 48// void YourMacro(const YourObjectType*, Double_t*&, Int_t&); //
004e0620 49// void YourMacro(const YourObjectType*, const YourObjectType2*, //
00dc25ef 50// Double_t*&, Int_t&); //
ce239ca6 51// TH1* YourMacro(const YourObjectType*); //
004e0620 52// TH1* YourMacro(const YourObjectType*, const YourObjectType2*); //
00dc25ef 53// //
54// The macros which take 2 tracks are applied to all track pairs //
55// (whereby BOTH tracks of the pair have to be selected by the single //
56// track selection macros and have to be unequal, otherwise they will //
57// be skipped) that have been selected by ALL correlated tracks //
58// selection macros. The selection macros with 2 tracks do NOT affect //
59// process macros that process only a single track! //
60//////////////////////////////////////////////////////////////////////////
61
ce239ca6 62#ifndef AliEveListAnalyser_H
63#define AliEveListAnalyser_H
00dc25ef 64
6e420565 65#include <TClass.h>
ce239ca6 66#include <TEveElement.h>
00dc25ef 67#include <EveDet/AliEveTRDData.h>
68
69#define SIGNATURE_ERROR -1
70#define NOT_EXIST_ERROR -2
71#define ERROR -3
72#define UNKNOWN_OBJECT_TYPE_ERROR -4
73#define WARNING 0
74#define SUCCESS 1
75
76#define MAX_MACRO_NAME_LENGTH 100
77#define MAX_MACRO_PATH_LENGTH 300
78#define MAX_APPLY_COMMAND_LENGTH 120
79
80#define UNSETBIT(n,i) ((n) &= ~BIT(i))
81
3c3cfd5f 82
00dc25ef 83class AliEveListAnalyserEditor;
84class AliTRDReconstructor;
85class TClass;
ce239ca6 86class TEveManager;
87class TEveSelection;
00dc25ef 88class TFile;
89class TFunction;
90class TH1;
00dc25ef 91class TList;
92class TMap;
ce239ca6 93class TObjString;
00dc25ef 94class TPair;
95class TString;
96class TTreeSRedirector;
97
98class AliEveListAnalyser: public TEveElementList
99{
100 friend class AliEveListAnalyserEditor;
101
102public:
103
104 enum
105 {
106 // Maximum length (number of characters) for a macro name:
107 fkMaxMacroNameLength = MAX_MACRO_NAME_LENGTH,
108 // Maximum length (number of characters) for a macro path:
109 fkMaxMacroPathLength = MAX_MACRO_PATH_LENGTH,
110 // Maximum length (number of characters) for a macro pathname:
111 fkMaxMacroPathNameLength = MAX_MACRO_NAME_LENGTH + MAX_MACRO_PATH_LENGTH,
112 // Maximum length (number of characters) for "apply macro" commands in addition to the length of the name, path...
113 fkMaxApplyCommandLength = MAX_APPLY_COMMAND_LENGTH
114 };
115
116 // Macro types
117 enum AliEveListAnalyserMacroType
118 {
119 kUnknown = 0,
120 kSingleObjectSelect = 1,
121 kSingleObjectAnalyse = 2,
122 kSingleObjectHisto = 3,
123 kCorrelObjectSelect = 4,
124 kCorrelObjectAnalyse = 5,
125 kCorrelObjectHisto = 6
126 };
127
128
129 AliEveListAnalyser(const Text_t* n = "AliEveListAnalyser", const Text_t* t = "", Bool_t doColor = kFALSE);
130 virtual ~AliEveListAnalyser();
131
132 Int_t AddMacro(const Char_t* path, const Char_t* name, Bool_t forceReload = kFALSE);
004e0620 133 Bool_t AddMacroFast(const Char_t* path, const Char_t* name, AliEveListAnalyserMacroType type, TClass* objectType, TClass* objectType2);
ce239ca6 134 Int_t AddPrimSelectedObject(TEveElement* el);
135 //void AddPrimSelectedObjects();
136 void AddSecSelectedSingleObjectToList(Int_t pointId);
137 virtual void AddStandardContent();
00dc25ef 138 Bool_t ApplyProcessMacros(const TList* selIterator, const TList* procIterator);
004e0620 139 void ApplySOSelectionMacros(const TList* iterator);
3c3cfd5f 140 Bool_t GetConnected() // Returns whether "adding objects by clicking" is enabled or not.
141 { return fConnected; };
004e0620 142 TClass* GetMacroObjectType(const Char_t* name, Int_t argNum = 1) const;
ce239ca6 143
00dc25ef 144 // Returns the type of the macro of the corresponding entry (i.e. "macro.C (Path: path)").
145 // If you have only the name and the path, you can simply use MakeMacroEntry.
146 // If "UseList" is kTRUE, the type will be looked up in the internal list (very fast). But if this list
147 // does not exist, you have to use kFALSE for this parameter. Then the type will be determined by the
148 // prototype! NOTE: It is assumed that the macro has been compiled! If not, the return value is not
149 // predictable, but normally will be kUnknown.
150 // "objectType" gives the class/"type of object" of the pointer(s), the macro accepts as a parametre.
151 // Note: AddMacro(Fast) will update the internal list and RemoveProcess(/Selection)Macros respectively.
004e0620 152 AliEveListAnalyserMacroType GetMacroType(const Char_t* name, const Char_t* objectType = "TObject",
153 const Char_t* objectType2 = "TObject", Bool_t UseList = kTRUE) const;
00dc25ef 154
ce239ca6 155 //void RemovePrimSelectedObjects();
3c3cfd5f 156 void RemoveSelectedMacros(const TList* iterator);
157 void ResetObjectList();
158 Bool_t StartAddingObjects();
159 Bool_t StopAddingObjects();
00dc25ef 160
3c3cfd5f 161protected:
162 Bool_t fConnected; // Connection to the TEvePointSet signal
00dc25ef 163
164 TList* fDataFromMacroList; // List of macros that currently have data for histograms
165
3c3cfd5f 166 AliEveListAnalyserEditor* fEditor; // Pointer to the editor of this list
167
00dc25ef 168 TMap* fMacroList; // Stores the names, paths, types and commands of all macros added to this list
169
170 TTreeSRedirector *fDataTree; // Tree containing data for histograms
171
172 Int_t fHistoDataSelected; // Stores the selection for the data of the histograms
173 Int_t fMacroListSelected; // Stores the selection of the macro list
174
175 Char_t fSelectedTab; // Holds the index of the selected tab
00dc25ef 176
177 Char_t GetSelectedTab() const // Gets the selected tab
178 { return fSelectedTab; }
179
00dc25ef 180 Bool_t HistoDataIsSelected(Int_t index) const // Is entry in list selected?
181 { return TESTBIT(fHistoDataSelected, index); }
182
183 Bool_t MacroListIsSelected(Int_t index) const // Is entry in list selected?
184 { return TESTBIT(fMacroListSelected, index); }
185
186 void SetHistoDataSelection(Int_t index, Bool_t set) // Set selection of entry in list
187 { if (set) SETBIT(fHistoDataSelected, index); else UNSETBIT(fHistoDataSelected, index); }
188
189 void SetMacroListSelection(Int_t index, Bool_t set) // Set selection of entry in list
190 { if (set) SETBIT(fMacroListSelected, index); else UNSETBIT(fMacroListSelected, index); }
191
192 void SetSelectedTab(Int_t index) // Sets the selected tab
193 { fSelectedTab = (Char_t)index; }
194
00dc25ef 195private:
196 AliEveListAnalyser(const AliEveListAnalyser&); // Not implemented
197 AliEveListAnalyser& operator=(const AliEveListAnalyser&); // Not implemented
198
199 ClassDef(AliEveListAnalyser, 0); // Class containing a list of analyse objects
200};
201
202//////////////////////////////////////////////////////////////////////////
203// //
204// TGeneralMacroData //
205// //
206// Stores macro data which will be used by AliEveListAnalyser. //
207// //
208//////////////////////////////////////////////////////////////////////////
209
210class TGeneralMacroData: public TObject
211{
212public:
213 TGeneralMacroData(const Char_t* name, const Char_t* path, // Constructor
214 AliEveListAnalyser::AliEveListAnalyserMacroType type = AliEveListAnalyser::kUnknown,
004e0620 215 TClass* objectType = TObject::Class(), TClass* objectType2 = TObject::Class()):
00dc25ef 216 TObject(),
217 fObjectType(0x0),
004e0620 218 fObjectType2(0x0),
00dc25ef 219 fIsSelected(kFALSE),
220 fType(AliEveListAnalyser::kUnknown)
221
222 {
223 // The command is automatically set via type.
224
225 SetName(name);
226 SetObjectType(objectType);
004e0620 227 SetObjectType2(objectType2);
00dc25ef 228 SetPath(path);
229 SetType(type);
230
231 // Register the commands for each type here
6e420565 232 // Note: The framework will cast all data objects to "TObject*"
233 // -> We need to cast to the correct type for the macro!
00dc25ef 234 switch (type)
235 {
236 case AliEveListAnalyser::kSingleObjectSelect:
237 case AliEveListAnalyser::kSingleObjectHisto:
6e420565 238 SetCmd(Form("%s((%s*)automaticObject_1);", name, fObjectType->GetName()));
00dc25ef 239 break;
240
241 case AliEveListAnalyser::kSingleObjectAnalyse:
6e420565 242 SetCmd(Form("%s((%s*)automaticObject_1, results, n);", name, fObjectType->GetName()));
00dc25ef 243 break;
244
245 case AliEveListAnalyser::kCorrelObjectSelect:
246 case AliEveListAnalyser::kCorrelObjectHisto:
004e0620 247 SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2);", name, fObjectType->GetName(), fObjectType2->GetName()));
00dc25ef 248 break;
249
250 case AliEveListAnalyser::kCorrelObjectAnalyse:
004e0620 251 SetCmd(Form("%s((%s*)automaticObject_1, (%s*)automaticObject_2, results, n);", name, fObjectType->GetName(), fObjectType2->GetName()));
00dc25ef 252 break;
253
254 default:
255 SetCmd("");
256 break;
257 }
258 }
259
260 const Char_t* GetCmd() const // Returns the command that will be used to call this macro
261 { return fCmd; }
262 const Char_t* GetName() const // Returns the macro name (without ".C")
263 { return fName; }
004e0620 264 TClass* GetObjectType() const // Returns the object type of the macro parameter (1st pointer)
00dc25ef 265 { return fObjectType; }
004e0620 266 TClass* GetObjectType2() const // Returns the object type of the macro parameter (2nd pointer)
267 { return fObjectType2; }
00dc25ef 268 const Char_t* GetPath() const // Returns the path of the macro
269 { return fPath; }
270 AliEveListAnalyser::AliEveListAnalyserMacroType GetType() const // Returns the type of the macro
271 { return fType; }
ce239ca6 272 Bool_t IsProcessMacro() const // Returns whether the macro is a process type macro or not
00dc25ef 273 {
274 switch (fType)
275 {
276 case AliEveListAnalyser::kSingleObjectAnalyse:
277 case AliEveListAnalyser::kSingleObjectHisto:
278 case AliEveListAnalyser::kCorrelObjectAnalyse:
279 case AliEveListAnalyser::kCorrelObjectHisto:
280 return kTRUE;
281 break;
282 default:
283 break;
284 }
285
286 return kFALSE;
287 }
288
289 Bool_t IsSelected() const // Returns whether the macro is selected or not
290 { return fIsSelected; }
291 Bool_t IsSelectionMacro() const // Returns whether the macro is a selection type macro or not
292 {
293 switch (fType)
294 {
295 case AliEveListAnalyser::kSingleObjectSelect:
296 case AliEveListAnalyser::kCorrelObjectSelect:
297 return kTRUE;
298 break;
299 default:
300 break;
301 }
302
303 return kFALSE;
304 }
305
004e0620 306 void SetCmd(const char* newCmd) // Sets the command that will be used to call this macro
00dc25ef 307 {
308 memset(fCmd, '\0', sizeof(Char_t) * MAX_APPLY_COMMAND_LENGTH);
309 sprintf(fCmd, "%s", newCmd);
310 }
004e0620 311 void SetName(const char* newName) // Sets the macro name (please use without ".C")
00dc25ef 312 {
313 memset(fName, '\0', sizeof(Char_t) * MAX_MACRO_NAME_LENGTH);
314 sprintf(fName, "%s", newName);
315 }
004e0620 316 void SetObjectType(TClass* newObjectType) // Sets the object type of the macro parameter (1st pointer)
00dc25ef 317 {
318 fObjectType = newObjectType;
319 }
004e0620 320 void SetObjectType2(TClass* newObjectType2) // Sets the object type of the macro parameter (2nd pointer)
321 {
322 fObjectType2 = newObjectType2;
323 }
324 void SetPath(const char* newPath) // Sets the path of the macro
00dc25ef 325 {
326 memset(fPath, '\0', sizeof(Char_t) * MAX_MACRO_PATH_LENGTH);
327 sprintf(fPath, "%s", newPath);
328 }
004e0620 329 void SetSelected(Bool_t selection) // Sets whether the macro is selected or not
00dc25ef 330 {
331 fIsSelected = selection;
332 }
333 void SetType(AliEveListAnalyser::AliEveListAnalyserMacroType newType) // Sets the type of the macro
334 {
335 fType = newType;
336 }
337
338private:
339 TGeneralMacroData(const TGeneralMacroData&); // Not implemented
340 TGeneralMacroData& operator=(const TGeneralMacroData&); // Not implemented
341
342 Char_t fCmd[MAX_APPLY_COMMAND_LENGTH]; // Command that will be used to call this macro
343 Char_t fName[MAX_MACRO_NAME_LENGTH]; // Macro name (without ".C"!)
004e0620 344 TClass* fObjectType; // Type of object of the macro parameter (1st pointer)
345 TClass* fObjectType2; // Type of object of the macro parameter (2nd pointer)
00dc25ef 346 Char_t fPath[MAX_MACRO_PATH_LENGTH]; // Path of the macro
347 Bool_t fIsSelected; // Is macro selected (e.g. in the editor's list)?
348 AliEveListAnalyser::AliEveListAnalyserMacroType fType; // Type of the macro
349};
350
351#endif