]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerFSMComponent.h
d3a347395b7f679dc542f11641f9ab4f18e8df00
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONMansoTrackerFSMComponent.h
1 #ifndef AliHLTMUONMANSOTRACKERFSMCOMPONENT_H
2 #define AliHLTMUONMANSOTRACKERFSMCOMPONENT_H
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * All rights reserved.                                                   *
6  *                                                                        *
7  * Primary Authors:                                                       *
8  *   Artur Szostak <artursz@iafrica.com>                                  *
9  *   Indranil Das <indra.das@saha.ac.in>                                  *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          * 
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /* $Id$ */
21
22 ///
23 ///  @file   AliHLTMUONMansoTrackerFSMComponent.h
24 ///  @author Artur Szostak <artursz@iafrica.com>,
25 ///          Indranil Das <indra.das@saha.ac.in>
26 ///  @date   
27 ///  @brief  Tracker component for the dimuon HLT using the Manso algorithm
28 ///          implemented as a finite state machine.
29 ///
30
31 #include "AliHLTMUONProcessor.h"
32 #include "AliHLTMUONDataTypes.h"
33 #include "AliHLTMUONMansoTrackerFSMCallback.h"
34
35 #if __GNUC__ && __GNUC__ < 3
36 #define std
37 #endif
38
39 class AliHLTMUONMansoTrackerFSM;
40 //class AliHLTMUONMansoTracksBlockWriter;
41 extern "C" {
42 struct AliHLTMUONRecHitStruct;
43 } // extern C
44
45
46 /**
47  * @class AliHLTMUONMansoTrackerFSMComponent
48  * @brief Dimuon HLT tracker component using the Manso tracking algorithm
49  *        implemented as a finite state machine.
50  */
51 class AliHLTMUONMansoTrackerFSMComponent
52         : public AliHLTMUONProcessor, public AliHLTMUONMansoTrackerFSMCallback
53 {
54 public:
55         AliHLTMUONMansoTrackerFSMComponent();
56         virtual ~AliHLTMUONMansoTrackerFSMComponent();
57
58         // Public functions to implement the AliHLTProcessor interface.
59         // These functions are required for the registration process.
60         virtual const char* GetComponentID();
61         virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
62         virtual AliHLTComponentDataType GetOutputDataType();
63         virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
64         virtual AliHLTComponent* Spawn();
65         
66         // Inherited from AliHLTMUONMansoTrackerFSMCallback:
67         virtual void RequestClusters(
68                         AliHLTMUONMansoTrackerFSM* tracker,
69                         AliHLTFloat32_t left, AliHLTFloat32_t right,
70                         AliHLTFloat32_t bottom, AliHLTFloat32_t top,
71                         AliHLTMUONChamberName chamber, const void* tag
72                 );
73         virtual void EndOfClusterRequests(AliHLTMUONMansoTrackerFSM* tracker);
74         virtual void FoundTrack(AliHLTMUONMansoTrackerFSM* tracker);
75         virtual void NoTrackFound(AliHLTMUONMansoTrackerFSM* tracker);
76
77 protected:
78
79         // Protected functions to implement the AliHLTProcessor interface.
80         // These functions provide initialization as well as the actual processing
81         // capabilities of the component. 
82         virtual int DoInit(int argc, const char** argv);
83         virtual int Reconfigure(const char* cdbEntry, const char* componentId);
84         virtual int ReadPreprocessorValues(const char* modules);
85         virtual int DoDeinit();
86         virtual int DoEvent(
87                         const AliHLTComponentEventData& evtData,
88                         const AliHLTComponentBlockData* blocks,
89                         AliHLTComponentTriggerData& trigData,
90                         AliHLTUInt8_t* outputPtr,
91                         AliHLTUInt32_t& size,
92                         AliHLTComponentBlockDataList& outputBlocks
93                 );
94         
95         using AliHLTProcessor::DoEvent;
96
97 private:
98
99         // Do not allow copying of this class.
100         AliHLTMUONMansoTrackerFSMComponent(const AliHLTMUONMansoTrackerFSMComponent& /*obj*/);
101         AliHLTMUONMansoTrackerFSMComponent& operator = (const AliHLTMUONMansoTrackerFSMComponent& /*obj*/);
102
103         void Reset();
104         void FreeMemory();
105         
106         void AddRecHits(
107                         AliHLTUInt32_t specification,
108                         const AliHLTMUONRecHitStruct* recHits,
109                         AliHLTUInt32_t count
110                 );
111         
112         void ResetCanLoadFlags();
113         bool AtLeastOneCanLoadFlagsIsSet() const;
114         
115         /**
116          * Reads this component's configuration parameters from the CDB.
117          * These include the middle of the dipole Z coordinate (zmiddle), the
118          * integrated magnetic field of the dipole, Z coordinates of the chambers
119          * and the region of interest parameters used during the tracking.
120          * \note Only those parameters are loaded from CDB for which the fCanLoadxyz
121          *       flags are true.
122          * \return 0 if no errors occured and negative error code compatible with
123          *       the HLT framework on errors.
124          */
125         int ReadConfigFromCDB();
126         
127
128         AliHLTMUONMansoTrackerFSM* fTracker;  //! Tracker to do the actual work.
129         
130         AliHLTUInt32_t fTrackCount;  //! Number of tracks currently found.
131         /*AliHLTMUONMansoTracksBlockWriter*/void* fBlock;  //! The current data block we are writing.
132         
133         class AliRecHitBlockInfo
134         {
135         public:
136         
137                 AliRecHitBlockInfo(AliHLTUInt32_t count = 0, const AliHLTMUONRecHitStruct* data = NULL) :
138                         fCount(count), fData(data)
139                 {}
140         
141                 // Perform a shallow copy.
142                 AliRecHitBlockInfo(const AliRecHitBlockInfo& obj) :
143                         fCount(obj.fCount), fData(obj.fData)
144                 {}
145                 
146                 AliRecHitBlockInfo& operator = (const AliRecHitBlockInfo& obj)
147                 {
148                         fCount = obj.fCount;
149                         fData = obj.fData;
150                         return *this;
151                 }
152                 
153                 AliHLTUInt32_t Count() const { return fCount; }
154                 const AliHLTMUONRecHitStruct* Data() const { return fData; }
155         
156         private:
157                 AliHLTUInt32_t fCount;  // Number of elements in fData.
158                 const AliHLTMUONRecHitStruct* fData; // Pointer to the array of rec hits.
159         };
160         
161         //std::vector<AliRecHitBlockInfo> fRecHitBlock[4];  //! Arrays of rec hit block data.
162         AliHLTUInt32_t fRecHitBlockArraySize;  ///< The array size of each array in fRecHitBlock.
163         AliHLTUInt32_t fRecHitBlockCount[4];   ///< The number of records actually stored in fRecHitBlock[i].
164         // The following are 4 dynamic arrays of AliRecHitBlockInfo structures.
165         // These arrays will all have the same size = fRecHitBlockArraySize.
166         // The array itself is actually allocated only once and the pointer stored in fRecHitBlock[0],
167         // while the other pointers fRecHitBlock[i] {i>0} will just be set relative to fRecHitBlock[0].
168         // The allocated memory is: 4 * fRecHitBlockArraySize * sizeof(AliRecHitBlockInfo).
169         AliRecHitBlockInfo* fRecHitBlock[4];  //! Arrays of rec hit block data.
170
171         bool fWarnForUnexpecedBlock;  ///< Flag indicating if we should log a warning if we got a block of an unexpected type.  
172         bool fCanLoadZmiddle;  ///< Indicates if the zmiddle parameter can be loaded from CDB.
173         bool fCanLoadBL;  ///< Indicates if the bfieldintegral parameter can be loaded from CDB.
174         bool fCanLoadA[4];  ///< Indicates if the roi_paramA_chamber[7..10] parameter can be loaded from CDB.
175         bool fCanLoadB[4];  ///< Indicates if the roi_paramB_chamber[7..10] parameter can be loaded from CDB.
176         bool fCanLoadZ[6];  ///< Indicates if the chamber[7..11,13]postion parameter can be loaded from CDB.
177         
178         ClassDef(AliHLTMUONMansoTrackerFSMComponent, 0);  // Manso tracker component implemented as a finite state machine (FSM).
179 };
180
181 #endif // AliHLTMUONMANSOTRACKERFSMCOMPONENT_H