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