]>
Commit | Line | Data |
---|---|---|
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 | 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 | virtual int PopulateAccessGrid(AliHLTSpacePointPropertyGrid* /*pGrid*/, AliHLTUInt32_t /*mask*/) const {return -ENOSYS;} | |
65 | virtual const AliHLTSpacePointPropertyGrid* GetSpacePointPropertyGrid(AliHLTUInt32_t /*mask*/) const {return NULL;} | |
66 | virtual int SetSpacePointPropertyGrid(AliHLTUInt32_t /*mask*/, AliHLTSpacePointPropertyGrid* /*pGrid*/) {return -ENOSYS;} | |
67 | ||
68 | // for backward compatibility | |
69 | virtual int PopulateAccessGrid(AliHLTSpacePointGrid* /*pGrid*/, AliHLTUInt32_t /*mask*/) const {return -ENOSYS;} | |
70 | virtual const AliHLTSpacePointGrid* GetAccessGrid(AliHLTUInt32_t /*mask*/) const {return NULL;} | |
71 | 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 | 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 | virtual float GetMaxSignal(AliHLTUInt32_t /*clusterID*/) const {return 0.0;} | |
85 | virtual float GetPhi(AliHLTUInt32_t /*clusterID*/) const {return 0.0;} | |
86 | ||
87 | /// create a collection of clusters for a space point mask | |
88 | virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const; | |
89 | ||
90 | /// create a collection of clusters for a specific track | |
91 | virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const; | |
92 | ||
93 | /// create a collection of clusters for a specific MC track | |
94 | virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const; | |
95 | ||
96 | /// create a collection of all used clusters | |
97 | virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const; | |
98 | ||
99 | /// create a collection of all unused clusters | |
100 | virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const; | |
101 | ||
102 | int MarkUsed(AliHLTUInt32_t clusterID) {return MarkUsed(&clusterID, sizeof(clusterID));} | |
103 | virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize); | |
104 | ||
105 | int SetTrackID(int trackID, AliHLTUInt32_t clusterID) { | |
106 | return SetTrackID(trackID, &clusterID, sizeof(clusterID)); | |
107 | } | |
108 | virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize); | |
109 | ||
110 | virtual int GetTrackID(AliHLTUInt32_t /*clusterID*/) const {return -1;} | |
111 | ||
112 | int SetMCID(int mcID, AliHLTUInt32_t clusterID) { | |
113 | return SetMCID(mcID, &clusterID, sizeof(clusterID)); | |
114 | } | |
115 | virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize); | |
116 | ||
117 | /// write blocks to HLT component output | |
118 | virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, | |
119 | vector<AliHLTComponentBlockData>& outputBlocks, | |
120 | AliHLTDataDeflater* /*pDeflater*/, | |
121 | const char* option="") const { | |
122 | return Write(outputPtr, size, outputBlocks, option); | |
123 | } | |
124 | ||
125 | /// write blocks to HLT component output: old function definition for backward compatibility | |
126 | virtual int Write(AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t /*size*/, | |
127 | vector<AliHLTComponentBlockData>& /*outputBlocks*/, | |
128 | const char* /*option*/="") const {return 0;} | |
129 | ||
130 | /// add input block from file to collection | |
131 | int AddInputBlock(const char* filename, AliHLTComponentDataType dt, unsigned specification); | |
132 | ||
133 | /// add input block from list of blank separated files to collection | |
134 | int AddInputBlocks(const char* filenames, AliHLTComponentDataType dt); | |
135 | ||
136 | /// alloc memory for a space point data block | |
137 | AliHLTUInt8_t* Alloc(int size); | |
138 | ||
139 | /// inherited from TObject: clear the object and reset pointer references | |
140 | virtual void Clear(Option_t * /*option*/ =""); | |
141 | ||
142 | /// inherited from TObject | |
143 | virtual void Print(Option_t *option="") const; | |
144 | ||
145 | virtual void Print(ostream& out, Option_t *option="") const; | |
146 | ||
147 | void Draw(Option_t *option); | |
148 | ||
149 | TH1* DrawProjection(const char* plane) const { | |
150 | vector<AliHLTUInt32_t> selection; // empty list -> no selection | |
151 | return DrawProjection(plane, selection); | |
152 | } | |
153 | ||
154 | TH1* DrawProjection(const char* plane, AliHLTUInt32_t specification) const { | |
155 | vector<AliHLTUInt32_t> selection; selection.push_back(specification); | |
156 | return DrawProjection(plane, selection); | |
157 | } | |
158 | ||
159 | TH1* DrawProjection(const char* plane, const vector<AliHLTUInt32_t>& selection) const; | |
160 | ||
161 | TTree* FillTree(const char* name, const char* title=""); | |
162 | ||
163 | protected: | |
164 | ||
165 | private: | |
166 | vector<TArrayC*> fBuffers; //! buffers of loaded files | |
167 | ||
168 | ClassDef(AliHLTSpacePointContainer, 0) | |
169 | }; | |
170 | ||
171 | ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c); | |
172 | ||
173 | ostream& operator<<(ostream &out, const AliHLTSpacePointContainer::AliHLTSpacePointProperties& p); | |
174 | ||
175 | bool operator==(const AliHLTSpacePointContainer::AliHLTSpacePointProperties& a, | |
176 | const AliHLTSpacePointContainer::AliHLTSpacePointProperties& b); | |
177 | #endif |