]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.h
Fixes to trigger reconstruction component to handle real data better.
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONTriggerReconstructorComponent.h
1 #ifndef AliHLTMUONTRIGGERRECONSTRUCTORCOMPONENT_H
2 #define AliHLTMUONTRIGGERRECONSTRUCTORCOMPONENT_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 // $Id$
8
9 ///
10 /// @file   AliHLTMUONTriggerReconstructorComponent.h
11 /// @author Indranil Das <indra.das@saha.ac.in>, Artur Szostak <artursz@iafrica.com>
12 /// @date   18 Sep 2007
13 /// @brief  A processing component for the dHLT trigger DDL reconstruction.
14 ///
15
16 #include "AliHLTMUONProcessor.h"
17 #include "AliHLTMUONDataTypes.h"
18
19 #if __GNUC__ && __GNUC__ < 3
20 #define std
21 #endif
22
23 class AliHLTMUONTriggerReconstructor;
24
25 /**
26  * @class AliHLTMUONTriggerReconstructorComponent
27  * @brief A processing component for the dHLT trigger DDL reconstruction.
28  *
29  * The trigger reconstructor component is used to decode the raw data coming
30  * from the trigger chambers and electronics of the muon spectrometer.
31  * The local trigger decisions are converted into trigger records which is a
32  * usable format by the tracking stage.
33  * No full cluster finding is performed, rather just the fired strip information
34  * as received from the trigger electronics is converted into global coordinates
35  * to be used by the tracker as track seeds.
36  *
37  * <h2>General properties:</h2>
38  *
39  * Component ID: \b MUONTriggerReconstructor <br>
40  * Library: \b libAliHLTMUON.so   <br>
41  * Input Data Types: AliHLTMUONConstants::DDLRawDataType() = "DDL_RAW :MUON" <br>
42  * Output Data Types: \li AliHLTMUONConstants::TriggerRecordsBlockDataType() = "TRIGRECS:MUON"
43  *                    \li AliHLTMUONConstants::TrigRecsDebugBlockDataType() = "TRIGRDBG:MUON" <br>
44  *
45  * <h2>Mandatory arguments:</h2>
46  * \li -ddl <i>number</i> <br>
47  *      This indicates the DDL from which the component is expect to receive data
48  *      and for which it should load the appropriate electronics mapping lookup
49  *      table.
50  *      The <i>number</i> should be in the range [21..22], following local dimuon
51  *      spectrometer DDL numbering. If either the -ddlid, -lut or -delaysetup
52  *      arguments are used, then -ddl becomes optional. <br>
53  * \li -ddlid <i>number</i> <br>
54  *      This indicates the DDL by equipment ID, from which the component is expect
55  *      to receive data and for which it should load the appropriate electronics
56  *      mapping lookup table.
57  *      The <i>number</i> should be in the range [2816..2817].
58  *      If either the -ddl, -lut or -delaysetup arguments are used, then -ddlid
59  *      becomes optional. <br>
60  * \li -delaysetup <br>
61  *      Specifying this option causes the component to initialise the lookup table
62  *      and magnetic field parameters from CDB only after receiving the first event
63  *      to process in DoEvent.
64  *      If -ddl or -ddlid were not used, then the DDL number will be taken from
65  *      the first block's specification during runtime from the first
66  *      event (i.e. Start-of-Run event).
67  *      Using the -lut, -zmiddle or -bfieldintegral arguments will override loading
68  *      from CDB for a delayed setup. <br>
69  *
70  * <h2>Optional arguments:</h2>
71  * \li -lut <i>filename</i> <br>
72  *      A pree-built lookup table for the electronics mapping and calibration
73  *      information can be loaded with this argument. The file should have been
74  *      generated with the GenerateLookupTable method. The location of the file
75  *      is given by the parameter <i>filename</i> <br>
76  * \li -cdb <br>
77  *      Indicates that the component should load from CDB. This option is implicit
78  *      if the -cdbpath is given. It will also override the -lut option.<br>
79  * \li -cdbpath <i>path</i> <br>
80  *      Specifies the CDB path to use, given by <i>path</i>. This option will override
81  *      the CDB path automatically set by the HLT framework. <br>
82  * \li -run <i>number</i> <br>
83  *      Specifies the run number to use, given by <i>number</i>. This option will
84  *      override the current run number automatically set by the HLT framework. <br>
85  * \li -zmiddle <i>position</i> <br>
86  *      This indicates the Z coordinate position of the middle of the dipole magnetic
87  *      field. <i>position</i> is a floating point value in centimeters. Specifying
88  *      this argument on the will override the value loaded from CDB. <br>
89  * \li -bfieldintegral <i>field</i> <br>
90  *      This indicates the magnetic field integral for the dipole magnetic field.
91  *      <i>field</i> must be a floating point value in Tesla meters (T.m).
92  *      The sign of the value will indicate the polarity setting of the dipole magnet.
93  *      Specifying this argument on the will override the value loaded from CDB. <br>
94  * \li -warn_on_unexpected_block <br>
95  *      This will cause the component to generate warnings when it receives data block
96  *      types it does not know how to handle. Without this option the component only
97  *      generates debug messages when they are compiled in. <br>
98  * \li -suppress_partial_triggers <br>
99  *      This option forces all trigger records that have less than 3 hits in them
100  *      to be removed from the output. This is the default setting. <br>
101  * \li -generate_partial_triggers <br>
102  *      With this option all trigger records, even partial ones with just one or two
103  *      hits is written to the output. <br>
104  * \li -stop_on_buffer_overflow <br>
105  *      If this option is specified then the component will stop processing and generate
106  *      an error code in the DoEvent method as soon as the output buffer has been filled.
107  *      Otherwise the component normally just keeps processing but some data might be lost
108  *      due to full buffers. <br>
109  * \li -tryrecover <br>
110  *      This is a special option to the raw data decoder to turn on logic which will
111  *      try and recover from corrupt raw DDL data. This is off by default. <br>
112  * \li -dont_use_crateid <br>
113  *      This option indicates that the crate ID values found in the regional structures
114  *      in the raw DDL data should not be used to identify the channels in the offline
115  *      mapping. Rather the position of the raw data structure instead. <br>
116  * \li -dont_use_localid <br>
117  *      This option indicates that the local structure ID values found in the raw DDL
118  *      data should not be used to identify the channels in the offline mapping, but
119  *      rather the position of the local structure in the DDL should be used instead. <br>
120  * \li -dumponerror <br>
121  *      This flag will cause the component to dump the data blocks it received if
122  *      an error occurs during the processing of an event. <br>
123  * \li -dumppath <i>path</i> <br>
124  *      Allows one to specify the path in which to dump the received data blocks
125  *      if an error occurs. <br>
126  * \li -makedebuginfo <br>
127  *      If specified then the trigger record debug informaiton data blocks are generated. <br>
128  *
129  * <h2>Standard configuration:</h2>
130  * The configuration is taken from the CDB by default. It can be overridden with
131  * the command line arguments.
132  *
133  * <h2>Default CDB entries:</h2>
134  * HLT/ConfigHLT/HLTGlobalTrigger - Contains the global trigger menu.
135  *
136  * <h2>Performance:</h2>
137  * This is a linear function of the number of input triggers (AliHLTTrigger) that
138  * need to be processed.
139  * For a modest trigger menu configurations the processing time per event should
140  * be on the order of a few milliseconds.
141  *
142  * <h2>Memory consumption:</h2>
143  * This is a linear function of the input data size, but only a fraction. Thus the
144  * memory usage is minimal. It should be under 1 MBytes.
145  *
146  * <h2>Output size:</h2>
147  * This will depend linearly on the number of tracks found. But for nominal multiplicities
148  * this should be less than 16 kBytes.
149  *
150  * @ingroup alihlt_dimuon_component
151  */
152 class AliHLTMUONTriggerReconstructorComponent : public AliHLTMUONProcessor
153 {
154 public:
155         AliHLTMUONTriggerReconstructorComponent();
156         virtual ~AliHLTMUONTriggerReconstructorComponent();
157
158         // Public functions to implement AliHLTComponent's interface.
159         // These functions are required for the registration process
160
161         virtual const char* GetComponentID();
162         virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
163         virtual AliHLTComponentDataType GetOutputDataType();
164         virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& list);
165         virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
166         virtual AliHLTComponent* Spawn();
167         
168         /**
169          * Generates a binary file containing the lookup table (LUT) from the
170          * CDB, which can be used for the trigger reconstructor component later.
171          * @param ddl  Must be the DDL for which to generate the DDL,
172          *             in the range [20..21].
173          * @param filename  The name of the LUT file to generate.
174          * @param cdbPath  The CDB path to use.
175          * @param run  The run number to use for the CDB.
176          * @param useCrateId  Indicates that the crate ID should be used rather
177          *             than a sequencial number (default is true).
178          * @return  True if the generation of the LUT file succeeded.
179          */
180         static bool GenerateLookupTable(
181                         AliHLTInt32_t ddl, const char* filename,
182                         const char* cdbPath, Int_t run, bool useCrateId = true
183                 );
184
185 protected:
186
187         // Protected functions to implement AliHLTComponent's interface.
188         // These functions provide initialization as well as the actual processing
189         // capabilities of the component.
190         
191         virtual int DoInit(int argc, const char** argv);
192         virtual int Reconfigure(const char* cdbEntry, const char* componentId);
193         virtual int ReadPreprocessorValues(const char* modules);
194         virtual int DoDeinit();
195
196         virtual int DoEvent(
197                         const AliHLTComponentEventData& evtData,
198                         const AliHLTComponentBlockData* blocks,
199                         AliHLTComponentTriggerData& trigData,
200                         AliHLTUInt8_t* outputPtr,
201                         AliHLTUInt32_t& size,
202                         AliHLTComponentBlockDataList& outputBlocks
203                 );
204         
205         using AliHLTProcessor::DoEvent;
206
207 private:
208
209         // Do not allow copying of this class.
210         /// Not implemented.
211         AliHLTMUONTriggerReconstructorComponent(const AliHLTMUONTriggerReconstructorComponent& /*obj*/);
212         /// Not implemented.
213         AliHLTMUONTriggerReconstructorComponent& operator = (const AliHLTMUONTriggerReconstructorComponent& /*obj*/);
214
215         /**
216          * Read in the lookup table from file.
217          * \param lutpath  The file to read the lookup table from.
218          */
219         int ReadLookUpTable(const char* lutpath);
220         
221         /**
222          * Loads the lookup table containing channel and geometrical position
223          * information about trigger strips from CDB.
224          *
225          * \note To override the default CDB path and/or run number the
226          * SetCDBPathAndRunNo(cdbPath, run) method should be called before this
227          * method.
228          *
229          * \return 0 on success and non zero codes for errors.
230          */
231         int ReadLutFromCDB();
232         
233         /**
234          * Reads this component's configuration parameters from the CDB.
235          * These include the middle of the dipole Z coordinate (zmiddle) and the
236          * integrated magnetic field of the dipole.
237          * \param setZmiddle Indicates if the zmiddle parameter should be set
238          *       (default true).
239          * \param setBL Indicates if the integrated magnetic field parameter should
240          *       be set (default true).
241          * \return 0 if no errors occured and negative error code compatible with
242          *       the HLT framework on errors.
243          */
244         int ReadConfigFromCDB(bool setZmiddle = true, bool setBL = true);
245         
246         AliHLTMUONTriggerReconstructor* fTrigRec; ///< The trigger reconstructor class implementing the algorithm.
247         AliHLTInt32_t fDDL;   ///< The DDL number in the range 20..21 from which to expect input. Set to -1 for invalid/unspecified value.
248         bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.
249         bool fStopOnOverflow;  ///< Flag indicating if we should fail in the DoEvent method if the output buffer was overflowed.
250         bool fUseCrateId;  ///< Flag to indicate if the crate ID as found in the regional header structures should be used or not.
251         bool fZmiddleSpecified;  ///< Indicates if the zmiddle parameter was specified on the command line.
252         bool fBLSpecified;  ///< Indicates if the bfieldintegral parameter was specified on the command line.
253         bool fLutInitialised;  ///< Flag to indicate if the LUT was loaded yet or not.
254
255         ClassDef(AliHLTMUONTriggerReconstructorComponent, 0) // Trigger reconstructor component for dHLT trigger DDL raw data.
256
257 };
258
259 #endif // AliHLTMUONTRIGGERRECONSTRUCTORCOMPONENT_H