]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTGlobalTriggerComponent.h
several bugfixes in order to get the HLTGlobalTrigger decision safely into the ESD
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTriggerComponent.h
1 //-*- Mode: C++ -*-
2 // $Id$
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"
15
16 class AliHLTTriggerMenu;
17 class AliHLTGlobalTrigger;
18 class TClonesArray;
19
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
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.
51  * \li -usecode <i>filename</i> <i>classname</i> <br>
52  *      Used to force the component to use an existing class for the global HLT trigger
53  *      class implementation, with the name of <i>classname</i> and found in the file
54  *      <i>filename</i>.
55  *
56  * <h2>Configuration:</h2>
57  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
58  * Configuration by component arguments.
59  *
60  * <h2>Default CDB entries:</h2>
61  * HLT/ConfigHLT/HLTGlobalTrigger - Contains the global trigger menu.
62  *
63  * <h2>Performance:</h2>
64  * This is a linear function of the number of input triggers (AliHLTTrigger) that
65  * need to be processed.
66  * For a modest trigger menu configurations the processing time per event should
67  * be on the order of a few milliseconds.
68  *
69  * <h2>Memory consumption:</h2>
70  * Memory consumption is minimal. It should be on the order of 2 or 3 MBytes.
71  *
72  * <h2>Output size:</h2>
73  * This will depend almost linearly on the number of intput triggers and summary
74  * data objects used. Thus, for every trigger (AliHLTTrigger object) specified
75  * in the trigger menu the output size will require about 1 kBytes.
76  * Then for every summary data object (i.e. TObject symbol defined in the trigger
77  * menu configuration) one will need an extra few kBytes, depending on the size
78  * of the summary objects.
79  * In total one would expect no more than a MByte output size for a large trigger
80  * configuration and typically only a few kBytes for a small or optimised one.
81  *
82  * \ingroup alihlt_trigger_components
83  */
84 class AliHLTGlobalTriggerComponent : public AliHLTTrigger
85 {
86  public:
87  
88   AliHLTGlobalTriggerComponent();
89   virtual ~AliHLTGlobalTriggerComponent();
90   
91   /**
92    * Inherited from AliHLTTrigger.
93    * @return string containing the global trigger name.
94    */
95   virtual const char* GetTriggerName() const { return "HLTGlobalTrigger"; };
96   
97   /**
98    * Get a ratio by how much the data volume is shrunk or enhanced.
99    * The method returns a size proportional to the trigger name string length
100    * for constBase, and 1 for inputMultiplier.
101    * @param constBase        <i>[out]</i>: additive part, independent of the
102    *                                   input data volume  
103    * @param inputMultiplier  <i>[out]</i>: multiplication ratio
104    */
105   virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
106   
107   /**
108    * Initialise the component.
109    * \param argc  The number of arguments in argv.
110    * \param argv  Array of component argument strings.
111    * \returns  Zero on success and negative number on failure.
112    */
113   virtual Int_t DoInit(int argc, const char** argv);
114   
115   /**
116    * Cleanup the component.
117    * \returns  Zero on success and negative number on failure.
118    */
119   virtual Int_t DoDeinit();
120   
121   /**
122    * Spawn function creates a new object.
123    * @return new class instance.
124    */
125   virtual AliHLTComponent* Spawn();
126
127  protected:
128
129   /**
130    * Applies the global HLT trigger.
131    * @return Zero is returned on success and a negative error code on failure.
132    */
133   virtual int DoTrigger();
134   
135  private:
136
137   /// Not implemented. Do not allow copying of this object.
138   AliHLTGlobalTriggerComponent(const AliHLTGlobalTriggerComponent& obj);
139   /// Not implemented. Do not allow copying of this object.
140   AliHLTGlobalTriggerComponent& operator = (const AliHLTGlobalTriggerComponent& obj);
141   
142   /**
143    * Generates the code for the global trigger to apply the given trigger menu.
144    * The code will then be compiled on the fly and loaded. The name of the new
145    * class is returned so that a new instance of the class can be created via:
146    * \code
147    *  AliHLTGlobalTrigger::CreateNew(name)
148    * \endcode
149    * where name is the name of the generated class as returned by this method.
150    * \param menu <i>in</i> The trigger menu to create the global trigger class from.
151    * \param name <i>out</i> The name of the generated class.
152    * \param includePaths <i>in</i> The list of include path strings.
153    * \param includeFiles <i>in</i> The list of include file strings.
154    * \returns  The error code suitable to return in DoInit. Zero on success.
155    */
156   int GenerateTrigger(
157       const AliHLTTriggerMenu* menu, TString& name,
158       const TClonesArray& includePaths, const TClonesArray& includeFiles
159     );
160   
161   /**
162    * Loads the code for the generated HLT global trigger class. The code is compiled
163    * on the fly if possible, otherwise the CINT interpreter is used to interpret
164    * the class.
165    * \param filename  The name of the file containing the code for the global trigger class.
166    * \param includePaths <i>in</i> The list of include path strings.
167    * \returns  The error code suitable to return in DoInit. Zero on success.
168    */
169   int LoadTriggerClass(const char* filename, const TClonesArray& includePaths);
170   
171   /**
172    * Searches for the specified symbol name in the given list.
173    * \param name  The name of the symbol to find.
174    * \param list  The list to search for the symbol in.
175    * \returns  The position (index) of the symbol found or -1 if it was not found.
176    */
177   int FindSymbol(const char* name, const TClonesArray& list);
178   
179   /**
180    * Builds the list of symbols to use in the custom global trigger menu
181    * implementation class.
182    * \param  menu  The trigger menu to create the global trigger class from.
183    * \param  list  The list to fill with symbols.
184    * \returns  The error code suitable to return in DoInit. Zero on success.
185    */
186   int BuildSymbolList(const AliHLTTriggerMenu* menu, TClonesArray& list);
187   
188   AliHLTGlobalTrigger* fTrigger;  //! Trigger object which implements the global trigger menu.
189   bool fDebugMode;  //! Indicates if the generated global trigger class should be in debug mode.
190   
191   static const char* fgkTriggerMenuCDBPath; //! The path string to read the trigger menu from the CDB.
192   
193   ClassDef(AliHLTGlobalTriggerComponent, 0) // Global HLT trigger component class which produces the final trigger decision and readout list.
194 };
195
196 #endif // ALIHLTGLOBALTRIGGERCOMPONENT_H
197