]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSBadChannelsSPD.cxx
8c7ee254ec26d576c61607f47976c01a1cc792e6
[u/mrichter/AliRoot.git] / ITS / AliITSBadChannelsSPD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 */
19
20 ///////////////////////////////////////////////////////////////////////////
21 // AliITSBadChannelsSPD implementation by P. Nilsson 2005
22 // AUTHOR/CONTACT: Paul.Nilsson@cern.ch
23 //
24 // The class is used by the AliITSPreprocessorSPD class to store the
25 // final noisy and dead channel objects in the calibration database for
26 // the SPD.
27 //
28 // An instance of this container class contains all the "bad" channels,
29 // i.e. the noisy or dead channels of the SPD. It contains TObjArrays
30 // for each module of the SPD (240 in total for ALICE, and 6 for the 2004
31 // joint ITS beam test. The instance object should, once filled with data,
32 // be stored in the calibration database. This is done by the SPD
33 // preprocessor.
34 ///////////////////////////////////////////////////////////////////////////
35
36 #include "AliITSBadChannelsSPD.h"
37
38 ClassImp(AliITSBadChannelsSPD)
39
40 //__________________________________________________________________________
41 AliITSBadChannelsSPD::AliITSBadChannelsSPD(void) :
42   fIndexArraySize(0),
43   fBadChannelsArraySize(0),
44   fIndexArray(0x0),
45   fBadChannelsArray(0x0)
46 {
47   // Default constructor
48 }
49
50 //__________________________________________________________________________
51 AliITSBadChannelsSPD::AliITSBadChannelsSPD(const AliITSBadChannelsSPD &bc) :
52   TObject(bc)
53 {
54   // Default copy constructor
55
56   // Copy array sizes
57   fIndexArraySize = bc.fIndexArraySize;
58   fBadChannelsArraySize = bc.fBadChannelsArraySize;
59
60   // Create new arrays
61   fIndexArray = new Int_t[fIndexArraySize];
62   fBadChannelsArray = new Int_t[fBadChannelsArraySize];
63
64   // Copy arrays
65   for (Int_t i = 0; i < fIndexArraySize; i++)
66     {
67       fIndexArray[i] = bc.fIndexArray[i];
68     }
69   for (Int_t i = 0; i < fBadChannelsArraySize; i++)
70     {
71       fBadChannelsArray[i] = bc.fBadChannelsArray[i];
72     }
73 }
74
75 //__________________________________________________________________________
76 AliITSBadChannelsSPD::~AliITSBadChannelsSPD(void)
77 {
78   // Default destructor
79
80   delete [] fIndexArray;
81   fIndexArray = 0;
82   delete [] fBadChannelsArray;
83   fBadChannelsArray = 0;
84 }
85
86 //__________________________________________________________________________
87 AliITSBadChannelsSPD& AliITSBadChannelsSPD::operator=(const AliITSBadChannelsSPD &bc)
88 {
89   // Assignment operator
90   
91   // Guard against self-assignment
92   if (this != &bc)
93     {
94       // Copy array sizes
95       fIndexArraySize = bc.fIndexArraySize;
96       fBadChannelsArraySize = bc.fBadChannelsArraySize;
97
98       delete [] fIndexArray;
99       fIndexArray = new Int_t[fIndexArraySize];
100
101       delete [] fBadChannelsArray;
102       fBadChannelsArray = new Int_t[fBadChannelsArraySize];
103
104       // Copy arrays
105       for (Int_t i = 0; i < fIndexArraySize; i++)
106         {
107           fIndexArray[i] = bc.fIndexArray[i];
108         }
109       for (Int_t i = 0; i < fBadChannelsArraySize; i++)
110         {
111           fBadChannelsArray[i] = bc.fBadChannelsArray[i];
112         }
113     }
114
115   return *this;
116 }
117
118
119 //__________________________________________________________________________
120 void AliITSBadChannelsSPD::Put(Int_t* &badChannelsArray, const Int_t &badChannelsArraySize,
121                                Int_t* &indexArray, const Int_t &indexArraySize)
122 {
123   // Add the bad channels and index arrays
124
125   fIndexArraySize = indexArraySize;
126   fBadChannelsArraySize = badChannelsArraySize;
127
128   fIndexArray = new Int_t[fIndexArraySize];
129   fBadChannelsArray = new Int_t[fBadChannelsArraySize];
130
131   // Copy the arrays
132   for (Int_t i = 0; i < fIndexArraySize; i++)
133     {
134       fIndexArray[i] = indexArray[i];
135     }
136   for (Int_t i = 0; i < fBadChannelsArraySize; i++)
137     {
138       fBadChannelsArray[i] = badChannelsArray[i];
139     }
140
141 }
142
143 //__________________________________________________________________________
144 Bool_t AliITSBadChannelsSPD::Get(Int_t* &badChannelsArray, Int_t* &indexArray) const
145 {
146   // Get the bad channels and the index arrays
147
148   Bool_t status = kTRUE;
149
150   // Set the array pointers
151   if (fIndexArraySize > 0)
152     {
153       badChannelsArray = fBadChannelsArray;
154       indexArray = fIndexArray;
155     }
156   else
157     {
158       status = kFALSE;
159     }
160
161   return status;
162 }
163
164 //__________________________________________________________________________
165 Int_t* AliITSBadChannelsSPD::CreateModuleArray(const Int_t module) const
166 {
167   // Create an Int_t array for a given module
168
169   Int_t *moduleArray = 0;
170
171   const Int_t kSize = AliITSBadChannelsSPD::GetModuleArraySize(module);
172   if (kSize > 0)
173     {
174       // Create a new array
175       moduleArray = new Int_t[kSize];
176
177       // Copy the module data into the module array from the bad channels array
178       const Int_t kPosition = fIndexArray[module];
179       for (Int_t index = 0; index < kSize; index++)
180         {
181           moduleArray[index] = fBadChannelsArray[kPosition + index];
182         }
183     }
184
185   return moduleArray;
186 }
187
188 //__________________________________________________________________________
189 TObjArray* AliITSBadChannelsSPD::CreateModuleObjArray(const Int_t module) const
190 {
191   // Create a TObjArray for a given module
192
193   TObjArray *moduleArray = 0;
194
195   const Int_t kSize = AliITSBadChannelsSPD::GetModuleObjArraySize(module);
196   if (kSize > 0)
197     {
198       // Create a new array
199       moduleArray = new TObjArray(kSize);
200
201       // Copy the module data into the module array from the bad channels array
202
203       // Get the start position of the data (skip the number of bad channels, i.e. the first stored number)
204       Int_t position = fIndexArray[module] + 1;
205
206       Int_t i = 0;
207       while (i < kSize)
208         {
209           // Create and add the current channel
210           AliITSChannelSPD *channel = new AliITSChannelSPD(fBadChannelsArray[position++], fBadChannelsArray[position++]);
211           moduleArray->Add(channel);
212
213           // Go to next bad channel
214           i++;
215         }
216     }
217
218   return moduleArray;
219 }