]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSDCSAnalyzerSDD.cxx
update of data handling classes for SSD calibration
[u/mrichter/AliRoot.git] / ITS / AliITSDCSAnalyzerSDD.cxx
CommitLineData
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
473ac76e 16/* $Id$ */
cfaccd71 17
18///////////////////////////////////////////////////////////////////
19// //
20// Implementation of the class for SDD DCS data analysis //
21// Origin: F.Prino, Torino, prino@to.infn.it //
e22bf775 22// V.Pospisil, CTU Prague, gdermog@seznam.cz //
cfaccd71 23///////////////////////////////////////////////////////////////////
24
25
26#include "AliITSDCSAnalyzerSDD.h"
27#include "AliDCSValue.h"
e22bf775 28#include "AliLog.h"
29#include "AliITSgeomTGeo.h"
cfaccd71 30
31ClassImp(AliITSDCSAnalyzerSDD)
32
33//---------------------------------------------------------------
e22bf775 34 AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD(): TObject(),
35fHVDelay(0),fMVDelay(0),fTLDelay(0),fTRDelay(0),fStTLDelay(0),fStTRDelay(0),fOKDelay(0)
36{
37// Default constructor
cfaccd71 38 Init();
e22bf775 39} /*AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD*/
40
cfaccd71 41//---------------------------------------------------------------
e22bf775 42
43AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD(const AliITSDCSAnalyzerSDD& /* dcsa */): TObject(),
44fHVDelay(0),fMVDelay(0),fTLDelay(0),fTRDelay(0),fStTLDelay(0),fStTRDelay(0),fOKDelay(0)
45{
46// copy constructor
47 // Copies are not allowed. The method is protected to avoid misuse.
48 fprintf( stderr, "Copy constructor not allowed");
49} /*AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD*/
50
cfaccd71 51//---------------------------------------------------------------
e22bf775 52
53AliITSDCSAnalyzerSDD& AliITSDCSAnalyzerSDD::operator=(const AliITSDCSAnalyzerSDD& /* dcsa */)
54{
55// assigment operator
56 // Assignment is not allowed. The method is protected to avoid misuse.
57 fprintf( stderr, "Assignment operator not allowed");
cfaccd71 58 return *this;
e22bf775 59}/*AliITSDCSAnalyzerSDD::operator=*/
60
cfaccd71 61//---------------------------------------------------------------
e22bf775 62
63AliITSDCSAnalyzerSDD::~AliITSDCSAnalyzerSDD()
64{
65// destructor
66 for(int j=0; j<kNmodules; j++)
67 {
cfaccd71 68 if(fDCSData[j]) delete fDCSData[j];
e22bf775 69 } /*for( j )*/
70} /*AliITSDCSAnalyzerSDD::~AliITSDCSAnalyzerSDD*/
71
cfaccd71 72//---------------------------------------------------------------
e22bf775 73
74void AliITSDCSAnalyzerSDD::AnalyzeData(TMap* dcsMap)
75{
76// Data processing
77
78 Int_t counter = 0;
79
80 for( Int_t iLay = 3; iLay < 5; iLay++ )
81 {
82
83 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
84 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
85
86 for(Int_t iLad = 0; iLad < maxLad; iLad++)
87 {
88 for(Int_t iMod = 0; iMod < maxMod; iMod++)
89 {
90 // Loads arrays of DCS variables from map. Variables are
91 // searched by names (for ex. SDD_LAYER3_LADDER5_MODULE4_HV)
92
93 Int_t moduleLoop = AliITSgeomTGeo::GetModuleIndex( iLay, iLad + 1, iMod + 1 ) - 240;
94
473ac76e 95 fDCSData[moduleLoop] = new AliITSDCSDataSDD();
96 // DCS data for specific SDD module will be stored in this class
97
e22bf775 98 TObjArray* arrHV = (TObjArray*) dcsMap->GetValue( fHVDPNames[moduleLoop].Data() );
99 if(!arrHV)
100 {
101 fprintf( stderr, Form("DCS HV alias %s not found!\n", fHVDPNames[moduleLoop].Data()));
102 continue;
103 } /*if*/
104
105 TObjArray* arrMV = (TObjArray*) dcsMap->GetValue( fMVDPNames[moduleLoop].Data() );
106 if(!arrMV)
107 {
108 fprintf( stderr, Form("DCS MV alias %s not found!\n", fMVDPNames[moduleLoop].Data()));
109 continue;
110 } /*if*/
111
112 TObjArray* arrOK = (TObjArray*) dcsMap->GetValue( fOKDPNames[moduleLoop].Data() );
113 if(!arrOK)
114 {
115 fprintf( stderr, Form("DCS MOD_OK alias %s not found!\n", fOKDPNames[moduleLoop].Data()));
116 continue;
117 } /*if*/
118
119 TObjArray* arrTL = (TObjArray*) dcsMap->GetValue( fTLDPNames[moduleLoop].Data() );
120 if(!arrTL)
121 {
122 fprintf( stderr, Form("DCS TEMP_L alias %s not found!\n", fTLDPNames[moduleLoop].Data()));
123 continue;
124 } /*if*/
125
126 TObjArray* arrTR = (TObjArray*) dcsMap->GetValue( fTRDPNames[moduleLoop].Data() );
127 if(!arrTR)
128 {
129 fprintf( stderr, Form("DCS TEMP_R alias %s not found!\n", fTRDPNames[moduleLoop].Data()));
130 continue;
131 } /*if*/
132
133 TObjArray* arrStTL = (TObjArray*) dcsMap->GetValue( fTLStDPNames[moduleLoop].Data() );
134 if(!arrStTL)
135 {
136 fprintf( stderr, Form("DCS TEMP_L_STATE alias %s not found!\n", fTLStDPNames[moduleLoop].Data()));
137 continue;
138 } /*if*/
139
140 TObjArray* arrStTR = (TObjArray*) dcsMap->GetValue( fTRStDPNames[moduleLoop].Data() );
141 if(!arrStTR)
142 {
143 fprintf( stderr, Form("DCS TEMP_R_STATE alias %s not found!\n", fTRStDPNames[moduleLoop].Data()));
144 continue;
145 } /*if*/
146
e22bf775 147
148 Int_t nEntries;
149 // Number of entries in each TObjArray, that contains DCS variable values
150 AliDCSValue *valToProcess;
151 // Pointer to currently processed DCS variable value
152
153 nEntries = arrTL->GetEntries();
154 fDCSData[moduleLoop]->SetNPointsTempLeft( nEntries );
155 // Left temperature array size is set
156
157 for( Int_t tlLoop = 0; tlLoop < nEntries; tlLoop++ )
158 { // Left temerature values are copied into the AliITSDCSDataSDD TempLeft array
159 valToProcess = (AliDCSValue *)(arrTL->At(tlLoop));
160 fDCSData[moduleLoop]->SetValueTempLeft( valToProcess->GetTimeStamp() - fTLDelay, valToProcess->GetFloat() );
161 } /*for( tlLoop )*/
162 counter += nEntries;
163
164 nEntries = arrTR->GetEntries();
165 fDCSData[moduleLoop]->SetNPointsTempRight( nEntries );
166 // Right temperature array size is set
167
168 for( Int_t trLoop = 0; trLoop < nEntries; trLoop++ )
169 { // Right temerature values are copied into the AliITSDCSDataSDD TempRight array
170 valToProcess = (AliDCSValue *)(arrTR->At(trLoop));
171 fDCSData[moduleLoop]->SetValueTempRight( valToProcess->GetTimeStamp() - fTRDelay, valToProcess->GetFloat() );
172 } /*for( trLoop )*/
173 counter += nEntries;
174
175 nEntries = arrHV->GetEntries();
176 fDCSData[moduleLoop]->SetNPointsHV( nEntries );
177 // HV array size is set
178
179 for( Int_t hvLoop = 0; hvLoop < nEntries; hvLoop++ )
180 { // HV values are copied into the AliITSDCSDataSDD HV array
181 valToProcess = (AliDCSValue *)(arrHV->At(hvLoop));
182 fDCSData[moduleLoop]->SetValueHV( valToProcess->GetTimeStamp() - fHVDelay, valToProcess->GetFloat() );
183 } /*for( hvLoop )*/
184 counter += nEntries;
185
186 nEntries = arrMV->GetEntries();
187 fDCSData[moduleLoop]->SetNPointsMV( nEntries );
188 // MV array size is set
189
190 for( Int_t mvLoop = 0; mvLoop < nEntries; mvLoop++ )
191 { // MV values are copied into the AliITSDCSDataSDD MV array
192 valToProcess = (AliDCSValue *)(arrMV->At(mvLoop));
193 fDCSData[moduleLoop]->SetValueMV( valToProcess->GetTimeStamp() - fMVDelay, valToProcess->GetFloat() );
194 } /*for( mvLoop )*/
195 counter += nEntries;
196
197/* Following part of the code is responsibile for the condensing of all status information given by DCS
198 into one array of Char_t. Each record of this array is in principle a bit map :
199
200 0. bit ... _OK
201 1. bit ... _TEMP_L_STATE
202 2. bit ... _TEMP_R_STATE
203
204 Each record have its own time stamp. Because there are three inputs with independent time stamp,
205 some algorithm which assigns new time stamp to bitmap according to three input time stamps is
206 necessary.
207
208 Let's vizualize time stamps of the three input arrays. There is time on x-axis :
209
210 +------------+---------------------+------
211 | | | _OK
212 +------+------+---+--------+------------+------
213 | | | | | _TEMP_L_STATE
214 +--+------+---+--+-------+-----+--------+---+------
215 | | | | | | _TEMP_R_STATE
216 +-------------+----------+-----+--------+---+------
217
218 | | | | | | | | | | |
219 V V V V V V V V V V V
220
221 +---+----+-+--+---+---+--+-----+--------+---+------
222 | | | | | | | | | | | Status bitmap
223 +---+----+-+--+---+---+--+-----+--------+---+------
224
225
226 Principle of combining three status records into one is visible from the picture.
227 If there are two sequent records with the same status bitmap, they are joined into
228 one (with the time stamp of the earliest one).
229
230*/
231
232 Int_t nStTLEntries = arrStTL->GetEntries();
233 Int_t nStTREntries = arrStTR->GetEntries();
234 Int_t nOKEntries = arrOK->GetEntries();
235 // Gets number of _STAT_L, _STAT_R and _OK values stored in dcsMap
236
237 if( nStTLEntries < 1 )
238 { // TObjArray arrStTL is empty. This would cause segmentation violation during
239 // the condensing, so this case must be handled before algorithm starts
240 fprintf( stderr, "%s contains no data!\n", fTLStDPNames[moduleLoop].Data() );
241 nStTLEntries = 1;
242 arrStTL->Add( new AliDCSValue( (Int_t)0, 0x7FFFFFFF ) );
243 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number. Left temperature
244 // sensor will be regarded as switched-off during whole run.
245 } /*if*/
246
247 if( nStTREntries < 1 )
248 { // TObjArray arrStTR is empty. This would cause segmentation violation during
249 // the condensing, so this case must be handled before algorithm starts
250 fprintf( stderr, "%s contains no data!\n", fTRStDPNames[moduleLoop].Data() );
251 nStTREntries = 1;
252 arrStTR->Add( new AliDCSValue( (Int_t)0, 0x7FFFFFFF ) );
253 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number. Right temperature
254 // sensor will be regarded as switched-off during whole run.
255 } /*if*/
256
257 if( nOKEntries < 1 )
258 { // TObjArray arrOK is empty. This would cause segmentation violation during
259 // the condensing, so this case must be handled before algorithm starts
260 fprintf( stderr, "%s contains no data!\n", fOKDPNames[moduleLoop].Data() );
261 nOKEntries = 1;
262 arrOK->Add( new AliDCSValue( (Bool_t)0, 0x7FFFFFFF ) );
263 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number.
264 // Module will be regarded as switched-off during whole run.
265 } /*if*/
266
267 arrStTL->Sort();
268 arrStTR->Sort();
269 arrOK->Sort();
270 // Condensing would work properly only in the case that
271 // the input arrays are sorted by time
272
273 Int_t nEntriesMax = nStTLEntries + nStTREntries + nOKEntries;
274 fDCSData[moduleLoop]->SetNPointsStatus( nEntriesMax );
275 // Determines necessary length of new array and sets its size
276 // Lot of space in such defined array will be probably
277 // vacant after the analysis, but this will be corrected
278 // by Compress() method
279
280 Int_t idxStTL = 0;
281 Int_t idxStTR = 0;
282 Int_t idxOK = 0;
283 // Input arrays indexes
284
285 Int_t tsStTL, tsStTR, tsOK;
286 // Time stamps ofinput arrays
287 Int_t tsNew;// New time stamp (output array)
288
289 Char_t bitStatus;
290 // New status record :
291 // 0. bit ... _OK
292 // 1. bit ... _TEMP_L_STATE
293 // 2. bit ... _TEMP_R_STATE
294 Char_t lastBitStatus = 100;
295
296 AliDCSValue *valStTL, *valStTR, *valOK;
297 // Pointers to input arrays records (input arrays are TObjArrays
298 // containing objects of type AliDCSValue
299
300 tsStTR = ( (AliDCSValue *)arrStTR->At(0) )->GetTimeStamp() - fStTLDelay;
301 tsStTL = ( (AliDCSValue *)arrStTL->At(0) )->GetTimeStamp() - fStTRDelay;
302 tsOK = ( (AliDCSValue *)arrOK->At(0) )->GetTimeStamp() - fOKDelay;
303 // Time stamps of first records in input filea are readed (and delays are substracted)
304
305 tsNew = (tsStTR < tsStTL) ? tsStTR : tsStTL;
306 if( tsNew > tsOK ) tsNew = tsOK;
307 // Time intervals are "prolonged" to the very eaarliest of time stamps.
308 // It means that first output time stamp will be the same as the one
309 // which is first in input arrays. Values of other DCS variables are
310 // not defined in this time yet, but they will be treated as equal to
311 // values in first records of input arrays.
312
313 nStTLEntries--; nStTREntries--; nOKEntries--;
314 // Indexes in the input array must not exceed last records.
315
316 while( (idxStTL < nStTLEntries) || (idxStTR < nStTREntries) || (idxOK < nOKEntries) )
317 { // Loop goes throug all three input files
318
319 valStTL = (AliDCSValue *)( arrStTL->At(idxStTL) );
320 valStTR = (AliDCSValue *)( arrStTR->At(idxStTR) );
321 valOK = (AliDCSValue *)( arrOK->At(idxOK) );
322 // Values are readed from input arrays
323
324 bitStatus = 0;
325 if( valOK->GetBool() ) bitStatus += 1; // 0. bit - _OK
326 if( valStTL->GetInt() == 1 ) bitStatus += 2; // 1. bit - _TEMP_L_STATE
327 if( valStTR->GetInt() == 1 ) bitStatus += 4; // 2. bit - _TEMP_R_STATE
328 // Bit map is created
329
330 if( lastBitStatus != bitStatus )
331 { // If the status bitmap is teh same as last one, it would not be stored.
332 // It will save much space.
333 fDCSData[moduleLoop]->SetValueStatus( tsNew, bitStatus );
334 // Bit map is written into the output array (if different from last value )
335 lastBitStatus = bitStatus;
336 counter += nEntries;
337 } /*if*/
338
339 if( idxStTL == nStTLEntries )
340 tsStTL = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
341 else
342 tsStTL = ( (AliDCSValue *)arrStTL->At(idxStTL + 1) )->GetTimeStamp() - fStTLDelay;
343
344 if( idxStTR == nStTREntries )
345 tsStTR = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
346 else
347 tsStTR = ( (AliDCSValue *)arrStTR->At(idxStTR + 1) )->GetTimeStamp() - fStTRDelay;
348
349 if( idxOK == nOKEntries )
350 tsOK = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
351 else
352 tsOK = ( (AliDCSValue *)arrOK->At(idxOK + 1) )->GetTimeStamp() - fOKDelay;
353 // Reads time stamps of folowing records in the input arrays (and substracts delays).
354 // Validity of the last records in the input arrays are prolonged
355 // to "infinity"
356
357 if( tsStTL == tsOK && tsStTR == tsOK ) { tsNew = tsStTL; idxStTL++; idxStTR++; idxOK++; continue; }
358 if( tsStTL == tsStTR && tsStTR < tsOK ) { tsNew = tsStTL; idxStTL++; idxStTR++; continue; }
359 if( tsStTL == tsOK && tsOK < tsStTR ) { tsNew = tsStTL; idxStTL++; idxOK++; continue; }
360 if( tsStTR == tsOK && tsOK < tsStTL ) { tsNew = tsStTR; idxStTR++; idxOK++; continue; }
361 if( tsOK < tsStTL && tsOK < tsStTR ) { tsNew = tsOK; idxOK++; continue; }
362 if( tsStTL < tsOK && tsStTL < tsStTR ) { tsNew = tsStTL; idxStTL++; continue; }
363 /*Last possibile case*/ { tsNew = tsStTR; idxStTR++; }
364
365 // Index of array, whose following record have time stamp closest to just written one,
366 // is increased. If there are more records with identical time stamps meeting this condition,
367 // all correspondent indexes are increased.
368
369 } /*while*/
370
371
372 } /*for( iMod )*/
373 } /*for( iLad )*/
374 } /*for( iLay )*/
375
376
377} /*AliITSDCSAnalyzerSDD::AnalyzeData*/
378
cfaccd71 379
380//---------------------------------------------------------------
e22bf775 381
382
383void AliITSDCSAnalyzerSDD::Init()
384{
cfaccd71 385 // Initialization of DCS DP names
386 Char_t dpName[50];
387 Char_t modName[50];
e22bf775 388
389
390 for( Int_t iLay = 3; iLay < 5; iLay++ )
391 {
392
393 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
394 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
395
396 for(Int_t iLad=0; iLad<maxLad; iLad++)
397 {
398 for(Int_t iMod=0; iMod<maxMod;iMod++)
399 {
400 sprintf(modName,"SDD_LAYER%i_LADDER%02d_MODULE%d", iLay, iLad, iMod);
401 Int_t id = AliITSgeomTGeo::GetModuleIndex( iLay, iLad + 1, iMod + 1 ) - 240;
402
403 sprintf(dpName,"%s_HV",modName);
404 fHVDPNames[id]=dpName;
405 sprintf(dpName,"%s_MV",modName);
406 fMVDPNames[id]=dpName;
407 sprintf(dpName,"%s_OK",modName);
408 fOKDPNames[id]=dpName;
409 sprintf(dpName,"%s_TEMP_L",modName);
410 fTLDPNames[id]=dpName;
411 sprintf(dpName,"%s_TEMP_R",modName);
412 fTRDPNames[id]=dpName;
413 sprintf(dpName,"%s_TEMP_L_STATE",modName);
414 fTLStDPNames[id]=dpName;
415 sprintf(dpName,"%s_TEMP_R_STATE",modName);
416 fTRStDPNames[id]=dpName;
417
418 } /*for( iMod )*/
419 } /*for( iLad )*/
420
421 } /*for( iLay )*/
422
423
424} /*AliITSDCSAnalyzerSDD::Init*/
cfaccd71 425
426//---------------------------------------------------------------
e22bf775 427void AliITSDCSAnalyzerSDD::PrintDCSDPNames( FILE *output )
428{
cfaccd71 429 // Data processing
e22bf775 430 for( Int_t j = 0; j < kNmodules; j++ )
431 {
432 fprintf( output, "Module %d %s %s %s %s\n",j,fHVDPNames[j].Data(),
433 fMVDPNames[j].Data(),fTLDPNames[j].Data(),fTRDPNames[j].Data());
434 } /*for( j )*/
435} /*AliITSDCSAnalyzerSDD::PrintDCSDPNames*/