]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDchamberTimeBin.h
Copy arrays in assignment instead of the pointer; avoid double delete.
[u/mrichter/AliRoot.git] / TRD / AliTRDchamberTimeBin.h
CommitLineData
eb38ed55 1#ifndef ALITRDCHAMBERTIMEBIN_H
2#define ALITRDCHAMBERTIMEBIN_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id: AliTRDchamberTimeBin.h 22646 2007-11-29 18:13:40Z cblume $ */
8
9////////////////////////////////////////////////////////////////////////////
10// //
11// A TRD layer in a single stack //
12// //
13////////////////////////////////////////////////////////////////////////////
14
15#ifndef ROOT_TObject
16#include "TObject.h"
17#endif
18
19#ifndef ALITRDCLUSTER_H
20#include "AliTRDcluster.h"
21#endif
22
23class AliTRDchamberTimeBin : public TObject
24{
25public:
26 enum{
27 kMaxClustersLayer = 150
28 ,kMaxRows = 16
29 };
30
31 AliTRDchamberTimeBin(Int_t plane=-1, Int_t stack=-1, Int_t sector=-1, Double_t z0=-1., Double_t zLength=-1.);
32 //AliTRDchamberTimeBin(const AliTRDpropagationLayer &layer, Double_t z0, Double_t zLength, UChar_t stackNr);
33 //AliTRDchamberTimeBin(const AliTRDpropagationLayer &layer);
34 AliTRDchamberTimeBin(const AliTRDchamberTimeBin &layer);
35 ~AliTRDchamberTimeBin();
36 //AliTRDchamberTimeBin &operator=(const AliTRDpropagationLayer &myLayer);
37 operator Int_t() const { return fN; }
38 AliTRDchamberTimeBin &operator=(const AliTRDchamberTimeBin &myLayer);
39 AliTRDcluster *operator[](const Int_t i) const {
40 return ((i < fN) && (i >= 0)) ? fClusters[i] : 0x0;
41 }
42
43 void BuildIndices(Int_t iter = 0);
44 void BuildCond(AliTRDcluster *cl, Double_t *cond, UChar_t Layer, Double_t theta=0., Double_t phi=0.);
45 inline void Clear(const Option_t *opt = 0x0);
46 AliTRDcluster* GetCluster(Int_t index) const {return index < fN && index >= 0 ? fClusters[index] : 0x0;}
47 Int_t GetGlobalIndex(const Int_t index) const {return ((index < fN) && (index >= 0)) ? fIndex[index] : 0; }
48 void GetClusters(Double_t *cond, Int_t *index, Int_t& ncl, Int_t BufferSize = kMaxClustersLayer);
49 AliTRDcluster* GetNearestCluster(Double_t *cond);
50 Double_t GetX() const {
51 return fX; }
52 Double_t GetZ0() const { return fZ0; }
53 Double_t GetDZ0() const { return fZLength;}
54 Int_t GetNClusters() const { return fN; }
55 Int_t GetPlane() const { return fPlane; }
56 Int_t GetStack() const { return fStack; }
57 Int_t GetSector() const { return fSector; }
58 void InsertCluster(AliTRDcluster *c, UInt_t index);
59
60 Bool_t IsT0() const {return TestBit(1);}
61
62 void PrintClusters() const;
63 Int_t SearchNearestCluster(const Double_t y, const Double_t z, const Double_t Roady, const Double_t Roadz) const;
64 void SetRange(Float_t z0, Float_t zLength);
65 void SetNRows(const Int_t nRows){ fNRows = nRows; }
66 void SetPlane(Int_t plane){ fPlane = plane; }
67 void SetStack(Int_t stack){ fStack = stack; }
68 void SetSector(Int_t sector){ fSector = sector; }
69 void SetOwner(Bool_t own = kTRUE) {fOwner = own;}
70 void SetT0(Bool_t set=kTRUE) {SetBit(1, set);}
71 void SetX(Double_t x) {fX = x;}
72private:
73 void Copy(TObject &o) const;
74 Int_t Find(Float_t y) const;
75 Int_t FindYPosition(Double_t y, UChar_t z, Int_t nClusters) const;
76 Int_t FindNearestYCluster(Double_t y, UChar_t z) const;
77
78private:
79 Bool_t fOwner; // owner of the clusters
80 Char_t fPlane; // Plane number
81 Char_t fStack; // stack number in supermodule
82 Char_t fSector; // Sector mumber
83 Char_t fNRows; // number of pad rows in the chamber
84 UChar_t fPositions[kMaxRows]; // starting index of clusters in pad row
85 Int_t fN; // number of clusters
86 AliTRDcluster *fClusters[kMaxClustersLayer]; //Array of pointers to clusters
87 UInt_t fIndex[kMaxClustersLayer]; //Array of cluster indexes
88 Double_t fX; // radial position of tb
89
90 // obsolete !!
91 Double_t fZ0; // starting position of the layer in Z direction
92 Double_t fZLength; // length of the layer in Z direction
93
94 ClassDef(AliTRDchamberTimeBin, 2) // tracking propagation layer for one time bin in chamber
95
96};
97
98inline
99void AliTRDchamberTimeBin::Clear(const Option_t *)
100{
101 for (Int_t i = 0; i < fN; i++) fClusters[i] = NULL;
102 fN = 0;
103}
104
105#endif // ALITRDCHAMBERTIMEBIN_H
106