]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTBlockFilterComponent.h
bugfix AliHLTCompStatCollector: filling entry 'Level' of the component statistics...
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTBlockFilterComponent.h
1 // -*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTBLOCKFILTERCOMPONENT_H
5 #define ALIHLTBLOCKFILTERCOMPONENT_H
6 //* This file is property of and copyright by the                          * 
7 //* ALICE Experiment at CERN, All rights reserved.                         *
8 //* See cxx source for full Copyright notice                               *
9
10 /// @file   AliHLTBlockFilterComponent.h
11 /// @author Matthias Richter
12 /// @date   
13 /// @brief  A simple data block filter and merger, merges block descriptors
14 ///
15
16 #include "AliHLTProcessor.h"
17
18 /**
19  * @class AliHLTBlockFilterComponent
20  * A data block merger and filter.
21  * It merges data block descriptors fulfilling the filtering rules and
22  * forwards the descriptors to the output. The actual data is not touched.
23  *
24  * <h2>General properties:</h2>
25  *
26  * Component ID: \b BlockFilter                                         <br>
27  * Library: \b libAliHLTUtil.so                                         <br>
28  * Input Data Types: kAliHLTAnyDataType                                 <br>
29  * Output Data Types: according to parameter and input blocks           <br>
30  *
31  * <h2>Mandatory arguments:</h2>
32  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
33  *      
34  * <h2>Optional arguments:</h2>
35  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
36  * \li -datatype     <i> id origin      </i>                            <br>
37  *      e.g. <tt> -datatype 'ESD_TREE' 'TPC ' </tt>                     <br>
38  *      \b Note: due to the 4-character data origin it might be necessary to
39  *      append a blank to the detectorname, e.g. <tt>TPC -> 'TPC '</tt>
40  *
41  * \li -origin  <i> origin  </i>                                        <br>
42  *      e.g. -origin 'TPC ', \b Note:  the filter rule has type id 'ANY'
43  *
44  * \li -typeid  <i> id      </i>                                        <br>
45  *      e.g. -typeid ESD_TREE, \b Note: the filter rule has origin 'ANY'
46  *
47  * \li -dataspec     <i> specification </i>                             <br>
48  *      data specification treated as decimal number or hex number if
49  *      prepended by '0x'
50  *
51  * \li -prescalar  <i> scalar      </i>                                 <br>
52  *      a prescalar value, forwarding only if eventcount%scalar is zero
53  *
54  * \li -skip-events  <i> count      </i>                                <br>
55  *      skip count events in the beginning
56  *
57  * \li -verbose                                                         <br>
58  *      print out some more info messages, mainly for the sake of tutorials
59  *
60  * <h2>Configuration:</h2>
61  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
62  * Configuration by component arguments.
63  *
64  * <h2>Default CDB entries:</h2>
65  * The component loads no CDB entries.
66  *
67  * <h2>Performance:</h2>
68  * The component does not process any event data.
69  *
70  * <h2>Memory consumption:</h2>
71  * The component does not process any event data.
72  *
73  * <h2>Output size:</h2>
74  * No additional data is produced. Data blocks are just forwarded.
75  *
76  * By default, all blocks will be published. By means of the \em -datatype,
77  * \em -origin, and \em -typeid arguments, the blocks can be selected. A list
78  * of filter rules can be built up by multiple usage of the arguments. Each
79  * time a new filter rule is added.
80  *
81  * No filtering by the data specification is applied unless then \em
82  * -specification argument is used. The specification applies to to the
83  * current filter rule, regardless of the sequence of -datatype/-specification
84  * arguments.
85  *
86  * @ingroup alihlt_util_components
87  */
88 class AliHLTBlockFilterComponent : public AliHLTProcessor
89 {
90  public:
91   /** standard constructor */
92   AliHLTBlockFilterComponent();
93   /** destructor */
94   virtual ~AliHLTBlockFilterComponent();
95
96   /**
97    * The id of the component.
98    * @return component id (string)
99    */
100   virtual const char* GetComponentID() {return "BlockFilter";};
101
102   /**
103    * Get the input data types of the component.
104    * @return list of data types in the vector reference
105    */
106   void GetInputDataTypes( AliHLTComponentDataTypeList& );
107
108   /**
109    * Get the output data type of the component.
110    * If @ref kAliHLTMultipleDataType is returned, the framework invokes
111    * @ref GetOutputDataTypes.
112    * @return output data type
113    */
114   AliHLTComponentDataType GetOutputDataType();
115
116   /**
117    * Get the output data types of the component.
118    * The function can be implemented to indicate multiple output data types
119    * in the target array.
120    * @ref GetOutputDataType must return @ref kAliHLTMultipleDataType in order
121    * to invoke this method.
122    * @param tgtList          list to receive the data types
123    * @return no of output data types, data types in the target list
124    */
125   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
126
127   /**
128    * Get a ratio by how much the data volume is shrinked or enhanced.
129    * @param constBase        <i>return</i>: additive part, independent of the
130    *                                   input data volume  
131    * @param inputMultiplier  <i>return</i>: multiplication ratio
132    * @return values in the reference variables
133    */
134   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
135
136   /**
137    * Spawn function.
138    * @return new class instance
139    */
140   virtual AliHLTComponent* Spawn() {return new AliHLTBlockFilterComponent;}
141
142  protected:
143
144   /**
145    * Data processing method for the component.
146    * Filters the incoming data descriptors according to the rules and forwards
147    * them into the output.
148    * @return neg. error code if failed 
149    */
150   int DoEvent( const AliHLTComponentEventData& evtData,
151                const AliHLTComponentBlockData* blocks, 
152                AliHLTComponentTriggerData& trigData,
153                AliHLTUInt8_t* outputPtr, 
154                AliHLTUInt32_t& size,
155                AliHLTComponentBlockDataList& outputBlocks );
156   
157   using AliHLTProcessor::DoEvent;
158
159   /**
160    * Component initialisation and argument scan.
161    */
162   int DoInit( int argc, const char** argv );
163
164   /**
165    * Component cleanup.
166    */
167   int DoDeinit();
168
169  private:
170   /** copy constructor prohibited */
171   AliHLTBlockFilterComponent(const AliHLTBlockFilterComponent&);
172   /** assignment operator prohibited */
173   AliHLTBlockFilterComponent& operator=(const AliHLTBlockFilterComponent&);
174
175   /**
176    * Check if the data block is selected by the filter rules.
177    * @return 1 if selected
178    */
179   int IsSelected(const AliHLTComponentBlockData& block);
180
181   /** filtering rules, only the data type and specification members are use */
182   AliHLTComponentBlockDataList fFilterRules;                       //! transient
183   AliHLTUInt32_t fPrescalar;                                       //! transient
184   AliHLTUInt32_t fFirstEvent;                                      //! transient
185
186   ClassDef(AliHLTBlockFilterComponent, 0)
187 };
188 #endif