Line data Source code
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 : Revision 1.2 2005/11/03 13:09:19 hristov
19 : Removing meaningless const declarations (linuxicc)
20 :
21 : Revision 1.1 2005/10/11 12:31:50 masera
22 : Preprocessor classes for SPD (Paul Nilsson)
23 :
24 : */
25 :
26 : ///////////////////////////////////////////////////////////////////////////
27 : // AliITSBadChannelsSPD implementation by P. Nilsson 2005
28 : // AUTHOR/CONTACT: Paul.Nilsson@cern.ch
29 : //
30 : // The class is used by the AliITSPreprocessorSPD class to store the
31 : // final noisy and dead channel objects in the calibration database for
32 : // the SPD.
33 : //
34 : // An instance of this container class contains all the "bad" channels,
35 : // i.e. the noisy or dead channels of the SPD. It contains TObjArrays
36 : // for each module of the SPD (240 in total for ALICE, and 6 for the 2004
37 : // joint ITS beam test. The instance object should, once filled with data,
38 : // be stored in the calibration database. This is done by the SPD
39 : // preprocessor.
40 : ///////////////////////////////////////////////////////////////////////////
41 :
42 : #include "AliITSBadChannelsSPD.h"
43 :
44 116 : ClassImp(AliITSBadChannelsSPD)
45 :
46 : //__________________________________________________________________________
47 0 : AliITSBadChannelsSPD::AliITSBadChannelsSPD(void) :
48 0 : fIndexArraySize(0),
49 0 : fBadChannelsArraySize(0),
50 0 : fIndexArray(0x0),
51 0 : fBadChannelsArray(0x0)
52 0 : {
53 : // Default constructor
54 0 : }
55 :
56 : //__________________________________________________________________________
57 : AliITSBadChannelsSPD::AliITSBadChannelsSPD(const AliITSBadChannelsSPD &bc) :
58 0 : TObject(bc),
59 0 : fIndexArraySize(bc.fIndexArraySize),
60 0 : fBadChannelsArraySize(bc.fBadChannelsArraySize),
61 0 : fIndexArray(0),
62 0 : fBadChannelsArray(0){
63 : // Default copy constructor
64 :
65 : // Create new arrays
66 0 : fIndexArray = new Int_t[fIndexArraySize];
67 0 : fBadChannelsArray = new Int_t[fBadChannelsArraySize];
68 :
69 : // Copy arrays
70 0 : for (Int_t i = 0; i < fIndexArraySize; i++)
71 : {
72 0 : fIndexArray[i] = bc.fIndexArray[i];
73 : }
74 0 : for (Int_t i = 0; i < fBadChannelsArraySize; i++)
75 : {
76 0 : fBadChannelsArray[i] = bc.fBadChannelsArray[i];
77 : }
78 0 : }
79 :
80 : //__________________________________________________________________________
81 : AliITSBadChannelsSPD::~AliITSBadChannelsSPD(void)
82 0 : {
83 : // Default destructor
84 :
85 0 : delete [] fIndexArray;
86 0 : fIndexArray = 0;
87 0 : delete [] fBadChannelsArray;
88 0 : fBadChannelsArray = 0;
89 0 : }
90 :
91 : //__________________________________________________________________________
92 : AliITSBadChannelsSPD& AliITSBadChannelsSPD::operator=(const AliITSBadChannelsSPD &bc)
93 : {
94 : // Assignment operator
95 :
96 : // Guard against self-assignment
97 0 : if (this != &bc)
98 : {
99 : // Copy array sizes
100 0 : fIndexArraySize = bc.fIndexArraySize;
101 0 : fBadChannelsArraySize = bc.fBadChannelsArraySize;
102 :
103 0 : delete [] fIndexArray;
104 0 : fIndexArray = new Int_t[fIndexArraySize];
105 :
106 0 : delete [] fBadChannelsArray;
107 0 : fBadChannelsArray = new Int_t[fBadChannelsArraySize];
108 :
109 : // Copy arrays
110 0 : for (Int_t i = 0; i < fIndexArraySize; i++)
111 : {
112 0 : fIndexArray[i] = bc.fIndexArray[i];
113 : }
114 0 : for (Int_t i = 0; i < fBadChannelsArraySize; i++)
115 : {
116 0 : fBadChannelsArray[i] = bc.fBadChannelsArray[i];
117 : }
118 0 : }
119 :
120 0 : return *this;
121 : }
122 :
123 :
124 : //__________________________________________________________________________
125 : void AliITSBadChannelsSPD::Put(Int_t* &badChannelsArray, const Int_t &badChannelsArraySize,
126 : Int_t* &indexArray, const Int_t &indexArraySize)
127 : {
128 : // Add the bad channels and index arrays
129 :
130 0 : fIndexArraySize = indexArraySize;
131 0 : fBadChannelsArraySize = badChannelsArraySize;
132 :
133 0 : fIndexArray = new Int_t[fIndexArraySize];
134 0 : fBadChannelsArray = new Int_t[fBadChannelsArraySize];
135 :
136 : // Copy the arrays
137 0 : for (Int_t i = 0; i < fIndexArraySize; i++)
138 : {
139 0 : fIndexArray[i] = indexArray[i];
140 : }
141 0 : for (Int_t i = 0; i < fBadChannelsArraySize; i++)
142 : {
143 0 : fBadChannelsArray[i] = badChannelsArray[i];
144 : }
145 :
146 0 : }
147 :
148 : //__________________________________________________________________________
149 : Bool_t AliITSBadChannelsSPD::Get(Int_t* &badChannelsArray, Int_t* &indexArray) const
150 : {
151 : // Get the bad channels and the index arrays
152 :
153 : Bool_t status = kTRUE;
154 :
155 : // Set the array pointers
156 0 : if (fIndexArraySize > 0)
157 : {
158 0 : badChannelsArray = fBadChannelsArray;
159 0 : indexArray = fIndexArray;
160 0 : }
161 : else
162 : {
163 : status = kFALSE;
164 : }
165 :
166 0 : return status;
167 : }
168 :
169 : //__________________________________________________________________________
170 : Int_t* AliITSBadChannelsSPD::CreateModuleArray(Int_t module) const
171 : {
172 : // Create an Int_t array for a given module
173 :
174 : Int_t *moduleArray = 0;
175 :
176 0 : const Int_t kSize = AliITSBadChannelsSPD::GetModuleArraySize(module);
177 0 : if (kSize > 0)
178 : {
179 : // Create a new array
180 0 : moduleArray = new Int_t[kSize];
181 :
182 : // Copy the module data into the module array from the bad channels array
183 0 : const Int_t kPosition = fIndexArray[module];
184 0 : for (Int_t index = 0; index < kSize; index++)
185 : {
186 0 : moduleArray[index] = fBadChannelsArray[kPosition + index];
187 : }
188 0 : }
189 :
190 0 : return moduleArray;
191 : }
192 :
193 : //__________________________________________________________________________
194 : TObjArray* AliITSBadChannelsSPD::CreateModuleObjArray(Int_t module) const
195 : {
196 : // Create a TObjArray for a given module
197 :
198 : TObjArray *moduleArray = 0;
199 :
200 0 : const Int_t kSize = AliITSBadChannelsSPD::GetModuleObjArraySize(module);
201 0 : if (kSize > 0)
202 : {
203 : // Create a new array
204 0 : moduleArray = new TObjArray(kSize);
205 :
206 : // Copy the module data into the module array from the bad channels array
207 :
208 : // Get the start position of the data (skip the number of bad channels, i.e. the first stored number)
209 0 : Int_t position = fIndexArray[module] + 1;
210 :
211 : Int_t i = 0;
212 0 : while (i < kSize)
213 : {
214 : // Create and add the current channel
215 0 : Int_t p1 = position++;
216 0 : Int_t p2 = position++;
217 0 : AliITSChannelSPD *channel = new AliITSChannelSPD(fBadChannelsArray[p1], fBadChannelsArray[p2]);
218 0 : moduleArray->Add(channel);
219 :
220 : // Go to next bad channel
221 0 : i++;
222 : }
223 0 : }
224 :
225 0 : return moduleArray;
226 0 : }
|