]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCHWCFSpacePointContainer.h
update of track model compression
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCHWCFSpacePointContainer.h
1 //-*- Mode: C++ -*-
2 // $Id$
3 #ifndef ALIHLTTPCHWCFSPACEPOINTCONTAINER_H
4 #define ALIHLTTPCHWCFSPACEPOINTCONTAINER_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   AliHLTTPCHWCFSpacePointContainer.h
10 /// @author Matthias Richter
11 /// @date   2011-08-08
12 /// @brief  Helper class for handling of HLT TPC cluster data blocks from the
13 ///         HW ClusterFinder
14 /// @note   Class is a duplicate of AliHLTTPCHWCFSpacePointContainer and should
15 ///         be merged with it in a generic way
16
17 #include "AliHLTSpacePointContainer.h"
18 #include "AliHLTTPCHWCFData.h"
19 #include <map>
20 using namespace std;
21
22 /**
23  * @class AliHLTTPCHWCFSpacePointContainer
24  * Handler class for HLT TPC hardware ClusterFinder space point data blocks.
25  *
26  * @ingroup alihlt_tpc
27  */
28 class AliHLTTPCHWCFSpacePointContainer : public AliHLTSpacePointContainer
29 {
30  public:
31   /// standard constructor
32   AliHLTTPCHWCFSpacePointContainer(int mode=0);
33   /// copy constructor
34   AliHLTTPCHWCFSpacePointContainer(const AliHLTTPCHWCFSpacePointContainer& c);
35   /// assignment operator
36   AliHLTTPCHWCFSpacePointContainer& operator=(const AliHLTTPCHWCFSpacePointContainer& c);
37   /// destructor
38   ~AliHLTTPCHWCFSpacePointContainer();
39
40   enum {
41     kModeSingle = 0x1,
42     kModeCreateMap = 0x2
43   };
44
45   virtual bool Check(AliHLTUInt32_t clusterID) const;
46   virtual int GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const;
47   virtual const vector<AliHLTUInt32_t>* GetClusterIDs(AliHLTUInt32_t mask);
48   virtual float GetX(AliHLTUInt32_t clusterID) const;
49   virtual float GetXWidth(AliHLTUInt32_t clusterID) const;
50   virtual float GetY(AliHLTUInt32_t clusterID) const;
51   virtual float GetYWidth(AliHLTUInt32_t clusterID) const;
52   virtual float GetZ(AliHLTUInt32_t clusterID) const;
53   virtual float GetZWidth(AliHLTUInt32_t clusterID) const;
54   virtual float GetCharge(AliHLTUInt32_t clusterID) const;
55   virtual float GetQMax(AliHLTUInt32_t clusterID) const;
56   virtual float GetPhi(AliHLTUInt32_t clusterID) const;
57
58   /// add input block to the collection
59   virtual int AddInputBlock(const AliHLTComponentBlockData* pDesc);
60
61   virtual int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTUInt32_t mask) const;
62   int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTTPCHWCFData* pDecoder, int slice, int partition) const;
63   virtual const AliHLTSpacePointPropertyGrid* GetSpacePointPropertyGrid(AliHLTUInt32_t mask) const;
64   virtual int SetSpacePointPropertyGrid(AliHLTUInt32_t mask, AliHLTSpacePointPropertyGrid*);
65
66   /// clear the object and reset pointer references
67   virtual void Clear(Option_t * option ="");
68
69   /// print information
70   virtual void Print(ostream& out, Option_t *option="") const;
71
72   /// create a collection of clusters for a space point mask
73   virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
74
75   /// create a collection of clusters for a specific track
76   virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
77
78   /// create a collection of clusters for a specific MC track
79   virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
80
81   /// create a collection of all used clusters
82   virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
83
84   /// create a collection of all unused clusters
85   virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
86
87   virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
88   virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
89   virtual int GetTrackID(AliHLTUInt32_t clusterID) const;
90   virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
91
92   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size,
93                     vector<AliHLTComponentBlockData>& outputBlocks,
94                     AliHLTDataDeflater* pDeflater,
95                     const char* option="") const;
96   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
97                     vector<AliHLTComponentBlockData>& outputBlocks,
98                     AliHLTDataDeflater* pDeflater,
99                     const char* option="") const;
100
101   int WriteSorted(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
102                   vector<AliHLTComponentBlockData>& outputBlocks,
103                   AliHLTDataDeflater* pDeflater,
104                   const char* option="") const;
105
106   int WriteSorted(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
107                   AliHLTTPCHWCFData* pDecoder, AliHLTSpacePointPropertyGrid* pGrid,
108                   AliHLTUInt32_t mask,
109                   vector<AliHLTComponentBlockData>&  outputBlocks,
110                   AliHLTDataDeflater* pDeflater,
111                   const char* option) const;
112
113   /// allocate index grid, one single point to define the dimensions
114   static AliHLTSpacePointPropertyGrid* AllocateIndexGrid();
115
116   class AliHLTTPCHWCFSpacePointProperties {
117   public:
118     AliHLTTPCHWCFSpacePointProperties();
119     AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index);
120     AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src);
121     AliHLTTPCHWCFSpacePointProperties& operator=(const AliHLTTPCHWCFSpacePointProperties& src);
122
123     ~AliHLTTPCHWCFSpacePointProperties() {}
124
125     const AliHLTTPCHWCFData* Decoder() const {return fDecoder;}
126     int GetSpacepointIndex() const {return fIndex;}
127     bool IsUsed() const {return fUsed;}
128     void MarkUsed(bool used=true) {fUsed=used;}
129     int GetTrackId() const {return fTrackId;}
130     void SetTrackId(int trackId) {fTrackId=trackId;}
131     int GetMCId() const {return fMCId;}
132     void SetMCId(int mcId) {fMCId=mcId;}
133
134     void Print(ostream& out, Option_t *option="") const;
135
136   private:
137     const AliHLTTPCHWCFData* fDecoder; //! decoder for data block
138     int fIndex; //! index within the decoder block
139     bool fUsed; //! transient
140     int fTrackId; //! track id from reconstruction
141     int fMCId; //! MC id
142   };
143
144   class AliHLTTPCHWCFSpacePointBlock {
145   public:
146     AliHLTTPCHWCFSpacePointBlock(AliHLTUInt32_t id=0, AliHLTTPCHWCFData* pDecoder=NULL, AliHLTSpacePointPropertyGrid* pGrid=NULL)
147       : fDecoder(pDecoder), fGrid(pGrid), fId(id) {}
148     AliHLTTPCHWCFSpacePointBlock(const AliHLTTPCHWCFSpacePointBlock& s) 
149       : fDecoder(s.fDecoder), fGrid(s.fGrid), fId(s.fId) {}
150     AliHLTTPCHWCFSpacePointBlock& operator=(const AliHLTTPCHWCFSpacePointBlock& s) 
151     { fDecoder=s.fDecoder; fGrid=s.fGrid; fId=s.fId; return *this;}
152     ~AliHLTTPCHWCFSpacePointBlock() {}
153
154     int GetNofSpacepoints() const {return fDecoder?fDecoder->GetNumberOfClusters():0;}
155     AliHLTUInt32_t GetId() const {return fId;}
156     void SetId(AliHLTUInt32_t id) {fId=id;}
157     AliHLTTPCHWCFData* GetDecoder() const {return fDecoder;} 
158     void SetDecoder(AliHLTTPCHWCFData* pDecoder) {fDecoder=pDecoder;}
159     AliHLTSpacePointPropertyGrid* GetGrid() const {return fGrid;}
160     void SetGrid(AliHLTSpacePointPropertyGrid* pGrid) {fGrid=pGrid;}
161
162   protected:
163   private:
164     AliHLTTPCHWCFData* fDecoder; //!
165     AliHLTSpacePointPropertyGrid* fGrid; //!
166     AliHLTUInt32_t fId; //!
167   };
168
169  protected:
170
171  private:
172   /// map of clusters
173   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties> fClusters; //!
174
175   /// map of cluster id collection for different masks
176   std::map<AliHLTUInt32_t, vector<AliHLTUInt32_t>*> fSelections; //!
177
178   /// array of decoders
179   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock> fBlocks; //!
180
181   /// the one instance for mode single (=1)
182   AliHLTTPCHWCFSpacePointBlock fSingleBlock;
183
184   /// mode
185   int fMode; //!
186
187   ClassDef(AliHLTTPCHWCFSpacePointContainer, 0)
188 };
189
190 ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p);
191
192 #endif