]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTSpacePointContainer.h
introducing deflater instance as function argument
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSpacePointContainer.h
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 <TObject.h>
17 #include "AliHLTLogging.h"
18 #include "AliHLTDataTypes.h"
19 #include "AliHLTStdIncludes.h"
20
21 class AliHLTDataDeflater;
22 class TArrayC;
23 class TH1;
24 class TTree;
25
26 /**
27  * @class AliHLTSpacePointContainer
28  * Base class of helper classes for space point data blocks.
29  * The class implements a couple of interface methods to be commonly used
30  * for space point data blocks.
31  *
32  * @ingroup alihlt_base
33  */
34 class AliHLTSpacePointContainer : public TObject, public AliHLTLogging
35 {
36  public:
37   /// standard constructor
38   AliHLTSpacePointContainer();
39   /// copy constructor
40   AliHLTSpacePointContainer(const AliHLTSpacePointContainer&);
41   /// assignment operator
42   AliHLTSpacePointContainer& operator=(const AliHLTSpacePointContainer&);
43
44   /// destructor
45   ~AliHLTSpacePointContainer();
46
47   /// add input block to the collection
48   virtual int AddInputBlock(const AliHLTComponentBlockData* pDesc)=0;
49
50   virtual int GetNumberOfSpacePoints() const;
51   virtual bool Check(AliHLTUInt32_t clusterID) const;
52   virtual int GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const = 0;
53   virtual const vector<AliHLTUInt32_t>* GetClusterIDs(AliHLTUInt32_t /*mask*/) {return NULL;}
54   virtual float GetX(AliHLTUInt32_t clusterID) const = 0;
55   virtual float GetXWidth(AliHLTUInt32_t clusterID) const = 0;
56   virtual float GetY(AliHLTUInt32_t clusterID) const = 0;
57   virtual float GetYWidth(AliHLTUInt32_t clusterID) const = 0;
58   virtual float GetZ(AliHLTUInt32_t clusterID) const = 0;
59   virtual float GetZWidth(AliHLTUInt32_t clusterID) const = 0;
60   virtual float GetCharge(AliHLTUInt32_t clusterID) const = 0;
61   virtual float GetMaxSignal(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
62   virtual float GetPhi(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
63
64   /// create a collection of clusters for a space point mask
65   virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
66
67   /// create a collection of clusters for a specific track
68   virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
69
70   /// create a collection of clusters for a specific MC track
71   virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
72
73   /// create a collection of all used clusters
74   virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
75
76   /// create a collection of all unused clusters
77   virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
78
79   int MarkUsed(AliHLTUInt32_t clusterID) {return MarkUsed(&clusterID, sizeof(clusterID));}
80   virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
81
82   int SetTrackID(int trackID, AliHLTUInt32_t clusterID) {
83     return SetTrackID(trackID, &clusterID, sizeof(clusterID));
84   }
85   virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
86
87   virtual int GetTrackID(AliHLTUInt32_t /*clusterID*/) const {return -1;}
88
89   int SetMCID(int mcID, AliHLTUInt32_t clusterID) {
90     return SetMCID(mcID, &clusterID, sizeof(clusterID));
91   }
92   virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
93
94   /// write blocks to HLT component output
95   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size,
96                     vector<AliHLTComponentBlockData>& outputBlocks,
97                     AliHLTDataDeflater* /*pDeflater*/,
98                     const char* option="") const {
99     return Write(outputPtr, size, outputBlocks, option);
100   }
101
102   /// write blocks to HLT component output: old function definition for backward compatibility
103   virtual int Write(AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t /*size*/,
104                     vector<AliHLTComponentBlockData>& /*outputBlocks*/,
105                     const char* /*option*/="") const {return 0;}
106
107   /// add input block from file to collection
108   int AddInputBlock(const char* filename, AliHLTComponentDataType dt, unsigned specification);
109
110   /// add input block from list of blank separated files to collection
111   int AddInputBlocks(const char* filenames, AliHLTComponentDataType dt);
112
113   /// alloc memory for a space point data block
114   AliHLTUInt8_t* Alloc(int size);
115
116   /// inherited from TObject: clear the object and reset pointer references
117   virtual void Clear(Option_t * /*option*/ ="");
118
119   /// inherited from TObject
120   virtual void Print(Option_t *option="") const;
121
122   virtual void Print(ostream& out, Option_t *option="") const;
123
124   void Draw(Option_t *option);
125
126   TH1* DrawProjection(const char* plane) const {
127     vector<AliHLTUInt32_t> selection; // empty list -> no selection
128     return DrawProjection(plane, selection);
129   }
130
131   TH1* DrawProjection(const char* plane, AliHLTUInt32_t specification) const {
132     vector<AliHLTUInt32_t> selection; selection.push_back(specification);
133     return DrawProjection(plane, selection);
134   }
135
136   TH1* DrawProjection(const char* plane, const vector<AliHLTUInt32_t>& selection) const;
137
138   TTree* FillTree(const char* name, const char* title="");
139
140  protected:
141
142  private:
143   vector<TArrayC*> fBuffers; //! buffers of loaded files
144
145   ClassDef(AliHLTSpacePointContainer, 0)
146 };
147
148 ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c);
149
150 #endif