]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTGlobalTriggerComponent.h
Finished code for global HLT trigger and the trigger menu implementation.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerComponent.h
1 #ifndef ALIHLTGLOBALTRIGGERCOMPONENT_H
2 #define ALIHLTGLOBALTRIGGERCOMPONENT_H
3 /* This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  * See cxx source for full Copyright notice                               */
6
7 /// @file   AliHLTGlobalTriggerComponent.h
8 /// @author Artur Szostak <artursz@iafrica.com>
9 /// @date   26 Nov 2008
10 /// @brief  Declaration of the AliHLTGlobalTriggerComponent component class.
11
12 #include "AliHLTTrigger.h"
13
14 class AliHLTTriggerMenu;
15 class AliHLTGlobalTrigger;
16 class TClonesArray;
17
18 /**
19  * \class AliHLTGlobalTriggerComponent
20  * This class applies the global HLT trigger to all trigger information produced
21  * by components deriving from AliHLTTrigger.
22  * Any information delivered by other components in data blocks that contain
23  * TObjects can also be used for the trigger algorithm. In such cases a symbol
24  * needs to be defined in the global trigger menu which can then be used inside
25  * the trigger condition expressions.
26  *
27  * <h2>General properties:</h2>
28  *
29  * Component ID: \b HLTGlobalTrigger <br>
30  * Library: \b libAliHLTTrigger.so   <br>
31  * Input Data Types: ::kAliHLTAnyDataType <br>
32  * Output Data Types: kAliHLTDataTypeTObject|kAliHLTDataOriginOut <br>
33  *
34  * <h2>Mandatory arguments:</h2>
35  *
36  * <h2>Optional arguments:</h2>
37  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
38  * \li -config <i>filename</i> <br>
39  *      Indicates the configuration macro file to use for the global HLT trigger menu.
40  * \li -includepath <i>path</i> <br>
41  *      Indicates the include path to use if the automatically generated code that
42  *      implements the global HLT trigger requires non-standard includes.
43  * \li -include <i>filename</i> <br>
44  *      Indicates a file name that should be included in the automatically generated
45  *      trigger implementation code.
46  * \li -debug <br>
47  *      If specified the automatically generated class will contain extra debugging
48  *      code and the ACLiC system will have debugging compilation turned on.
49  * \li -usecode <i>filename</i> <i>classname</i> <br>
50  *      Used to force the component to use an existing class for the global HLT trigger
51  *      class implementation, with the name of <i>classname</i> and found in the file
52  *      <i>filename</i>.
53  *
54  * <h2>Configuration:</h2>
55  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
56  * Configuration by component arguments.
57  *
58  * <h2>Default CDB entries:</h2>
59  * TODO
60  *
61  * <h2>Performance:</h2>
62  * TODO
63  *
64  * <h2>Memory consumption:</h2>
65  * TODO
66  *
67  * <h2>Output size:</h2>
68  * TODO
69  *
70  * \ingroup alihlt_trigger_components
71  */
72 class AliHLTGlobalTriggerComponent : public AliHLTTrigger
73 {
74  public:
75  
76   AliHLTGlobalTriggerComponent();
77   virtual ~AliHLTGlobalTriggerComponent();
78   
79   /**
80    * Inherited from AliHLTTrigger.
81    * @return string containing the global trigger name.
82    */
83   virtual const char* GetTriggerName() const { return "HLTGlobalTrigger"; };
84   
85   /**
86    * Get a ratio by how much the data volume is shrunk or enhanced.
87    * The method returns a size proportional to the trigger name string length
88    * for constBase, and 1 for inputMultiplier.
89    * @param constBase        <i>[out]</i>: additive part, independent of the
90    *                                   input data volume  
91    * @param inputMultiplier  <i>[out]</i>: multiplication ratio
92    */
93   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
94   
95   /**
96    * Initialise the component.
97    * \param argc  The number of arguments in argv.
98    * \param argv  Array of component argument strings.
99    * \returns  Zero on success and negative number on failure.
100    */
101   virtual Int_t DoInit(int argc, const char** argv);
102   
103   /**
104    * Cleanup the component.
105    * \returns  Zero on success and negative number on failure.
106    */
107   virtual Int_t DoDeinit();
108   
109   /**
110    * Spawn function creates a new object.
111    * @return new class instance.
112    */
113   virtual AliHLTComponent* Spawn();
114
115  protected:
116
117   /**
118    * Applies the global HLT trigger.
119    * @return Zero is returned on success and a negative error code on failure.
120    */
121   virtual int DoTrigger();
122   
123  private:
124
125   /// Not implemented. Do not allow copying of this object.
126   AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj);
127   /// Not implemented. Do not allow copying of this object.
128   AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj);
129   
130   /**
131    * Generates the code for the global trigger to apply the given trigger menu.
132    * The code will then be compiled on the fly and loaded. The name of the new
133    * class is returned so that a new instance of the class can be created via:
134    * \code
135    *  AliHLTGlobalTrigger::CreateNew(name)
136    * \endcode
137    * where name is the name of the generated class as returned by this method.
138    * \param menu <i>in</i> The trigger menu to create the global trigger class from.
139    * \param name <i>out</i> The name of the generated class.
140    * \param includePaths <i>in</i> The list of include path strings.
141    * \param includeFiles <i>in</i> The list of include file strings.
142    * \returns  The error code suitable to return in DoInit. Zero on success.
143    */
144   int GenerateTrigger(
145       const AliHLTTriggerMenu* menu, TString& name,
146       const TClonesArray& includePaths, const TClonesArray& includeFiles
147     );
148   
149   /**
150    * Loads the code for the generated HLT global trigger class. The code is compiled
151    * on the fly if possible, otherwise the CINT interpreter is used to interpret
152    * the class.
153    * \param filename  The name of the file containing the code for the global trigger class.
154    * \param includePaths <i>in</i> The list of include path strings.
155    * \returns  The error code suitable to return in DoInit. Zero on success.
156    */
157   int LoadTriggerClass(const char* filename, const TClonesArray& includePaths);
158   
159   /**
160    * Searches for the specified symbol name in the given list.
161    * \param name  The name of the symbol to find.
162    * \param list  The list to search for the symbol in.
163    * \returns  The position (index) of the symbol found or -1 if it was not found.
164    */
165   int FindSymbol(const char* name, const TClonesArray& list);
166   
167   /**
168    * Builds the list of symbols to use in the custom global trigger menu
169    * implementation class.
170    * \param  menu  The trigger menu to create the global trigger class from.
171    * \param  list  The list to fill with symbols.
172    * \returns  The error code suitable to return in DoInit. Zero on success.
173    */
174   int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list);
175   
176   AliHLTGlobalTrigger* fTrigger;  //! Trigger object which implements the global trigger menu.
177   bool fDebugMode;  //! Indicates if the generated global trigger class should be in debug mode.
178   
179   ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.
180 };
181
182 #endif // ALIHLTGLOBALTRIGGERCOMPONENT_H
183