]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h
Refactoring code to pull common functionality for loading CDB configuration entries...
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONHitReconstructorComponent.h
1 #ifndef ALIHLTMUONHITRECONSTRUCTORCOMPONENT_H
2 #define ALIHLTMUONHITRECONSTRUCTORCOMPONENT_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   AliHLTMUONHitReconstructorComponent.h
11 ///  @author Indranil Das <indra.das@saha.ac.in> | <indra.ehep@gmail.com>, Artur Szostak <artursz@iafrica.com>
12 ///  @date   28 May 2007
13 ///  @brief  Hit Reconstruction processing component for the dimuon HLT.
14 ///
15
16 #include "AliHLTMUONProcessor.h"
17 #include "AliHLTMUONHitReconstructor.h"
18
19 #if __GNUC__ && __GNUC__ < 3
20 #define std
21 #endif
22
23
24 extern "C" struct AliHLTMUONHitRecoLutRow;
25
26 /**
27  * @class AliHLTMUONHitReconstructorComponent
28  * @brief A processing component for the dHLT tracker DDL reconstruction.
29  *
30  * This is the hit reconstruction component which forms part of the online dHLT
31  * reconstruction algorithm. It processes the raw DDL data from a dimuon spectrometer
32  * tracker station, applies simple 3 pad cluster finding and then a centre of gravity
33  * calculation to reconstruct the hit coordinate.
34  *
35  * <h2>General properties:</h2>
36  *
37  * Component ID: \b MUONHitReconstructor <br>
38  * Library: \b libAliHLTMUON.so  <br>
39  * Input Data Types: ('DDL_RAW ', 'MUON') <br>
40  * Output Data Types: ('RECHITS ', 'MUON') <br>
41  *
42  * <h2>Mandatory arguments:</h2>
43  * \li -ddl <i>number</i> <br>
44  *      This indicates the DDL from which the component is expect to receive data
45  *      and for which it should load the appropriate electronics mapping lookup
46  *      table.
47  *      The <i>number</i> should be in the range [13..20], following local dimuon
48  *      spectrometer DDL numbering. If either the -ddlid, -lut or -delaysetup
49  *      arguments are used, then -ddl becomes optional. <br>
50  * \li -ddlid <i>number</i> <br>
51  *      This indicates the DDL by equipment ID, from which the component is expect
52  *      to receive data and for which it should load the appropriate electronics
53  *      mapping lookup table.
54  *      The <i>number</i> should be in the range [2572..2579].
55  *      If either the -ddl, -lut or -delaysetup arguments are used, then -ddlid
56  *      becomes optional. <br>
57  * \li -delaysetup <br>
58  *      Specifying this option causes the component to initialise the lookup table
59  *      and DC cut parameters from CDB only after receiving the first event to
60  *      process in DoEvent.
61  *      If -ddl or -ddlid were not used, then the DDL number will be taken from
62  *      the first block's specification during runtime from the first
63  *      event (Start-of-Run event).
64  *      Using the -lut or -dccut arguments will override loading from CDB for a
65  *      delayed setup. <br>
66  *
67  * <h2>Optional arguments:</h2>
68  * \li -lut <i>filename</i> <br>
69  *      A pree-built lookup table for the electronics mapping and calibration
70  *      information can be loaded with this argument. The file should have been
71  *      generated with the GenerateLookupTable method. The location of the file
72  *      is given by the parameter <i>filename</i> <br>
73  * \li -cdb <br>
74  *      Indicates that the component should load from CDB. This option is implicit
75  *      if the -cdbpath is given. It will also override the -lut option.<br>
76  * \li -cdbpath <i>path</i> <br>
77  *      Specifies the CDB path to use, given by <i>path</i>. This option will override
78  *      the CDB path automatically set by the HLT framework. <br>
79  * \li -run <i>number</i> <br>
80  *      Specifies the run number to use, given by <i>number</i>. This option will
81  *      override the current run number automatically set by the HLT framework. <br>
82  * \li -dccut <i>number</i> <br>
83  *      Used to override the DC cut parameter in the CDB with the value given by
84  *      <i>number</i>. <br>
85  * \li -warn_on_unexpected_block <br>
86  *      This will cause the component to generate warnings when it receives data block
87  *      types it does not know how to handle. Without this option the component only
88  *      generates debug messages when they are compiled in. <br>
89  * \li -tryrecover <br>
90  *      This is a special option to the raw data decoder to turn on logic which will
91  *      try and recover from corrupt raw DDL data. This is off by default. <br>
92  *
93  * <h2>Standard configuration:</h2>
94  * This component should normally be configured with either of the two sets of
95  * options in the XML configuration. <br>
96  * \li -delaysetup <br>
97  * \li -ddlid ${DDL_ID} <br>
98  *
99  * <h2>Default CDB entries:</h2>
100  * The component loads electronics mapping and calibration information from the MUON
101  * subdirectory in the CDB, MUON/Calib and MUON/Align.
102  * The DC cut parameter is stored in a TMap under HLT/ConfigMUON/HitReconstructor
103  * with a default value of 50 ADC channels.
104  *
105  * <h2>Performance:</h2>
106  * Can achieve about 2kHz processing rate for nominal event sizes containing
107  * 150 tracks per event.
108  *
109  * <h2>Memory consumption:</h2>
110  * The lookup table requires about 3.5 MBytes of memory.
111  *
112  * <h2>Output size:</h2>
113  * Output size is about 10% of incoming raw input data for nominal p+p events.
114  *
115  * @ingroup alihlt_dimuon_component
116  */
117 class AliHLTMUONHitReconstructorComponent : public AliHLTMUONProcessor
118 {
119 public:
120         AliHLTMUONHitReconstructorComponent();
121         virtual ~AliHLTMUONHitReconstructorComponent();
122
123         // Public functions to implement AliHLTComponent's interface.
124         // These functions are required for the registration process
125
126         virtual const char* GetComponentID();
127         virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list);
128         virtual AliHLTComponentDataType GetOutputDataType();
129         virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
130         virtual AliHLTComponent* Spawn();
131         
132         /**
133          * Generates an ASCII text file containing the lookup table (LUT) from
134          * the CDB, which can be used for the hit reconstructor component later.
135          * @param ddl  Must be the DDL for which to generate the DDL,
136          *             in the range [12..19].
137          * @param filename  The name of the LUT file to generate.
138          * @param cdbPath  The CDB path to use.
139          * @param run  The run number to use for the CDB.
140          * @return  True if the generation of the LUT file succeeded.
141          */
142         static bool GenerateLookupTable(
143                         AliHLTInt32_t ddl, const char* filename,
144                         const char* cdbPath, Int_t run
145                 );
146         
147 protected:
148         
149         // Protected functions to implement AliHLTComponent's interface.
150         // These functions provide initialization as well as the actual processing
151         // capabilities of the component.
152
153         virtual int DoInit(int argc, const char** argv);
154         virtual int Reconfigure(const char* cdbEntry, const char* componentId);
155         virtual int ReadPreprocessorValues(const char* modules);
156         virtual int DoDeinit();
157         virtual int DoEvent(
158                         const AliHLTComponentEventData& evtData,
159                         const AliHLTComponentBlockData* blocks,
160                         AliHLTComponentTriggerData& trigData,
161                         AliHLTUInt8_t* outputPtr,
162                         AliHLTUInt32_t& size,
163                         std::vector<AliHLTComponentBlockData>& outputBlocks
164                 );
165         
166         using AliHLTProcessor::DoEvent;
167         
168 private:
169
170         // Do not allow copying of this class.
171         /// Not implemented.
172         AliHLTMUONHitReconstructorComponent(const AliHLTMUONHitReconstructorComponent& /*obj*/);
173         /// Not implemented.
174         AliHLTMUONHitReconstructorComponent& operator = (const AliHLTMUONHitReconstructorComponent& /*obj*/);
175         
176         void FreeMemory();
177         int ReadLookUpTable(const char* lutpath);
178         int ReadLutFromCDB();
179         int ReadDCCutFromCDB(const char* path = NULL);
180         
181         AliHLTMUONHitReconstructor* fHitRec;  ///< Internal class instance implementing the hit reconstruction algorithm.
182         AliHLTInt32_t fDDL;  ///< DDL number in the range [12..19]. Set to -1 for invalid/unspecified value.
183         AliHLTUInt32_t fLutSize;  ///< The number of rows / entries in the LUT.
184         AliHLTMUONHitRecoLutRow* fLut;  ///< The lookup table used by the hit reconstruction algorithm (Owned by this component however).
185         IdManuChannelToEntry fIdToEntry; ///< id to line mapping.
186         bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.
187         bool fDelaySetup;  ///< Indicates if the component should delay loading and initialising from the CDB to the start of run event.
188         
189         ClassDef(AliHLTMUONHitReconstructorComponent, 0) // Hit reconstructor component for dHLT tracker DDL raw data.
190 };
191
192 #endif // ALIHLTMUONHITRECONSTRUCTORCOMPONENT_H