Line data Source code
1 : //-*- Mode: C++ -*-
2 : // $Id$
3 : #ifndef ALIHLTSPACEPOINTCONTAINER_H
4 : #define ALIHLTSPACEPOINTCONTAINER_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 AliHLTSpacePointContainer.h
10 : /// @author Matthias Richter
11 : /// @date 2011-04-29
12 : /// @brief Base helper class for handling of HLT space point data blocks
13 : ///
14 :
15 : #include <vector>
16 : #include <cmath>
17 : #include <TObject.h>
18 : #include "AliHLTLogging.h"
19 : #include "AliHLTDataTypes.h"
20 : #include "AliHLTStdIncludes.h"
21 : #include "AliHLTIndexGrid.h"
22 :
23 : class AliHLTDataDeflater;
24 : class TArrayC;
25 : class TH1;
26 : class TTree;
27 :
28 : /**
29 : * @class AliHLTSpacePointContainer
30 : * Base class of helper classes for space point data blocks.
31 : * The class implements a couple of interface methods to be commonly used
32 : * for space point data blocks.
33 : *
34 : * @ingroup alihlt_base
35 : */
36 : class AliHLTSpacePointContainer : public TObject, public AliHLTLogging
37 : {
38 : public:
39 : /// standard constructor
40 : AliHLTSpacePointContainer();
41 : /// copy constructor
42 : AliHLTSpacePointContainer(const AliHLTSpacePointContainer&);
43 : /// assignment operator
44 : AliHLTSpacePointContainer& operator=(const AliHLTSpacePointContainer&);
45 :
46 : /// destructor
47 : ~AliHLTSpacePointContainer();
48 :
49 : struct AliHLTSpacePointProperties {
50 0 : AliHLTSpacePointProperties(AliHLTUInt32_t id=~(AliHLTUInt32_t)0, int trackid=-1) : fId(id), fTrackId(trackid) {}
51 : AliHLTUInt32_t fId; //! the id of the spacepoint
52 : int fTrackId; //! track the spacepoint is assigned to
53 : };
54 : typedef AliHLTIndexGrid<float, AliHLTSpacePointProperties> AliHLTSpacePointPropertyGrid;
55 : typedef AliHLTIndexGrid<float, AliHLTUInt32_t> AliHLTSpacePointGrid;
56 :
57 : //////////////////////////////////////////////////////////////////////////
58 : //
59 : // interface functions
60 : //
61 :
62 : /// add input block to the collection
63 : virtual int AddInputBlock(const AliHLTComponentBlockData* pDesc)=0;
64 0 : virtual int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* /*pGrid*/, AliHLTUInt32_t /*mask*/) const {return -ENOSYS;}
65 0 : virtual const AliHLTSpacePointPropertyGrid* GetSpacePointPropertyGrid(AliHLTUInt32_t /*mask*/) const {return NULL;}
66 0 : virtual int SetSpacePointPropertyGrid(AliHLTUInt32_t /*mask*/, AliHLTSpacePointPropertyGrid* /*pGrid*/) {return -ENOSYS;}
67 :
68 : // for backward compatibility
69 0 : virtual int PopulateAccessGrid(AliHLTSpacePointGrid* /*pGrid*/, AliHLTUInt32_t /*mask*/) const {return -ENOSYS;}
70 0 : virtual const AliHLTSpacePointGrid* GetAccessGrid(AliHLTUInt32_t /*mask*/) const {return NULL;}
71 0 : virtual int SetAccessGrid(AliHLTUInt32_t /*mask*/, AliHLTSpacePointGrid* /*pGrid*/) {return -ENOSYS;}
72 :
73 : virtual int GetNumberOfSpacePoints() const;
74 : virtual bool Check(AliHLTUInt32_t clusterID) const;
75 : virtual int GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const = 0;
76 0 : virtual const vector<AliHLTUInt32_t>* GetClusterIDs(AliHLTUInt32_t /*mask*/) {return NULL;}
77 : virtual float GetX(AliHLTUInt32_t clusterID) const = 0;
78 : virtual float GetXWidth(AliHLTUInt32_t clusterID) const = 0;
79 : virtual float GetY(AliHLTUInt32_t clusterID) const = 0;
80 : virtual float GetYWidth(AliHLTUInt32_t clusterID) const = 0;
81 : virtual float GetZ(AliHLTUInt32_t clusterID) const = 0;
82 : virtual float GetZWidth(AliHLTUInt32_t clusterID) const = 0;
83 : virtual float GetCharge(AliHLTUInt32_t clusterID) const = 0;
84 0 : virtual float GetMaxSignal(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
85 0 : virtual float GetPhi(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
86 0 : virtual UChar_t GetPadRow(AliHLTUInt32_t /*clusterID*/) const {return 0;}
87 :
88 : /// create a collection of clusters for a space point mask
89 : virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
90 :
91 : /// create a collection of clusters for a specific track
92 : virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
93 :
94 : /// create a collection of clusters for a specific MC track
95 : virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
96 :
97 : /// create a collection of all used clusters
98 : virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
99 :
100 : /// create a collection of all unused clusters
101 : virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
102 :
103 0 : int MarkUsed(AliHLTUInt32_t clusterID) {return MarkUsed(&clusterID, sizeof(clusterID));}
104 : virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
105 :
106 : int SetTrackID(int trackID, AliHLTUInt32_t clusterID) {
107 0 : return SetTrackID(trackID, &clusterID, sizeof(clusterID));
108 : }
109 : virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
110 :
111 0 : virtual int GetTrackID(AliHLTUInt32_t /*clusterID*/) const {return -1;}
112 :
113 : int SetMCID(int mcID, AliHLTUInt32_t clusterID) {
114 0 : return SetMCID(mcID, &clusterID, sizeof(clusterID));
115 : }
116 : virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
117 :
118 : /// write blocks to HLT component output
119 : virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size,
120 : vector<AliHLTComponentBlockData>& outputBlocks,
121 : AliHLTDataDeflater* /*pDeflater*/,
122 : const char* option="") const {
123 0 : return Write(outputPtr, size, outputBlocks, option);
124 : }
125 :
126 : /// write blocks to HLT component output: old function definition for backward compatibility
127 : virtual int Write(AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t /*size*/,
128 : vector<AliHLTComponentBlockData>& /*outputBlocks*/,
129 0 : const char* /*option*/="") const {return 0;}
130 :
131 : /// add input block from file to collection
132 : int AddInputBlock(const char* filename, AliHLTComponentDataType dt, unsigned specification);
133 :
134 : /// add input block from list of blank separated files to collection
135 : int AddInputBlocks(const char* filenames, AliHLTComponentDataType dt);
136 :
137 : /// alloc memory for a space point data block
138 : AliHLTUInt8_t* Alloc(int size);
139 :
140 : /// inherited from TObject: clear the object and reset pointer references
141 : virtual void Clear(Option_t * /*option*/ ="");
142 :
143 : /// inherited from TObject
144 : virtual void Print(Option_t *option="") const;
145 :
146 : virtual void Print(ostream& out, Option_t *option="") const;
147 :
148 : void Draw(Option_t *option);
149 :
150 : TH1* DrawProjection(const char* plane) const {
151 0 : vector<AliHLTUInt32_t> selection; // empty list -> no selection
152 0 : return DrawProjection(plane, selection);
153 0 : }
154 :
155 : TH1* DrawProjection(const char* plane, AliHLTUInt32_t specification) const {
156 0 : vector<AliHLTUInt32_t> selection; selection.push_back(specification);
157 0 : return DrawProjection(plane, selection);
158 0 : }
159 :
160 : TH1* DrawProjection(const char* plane, const vector<AliHLTUInt32_t>& selection) const;
161 :
162 : TTree* FillTree(const char* name, const char* title="");
163 :
164 : protected:
165 :
166 : private:
167 : vector<TArrayC*> fBuffers; //! buffers of loaded files
168 :
169 126 : ClassDef(AliHLTSpacePointContainer, 0)
170 : };
171 :
172 : ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c);
173 :
174 : ostream& operator<<(ostream &out, const AliHLTSpacePointContainer::AliHLTSpacePointProperties& p);
175 :
176 : bool operator==(const AliHLTSpacePointContainer::AliHLTSpacePointProperties& a,
177 : const AliHLTSpacePointContainer::AliHLTSpacePointProperties& b);
178 : #endif
|