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 *
9 /// @file AliHLTSpacePointContainer.h
10 /// @author Matthias Richter
12 /// @brief Base helper class for handling of HLT space point data blocks
18 #include "AliHLTLogging.h"
19 #include "AliHLTDataTypes.h"
20 #include "AliHLTStdIncludes.h"
21 #include "AliHLTIndexGrid.h"
23 class AliHLTDataDeflater;
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.
34 * @ingroup alihlt_base
36 class AliHLTSpacePointContainer : public TObject, public AliHLTLogging
39 /// standard constructor
40 AliHLTSpacePointContainer();
42 AliHLTSpacePointContainer(const AliHLTSpacePointContainer&);
43 /// assignment operator
44 AliHLTSpacePointContainer& operator=(const AliHLTSpacePointContainer&);
47 ~AliHLTSpacePointContainer();
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
54 typedef AliHLTIndexGrid<float, AliHLTSpacePointProperties> AliHLTSpacePointPropertyGrid;
55 typedef AliHLTIndexGrid<float, AliHLTUInt32_t> AliHLTSpacePointGrid;
57 //////////////////////////////////////////////////////////////////////////
59 // interface functions
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;}
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;}
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;}
87 /// create a collection of clusters for a space point mask
88 virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
90 /// create a collection of clusters for a specific track
91 virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
93 /// create a collection of clusters for a specific MC track
94 virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
96 /// create a collection of all used clusters
97 virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
99 /// create a collection of all unused clusters
100 virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
102 int MarkUsed(AliHLTUInt32_t clusterID) {return MarkUsed(&clusterID, sizeof(clusterID));}
103 virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
105 int SetTrackID(int trackID, AliHLTUInt32_t clusterID) {
106 return SetTrackID(trackID, &clusterID, sizeof(clusterID));
108 virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
110 virtual int GetTrackID(AliHLTUInt32_t /*clusterID*/) const {return -1;}
112 int SetMCID(int mcID, AliHLTUInt32_t clusterID) {
113 return SetMCID(mcID, &clusterID, sizeof(clusterID));
115 virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
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);
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;}
130 /// add input block from file to collection
131 int AddInputBlock(const char* filename, AliHLTComponentDataType dt, unsigned specification);
133 /// add input block from list of blank separated files to collection
134 int AddInputBlocks(const char* filenames, AliHLTComponentDataType dt);
136 /// alloc memory for a space point data block
137 AliHLTUInt8_t* Alloc(int size);
139 /// inherited from TObject: clear the object and reset pointer references
140 virtual void Clear(Option_t * /*option*/ ="");
142 /// inherited from TObject
143 virtual void Print(Option_t *option="") const;
145 virtual void Print(ostream& out, Option_t *option="") const;
147 void Draw(Option_t *option);
149 TH1* DrawProjection(const char* plane) const {
150 vector<AliHLTUInt32_t> selection; // empty list -> no selection
151 return DrawProjection(plane, selection);
154 TH1* DrawProjection(const char* plane, AliHLTUInt32_t specification) const {
155 vector<AliHLTUInt32_t> selection; selection.push_back(specification);
156 return DrawProjection(plane, selection);
159 TH1* DrawProjection(const char* plane, const vector<AliHLTUInt32_t>& selection) const;
161 TTree* FillTree(const char* name, const char* title="");
166 vector<TArrayC*> fBuffers; //! buffers of loaded files
168 ClassDef(AliHLTSpacePointContainer, 0)
171 ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c);
173 ostream& operator<<(ostream &out, const AliHLTSpacePointContainer::AliHLTSpacePointProperties& p);
175 bool operator==(const AliHLTSpacePointContainer::AliHLTSpacePointProperties& a,
176 const AliHLTSpacePointContainer::AliHLTSpacePointProperties& b);