1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////
20 // Implementation of the class for SDD DCS data analysis //
21 // Origin: F.Prino, Torino, prino@to.infn.it //
22 // V.Pospisil, CTU Prague, gdermog@seznam.cz //
23 ///////////////////////////////////////////////////////////////////
26 #include "AliITSDCSAnalyzerSDD.h"
27 #include "AliDCSValue.h"
29 #include "AliITSgeomTGeo.h"
31 ClassImp(AliITSDCSAnalyzerSDD)
33 //---------------------------------------------------------------
34 AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD(): TObject(),
35 fHVDelay(0),fMVDelay(0),fTLDelay(0),fTRDelay(0),fStTLDelay(0),fStTRDelay(0),fOKDelay(0)
37 // Default constructor
39 } /*AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD*/
41 //---------------------------------------------------------------
43 AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD(const AliITSDCSAnalyzerSDD& /* dcsa */): TObject(),
44 fHVDelay(0),fMVDelay(0),fTLDelay(0),fTRDelay(0),fStTLDelay(0),fStTRDelay(0),fOKDelay(0)
47 // Copies are not allowed. The method is protected to avoid misuse.
48 fprintf( stderr, "Copy constructor not allowed");
49 } /*AliITSDCSAnalyzerSDD::AliITSDCSAnalyzerSDD*/
51 //---------------------------------------------------------------
53 AliITSDCSAnalyzerSDD& AliITSDCSAnalyzerSDD::operator=(const AliITSDCSAnalyzerSDD& /* dcsa */)
56 // Assignment is not allowed. The method is protected to avoid misuse.
57 fprintf( stderr, "Assignment operator not allowed");
59 }/*AliITSDCSAnalyzerSDD::operator=*/
61 //---------------------------------------------------------------
63 AliITSDCSAnalyzerSDD::~AliITSDCSAnalyzerSDD()
66 for(int j=0; j<kNmodules; j++)
68 if(fDCSData[j]) delete fDCSData[j];
70 } /*AliITSDCSAnalyzerSDD::~AliITSDCSAnalyzerSDD*/
72 //---------------------------------------------------------------
74 void AliITSDCSAnalyzerSDD::AnalyzeData(TMap* dcsMap)
80 for( Int_t iLay = 3; iLay < 5; iLay++ )
83 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
84 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
86 for(Int_t iLad = 0; iLad < maxLad; iLad++)
88 for(Int_t iMod = 0; iMod < maxMod; iMod++)
90 // Loads arrays of DCS variables from map. Variables are
91 // searched by names (for ex. SDD_LAYER3_LADDER5_MODULE4_HV)
93 Int_t moduleLoop = AliITSgeomTGeo::GetModuleIndex( iLay, iLad + 1, iMod + 1 ) - 240;
95 TObjArray* arrHV = (TObjArray*) dcsMap->GetValue( fHVDPNames[moduleLoop].Data() );
98 fprintf( stderr, Form("DCS HV alias %s not found!\n", fHVDPNames[moduleLoop].Data()));
102 TObjArray* arrMV = (TObjArray*) dcsMap->GetValue( fMVDPNames[moduleLoop].Data() );
105 fprintf( stderr, Form("DCS MV alias %s not found!\n", fMVDPNames[moduleLoop].Data()));
109 TObjArray* arrOK = (TObjArray*) dcsMap->GetValue( fOKDPNames[moduleLoop].Data() );
112 fprintf( stderr, Form("DCS MOD_OK alias %s not found!\n", fOKDPNames[moduleLoop].Data()));
116 TObjArray* arrTL = (TObjArray*) dcsMap->GetValue( fTLDPNames[moduleLoop].Data() );
119 fprintf( stderr, Form("DCS TEMP_L alias %s not found!\n", fTLDPNames[moduleLoop].Data()));
123 TObjArray* arrTR = (TObjArray*) dcsMap->GetValue( fTRDPNames[moduleLoop].Data() );
126 fprintf( stderr, Form("DCS TEMP_R alias %s not found!\n", fTRDPNames[moduleLoop].Data()));
130 TObjArray* arrStTL = (TObjArray*) dcsMap->GetValue( fTLStDPNames[moduleLoop].Data() );
133 fprintf( stderr, Form("DCS TEMP_L_STATE alias %s not found!\n", fTLStDPNames[moduleLoop].Data()));
137 TObjArray* arrStTR = (TObjArray*) dcsMap->GetValue( fTRStDPNames[moduleLoop].Data() );
140 fprintf( stderr, Form("DCS TEMP_R_STATE alias %s not found!\n", fTRStDPNames[moduleLoop].Data()));
144 fDCSData[moduleLoop] = new AliITSDCSDataSDD;
145 // DCS data for specific SDD module will be stored in this class
148 // Number of entries in each TObjArray, that contains DCS variable values
149 AliDCSValue *valToProcess;
150 // Pointer to currently processed DCS variable value
152 nEntries = arrTL->GetEntries();
153 fDCSData[moduleLoop]->SetNPointsTempLeft( nEntries );
154 // Left temperature array size is set
156 for( Int_t tlLoop = 0; tlLoop < nEntries; tlLoop++ )
157 { // Left temerature values are copied into the AliITSDCSDataSDD TempLeft array
158 valToProcess = (AliDCSValue *)(arrTL->At(tlLoop));
159 fDCSData[moduleLoop]->SetValueTempLeft( valToProcess->GetTimeStamp() - fTLDelay, valToProcess->GetFloat() );
163 nEntries = arrTR->GetEntries();
164 fDCSData[moduleLoop]->SetNPointsTempRight( nEntries );
165 // Right temperature array size is set
167 for( Int_t trLoop = 0; trLoop < nEntries; trLoop++ )
168 { // Right temerature values are copied into the AliITSDCSDataSDD TempRight array
169 valToProcess = (AliDCSValue *)(arrTR->At(trLoop));
170 fDCSData[moduleLoop]->SetValueTempRight( valToProcess->GetTimeStamp() - fTRDelay, valToProcess->GetFloat() );
174 nEntries = arrHV->GetEntries();
175 fDCSData[moduleLoop]->SetNPointsHV( nEntries );
176 // HV array size is set
178 for( Int_t hvLoop = 0; hvLoop < nEntries; hvLoop++ )
179 { // HV values are copied into the AliITSDCSDataSDD HV array
180 valToProcess = (AliDCSValue *)(arrHV->At(hvLoop));
181 fDCSData[moduleLoop]->SetValueHV( valToProcess->GetTimeStamp() - fHVDelay, valToProcess->GetFloat() );
185 nEntries = arrMV->GetEntries();
186 fDCSData[moduleLoop]->SetNPointsMV( nEntries );
187 // MV array size is set
189 for( Int_t mvLoop = 0; mvLoop < nEntries; mvLoop++ )
190 { // MV values are copied into the AliITSDCSDataSDD MV array
191 valToProcess = (AliDCSValue *)(arrMV->At(mvLoop));
192 fDCSData[moduleLoop]->SetValueMV( valToProcess->GetTimeStamp() - fMVDelay, valToProcess->GetFloat() );
196 /* Following part of the code is responsibile for the condensing of all status information given by DCS
197 into one array of Char_t. Each record of this array is in principle a bit map :
200 1. bit ... _TEMP_L_STATE
201 2. bit ... _TEMP_R_STATE
203 Each record have its own time stamp. Because there are three inputs with independent time stamp,
204 some algorithm which assigns new time stamp to bitmap according to three input time stamps is
207 Let's vizualize time stamps of the three input arrays. There is time on x-axis :
209 +------------+---------------------+------
211 +------+------+---+--------+------------+------
212 | | | | | _TEMP_L_STATE
213 +--+------+---+--+-------+-----+--------+---+------
214 | | | | | | _TEMP_R_STATE
215 +-------------+----------+-----+--------+---+------
217 | | | | | | | | | | |
218 V V V V V V V V V V V
220 +---+----+-+--+---+---+--+-----+--------+---+------
221 | | | | | | | | | | | Status bitmap
222 +---+----+-+--+---+---+--+-----+--------+---+------
225 Principle of combining three status records into one is visible from the picture.
226 If there are two sequent records with the same status bitmap, they are joined into
227 one (with the time stamp of the earliest one).
231 Int_t nStTLEntries = arrStTL->GetEntries();
232 Int_t nStTREntries = arrStTR->GetEntries();
233 Int_t nOKEntries = arrOK->GetEntries();
234 // Gets number of _STAT_L, _STAT_R and _OK values stored in dcsMap
236 if( nStTLEntries < 1 )
237 { // TObjArray arrStTL is empty. This would cause segmentation violation during
238 // the condensing, so this case must be handled before algorithm starts
239 fprintf( stderr, "%s contains no data!\n", fTLStDPNames[moduleLoop].Data() );
241 arrStTL->Add( new AliDCSValue( (Int_t)0, 0x7FFFFFFF ) );
242 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number. Left temperature
243 // sensor will be regarded as switched-off during whole run.
246 if( nStTREntries < 1 )
247 { // TObjArray arrStTR is empty. This would cause segmentation violation during
248 // the condensing, so this case must be handled before algorithm starts
249 fprintf( stderr, "%s contains no data!\n", fTRStDPNames[moduleLoop].Data() );
251 arrStTR->Add( new AliDCSValue( (Int_t)0, 0x7FFFFFFF ) );
252 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number. Right temperature
253 // sensor will be regarded as switched-off during whole run.
257 { // TObjArray arrOK is empty. This would cause segmentation violation during
258 // the condensing, so this case must be handled before algorithm starts
259 fprintf( stderr, "%s contains no data!\n", fOKDPNames[moduleLoop].Data() );
261 arrOK->Add( new AliDCSValue( (Bool_t)0, 0x7FFFFFFF ) );
262 // 0x7FFFFFFF = 2147483647, maximal signed Int_t number.
263 // Module will be regarded as switched-off during whole run.
269 // Condensing would work properly only in the case that
270 // the input arrays are sorted by time
272 Int_t nEntriesMax = nStTLEntries + nStTREntries + nOKEntries;
273 fDCSData[moduleLoop]->SetNPointsStatus( nEntriesMax );
274 // Determines necessary length of new array and sets its size
275 // Lot of space in such defined array will be probably
276 // vacant after the analysis, but this will be corrected
277 // by Compress() method
282 // Input arrays indexes
284 Int_t tsStTL, tsStTR, tsOK;
285 // Time stamps ofinput arrays
286 Int_t tsNew;// New time stamp (output array)
289 // New status record :
291 // 1. bit ... _TEMP_L_STATE
292 // 2. bit ... _TEMP_R_STATE
293 Char_t lastBitStatus = 100;
295 AliDCSValue *valStTL, *valStTR, *valOK;
296 // Pointers to input arrays records (input arrays are TObjArrays
297 // containing objects of type AliDCSValue
299 tsStTR = ( (AliDCSValue *)arrStTR->At(0) )->GetTimeStamp() - fStTLDelay;
300 tsStTL = ( (AliDCSValue *)arrStTL->At(0) )->GetTimeStamp() - fStTRDelay;
301 tsOK = ( (AliDCSValue *)arrOK->At(0) )->GetTimeStamp() - fOKDelay;
302 // Time stamps of first records in input filea are readed (and delays are substracted)
304 tsNew = (tsStTR < tsStTL) ? tsStTR : tsStTL;
305 if( tsNew > tsOK ) tsNew = tsOK;
306 // Time intervals are "prolonged" to the very eaarliest of time stamps.
307 // It means that first output time stamp will be the same as the one
308 // which is first in input arrays. Values of other DCS variables are
309 // not defined in this time yet, but they will be treated as equal to
310 // values in first records of input arrays.
312 nStTLEntries--; nStTREntries--; nOKEntries--;
313 // Indexes in the input array must not exceed last records.
315 while( (idxStTL < nStTLEntries) || (idxStTR < nStTREntries) || (idxOK < nOKEntries) )
316 { // Loop goes throug all three input files
318 valStTL = (AliDCSValue *)( arrStTL->At(idxStTL) );
319 valStTR = (AliDCSValue *)( arrStTR->At(idxStTR) );
320 valOK = (AliDCSValue *)( arrOK->At(idxOK) );
321 // Values are readed from input arrays
324 if( valOK->GetBool() ) bitStatus += 1; // 0. bit - _OK
325 if( valStTL->GetInt() == 1 ) bitStatus += 2; // 1. bit - _TEMP_L_STATE
326 if( valStTR->GetInt() == 1 ) bitStatus += 4; // 2. bit - _TEMP_R_STATE
327 // Bit map is created
329 if( lastBitStatus != bitStatus )
330 { // If the status bitmap is teh same as last one, it would not be stored.
331 // It will save much space.
332 fDCSData[moduleLoop]->SetValueStatus( tsNew, bitStatus );
333 // Bit map is written into the output array (if different from last value )
334 lastBitStatus = bitStatus;
338 if( idxStTL == nStTLEntries )
339 tsStTL = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
341 tsStTL = ( (AliDCSValue *)arrStTL->At(idxStTL + 1) )->GetTimeStamp() - fStTLDelay;
343 if( idxStTR == nStTREntries )
344 tsStTR = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
346 tsStTR = ( (AliDCSValue *)arrStTR->At(idxStTR + 1) )->GetTimeStamp() - fStTRDelay;
348 if( idxOK == nOKEntries )
349 tsOK = 0x7FFFFFFF; // = 2147483647, maximal signed Int_t number
351 tsOK = ( (AliDCSValue *)arrOK->At(idxOK + 1) )->GetTimeStamp() - fOKDelay;
352 // Reads time stamps of folowing records in the input arrays (and substracts delays).
353 // Validity of the last records in the input arrays are prolonged
356 if( tsStTL == tsOK && tsStTR == tsOK ) { tsNew = tsStTL; idxStTL++; idxStTR++; idxOK++; continue; }
357 if( tsStTL == tsStTR && tsStTR < tsOK ) { tsNew = tsStTL; idxStTL++; idxStTR++; continue; }
358 if( tsStTL == tsOK && tsOK < tsStTR ) { tsNew = tsStTL; idxStTL++; idxOK++; continue; }
359 if( tsStTR == tsOK && tsOK < tsStTL ) { tsNew = tsStTR; idxStTR++; idxOK++; continue; }
360 if( tsOK < tsStTL && tsOK < tsStTR ) { tsNew = tsOK; idxOK++; continue; }
361 if( tsStTL < tsOK && tsStTL < tsStTR ) { tsNew = tsStTL; idxStTL++; continue; }
362 /*Last possibile case*/ { tsNew = tsStTR; idxStTR++; }
364 // Index of array, whose following record have time stamp closest to just written one,
365 // is increased. If there are more records with identical time stamps meeting this condition,
366 // all correspondent indexes are increased.
376 } /*AliITSDCSAnalyzerSDD::AnalyzeData*/
379 //---------------------------------------------------------------
382 void AliITSDCSAnalyzerSDD::Init()
384 // Initialization of DCS DP names
389 for( Int_t iLay = 3; iLay < 5; iLay++ )
392 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
393 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
395 for(Int_t iLad=0; iLad<maxLad; iLad++)
397 for(Int_t iMod=0; iMod<maxMod;iMod++)
399 sprintf(modName,"SDD_LAYER%i_LADDER%02d_MODULE%d", iLay, iLad, iMod);
400 Int_t id = AliITSgeomTGeo::GetModuleIndex( iLay, iLad + 1, iMod + 1 ) - 240;
402 sprintf(dpName,"%s_HV",modName);
403 fHVDPNames[id]=dpName;
404 sprintf(dpName,"%s_MV",modName);
405 fMVDPNames[id]=dpName;
406 sprintf(dpName,"%s_OK",modName);
407 fOKDPNames[id]=dpName;
408 sprintf(dpName,"%s_TEMP_L",modName);
409 fTLDPNames[id]=dpName;
410 sprintf(dpName,"%s_TEMP_R",modName);
411 fTRDPNames[id]=dpName;
412 sprintf(dpName,"%s_TEMP_L_STATE",modName);
413 fTLStDPNames[id]=dpName;
414 sprintf(dpName,"%s_TEMP_R_STATE",modName);
415 fTRStDPNames[id]=dpName;
423 } /*AliITSDCSAnalyzerSDD::Init*/
425 //---------------------------------------------------------------
426 void AliITSDCSAnalyzerSDD::PrintDCSDPNames( FILE *output )
429 for( Int_t j = 0; j < kNmodules; j++ )
431 fprintf( output, "Module %d %s %s %s %s\n",j,fHVDPNames[j].Data(),
432 fMVDPNames[j].Data(),fTLDPNames[j].Data(),fTRDPNames[j].Data());
434 } /*AliITSDCSAnalyzerSDD::PrintDCSDPNames*/