]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDarrayADC.h
Fixing CONSTANT_EXPRESSION_RESULT Coverity defect
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayADC.h
1 #ifndef ALITRDARRAYADC_H
2 #define ALITRDARRAYADC_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * 
4  * See cxx source for full Copyright notice */ 
5
6 /* $Id: AliTRDarrayADC.h 23387 2008-01-17 17:25:16Z cblume $ */
7
8 ///////////////////////////////////////////////
9 //                                           //
10 // Container class for ADC values            //
11 //                                           // 
12 ///////////////////////////////////////////////
13
14 #include <TObject.h>
15
16 class AliTRDSignalIndex;
17 class AliTRDarrayADC: public TObject
18 {
19  public:
20
21   AliTRDarrayADC();
22   AliTRDarrayADC(Int_t nrow, Int_t ncol, Int_t ntime);
23   AliTRDarrayADC(const AliTRDarrayADC &b);
24   ~AliTRDarrayADC();
25   AliTRDarrayADC &operator=(const AliTRDarrayADC &b);
26
27   void    Allocate(Int_t nrow, Int_t ncol, Int_t ntime);
28   void    SetNdet(Int_t ndet) {fNdet=ndet;};  
29   Int_t   GetNdet()  const {return fNdet;};
30   void    SetDataByAdcCol(Int_t nrow, Int_t ncol, Int_t ntime, Short_t value)
31                          {fADC[(nrow*fNumberOfChannels+ncol)*fNtime+ntime]=value;}
32   Bool_t  HasData() const {return fNtime ? 1 : 0;};
33   Short_t GetDataByAdcCol(Int_t nrow, Int_t ncol, Int_t ntime) const
34                          {return fADC[(nrow*fNumberOfChannels+ncol)*fNtime+ntime];};
35   inline  void GetData(Int_t r, Int_t c, Int_t t, Int_t n, Short_t *vals) const;
36   Short_t GetDataBits(Int_t nrow, Int_t ncol, Int_t ntime) const;
37   UChar_t GetPadStatus(Int_t nrow, Int_t ncol, Int_t ntime) const;
38   void    SetPadStatus(Int_t nrow, Int_t ncol, Int_t ntime, UChar_t status);
39   Bool_t  IsPadCorrupted(Int_t nrow, Int_t ncol, Int_t ntime);
40   void    Compress();
41   void    Expand();
42   Int_t   GetNtime() const {return fNtime;};
43   Int_t   GetNrow() const {return fNrow;};
44   Int_t   GetNcol() const {return fNcol;};
45   Int_t   GetDim() const {return fNAdim;};
46   void    DeleteNegatives();
47   void    Reset();
48   void    ConditionalReset(AliTRDSignalIndex* idx);
49   inline  Short_t* GetDataAddress(Int_t nrow, Int_t ncol, Int_t ntime = 0) const;
50   inline  Short_t GetData(Int_t nrow, Int_t ncol, Int_t ntime) const;
51   inline  void    SetData(Int_t nrow, Int_t ncol, Int_t ntime, Short_t value);
52   static  void    CreateLut(); 
53
54  protected:
55
56   Int_t fNdet;    //ID number of the chamber
57   Int_t fNrow;    //Number of rows
58   Int_t fNcol;    //Number of columns(pads)
59   Int_t fNumberOfChannels;  //  Number of MCM channels per row
60   Int_t fNtime;   //Number of time bins
61   Int_t fNAdim;   //Dimension of the ADC array
62   Short_t* fADC;  //[fNAdim]   //Pointer to adc values
63   static Short_t *fgLutPadNumbering;   //  [fNcol] Look Up Table
64
65   ClassDef(AliTRDarrayADC,4) //ADC container class
66     
67 };
68
69 //________________________________________________________________________________
70 Short_t* AliTRDarrayADC::GetDataAddress(Int_t nrow, Int_t ncol, Int_t ntime) const
71 {
72   //
73   // Get the address of the given pad
74   //
75
76   Int_t corrcolumn = fgLutPadNumbering[ncol];
77
78   return &fADC[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
79
80 }
81 //________________________________________________________________________________
82 Short_t AliTRDarrayADC::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
83 {
84   //
85   // Get the data using the pad numbering.
86   // To access data using the mcm scheme use instead
87   // the method GetDataByAdcCol
88   //
89
90   Int_t corrcolumn = fgLutPadNumbering[ncol];
91
92   return fADC[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
93
94 }
95 //________________________________________________________________________________
96 void AliTRDarrayADC::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Short_t value)
97 {
98   //
99   // Set the data using the pad numbering.
100   // To write data using the mcm scheme use instead
101   // the method SetDataByAdcCol
102   //
103
104   Int_t colnumb = fgLutPadNumbering[ncol];
105
106   fADC[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime] = value;
107
108 }
109
110 void AliTRDarrayADC::GetData(Int_t r, Int_t c, Int_t t, Int_t n, Short_t *vals) const
111 {
112   Int_t colNum = fgLutPadNumbering[c];
113   for(Int_t ic=n, idx = (r*fNumberOfChannels+colNum)*fNtime+t; ic--; idx+=fNtime) vals[ic] = fADC[idx];
114  }
115
116 #endif 
117