]>
Commit | Line | Data |
---|---|---|
cfaccd71 | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, 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 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////// | |
cfaccd71 | 19 | // Implementation of the class containing SDD DCS data // |
20 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
e22bf775 | 21 | // V. Pospisil, CTU Praguem gdermog@seznam.cz // |
cfaccd71 | 22 | /////////////////////////////////////////////////////////////////// |
23 | ||
24 | #include "AliITSDCSDataSDD.h" | |
25 | #include "AliLog.h" | |
26 | ||
e22bf775 | 27 | #define AUTORESIZE 50 |
28 | ||
cfaccd71 | 29 | ClassImp(AliITSDCSDataSDD) |
30 | ||
dc5eacf8 | 31 | const Float_t AliITSDCSDataSDD::fgkTPrec = 100.0; |
32 | const Float_t AliITSDCSDataSDD::fgkMVPrec = 1000.0; | |
33 | ||
e22bf775 | 34 | //--------------------------------------------------------------------------- |
35 | AliITSDCSDataSDD::AliITSDCSDataSDD(): TObject(), | |
36 | fTempLeft(0), | |
37 | fTempLeftTimeStamp(0), | |
38 | fTempLeftMaxPoints(0), | |
39 | fTempLeftSetPoints(0), | |
40 | fTempRight(0), | |
41 | fTempRightTimeStamp(0), | |
42 | fTempRightMaxPoints(0), | |
43 | fTempRightSetPoints(0), | |
44 | fHV(0), | |
45 | fHVTimeStamp(0), | |
46 | fHVMaxPoints(0), | |
47 | fHVSetPoints(0), | |
48 | fMV(0), | |
49 | fMVTimeStamp(0), | |
50 | fMVMaxPoints(0), | |
51 | fMVSetPoints(0), | |
52 | fStatus(0), | |
53 | fStatusTimeStamp(0), | |
54 | fStatusMaxPoints(0), | |
55 | fStatusSetPoints(0) | |
cfaccd71 | 56 | { |
e22bf775 | 57 | // default constructor |
58 | } /*AliITSDCSDataSDD::AliITSDCSDataSDD*/ | |
59 | ||
60 | //--------------------------------------------------------------------------- | |
61 | ||
62 | void AliITSDCSDataSDD::SetNPointsTempLeft( Int_t npts ) | |
cfaccd71 | 63 | { |
776c19a3 | 64 | // dimension arrays with left side temperatures |
e22bf775 | 65 | // |
776c19a3 | 66 | |
e22bf775 | 67 | if( npts < fTempLeftSetPoints) |
68 | { // Cannot resize arrays - some elements would be lost | |
69 | AliWarning("Attemp to reduce size of full array (SDD DCS _TEMP_L)"); | |
cfaccd71 | 70 | return; |
e22bf775 | 71 | } /*if*/ |
72 | ||
73 | fTempLeft.Set( npts ); | |
74 | fTempLeftTimeStamp.Set( npts ); | |
75 | // Both temperature and tme stamp arrays are resized | |
76 | ||
77 | fTempLeftMaxPoints = npts; | |
78 | // New size is stored | |
79 | } /*AliITSDCSDataSDD::SetNPointsTempLeft*/ | |
80 | ||
81 | //--------------------------------------------------------------------------- | |
82 | ||
83 | void AliITSDCSDataSDD::SetNPointsTempRight( Int_t npts ) | |
84 | { | |
776c19a3 | 85 | // dimension arrays with right side temperatures |
e22bf775 | 86 | // |
776c19a3 | 87 | |
e22bf775 | 88 | if( npts < fTempRightSetPoints) |
89 | { // Cannot resize arrays - some elements would be lost | |
90 | AliWarning("Attemp to reduce size of full array (SDD DCS _TEMP_R)"); | |
91 | return; | |
92 | } /*if*/ | |
93 | ||
94 | fTempRight.Set( npts ); | |
95 | fTempRightTimeStamp.Set( npts ); | |
96 | // Both temperature and tme stamp arrays are resized | |
97 | ||
98 | fTempRightMaxPoints = npts; | |
99 | // New size is stored | |
100 | } /*AliITSDCSDataSDD::SetNPointsTempRight*/ | |
101 | ||
102 | //--------------------------------------------------------------------------- | |
103 | ||
104 | void AliITSDCSDataSDD::SetNPointsHV( Int_t npts ) | |
105 | { | |
776c19a3 | 106 | // dimension arrays with HV values |
e22bf775 | 107 | // |
776c19a3 | 108 | |
e22bf775 | 109 | if( npts < fHVSetPoints) |
110 | { // Cannot resize arrays - some elements would be lost | |
111 | AliWarning("Attemp to reduce size of full array (SDD DCS _HV)"); | |
112 | return; | |
113 | } /*if*/ | |
114 | ||
115 | fHV.Set( npts ); | |
116 | fHVTimeStamp.Set( npts ); | |
117 | // Both temperature and tme stamp arrays are resized | |
118 | ||
119 | fHVMaxPoints = npts; // New size is stored | |
120 | ||
121 | }/*AliITSDCSDataSDD::SetNPointsHV*/ | |
122 | ||
123 | //--------------------------------------------------------------------------- | |
124 | ||
125 | void AliITSDCSDataSDD::SetNPointsMV( Int_t npts ) | |
126 | { | |
776c19a3 | 127 | // dimension arrays with MV values |
e22bf775 | 128 | // |
776c19a3 | 129 | |
e22bf775 | 130 | if( npts < fMVSetPoints) |
131 | { // Cannot resize arrays - some elements would be lost | |
132 | AliWarning("Attemp to reduce size of full array (SDD DCS _MV)"); | |
133 | return; | |
134 | } /*if*/ | |
135 | ||
136 | fMV.Set( npts ); | |
137 | fMVTimeStamp.Set( npts ); | |
138 | // Both temperature and tme stamp arrays are resized | |
139 | ||
140 | fMVMaxPoints = npts; // New size is stored | |
141 | ||
142 | } /*AliITSDCSDataSDD::SetNPointsMV*/ | |
143 | ||
144 | //--------------------------------------------------------------------------- | |
145 | ||
146 | void AliITSDCSDataSDD::SetNPointsStatus( Int_t npts ) | |
147 | { | |
776c19a3 | 148 | // dimension arrays withn DCS channel status |
e22bf775 | 149 | // |
776c19a3 | 150 | |
e22bf775 | 151 | if( npts < fStatusSetPoints) |
152 | { // Cannot resize arrays - some elements would be lost | |
153 | AliWarning("Attemp to reduce size of full array (SDD DCS Status)"); | |
154 | return; | |
155 | } /*if*/ | |
156 | ||
157 | fStatus.Set( npts ); | |
158 | fStatusTimeStamp.Set( npts ); | |
159 | // Both temperature and tme stamp arrays are resized | |
160 | ||
161 | fStatusMaxPoints = npts; | |
162 | // New size is stored | |
163 | ||
164 | } /*AliITSDCSDataSDD::SetNPointsMV*/ | |
165 | ||
166 | //--------------------------------------------------------------------------- | |
167 | void AliITSDCSDataSDD::SetValueTempLeft(Int_t time, Float_t temperature ) | |
168 | { | |
776c19a3 | 169 | // insert a value for left temperature data point |
e22bf775 | 170 | // |
776c19a3 | 171 | |
e22bf775 | 172 | if( fTempLeftMaxPoints == fTempLeftSetPoints ) |
173 | SetNPointsTempLeft( fTempLeftMaxPoints + AUTORESIZE ); | |
174 | // Enlarges arrays if necessary | |
175 | ||
176 | Int_t i = FindIndex( time, fTempLeftTimeStamp, fTempLeftSetPoints ); | |
177 | // Finds place where the new value have to be inserted | |
178 | ||
179 | if( i < 0 ) | |
180 | i = 0; // New value have to be inserted before the first one in the array | |
181 | else | |
182 | i++; // New value will be put somewhere in the middle of the array | |
183 | // or at the end | |
184 | ||
185 | if( i < fTempLeftSetPoints ) | |
186 | { | |
dc5eacf8 | 187 | Short_t *fromPtrF = fTempLeft.GetArray() + i; |
e22bf775 | 188 | // Sets pointer to cell which have to be filled by new value |
dc5eacf8 | 189 | Short_t *toPtrF = fromPtrF + 1; |
e22bf775 | 190 | // Sets pointer to cell where the array content have to be shifted |
191 | ||
dc5eacf8 | 192 | memmove( toPtrF, fromPtrF, (fTempLeftSetPoints - i)*sizeof(Short_t) ); |
e22bf775 | 193 | // Shifts array content. Now there is vacant place for new value to be inserted |
194 | ||
195 | Int_t *fromPtrI = fTempLeftTimeStamp.GetArray() + i; | |
196 | Int_t *toPtrI = fromPtrI + 1; | |
197 | memmove( toPtrI, fromPtrI, (fTempLeftSetPoints - i)*sizeof(Int_t) ); | |
198 | // Do the same for time stamp array | |
199 | } /*if*/ | |
200 | ||
dc5eacf8 | 201 | UShort_t val = (UShort_t)( temperature * fgkTPrec ); |
202 | // Float value of temperature is stored as UShort_t with given precision | |
203 | ||
204 | fTempLeft.AddAt( (Short_t)val, i ); | |
e22bf775 | 205 | fTempLeftTimeStamp.AddAt( time, i ); |
206 | fTempLeftSetPoints++; | |
207 | // New values are inserted | |
208 | } /*AliITSDCSDataSDD::SetValueTempLeft*/ | |
209 | ||
210 | //--------------------------------------------------------------------------- | |
211 | ||
212 | void AliITSDCSDataSDD::SetValueTempRight(Int_t time, Float_t temperature ) | |
213 | { | |
776c19a3 | 214 | // insert a value for right temperature data point |
e22bf775 | 215 | // |
776c19a3 | 216 | |
e22bf775 | 217 | if( fTempRightMaxPoints == fTempRightSetPoints ) |
218 | SetNPointsTempRight( fTempRightMaxPoints + AUTORESIZE ); | |
219 | // Enlarges arrays if necessary | |
220 | ||
221 | Int_t i = FindIndex( time, fTempRightTimeStamp, fTempRightSetPoints ); | |
222 | // Finds place where the new value have to be inserted | |
223 | ||
224 | if( i < 0 ) | |
225 | i = 0; // New value have to be inserted before the first one in the array | |
226 | else | |
227 | i++; // New value will be put somewhere in the middle of the array | |
228 | // or at the end | |
229 | ||
230 | if( i < fTempRightSetPoints ) | |
231 | { // Some values have to be moved | |
dc5eacf8 | 232 | Short_t *fromPtrF = fTempRight.GetArray() + i; |
e22bf775 | 233 | // Sets pointer to cell which have to be filled by new value |
dc5eacf8 | 234 | Short_t *toPtrF = fromPtrF + 1; |
e22bf775 | 235 | // Sets pointer to cell where the array content have to be shifted |
236 | ||
dc5eacf8 | 237 | memmove( toPtrF, fromPtrF, (fTempRightSetPoints - i)*sizeof(Short_t) ); |
e22bf775 | 238 | // Shifts array content. Now there is vacant place for new value to be inserted |
239 | ||
240 | Int_t *fromPtrI = fTempRightTimeStamp.GetArray() + i; | |
241 | Int_t *toPtrI = fromPtrI + 1; | |
242 | memmove( toPtrI, fromPtrI, (fTempRightSetPoints - i)*sizeof(Int_t) ); | |
243 | // Do the same for time stamp array | |
244 | } /*if*/ | |
245 | ||
dc5eacf8 | 246 | UShort_t val = (UShort_t)( temperature * fgkTPrec ); |
247 | // Float value of temperature is stored as UShort_t with given precision | |
248 | ||
249 | fTempRight.AddAt( (Short_t)val, i ); | |
e22bf775 | 250 | fTempRightTimeStamp.AddAt( time, i ); |
251 | fTempRightSetPoints++; | |
252 | // New values are inserted | |
253 | } /*AliITSDCSDataSDD::SetValueTempRight*/ | |
254 | ||
255 | //--------------------------------------------------------------------------- | |
256 | ||
257 | void AliITSDCSDataSDD::SetValueHV(Int_t time, Float_t voltage ) | |
258 | { | |
776c19a3 | 259 | // insert a value for HV data point |
e22bf775 | 260 | // |
776c19a3 | 261 | |
e22bf775 | 262 | if( fHVMaxPoints == fHVSetPoints ) |
263 | SetNPointsHV( fHVMaxPoints + AUTORESIZE ); | |
264 | // Enlarges arrays if necessary | |
265 | ||
266 | Int_t i = FindIndex( time, fHVTimeStamp, fHVSetPoints ); | |
267 | // Finds place where the new value have to be inserted | |
268 | ||
269 | if( i < 0 ) | |
270 | i = 0; // New value have to be inserted before the first one in the array | |
271 | else | |
272 | i++; // New value will be put somewhere in the middle of the array | |
273 | // or at the end | |
274 | ||
275 | if( i < fHVSetPoints ) | |
276 | { | |
277 | Float_t *fromPtrF = fHV.GetArray() + i; | |
278 | // Sets pointer to cell which have to be filled by new value | |
279 | Float_t *toPtrF = fromPtrF + 1; | |
280 | // Sets pointer to cell where the array content have to be shifted | |
281 | ||
282 | memmove( toPtrF, fromPtrF, (fHVSetPoints - i)*sizeof(Float_t) ); | |
283 | // Shifts array content. Now there is vacant place for new value to be inserted | |
284 | ||
285 | Int_t *fromPtrI = fHVTimeStamp.GetArray() + i; | |
286 | Int_t *toPtrI = fromPtrI + 1; | |
287 | memmove( toPtrI, fromPtrI, (fHVSetPoints - i)*sizeof(Int_t) ); | |
288 | // Do the same for time stamp array | |
289 | } /*if*/ | |
290 | ||
291 | fHV.AddAt( voltage, i ); | |
292 | fHVTimeStamp.AddAt( time, i ); | |
293 | fHVSetPoints++; | |
294 | // New values are inserted | |
295 | } /*AliITSDCSDataSDD::SetValueHV*/ | |
296 | ||
297 | //--------------------------------------------------------------------------- | |
298 | ||
299 | void AliITSDCSDataSDD::SetValueMV(Int_t time, Float_t voltage ) | |
300 | { | |
776c19a3 | 301 | // insert a value for MV data point |
e22bf775 | 302 | // |
776c19a3 | 303 | |
e22bf775 | 304 | if( fMVMaxPoints == fMVSetPoints ) |
305 | SetNPointsMV( fMVMaxPoints + AUTORESIZE ); | |
306 | // Enlarges arrays if necessary | |
307 | ||
308 | Int_t i = FindIndex( time, fMVTimeStamp, fMVSetPoints ); | |
309 | // Finds place where the new value have to be inserted | |
310 | ||
311 | if( i < 0 ) | |
312 | i = 0; // New value have to be inserted before the first one in the array | |
313 | else | |
314 | i++; // New value will be put somewhere in the middle of the array | |
315 | // or at the end | |
316 | ||
317 | if( i < fMVSetPoints ) | |
318 | { | |
dc5eacf8 | 319 | Short_t *fromPtrF = fMV.GetArray() + i; |
e22bf775 | 320 | // Sets pointer to cell which have to be filled by new value |
dc5eacf8 | 321 | Short_t *toPtrF = fromPtrF + 1; |
e22bf775 | 322 | // Sets pointer to cell where the array content have to be shifted |
323 | ||
dc5eacf8 | 324 | memmove( toPtrF, fromPtrF, (fMVSetPoints - i)*sizeof(Short_t) ); |
e22bf775 | 325 | // Shifts array content. Now there is vacant place for new value to be inserted |
326 | ||
327 | Int_t *fromPtrI = fMVTimeStamp.GetArray() + i; | |
328 | Int_t *toPtrI = fromPtrI + 1; | |
329 | memmove( toPtrI, fromPtrI, (fMVSetPoints - i)*sizeof(Int_t) ); | |
330 | // Do the same for time stamp array | |
331 | } /*if*/ | |
332 | ||
dc5eacf8 | 333 | UShort_t val = (UShort_t)( voltage * fgkMVPrec ); |
334 | // Float value of temperature is stored as UShort_t with given precision | |
335 | ||
336 | fMV.AddAt( (Short_t)val, i ); | |
e22bf775 | 337 | fMVTimeStamp.AddAt( time, i ); |
338 | fMVSetPoints++; | |
339 | // New values are inserted | |
340 | } /*AliITSDCSDataSDD::SetValueMV*/ | |
341 | ||
342 | //--------------------------------------------------------------------------- | |
343 | ||
344 | void AliITSDCSDataSDD::SetValueStatus(Int_t time, Char_t status ) | |
345 | { | |
776c19a3 | 346 | // insert a value for channel status |
e22bf775 | 347 | // |
776c19a3 | 348 | |
e22bf775 | 349 | if( fStatusMaxPoints == fStatusSetPoints ) |
350 | SetNPointsStatus( fStatusMaxPoints + AUTORESIZE ); | |
351 | // Enlarges arrays if necessary | |
352 | ||
353 | Int_t i = FindIndex( time, fStatusTimeStamp, fStatusSetPoints ); | |
354 | // Finds place where the new value have to be inserted | |
355 | ||
356 | if( i < 0 ) | |
357 | i = 0; // New value have to be inserted before the first one in the array | |
358 | else | |
359 | i++; // New value will be put somewhere in the middle of the array | |
360 | // or at the end | |
361 | ||
362 | if( i < fStatusSetPoints ) | |
363 | { | |
364 | Char_t *fromPtrF = fStatus.GetArray() + i; | |
365 | // Sets pointer to cell which have to be filled by new value | |
366 | Char_t *toPtrF = fromPtrF + 1; | |
367 | // Sets pointer to cell where the array content have to be shifted | |
368 | ||
369 | memmove( toPtrF, fromPtrF, (fStatusSetPoints - i)*sizeof(Char_t) ); | |
370 | // Shifts array content. Now there is vacant place for new value to be inserted | |
371 | ||
372 | Int_t *fromPtrI = fStatusTimeStamp.GetArray() + i; | |
373 | Int_t *toPtrI = fromPtrI + 1; | |
374 | memmove( toPtrI, fromPtrI, (fStatusSetPoints - i)*sizeof(Int_t) ); | |
375 | // Do the same for time stamp array | |
376 | } /*if*/ | |
377 | ||
378 | fStatus.AddAt( status, i ); | |
379 | fStatusTimeStamp.AddAt( time, i ); | |
380 | fStatusSetPoints++; | |
381 | // New values are inserted | |
382 | ||
383 | } /*AliITSDCSDataSDD::SetValueStatus*/ | |
384 | ||
385 | ||
e22bf775 | 386 | //--------------------------------------------------------------------------- |
387 | ||
388 | void AliITSDCSDataSDD::Compress() | |
389 | { | |
dc5eacf8 | 390 | // Minimize array sizes |
e22bf775 | 391 | |
392 | SetNPointsTempLeft( fTempLeftSetPoints ); | |
393 | SetNPointsTempRight( fTempRightSetPoints ); | |
394 | SetNPointsHV( fHVSetPoints ); | |
395 | SetNPointsMV( fMVSetPoints ); | |
396 | SetNPointsStatus( fStatusSetPoints ); | |
397 | ||
398 | } /*AliITSDCSDataSDD::Compress*/ | |
399 | ||
400 | //--------------------------------------------------------------------------- | |
401 | ||
dc5eacf8 | 402 | Float_t AliITSDCSDataSDD::GetDriftField( Int_t timeStamp ) const |
403 | { | |
e22bf775 | 404 | // Returns drift field counted for specific time |
405 | ||
406 | Int_t cathodesNumber = 291; | |
407 | Float_t cathodesPitch = 0.0120; | |
408 | ||
409 | Float_t hv = GetHV( timeStamp ); | |
410 | Float_t mv = GetMV( timeStamp ); | |
411 | ||
412 | if( hv < 0.0 || mv < 0.0 ) return -1.0; | |
413 | // HV or MV is unknown at this time | |
414 | ||
415 | return ( hv - mv ) / ( cathodesNumber * cathodesPitch ); | |
416 | ||
417 | } /*AliITSDCSDataSDD::GetDriftField*/ | |
418 | ||
419 | //--------------------------------------------------------------------------- | |
420 | ||
421 | ||
422 | Float_t AliITSDCSDataSDD::GetDriftSpeed( Int_t /*timeStamp*/ ) const | |
dc5eacf8 | 423 | { |
424 | // Returns drift speed counted for specific time. Calculation is based on temerature | |
425 | // taken from DCS. This metod is not dedicated for normal usage, it should be used | |
426 | // only in cases that the injectors for given module fails. | |
427 | // | |
428 | // Presently only a prototype, returns -1.0. | |
e22bf775 | 429 | |
430 | /* PROTOTYPE */ | |
431 | ||
432 | return -1.0; | |
433 | ||
434 | } /*AliITSDCSDataSDD::*/ | |
435 | ||
436 | //--------------------------------------------------------------------------- | |
437 | ||
438 | ||
439 | void AliITSDCSDataSDD:: PrintValues( FILE *output ) const | |
dc5eacf8 | 440 | { |
e22bf775 | 441 | // Prints array contents |
442 | ||
443 | Int_t nTLEntries = GetTempLeftRecords(); | |
444 | Int_t nTREntries = GetTempRightRecords(); | |
445 | Int_t nHVEntries = GetHVRecords() ; | |
446 | Int_t nMVEntries = GetMVRecords(); | |
447 | Int_t nStatEntries = GetStatusRecords(); | |
448 | ||
dc5eacf8 | 449 | fprintf( output, "+------------------------------------------------------------------------------------------------------------+\n"); |
450 | fprintf( output, "| DCS content |\n" ); | |
451 | fprintf( output, "+----------------------+-----------------------+---------------------+---------------------+-----------------+\n"); | |
452 | fprintf( output, "| %05i records | %05i records | %05i records | %05i records | %05i records |\n", | |
e22bf775 | 453 | nHVEntries, nMVEntries, nTLEntries, nTREntries, nStatEntries ); |
dc5eacf8 | 454 | fprintf( output, "| time (s) HV | time (s) MV | time (s) TL | time (s) TR | time (s) Stat |\n" ); |
455 | fprintf( output, "+----------------------+-----------------------+---------------------+---------------------+-----------------+\n"); | |
e22bf775 | 456 | |
457 | Int_t a = (nHVEntries > nMVEntries ) ? nHVEntries : nMVEntries; | |
458 | Int_t b = (nTLEntries > nTREntries ) ? nTLEntries : nTREntries; | |
459 | if( a < b ) a = b; | |
460 | Int_t loopMax = ( a > nStatEntries ) ? a : nStatEntries ; | |
461 | // Finds maximal entry number | |
462 | ||
463 | for( Int_t entryLoop = 0; entryLoop < loopMax; entryLoop++ ) | |
464 | { | |
465 | ||
466 | if( entryLoop < nHVEntries ) | |
467 | fprintf( output, "| %12i %4.2f | ", GetHVTimeIdx(entryLoop), GetHVIdx(entryLoop) ); | |
468 | else | |
469 | fprintf( output, "| | "); | |
470 | ||
471 | if( entryLoop < nMVEntries ) | |
dc5eacf8 | 472 | fprintf( output, " %12i %2.3f | ", GetMVTimeIdx(entryLoop), GetMVIdx(entryLoop) ); |
e22bf775 | 473 | else |
dc5eacf8 | 474 | fprintf( output, " | "); |
e22bf775 | 475 | |
476 | if( entryLoop < nTLEntries ) | |
477 | fprintf( output, "%12i %2.2f | ", GetTempLeftTimeIdx(entryLoop), GetTempLeftIdx(entryLoop) ); | |
478 | else | |
479 | fprintf( output, " | "); | |
480 | ||
481 | if( entryLoop < nTREntries ) | |
482 | fprintf( output, "%12i %2.2f | ", GetTempRightTimeIdx(entryLoop), GetTempRightIdx(entryLoop) ); | |
483 | else | |
484 | fprintf( output, " | "); | |
485 | ||
486 | if( entryLoop < nStatEntries ) | |
487 | fprintf( output, "%12i %i |\n", GetStatusTimeIdx(entryLoop), GetStatusIdx(entryLoop) ); | |
488 | else | |
489 | fprintf( output, " |\n"); | |
490 | ||
491 | } /*for( entryLoop )*/ | |
492 | ||
493 | ||
494 | } /*AliITSDCSDataSDD::PrintValues()*/ | |
495 | ||
496 | //--------------------------------------------------------------------------- | |
497 | ||
dc5eacf8 | 498 | Int_t AliITSDCSDataSDD::FindIndex( Int_t timeStamp, const TArrayI &timeStampArray, Int_t n ) const |
499 | { | |
500 | // Provides binary search in the time array. Returns index in the array of time | |
501 | // stamps by selected value. Returns -1 if the time is less than time stamp in | |
502 | // the timeArray[0] | |
e22bf775 | 503 | |
504 | if( n < 1 ) return -1;// Empty array or wrong value of array size | |
505 | ||
dc5eacf8 | 506 | if( timeStamp >= timeStampArray.At(n-1) ) return n-1; |
e22bf775 | 507 | // Time is larger than last timestamp - last value in the array have |
508 | // to be used. This is the most frequent case, so it have sense | |
509 | // to check it and avoid searching. | |
510 | ||
dc5eacf8 | 511 | if( timeStamp < timeStampArray.At(0) ) return -1; |
e22bf775 | 512 | // Time is less than all time stamp stored in the array |
513 | ||
514 | Int_t left = 0; | |
515 | Int_t right = n-1; | |
516 | Int_t middle = (left + right)/2; | |
517 | ||
518 | while( !( middle == left || middle == right) ) | |
519 | { // Binary search in the time stamp array | |
520 | ||
dc5eacf8 | 521 | if( timeStampArray.At(middle) < timeStamp ) |
e22bf775 | 522 | left = middle; |
523 | else | |
524 | right = middle; | |
525 | middle = (left + right)/2; | |
526 | } /*while*/ | |
527 | ||
dc5eacf8 | 528 | if( timeStamp >= timeStampArray.At(right) ) |
e22bf775 | 529 | return right; |
530 | else | |
531 | return left; | |
532 | ||
533 | } /*AliITSDCSDataSDD::FindIndexByTimeStamp*/ | |
534 | ||
535 | //--------------------------------------------------------------------------- |