]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTGlobalTriggerComponent.h
Fixing bug caused by UUID not being generated properly.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerComponent.h
CommitLineData
c580e182 1//-*- Mode: C++ -*-
3da1c6d7 2// $Id$
1b9a175e 3#ifndef ALIHLTGLOBALTRIGGERCOMPONENT_H
4#define ALIHLTGLOBALTRIGGERCOMPONENT_H
5/* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
9/// @file AliHLTGlobalTriggerComponent.h
10/// @author Artur Szostak <artursz@iafrica.com>
11/// @date 26 Nov 2008
12/// @brief Declaration of the AliHLTGlobalTriggerComponent component class.
13
14#include "AliHLTTrigger.h"
81d62bb4 15#include "TClonesArray.h"
1b9a175e 16
e2bb8ddd 17class AliHLTTriggerMenu;
18class AliHLTGlobalTrigger;
19
1b9a175e 20/**
21 * \class AliHLTGlobalTriggerComponent
22 * This class applies the global HLT trigger to all trigger information produced
23 * by components deriving from AliHLTTrigger.
24 * Any information delivered by other components in data blocks that contain
52f67e50 25 * TObjects can also be used for the trigger algorithm. In such cases a symbol
26 * needs to be defined in the global trigger menu which can then be used inside
27 * the trigger condition expressions.
28 *
29 * <h2>General properties:</h2>
30 *
31 * Component ID: \b HLTGlobalTrigger <br>
32 * Library: \b libAliHLTTrigger.so <br>
33 * Input Data Types: ::kAliHLTAnyDataType <br>
1d8ae082 34 * Output Data Types: kAliHLTDataTypeGlobalTrigger and kAliHLTDataTypeReadoutList <br>
52f67e50 35 *
36 * <h2>Mandatory arguments:</h2>
1d8ae082 37 * None.
52f67e50 38 *
39 * <h2>Optional arguments:</h2>
40 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
41 * \li -config <i>filename</i> <br>
42 * Indicates the configuration macro file to use for the global HLT trigger menu.
43 * \li -includepath <i>path</i> <br>
44 * Indicates the include path to use if the automatically generated code that
45 * implements the global HLT trigger requires non-standard includes.
46 * \li -include <i>filename</i> <br>
47 * Indicates a file name that should be included in the automatically generated
48 * trigger implementation code.
49 * \li -debug <br>
50 * If specified the automatically generated class will contain extra debugging
51 * code and the ACLiC system will have debugging compilation turned on.
566a01d0 52 * \li -cint <br>
53 * Use CINT to interprete the generated global trigger instead of compiling it.
54 * This will also be the case if no compiler is available.
52f67e50 55 * \li -usecode <i>filename</i> <i>classname</i> <br>
56 * Used to force the component to use an existing class for the global HLT trigger
57 * class implementation, with the name of <i>classname</i> and found in the file
58 * <i>filename</i>.
81d62bb4 59 * \li -skipctp <br>
60 * Indicates that the CTP data should not be added to the global HLT trigger decision.
6598c82b 61 * \li -forward-input <br>
62 * Forward the input objects instead of adding them to the global HLT trigger decision.
63 * This will also add a short info on the input objects and decisions, like
64 * -include-input=short, to switch off -include-input=none can be placed after the
65 * parameter
d543303d 66 * \li -include-input[=none,short,objects,both] <br>
6598c82b 67 * Steer adding of input objects to the global HLT trigger decision.
68 * Options: none - include nothing, short - include a short TNames array,
69 * objects - include objects, by default on
d543303d 70 * both - include both objects and short info
3d6ea577 71 * \li -process-all-events <br>
72 * Indicates that all events should be processed with the global trigger logic and
73 * not just the data events. The default is not to process just the data events.
52f67e50 74 *
75 * <h2>Configuration:</h2>
1d8ae082 76 * Configured from CDB but can be overridden with the -config argument.
52f67e50 77 *
78 * <h2>Default CDB entries:</h2>
3da1c6d7 79 * HLT/ConfigHLT/HLTGlobalTrigger - Contains the global trigger menu.
52f67e50 80 *
81 * <h2>Performance:</h2>
3da1c6d7 82 * This is a linear function of the number of input triggers (AliHLTTrigger) that
83 * need to be processed.
84 * For a modest trigger menu configurations the processing time per event should
85 * be on the order of a few milliseconds.
52f67e50 86 *
87 * <h2>Memory consumption:</h2>
3da1c6d7 88 * Memory consumption is minimal. It should be on the order of 2 or 3 MBytes.
52f67e50 89 *
90 * <h2>Output size:</h2>
3da1c6d7 91 * This will depend almost linearly on the number of intput triggers and summary
92 * data objects used. Thus, for every trigger (AliHLTTrigger object) specified
93 * in the trigger menu the output size will require about 1 kBytes.
94 * Then for every summary data object (i.e. TObject symbol defined in the trigger
95 * menu configuration) one will need an extra few kBytes, depending on the size
96 * of the summary objects.
97 * In total one would expect no more than a MByte output size for a large trigger
98 * configuration and typically only a few kBytes for a small or optimised one.
52f67e50 99 *
100 * \ingroup alihlt_trigger_components
1b9a175e 101 */
102class AliHLTGlobalTriggerComponent : public AliHLTTrigger
103{
104 public:
105
106 AliHLTGlobalTriggerComponent();
107 virtual ~AliHLTGlobalTriggerComponent();
108
109 /**
110 * Inherited from AliHLTTrigger.
111 * @return string containing the global trigger name.
112 */
113 virtual const char* GetTriggerName() const { return "HLTGlobalTrigger"; };
025443e0 114
115 /**
116 * Inherited from AliHLTTrigger.
117 * This returns kAliHLTDataTypeGlobalTrigger by default.
118 * @param list <i>[out]</i>: The list of data types to be filled.
119 */
120 virtual void GetOutputDataTypes(AliHLTComponentDataTypeList& list) const;
e2bb8ddd 121
1b9a175e 122 /**
123 * Get a ratio by how much the data volume is shrunk or enhanced.
124 * The method returns a size proportional to the trigger name string length
125 * for constBase, and 1 for inputMultiplier.
126 * @param constBase <i>[out]</i>: additive part, independent of the
127 * input data volume
128 * @param inputMultiplier <i>[out]</i>: multiplication ratio
129 */
130 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
4f1d6b68 131
e2bb8ddd 132 /**
133 * Initialise the component.
134 * \param argc The number of arguments in argv.
135 * \param argv Array of component argument strings.
136 * \returns Zero on success and negative number on failure.
137 */
138 virtual Int_t DoInit(int argc, const char** argv);
139
140 /**
141 * Cleanup the component.
142 * \returns Zero on success and negative number on failure.
143 */
144 virtual Int_t DoDeinit();
145
4f1d6b68 146 /**
147 * Spawn function creates a new object.
148 * @return new class instance.
149 */
150 virtual AliHLTComponent* Spawn();
1b9a175e 151
6598c82b 152 enum StatusBits {
153 kForwardInput = BIT(14), // forward input objects instead of adding them to the decision object
154 kIncludeInput = BIT(15), // include input objects in the decision object
155 kIncludeShort = BIT(16), // include short description of input objects: name, title, decision
156 kSkipCTP = BIT(17), // skip CTP data object in the decision object
157 };
158
159 void SetBit(AliHLTUInt32_t f, bool set) {
160 if (set) SetBit(f);
161 else ResetBit(f);
162 }
163 void SetBit(AliHLTUInt32_t f) { fBits |= f; }
164 void ResetBit(AliHLTUInt32_t f) { fBits &= ~f; }
165 bool TestBit(AliHLTUInt32_t f) const { return (bool) ((fBits & f) != 0); }
166
1b9a175e 167 protected:
168
1b9a175e 169 /**
170 * Applies the global HLT trigger.
171 * @return Zero is returned on success and a negative error code on failure.
172 */
173 virtual int DoTrigger();
174
81d62bb4 175 /**
176 * Reconfigures the component by loading the trigger menu from the given
177 * CDB entry.
178 * \param cdbEntry The CDB path to the trigger menu to load.
179 * \param chainId The ID of the component in the chain.
180 * \returns Zero on success and non-zero values otherwise.
181 */
182 virtual int Reconfigure(const char* cdbEntry, const char* chainId);
183
1b9a175e 184 private:
52f67e50 185
186 /// Not implemented. Do not allow copying of this object.
187 AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj);
188 /// Not implemented. Do not allow copying of this object.
189 AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj);
1b9a175e 190
81d62bb4 191 /**
192 * Loads a trigger menu object from the CDB.
193 * \param cdbPath <i>in</i> The path in the CDB to load the trigger menu object from.
194 * \param menu <i>out</i> A pointer that gets filled with the new trigger menu object.
195 * \returns Zero if the trigger menu object was found and the pointer to it
196 * set in the <i>menu</i> variable. If a non-zero error code is returned then
197 * the <i>menu</i> variable is not changed at all.
198 */
199 int LoadTriggerMenu(const char* cdbPath, const AliHLTTriggerMenu*& menu);
200
579a2996 201 /**
202 * Generates a file name for the generated on the fly code using a UUID.
203 * \param name <i>out</i> The name of the class to use.
204 * \param filename <i>out</i> The name of the file containing the code.
205 */
206 void GenerateFileName(TString& name, TString& filename) const;
207
e2bb8ddd 208 /**
209 * Generates the code for the global trigger to apply the given trigger menu.
210 * The code will then be compiled on the fly and loaded. The name of the new
211 * class is returned so that a new instance of the class can be created via:
212 * \code
213 * AliHLTGlobalTrigger::CreateNew(name)
214 * \endcode
215 * where name is the name of the generated class as returned by this method.
81d62bb4 216 *
217 * The name of the generated code file is stored in the variable fCodeFileName
218 * and the fDeleteCodeFile is set to true.
219 *
52f67e50 220 * \param menu <i>in</i> The trigger menu to create the global trigger class from.
221 * \param name <i>out</i> The name of the generated class.
81d62bb4 222 * \param filename <i>out</i> The name of the generated file containing the code.
52f67e50 223 * \param includePaths <i>in</i> The list of include path strings.
224 * \param includeFiles <i>in</i> The list of include file strings.
225 * \returns The error code suitable to return in DoInit. Zero on success.
226 */
227 int GenerateTrigger(
81d62bb4 228 const AliHLTTriggerMenu* menu, TString& name, TString& filename,
52f67e50 229 const TClonesArray& includePaths, const TClonesArray& includeFiles
230 );
231
232 /**
233 * Loads the code for the generated HLT global trigger class. The code is compiled
234 * on the fly if possible, otherwise the CINT interpreter is used to interpret
235 * the class.
236 * \param filename The name of the file containing the code for the global trigger class.
237 * \param includePaths <i>in</i> The list of include path strings.
238 * \returns The error code suitable to return in DoInit. Zero on success.
239 */
240 int LoadTriggerClass(const char* filename, const TClonesArray& includePaths);
241
81d62bb4 242 /**
243 * Unloads the code that was previously loaded by LoadTriggerClass.
244 * \param filename The name of the file containing the global trigger class logic to be unloaded.
245 * \returns The error code suitable to return in DoInit. Zero on success.
246 */
247 int UnloadTriggerClass(const char* filename);
248
52f67e50 249 /**
250 * Searches for the specified symbol name in the given list.
251 * \param name The name of the symbol to find.
252 * \param list The list to search for the symbol in.
253 * \returns The position (index) of the symbol found or -1 if it was not found.
254 */
255 int FindSymbol(const char* name, const TClonesArray& list);
256
257 /**
258 * Builds the list of symbols to use in the custom global trigger menu
259 * implementation class.
e2bb8ddd 260 * \param menu The trigger menu to create the global trigger class from.
52f67e50 261 * \param list The list to fill with symbols.
e2bb8ddd 262 * \returns The error code suitable to return in DoInit. Zero on success.
263 */
52f67e50 264 int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list);
81d62bb4 265
266 /**
267 * Extracts the trailing operator in a C++ expression and returns the found
268 * operator in a separate output string.
269 * [in/out] \param expr The C++ expression to check. The trailing operator
270 * is removed from the expression if found.
271 * [out] \param op The output variable which will be filled with the
272 * operator found in the expression.
273 * \return true if the trailing operator was found in the expression and
274 * false otherwise.
275 */
276 bool ExtractedOperator(TString& expr, TString& op);
2974f8dc 277
566a01d0 278 /**
279 * Add trigger decisions according to the active CTP trigger classes
280 * An internal TclonesArray holds the trigger decisions to be added. The trigger
281 * decisions are updated according to the active CTP trigger mask.
282 * \param pTrigger The instance of the global trigger
283 * \param pCTPData Instance of the CTP data
284 * \param trigData Current trigger data, if NULL, the active trigger data from the CTP data is used
285 */
286 int AddCTPDecisions(AliHLTGlobalTrigger* pTrigger, const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData);
287
2974f8dc 288 /**
289 * Print some statistics based on the trigger counters
290 */
291 int PrintStatistics(const AliHLTGlobalTrigger* pTrigger, AliHLTComponentLogSeverity level=kHLTLogInfo, int offset=1) const;
e2bb8ddd 292
293 AliHLTGlobalTrigger* fTrigger; //! Trigger object which implements the global trigger menu.
52f67e50 294 bool fDebugMode; //! Indicates if the generated global trigger class should be in debug mode.
566a01d0 295 bool fRuntimeCompile; //! Indicates if the generated global trigger class should be compiled
81d62bb4 296 bool fDeleteCodeFile; //! If true then the code file indicated by fCodeFileName should be deleted during DoDeinit.
72bc5ab0 297 TString fCodeFileName; //! base file name of the generated code for the global trigger
81d62bb4 298 TString fClassName; //! The generated/loaded trigger class name.
566a01d0 299 TClonesArray* fCTPDecisions; //! AliHLTTriggerDecision objects for the CTP classes
81d62bb4 300 unsigned long fBufferSizeConst; //! Constant size estimate for GetOutputDataSize.
301 double fBufferSizeMultiplier; //! Buffer size multiplier estimate for GetOutputDataSize.
302 TClonesArray fIncludePaths; //! Paths specified by the -includepath command line option.
303 TClonesArray fIncludeFiles; //! Files specified by the -include command line option.
1b820a65 304 TString fLibStateAtLoad; //! This stores the loaded libraries just before we tell CINT to load the interpreted file.
6598c82b 305 AliHLTUInt32_t fBits; //! Status bits
3d6ea577 306 bool fDataEventsOnly; //! Flag indicating if only data events are processed with trigger logic.
566a01d0 307
3da1c6d7 308 static const char* fgkTriggerMenuCDBPath; //! The path string to read the trigger menu from the CDB.
309
1b9a175e 310 ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.
311};
312
313#endif // ALIHLTGLOBALTRIGGERCOMPONENT_H
314