]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTSpacePointContainer.h
restoring ostream properties after printout
[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 <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   typedef AliHLTIndexGrid<float, AliHLTUInt32_t> AliHLTSpacePointGrid;
50
51   //////////////////////////////////////////////////////////////////////////
52   //
53   // interface functions
54   //
55
56   /// add input block to the collection
57   virtual int AddInputBlock(const AliHLTComponentBlockData* pDesc)=0;
58   virtual int PopulateAccessGrid(AliHLTSpacePointGrid* /*pGrid*/, AliHLTUInt32_t /*mask*/) const {return -ENOSYS;}
59   virtual const AliHLTSpacePointGrid* GetAccessGrid(AliHLTUInt32_t /*mask*/) const {return NULL;}
60
61   virtual int GetNumberOfSpacePoints() const;
62   virtual bool Check(AliHLTUInt32_t clusterID) const;
63   virtual int GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const = 0;
64   virtual const vector<AliHLTUInt32_t>* GetClusterIDs(AliHLTUInt32_t /*mask*/) {return NULL;}
65   virtual float GetX(AliHLTUInt32_t clusterID) const = 0;
66   virtual float GetXWidth(AliHLTUInt32_t clusterID) const = 0;
67   virtual float GetY(AliHLTUInt32_t clusterID) const = 0;
68   virtual float GetYWidth(AliHLTUInt32_t clusterID) const = 0;
69   virtual float GetZ(AliHLTUInt32_t clusterID) const = 0;
70   virtual float GetZWidth(AliHLTUInt32_t clusterID) const = 0;
71   virtual float GetCharge(AliHLTUInt32_t clusterID) const = 0;
72   virtual float GetMaxSignal(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
73   virtual float GetPhi(AliHLTUInt32_t /*clusterID*/) const {return 0.0;}
74
75   /// create a collection of clusters for a space point mask
76   virtual AliHLTSpacePointContainer* SelectByMask(AliHLTUInt32_t mask, bool bAlloc=false) const;
77
78   /// create a collection of clusters for a specific track
79   virtual AliHLTSpacePointContainer* SelectByTrack(int trackId, bool bAlloc=false) const;
80
81   /// create a collection of clusters for a specific MC track
82   virtual AliHLTSpacePointContainer* SelectByMC(int mcId, bool bAlloc=false) const;
83
84   /// create a collection of all used clusters
85   virtual AliHLTSpacePointContainer* UsedClusters(bool bAlloc=false) const;
86
87   /// create a collection of all unused clusters
88   virtual AliHLTSpacePointContainer* UnusedClusters(bool bAlloc=false) const;
89
90   int MarkUsed(AliHLTUInt32_t clusterID) {return MarkUsed(&clusterID, sizeof(clusterID));}
91   virtual int MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize);
92
93   int SetTrackID(int trackID, AliHLTUInt32_t clusterID) {
94     return SetTrackID(trackID, &clusterID, sizeof(clusterID));
95   }
96   virtual int SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize);
97
98   virtual int GetTrackID(AliHLTUInt32_t /*clusterID*/) const {return -1;}
99
100   int SetMCID(int mcID, AliHLTUInt32_t clusterID) {
101     return SetMCID(mcID, &clusterID, sizeof(clusterID));
102   }
103   virtual int SetMCID(int clusterID, const AliHLTUInt32_t* clusterIDs, int arraySize);
104
105   /// write blocks to HLT component output
106   virtual int Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size,
107                     vector<AliHLTComponentBlockData>& outputBlocks,
108                     AliHLTDataDeflater* /*pDeflater*/,
109                     const char* option="") const {
110     return Write(outputPtr, size, outputBlocks, option);
111   }
112
113   /// write blocks to HLT component output: old function definition for backward compatibility
114   virtual int Write(AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t /*size*/,
115                     vector<AliHLTComponentBlockData>& /*outputBlocks*/,
116                     const char* /*option*/="") const {return 0;}
117
118   /// add input block from file to collection
119   int AddInputBlock(const char* filename, AliHLTComponentDataType dt, unsigned specification);
120
121   /// add input block from list of blank separated files to collection
122   int AddInputBlocks(const char* filenames, AliHLTComponentDataType dt);
123
124   /// alloc memory for a space point data block
125   AliHLTUInt8_t* Alloc(int size);
126
127   /// inherited from TObject: clear the object and reset pointer references
128   virtual void Clear(Option_t * /*option*/ ="");
129
130   /// inherited from TObject
131   virtual void Print(Option_t *option="") const;
132
133   virtual void Print(ostream& out, Option_t *option="") const;
134
135   void Draw(Option_t *option);
136
137   TH1* DrawProjection(const char* plane) const {
138     vector<AliHLTUInt32_t> selection; // empty list -> no selection
139     return DrawProjection(plane, selection);
140   }
141
142   TH1* DrawProjection(const char* plane, AliHLTUInt32_t specification) const {
143     vector<AliHLTUInt32_t> selection; selection.push_back(specification);
144     return DrawProjection(plane, selection);
145   }
146
147   TH1* DrawProjection(const char* plane, const vector<AliHLTUInt32_t>& selection) const;
148
149   TTree* FillTree(const char* name, const char* title="");
150
151  protected:
152
153  private:
154   vector<TArrayC*> fBuffers; //! buffers of loaded files
155
156   ClassDef(AliHLTSpacePointContainer, 0)
157 };
158
159 ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c);
160
161 #endif