]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTGlobalTriggerComponent.h
* Adding explicit priority settings for the global trigger menu items.
[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>
34 * Output Data Types: kAliHLTDataTypeTObject|kAliHLTDataOriginOut <br>
35 *
36 * <h2>Mandatory arguments:</h2>
37 *
38 * <h2>Optional arguments:</h2>
39 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
40 * \li -config <i>filename</i> <br>
41 * Indicates the configuration macro file to use for the global HLT trigger menu.
42 * \li -includepath <i>path</i> <br>
43 * Indicates the include path to use if the automatically generated code that
44 * implements the global HLT trigger requires non-standard includes.
45 * \li -include <i>filename</i> <br>
46 * Indicates a file name that should be included in the automatically generated
47 * trigger implementation code.
48 * \li -debug <br>
49 * If specified the automatically generated class will contain extra debugging
50 * code and the ACLiC system will have debugging compilation turned on.
566a01d0 51 * \li -cint <br>
52 * Use CINT to interprete the generated global trigger instead of compiling it.
53 * This will also be the case if no compiler is available.
52f67e50 54 * \li -usecode <i>filename</i> <i>classname</i> <br>
55 * Used to force the component to use an existing class for the global HLT trigger
56 * class implementation, with the name of <i>classname</i> and found in the file
57 * <i>filename</i>.
81d62bb4 58 * \li -skipctp <br>
59 * Indicates that the CTP data should not be added to the global HLT trigger decision.
52f67e50 60 *
61 * <h2>Configuration:</h2>
62 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
63 * Configuration by component arguments.
64 *
65 * <h2>Default CDB entries:</h2>
3da1c6d7 66 * HLT/ConfigHLT/HLTGlobalTrigger - Contains the global trigger menu.
52f67e50 67 *
68 * <h2>Performance:</h2>
3da1c6d7 69 * This is a linear function of the number of input triggers (AliHLTTrigger) that
70 * need to be processed.
71 * For a modest trigger menu configurations the processing time per event should
72 * be on the order of a few milliseconds.
52f67e50 73 *
74 * <h2>Memory consumption:</h2>
3da1c6d7 75 * Memory consumption is minimal. It should be on the order of 2 or 3 MBytes.
52f67e50 76 *
77 * <h2>Output size:</h2>
3da1c6d7 78 * This will depend almost linearly on the number of intput triggers and summary
79 * data objects used. Thus, for every trigger (AliHLTTrigger object) specified
80 * in the trigger menu the output size will require about 1 kBytes.
81 * Then for every summary data object (i.e. TObject symbol defined in the trigger
82 * menu configuration) one will need an extra few kBytes, depending on the size
83 * of the summary objects.
84 * In total one would expect no more than a MByte output size for a large trigger
85 * configuration and typically only a few kBytes for a small or optimised one.
52f67e50 86 *
87 * \ingroup alihlt_trigger_components
1b9a175e 88 */
89class AliHLTGlobalTriggerComponent : public AliHLTTrigger
90{
91 public:
92
93 AliHLTGlobalTriggerComponent();
94 virtual ~AliHLTGlobalTriggerComponent();
95
96 /**
97 * Inherited from AliHLTTrigger.
98 * @return string containing the global trigger name.
99 */
100 virtual const char* GetTriggerName() const { return "HLTGlobalTrigger"; };
e2bb8ddd 101
1b9a175e 102 /**
103 * Get a ratio by how much the data volume is shrunk or enhanced.
104 * The method returns a size proportional to the trigger name string length
105 * for constBase, and 1 for inputMultiplier.
106 * @param constBase <i>[out]</i>: additive part, independent of the
107 * input data volume
108 * @param inputMultiplier <i>[out]</i>: multiplication ratio
109 */
110 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
4f1d6b68 111
e2bb8ddd 112 /**
113 * Initialise the component.
114 * \param argc The number of arguments in argv.
115 * \param argv Array of component argument strings.
116 * \returns Zero on success and negative number on failure.
117 */
118 virtual Int_t DoInit(int argc, const char** argv);
119
120 /**
121 * Cleanup the component.
122 * \returns Zero on success and negative number on failure.
123 */
124 virtual Int_t DoDeinit();
125
4f1d6b68 126 /**
127 * Spawn function creates a new object.
128 * @return new class instance.
129 */
130 virtual AliHLTComponent* Spawn();
1b9a175e 131
132 protected:
133
1b9a175e 134 /**
135 * Applies the global HLT trigger.
136 * @return Zero is returned on success and a negative error code on failure.
137 */
138 virtual int DoTrigger();
139
81d62bb4 140 /**
141 * Reconfigures the component by loading the trigger menu from the given
142 * CDB entry.
143 * \param cdbEntry The CDB path to the trigger menu to load.
144 * \param chainId The ID of the component in the chain.
145 * \returns Zero on success and non-zero values otherwise.
146 */
147 virtual int Reconfigure(const char* cdbEntry, const char* chainId);
148
1b9a175e 149 private:
52f67e50 150
151 /// Not implemented. Do not allow copying of this object.
152 AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj);
153 /// Not implemented. Do not allow copying of this object.
154 AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj);
1b9a175e 155
81d62bb4 156 /**
157 * Loads a trigger menu object from the CDB.
158 * \param cdbPath <i>in</i> The path in the CDB to load the trigger menu object from.
159 * \param menu <i>out</i> A pointer that gets filled with the new trigger menu object.
160 * \returns Zero if the trigger menu object was found and the pointer to it
161 * set in the <i>menu</i> variable. If a non-zero error code is returned then
162 * the <i>menu</i> variable is not changed at all.
163 */
164 int LoadTriggerMenu(const char* cdbPath, const AliHLTTriggerMenu*& menu);
165
e2bb8ddd 166 /**
167 * Generates the code for the global trigger to apply the given trigger menu.
168 * The code will then be compiled on the fly and loaded. The name of the new
169 * class is returned so that a new instance of the class can be created via:
170 * \code
171 * AliHLTGlobalTrigger::CreateNew(name)
172 * \endcode
173 * where name is the name of the generated class as returned by this method.
81d62bb4 174 *
175 * The name of the generated code file is stored in the variable fCodeFileName
176 * and the fDeleteCodeFile is set to true.
177 *
52f67e50 178 * \param menu <i>in</i> The trigger menu to create the global trigger class from.
179 * \param name <i>out</i> The name of the generated class.
81d62bb4 180 * \param filename <i>out</i> The name of the generated file containing the code.
52f67e50 181 * \param includePaths <i>in</i> The list of include path strings.
182 * \param includeFiles <i>in</i> The list of include file strings.
183 * \returns The error code suitable to return in DoInit. Zero on success.
184 */
185 int GenerateTrigger(
81d62bb4 186 const AliHLTTriggerMenu* menu, TString& name, TString& filename,
52f67e50 187 const TClonesArray& includePaths, const TClonesArray& includeFiles
188 );
189
190 /**
191 * Loads the code for the generated HLT global trigger class. The code is compiled
192 * on the fly if possible, otherwise the CINT interpreter is used to interpret
193 * the class.
194 * \param filename The name of the file containing the code for the global trigger class.
195 * \param includePaths <i>in</i> The list of include path strings.
196 * \returns The error code suitable to return in DoInit. Zero on success.
197 */
198 int LoadTriggerClass(const char* filename, const TClonesArray& includePaths);
199
81d62bb4 200 /**
201 * Unloads the code that was previously loaded by LoadTriggerClass.
202 * \param filename The name of the file containing the global trigger class logic to be unloaded.
203 * \returns The error code suitable to return in DoInit. Zero on success.
204 */
205 int UnloadTriggerClass(const char* filename);
206
52f67e50 207 /**
208 * Searches for the specified symbol name in the given list.
209 * \param name The name of the symbol to find.
210 * \param list The list to search for the symbol in.
211 * \returns The position (index) of the symbol found or -1 if it was not found.
212 */
213 int FindSymbol(const char* name, const TClonesArray& list);
214
215 /**
216 * Builds the list of symbols to use in the custom global trigger menu
217 * implementation class.
e2bb8ddd 218 * \param menu The trigger menu to create the global trigger class from.
52f67e50 219 * \param list The list to fill with symbols.
e2bb8ddd 220 * \returns The error code suitable to return in DoInit. Zero on success.
221 */
52f67e50 222 int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list);
81d62bb4 223
224 /**
225 * Extracts the trailing operator in a C++ expression and returns the found
226 * operator in a separate output string.
227 * [in/out] \param expr The C++ expression to check. The trailing operator
228 * is removed from the expression if found.
229 * [out] \param op The output variable which will be filled with the
230 * operator found in the expression.
231 * \return true if the trailing operator was found in the expression and
232 * false otherwise.
233 */
234 bool ExtractedOperator(TString& expr, TString& op);
2974f8dc 235
566a01d0 236 /**
237 * Add trigger decisions according to the active CTP trigger classes
238 * An internal TclonesArray holds the trigger decisions to be added. The trigger
239 * decisions are updated according to the active CTP trigger mask.
240 * \param pTrigger The instance of the global trigger
241 * \param pCTPData Instance of the CTP data
242 * \param trigData Current trigger data, if NULL, the active trigger data from the CTP data is used
243 */
244 int AddCTPDecisions(AliHLTGlobalTrigger* pTrigger, const AliHLTCTPData* pCTPData, const AliHLTComponentTriggerData* trigData);
245
2974f8dc 246 /**
247 * Print some statistics based on the trigger counters
248 */
249 int PrintStatistics(const AliHLTGlobalTrigger* pTrigger, AliHLTComponentLogSeverity level=kHLTLogInfo, int offset=1) const;
e2bb8ddd 250
251 AliHLTGlobalTrigger* fTrigger; //! Trigger object which implements the global trigger menu.
52f67e50 252 bool fDebugMode; //! Indicates if the generated global trigger class should be in debug mode.
566a01d0 253 bool fRuntimeCompile; //! Indicates if the generated global trigger class should be compiled
254 bool fSkipCTPCounters; //! Indicates whether to ship CTP info with the trigger decision
81d62bb4 255 bool fDeleteCodeFile; //! If true then the code file indicated by fCodeFileName should be deleted during DoDeinit.
72bc5ab0 256 TString fCodeFileName; //! base file name of the generated code for the global trigger
81d62bb4 257 TString fClassName; //! The generated/loaded trigger class name.
566a01d0 258 TClonesArray* fCTPDecisions; //! AliHLTTriggerDecision objects for the CTP classes
81d62bb4 259 unsigned long fBufferSizeConst; //! Constant size estimate for GetOutputDataSize.
260 double fBufferSizeMultiplier; //! Buffer size multiplier estimate for GetOutputDataSize.
261 TClonesArray fIncludePaths; //! Paths specified by the -includepath command line option.
262 TClonesArray fIncludeFiles; //! Files specified by the -include command line option.
566a01d0 263
3da1c6d7 264 static const char* fgkTriggerMenuCDBPath; //! The path string to read the trigger menu from the CDB.
265
1b9a175e 266 ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.
267};
268
269#endif // ALIHLTGLOBALTRIGGERCOMPONENT_H
270