]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCHWCFSpacePointContainer.h
debug output removed
[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   virtual bool Check(AliHLTUInt32_t clusterID) const;
41   virtual int GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const;
42   virtual const vector<AliHLTUInt32_t>* GetClusterIDs(AliHLTUInt32_t mask);
43   virtual float GetX(AliHLTUInt32_t clusterID) const;
44   virtual float GetXWidth(AliHLTUInt32_t clusterID) const;
45   virtual float GetY(AliHLTUInt32_t clusterID) const;
46   virtual float GetYWidth(AliHLTUInt32_t clusterID) const;
47   virtual float GetZ(AliHLTUInt32_t clusterID) const;
48   virtual float GetZWidth(AliHLTUInt32_t clusterID) const;
49   virtual float GetCharge(AliHLTUInt32_t clusterID) const;
50   virtual float GetPhi(AliHLTUInt32_t clusterID) const;
51
52   /// add input block to the collection
53   virtual int AddInputBlock(const AliHLTComponentBlockData* pDesc);
54
55   virtual int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTUInt32_t mask) const;
56   int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTTPCHWCFData* pDecoder, int slice, int partition) const;
57   virtual const AliHLTSpacePointPropertyGrid* GetSpacePointPropertyGrid(AliHLTUInt32_t mask) const;
58   virtual int SetSpacePointPropertyGrid(AliHLTUInt32_t mask, AliHLTSpacePointPropertyGrid*);
59
60   /// clear the object and reset pointer references
61   virtual void Clear(Option_t * option ="");
62
63   /// print information
64   virtual void Print(ostream& out, Option_t *option="") const;
65
66   /// create a collection of clusters for a space point mask
67   virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
68
69   /// create a collection of clusters for a specific track
70   virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
71
72   /// create a collection of clusters for a specific MC track
73   virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
74
75   /// create a collection of all used clusters
76   virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
77
78   /// create a collection of all unused clusters
79   virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
80
81   virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
82   virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
83   virtual int GetTrackID(AliHLTUInt32_t clusterID) const;
84   virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
85
86   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size,
87                     vector<AliHLTComponentBlockData>& outputBlocks,
88                     AliHLTDataDeflater* pDeflater,
89                     const char* option="") const;
90   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
91                     vector<AliHLTComponentBlockData>& outputBlocks,
92                     AliHLTDataDeflater* pDeflater,
93                     const char* option="") const;
94
95   int WriteUnsorted(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
96                     vector<AliHLTComponentBlockData>& outputBlocks,
97                     AliHLTDataDeflater* pDeflater,
98                     const char* option="") const;
99
100   int WriteSorted(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
101                   vector<AliHLTComponentBlockData>& outputBlocks,
102                   AliHLTDataDeflater* pDeflater,
103                   const char* option="") const;
104
105   int WriteSorted(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTUInt32_t offset,
106                   AliHLTTPCHWCFData* pDecoder, AliHLTSpacePointPropertyGrid* pGrid,
107                   AliHLTUInt32_t mask,
108                   vector<AliHLTComponentBlockData>&  outputBlocks,
109                   AliHLTDataDeflater* pDeflater,
110                   const char* option) const;
111
112   /// allocate index grid, one single point to define the dimensions
113   static AliHLTSpacePointPropertyGrid* AllocateIndexGrid();
114
115   class AliHLTTPCHWCFSpacePointProperties {
116   public:
117     AliHLTTPCHWCFSpacePointProperties();
118     AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index);
119     AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src);
120     AliHLTTPCHWCFSpacePointProperties& operator=(const AliHLTTPCHWCFSpacePointProperties& src);
121
122     ~AliHLTTPCHWCFSpacePointProperties() {}
123
124     const AliHLTTPCHWCFData* Decoder() const {return fDecoder;}
125     int GetSpacepointIndex() const {return fIndex;}
126     bool IsUsed() const {return fUsed;}
127     void MarkUsed(bool used=true) {fUsed=used;}
128     int GetTrackId() const {return fTrackId;}
129     void SetTrackId(int trackId) {fTrackId=trackId;}
130     int GetMCId() const {return fMCId;}
131     void SetMCId(int mcId) {fMCId=mcId;}
132
133     void Print(ostream& out, Option_t *option="") const;
134
135   private:
136     const AliHLTTPCHWCFData* fDecoder; //! decoder for data block
137     int fIndex; //! index within the decoder block
138     bool fUsed; //! transient
139     int fTrackId; //! track id from reconstruction
140     int fMCId; //! MC id
141   };
142
143   class AliHLTTPCHWCFSpacePointBlock {
144   public:
145     AliHLTTPCHWCFSpacePointBlock(AliHLTUInt32_t id=0, AliHLTTPCHWCFData* pDecoder=NULL, AliHLTSpacePointPropertyGrid* pGrid=NULL)
146       : fDecoder(pDecoder), fGrid(pGrid), fId(id) {}
147     AliHLTTPCHWCFSpacePointBlock(const AliHLTTPCHWCFSpacePointBlock& s) 
148       : fDecoder(s.fDecoder), fGrid(s.fGrid), fId(s.fId) {}
149     AliHLTTPCHWCFSpacePointBlock& operator=(const AliHLTTPCHWCFSpacePointBlock& s) 
150     { fDecoder=s.fDecoder; fGrid=s.fGrid; fId=s.fId; return *this;}
151     ~AliHLTTPCHWCFSpacePointBlock() {}
152
153     int GetNofSpacepoints() const {return fDecoder?fDecoder->GetNumberOfClusters():0;}
154     AliHLTUInt32_t GetId() const {return fId;}
155     void SetId(AliHLTUInt32_t id) {fId=id;}
156     AliHLTTPCHWCFData* GetDecoder() const {return fDecoder;} 
157     void SetDecoder(AliHLTTPCHWCFData* pDecoder) {fDecoder=pDecoder;}
158     AliHLTSpacePointPropertyGrid* GetGrid() const {return fGrid;}
159     void SetGrid(AliHLTSpacePointPropertyGrid* pGrid) {fGrid=pGrid;}
160
161   protected:
162   private:
163     AliHLTTPCHWCFData* fDecoder; //!
164     AliHLTSpacePointPropertyGrid* fGrid; //!
165     AliHLTUInt32_t fId; //!
166   };
167
168  protected:
169
170  private:
171   /// map of clusters
172   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties> fClusters; //!
173
174   /// map of cluster id collection for different masks
175   std::map<AliHLTUInt32_t, vector<AliHLTUInt32_t>*> fSelections; //!
176
177   /// array of decoders
178   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock> fBlocks; //!
179
180   /// the one instance for mode single (=1)
181   AliHLTTPCHWCFSpacePointBlock fSingleBlock;
182
183   /// mode
184   int fMode; //!
185
186   ClassDef(AliHLTTPCHWCFSpacePointContainer, 0)
187 };
188
189 ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p);
190
191 #endif