fix bugs add new features
[u/mrichter/AliRoot.git] / ITS / CreateSDDDCSMap.C
CommitLineData
e22bf775 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TTimeStamp.h>
3#include <TMap.h>
4#include <TMath.h>
5#include <TFile.h>
6#include <TObjArray.h>
7#include <TObjString.h>
8#include <TRandom.h>
9#include <TSystem.h>
10#include <AliDCSValue.h>
11#endif
12
e22bf775 13//////////////////////////////////////////////////////////////////////////////////////
14// Generator of testing data for AliITSDCSPreprocessorSDD and AliITSAnalyzerrSDD //
15// Origin: F.Prino, Torino, prino@to.infn.it //
16// V.Pospisil, CTU Prague, gdermog@seznam.cz //
17//////////////////////////////////////////////////////////////////////////////////////
18
e22bf775 19TMap* CreateRealisticMap( TTimeStamp startTime, TTimeStamp stopTime );
20TMap* CreateRandomMap( Int_t maxRecords = 1000, Int_t randomTimeStamps = 0 );
21void GenerateOutputFiles( TMap *map, char *dir );
22
dc5eacf8 23Int_t sizeOfMapContent = 0;
e22bf775 24
25void CreateSDDDCSMap( void )
26{
27
28 TTimeStamp startT( 2008, 2, 7, 15, 0, 0 );
29 TTimeStamp stopT( 2008, 2, 7, 18, 0, 0 );
30 // The beginning and the end of the simulated run
31
32// delete gRandom;
33// gRandom = new TRandom2;
34 gRandom->SetSeed(0);
35
36/* Macro can generate random purely random data or simulate DCS. Choose
37 one of the methods - CreateRandomMap() or CreateRealisticMap() */
38
39// TMap *outMap = CreateRandomMap( 1000 );
40 TMap *outMap = CreateRealisticMap( startT, stopT );
41
42 GenerateOutputFiles( outMap, "./maps_3h_SIM" );
43
44 TFile newfile( "DCSAliasMap_3h_SIM.root", "RECREATE" );
45
46 printf( "Writting map into the file ...\n");
47
48 outMap->Write( "DCSAliasMap", TObject::kSingleKey );
49
dc5eacf8 50 printf( "DCSAliasMap created, it size is %i byte ...\n", sizeOfMapContent );
e22bf775 51
52} /*CreateMap*/
53
54
55/***************************************************************/
56/* DCS simulation setup - used in CreateRealisticMap() */
57/* Choose simulation setup by changing following variables */
58/***************************************************************/
59
60// --- Temperature (left side) - behavior of SDD chip -----------
61
62 Float_t mvalTL = 20.0; // Mean value of temperature
63 Float_t fluctTL = 0.5; // Fluctuation (gaussian sigma)
64
65// --- Temperature readout (left side) - behavior of DCS --------
66
dc5eacf8 67 Int_t freqROTL = 300; // Frequency of fixed readout
e22bf775 68 Float_t fluctROTL = 5.0;
69 // Allowed fluctuation (%)
70
71// Temperature readout status (left side) - behavior of SDD chip
72
dc5eacf8 73 Int_t freqROStTL = 300;// Frequency of fixed readout
e22bf775 74 Float_t failureTL = 0.01;
75 // Probability of thermometer
76 // failure (in one hour)
77
78// --- Temperature (right side) - behavior of SDD chip ----------
79
80 Float_t mvalTR = 20.0; // Mean value of temperature
81 Float_t fluctTR = 0.5;// Fluctuation (gaussian sigma)
82
83// --- Temperature readout (right side) - behavior of DCS -------
84
dc5eacf8 85 Int_t freqROTR = 300; // Frequency of fixed readout
e22bf775 86 Float_t fluctROTR = 5.0;
87 // Allowed fluctuation (%)
88
89// Temperature readout status (right side) - behavior of SDD
90
dc5eacf8 91 Int_t freqROStTR = 300;// Frequency of fixed readout
e22bf775 92 Float_t failureTR = 0.01;
93 // Probability of thermometer
94 // failure (in one hour)
95
96// --- High voltage - behavior of SDD voltage source -----------
97
98 Float_t mvalHV = 1791.0;
99 // Mean value of HV
dc5eacf8 100 Float_t fluctHV = 0.03;// Fluctuation (gaussian sigma)
e22bf775 101
102// --- High voltage readout - behavior of DCS -------------------
103
dc5eacf8 104 Int_t freqROHV = 300; // Frequency of fixed readout
e22bf775 105 Float_t fluctROHV = 0.01;
106 // Allowed fluctuation (%)
107
108// --- High voltage readout status - behavior of SDD voltage ----
109
dc5eacf8 110 Int_t freqROOK = 300; // Frequency of fixed readout
e22bf775 111 Float_t failureHV = 0.005;
112 // Probability of HV source
113 // failure (in one hour)
114
115// --- Medium voltage - behavior of SDD voltage source --------
116
117 Float_t mvalMV = 45.0; // Mean value of MV
dc5eacf8 118 Float_t fluctMV = 0.005;
119 // Fluctuation (gaussian sigma)
e22bf775 120
121// --- Medium voltage readout - behavior of DCS -----------------
122
dc5eacf8 123 Int_t freqROMV = 300; // Frequency of fixed readout
e22bf775 124 Float_t fluctROMV = 0.1;
125 // Allowed fluctuation (%)
126
127// --- Medium voltage readout status - behavior of SDD voltage --
128
129 Float_t failureMV = 0.005;
130 // Probability of MV source
131 // failure (in one hour)
132
133/***************************************************************/
134/* ITS geometry setup */
135/***************************************************************/
136
137 Int_t kNladders3=14;
138 Int_t kNladders4=22;
139 Int_t kNmodLad3=6;
140 Int_t kNmodLad4=8;
141
142/***************************************************************/
143
144//----------------------------------------------------------------------------------------
145
146TMap* CreateRealisticMap( TTimeStamp startTime, TTimeStamp stopTime )
147{
148 // Creates a DCS structure
149 // The structure is the following:
150 // TMap (key --> value)
151 // <DCSAlias> --> <valueList>
152 // <DCSAlias> is a string
153 // <valueList> is a TObjArray of AliDCSValue
154 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
155
156 TMap* aliasMap = new TMap;
157 aliasMap->SetOwner(1);
158 // Empty map is created
159
dc5eacf8 160 sizeOfMapContent += sizeof( TMap );
161
e22bf775 162 TString aliasName;
163 Char_t dpName[50];
164 Int_t created = 0;
165 Int_t created1 = 0; // DCS records counter
166
167 Double_t failureTLpersec;
168 Double_t failureTRpersec;
169 Double_t failureHVpersec;
170 Double_t failureMVpersec;
171 // Probabilities of failure per one second
172 Double_t lambda;
173 lambda = ( TMath::Log( 1.0 - failureTL ) ) / -3600.0;
174 failureTLpersec = 1.0 - TMath::Exp(-lambda );
175 lambda = ( TMath::Log( 1.0 - failureTR ) ) / -3600.0;
176 failureTRpersec = 1.0 - TMath::Exp(-lambda );
177 lambda = ( TMath::Log( 1.0 - failureHV ) ) / -3600.0;
178 failureHVpersec = 1.0 - TMath::Exp(-lambda );
179 lambda = ( TMath::Log( 1.0 - failureMV ) ) / -3600.0;
180 failureMVpersec = 1.0 - TMath::Exp(-lambda );
181 // Probabilities of failure per one second are counted
182
183 fluctROTL /= 100.0;
184 fluctROTR /= 100.0;
185 fluctROHV /= 100.0;
186 fluctROMV /= 100.0; // Percents to fractions
187
188 Double_t failureOK = ( failureHV + failureMV ) / 2.0;
189 // This value is used only for noise in timing
190
191 for( Int_t iLay = 3; iLay < 5; iLay++ )
192 {
193
194 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
195 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
196
197 for(Int_t iLad=0; iLad<maxLad; iLad++)
198 {
199 for(Int_t iMod=0; iMod<maxMod; iMod++)
200 {
201
202 fprintf( stderr, "Simulating data taking for layer %i, ladder %i, module %i ... \n", iLay, iLad, iMod );
203
204 TObjArray* valueSetOK = new TObjArray;
205 TObjArray* valueSetHV = new TObjArray;
206 TObjArray* valueSetMV = new TObjArray;
207 TObjArray* valueSetTL = new TObjArray;
208 TObjArray* valueSetTR = new TObjArray;
209 TObjArray* valueSetStTL = new TObjArray;
210 TObjArray* valueSetStTR = new TObjArray;
211
dc5eacf8 212 sizeOfMapContent += 7 * sizeof( TObjArray );
213
e22bf775 214 valueSetOK->SetOwner(1);
215 valueSetHV->SetOwner(1);
216 valueSetMV->SetOwner(1);
217 valueSetTL->SetOwner(1);
218 valueSetTR->SetOwner(1);
219 valueSetStTL->SetOwner(1);
220 valueSetStTR->SetOwner(1);
221
222 Float_t actualTL, actualTR;
223 Float_t actualHV, actualMV;
224 Int_t actualStTL = 1;
225 Int_t actualStTR = 1;
226 Int_t actualStHV = 1;
227 Int_t actualStMV = 1;
228 // Readout devices are alive/dead
229
230 Float_t lastTL = mvalTL;
231 Float_t lastTR = mvalTR;
232 Float_t lastHV = mvalHV;
233 Float_t lastMV = mvalMV;
234 // Last written values - udes for threshold readout
235
236 Int_t counterTL = 0;
237 Int_t counterTR = 0;
238 Int_t counterHV = 0;
239 Int_t counterMV = 0;
240 Int_t counterStTL = 0;
241 Int_t counterStTR = 0;
242 Int_t counterOK = 0;
243 // Periodic readout counters
244
dc5eacf8 245 Int_t endingTimeStamp = /*1197477000;*/ stopTime.GetSec();
e22bf775 246
dc5eacf8 247 for( Int_t timeLoop = /*1197470000 */ startTime.GetSec(); timeLoop < endingTimeStamp; timeLoop ++ )
e22bf775 248 { // Loop goes through period of run second per second and determines
249 // all values according to rules of DCS
250
251 actualTL = gRandom->Gaus( mvalTL, fluctTL );
252 actualTR = gRandom->Gaus( mvalTR, fluctTR );
253 actualHV = gRandom->Gaus( mvalHV, fluctHV );
254 actualMV = gRandom->Gaus( mvalMV, fluctMV );
255 // Generates random values of temperatures and voltages
256 // in given ranges
257
258 if( gRandom->Rndm() < failureTLpersec )
259 if( actualStTL ) actualStTL = 0; else if( gRandom->Rndm() < 0.1 ) actualStTL = 1;
260 if( gRandom->Rndm() < failureTRpersec )
261 if( actualStTR ) actualStTR = 0; else if( gRandom->Rndm() < 0.1 ) actualStTR = 1;
262 if( gRandom->Rndm() < failureHVpersec )
263 if( actualStHV ) actualStHV = 0; else if( gRandom->Rndm() < 0.1 ) actualStHV = 1;
264 if( gRandom->Rndm() < failureMVpersec )
265 if( actualStMV ) actualStMV = 0; else if( gRandom->Rndm() < 0.1 ) actualStMV = 1;
266 // Decides if any thermometer or voltage source becomes
267 // dead (or alive again, but this have much 10x les probability )
268
269 if( gRandom->Rndm() < failureTL ) counterTL++;
270 if( gRandom->Rndm() < failureTL ) counterTL--;
271 if( gRandom->Rndm() < failureTR ) counterTR++;
272 if( gRandom->Rndm() < failureTR ) counterTR--;
273 if( gRandom->Rndm() < failureHV ) counterHV++;
274 if( gRandom->Rndm() < failureHV ) counterHV--;
275 if( gRandom->Rndm() < failureMV ) counterMV++;
276 if( gRandom->Rndm() < failureMV ) counterMV--;
277 if( gRandom->Rndm() < failureTL ) counterStTL++;
278 if( gRandom->Rndm() < failureTL ) counterStTL--;
279 if( gRandom->Rndm() < failureTR ) counterStTR++;
280 if( gRandom->Rndm() < failureTR ) counterStTR--;
281 if( gRandom->Rndm() < failureOK ) counterOK++;
282 if( gRandom->Rndm() < failureOK ) counterOK--;
283 // Simulating noise in the clock frequency
284
285 if( counterTL >= freqROTL )
286 { valueSetTL->Add( new AliDCSValue( actualTL, timeLoop ) ); lastTL = actualTL; counterTL = 0; created++; }
287 if( counterTR >= freqROTR )
288 { valueSetTR->Add( new AliDCSValue( actualTR, timeLoop ) ); lastTR = actualTR; counterTR = 0; created++; }
289 if( counterHV >= freqROHV )
290 { valueSetHV->Add( new AliDCSValue( actualHV, timeLoop ) ); lastHV = actualHV; counterHV = 0; created++; }
291 if( counterMV >= freqROMV )
292 { valueSetMV->Add( new AliDCSValue( actualMV, timeLoop ) ); lastMV = actualMV; counterMV = 0; created++; }
293 if( counterStTL >= freqROStTL )
294 { valueSetStTL->Add( new AliDCSValue( actualStTL, timeLoop ) ); counterStTL = 0; created++; }
295 if( counterStTR >= freqROStTR )
296 { valueSetStTR->Add( new AliDCSValue( actualStTR, timeLoop ) ); counterStTR = 0; created++; }
297 if( counterOK >= freqROOK )
298 { valueSetOK->Add( new AliDCSValue( (Bool_t)(actualStHV & actualStMV), timeLoop ) ); counterOK = 0; created++; }
299 // Periodic readout
300
301 if( TMath::Abs( (lastTL - actualTL) / lastTL ) > fluctROTL )
302 { valueSetTL->Add( new AliDCSValue( actualTL, timeLoop ) ); lastTL = actualTL; counterTL = 0; created1++; }
303 if( TMath::Abs( (lastTR - actualTR) / lastTR ) > fluctROTR )
304 { valueSetTR->Add( new AliDCSValue( actualTR, timeLoop ) ); lastTR = actualTR; counterTR = 0; created1++; }
305 if( TMath::Abs( (lastHV - actualHV) / lastHV ) > fluctROHV )
306 { valueSetHV->Add( new AliDCSValue( actualHV, timeLoop ) ); lastHV = actualHV; counterHV = 0; created1++; }
307 if( TMath::Abs( (lastMV - actualMV) / lastMV ) > fluctROMV )
308 { valueSetMV->Add( new AliDCSValue( actualMV, timeLoop ) ); lastMV = actualMV; counterMV = 0; created1++; }
309 // Treshold readout
310
311 counterTL++;
312 counterTR++;
313 counterHV++;
314 counterMV++;
315 counterStTL++;
316 counterStTR++;
317 counterOK++;
318
319 } /*for( timeLoop )*/
320
321 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_OK", iLay, iLad, iMod );
322 aliasName = dpName;
323 aliasMap->Add( new TObjString(aliasName), valueSetOK );
324
325 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_HV", iLay, iLad, iMod );
326 aliasName = dpName;
327 aliasMap->Add( new TObjString(aliasName), valueSetHV );
328
329 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_MV", iLay, iLad, iMod );
330 aliasName = dpName;
331 aliasMap->Add( new TObjString(aliasName), valueSetMV );
332
333 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L", iLay, iLad, iMod );
334 aliasName = dpName;
335 aliasMap->Add( new TObjString(aliasName), valueSetTL );
336
337 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R", iLay, iLad, iMod );
338 aliasName = dpName;
339 aliasMap->Add( new TObjString(aliasName), valueSetTR );
340
341 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L_STATE", iLay, iLad, iMod );
342 aliasName = dpName;
343 aliasMap->Add( new TObjString(aliasName), valueSetStTL );
344
345 sprintf( dpName, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R_STATE", iLay, iLad, iMod );
346 aliasName = dpName;
347 aliasMap->Add( new TObjString(aliasName), valueSetStTR );
348
349 } /*for( iMod ) */
350 } /*for( iLad )*/
351 } /*for( iLay )*/
352
353 fprintf( stderr, "\nCreated %i objects of type AliDCSValue (%i periodic + %i treshold)... \n",
354 created + created1, created, created1 );
355
dc5eacf8 356 sizeOfMapContent += (created + created1 ) * ( sizeof( AliDCSValue ) + sizeof( AliDCSValue * ) );
357
e22bf775 358 return aliasMap;
359
360} /*CreateRealisticMap*/
361
362//----------------------------------------------------------------------------------------
363
364
365TMap* CreateRandomMap( Int_t maxRecords , Int_t randomTimeStamps )
366{
367 // Creates a DCS structure
368 // The structure is the following:
369 // TMap (key --> value)
370 // <DCSAlias> --> <valueList>
371 // <DCSAlias> is a string
372 // <valueList> is a TObjArray of AliDCSValue
373 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
374
375
376 TMap* aliasMap = new TMap;
377 aliasMap->SetOwner(1);
378
dc5eacf8 379 sizeOfMapContent += sizeof( TMap );
e22bf775 380
381 TString aliasName;
382 Char_t dpName[50];
383 Int_t created = 0;
384
385 for( Int_t iLay = 3; iLay < 5; iLay++ )
386 {
387
388 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
389 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
390
391 for(Int_t iLad = 0; iLad < maxLad; iLad++)
392 {
393 for(Int_t iMod =0 ; iMod < maxMod;iMod++)
394 {
395
396 fprintf( stderr, "Generating data for layer %i, ladder %i, module %i ... \n", iLay, iLad, iMod );
397
398 TObjArray* valueSetOK = new TObjArray;
399 TObjArray* valueSetH = new TObjArray;
400 TObjArray* valueSetM = new TObjArray;
401 TObjArray* valueSetTL = new TObjArray;
402 TObjArray* valueSetTR = new TObjArray;
403 TObjArray* valueSetStTL = new TObjArray;
404 TObjArray* valueSetStTR = new TObjArray;
405
dc5eacf8 406 sizeOfMapContent += 7 * sizeof( TObjArray );
407
e22bf775 408 valueSetOK->SetOwner(1);
409 valueSetH->SetOwner(1);
410 valueSetM->SetOwner(1);
411 valueSetTL->SetOwner(1);
412 valueSetTR->SetOwner(1);
413 valueSetStTL->SetOwner(1);
414 valueSetStTR->SetOwner(1);
415
416 Int_t nrOfRecords;
417 AliDCSValue* dcsVal;
418 Int_t timeStamp;
419
420 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_OK", iLay,iLad,iMod);
421 aliasName=dpName;
dc5eacf8 422 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ) );
e22bf775 423 timeStamp = 1000000000;
dc5eacf8 424 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
e22bf775 425 {
426 if( randomTimeStamps )
427 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
428 else
429 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
dc5eacf8 430 if( 1000*(gRandom->Rndm()) > 50 )
431 dcsVal = new AliDCSValue((Bool_t)1, timeStamp);
432 else
433 dcsVal = new AliDCSValue((Bool_t)0, timeStamp);
434 valueSetOK->Add(dcsVal);
e22bf775 435 } /*for( recLoop )*/
436 aliasMap->Add(new TObjString(aliasName), valueSetOK);
437 created += nrOfRecords;
438
439 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_HV", iLay, iLad,iMod);
440 aliasName=dpName;
441 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
442 timeStamp = 1000000000;
443 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
444 {
445 if( randomTimeStamps )
446 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
447 else
dc5eacf8 448 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 449 dcsVal = new AliDCSValue( (Float_t)( 1600 + 200*(gRandom->Rndm()) ), timeStamp );
450 valueSetH->Add(dcsVal);
e22bf775 451 } /*for( recLoop )*/
452 aliasMap->Add(new TObjString(aliasName), valueSetH);
453 created += nrOfRecords;
454
455 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_MV", iLay, iLad,iMod);
456 aliasName=dpName;
dc5eacf8 457 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
e22bf775 458 timeStamp = 1000000000;
459 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
460 {
461 if( randomTimeStamps )
462 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
463 else
dc5eacf8 464 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 465 dcsVal = new AliDCSValue( (Float_t)( 30 + 20*(gRandom->Rndm()) ), timeStamp );
466 valueSetM->Add(dcsVal);
467 } /*for( recLoop )*/
468 aliasMap->Add(new TObjString(aliasName), valueSetM);
469 created += nrOfRecords;
470
471 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L", iLay, iLad,iMod);
472 aliasName=dpName;
dc5eacf8 473 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
e22bf775 474 timeStamp = 1000000000;
475 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
476 {
477 if( randomTimeStamps )
478 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
dc5eacf8 479 else
480 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 481 dcsVal = new AliDCSValue( (Float_t)( 50 + 50*(gRandom->Rndm()) ), timeStamp );
482 valueSetTL->Add(dcsVal);
483 } /*for( recLoop )*/
484 aliasMap->Add(new TObjString(aliasName), valueSetTL);
485 created += nrOfRecords;
486
487 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R", iLay, iLad,iMod);
488 aliasName=dpName;
dc5eacf8 489 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
490 timeStamp = 1000000000;
e22bf775 491 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
492 {
493 if( randomTimeStamps )
494 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
495 else
dc5eacf8 496 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 497 dcsVal = new AliDCSValue( (Float_t)( 50 + 50*(gRandom->Rndm()) ), timeStamp );
498 valueSetTR->Add(dcsVal);
499 } /*for( recLoop )*/
500 aliasMap->Add(new TObjString(aliasName), valueSetTR);
501 created += nrOfRecords;
502
503 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L_STATE", iLay, iLad,iMod);
504 aliasName=dpName;
dc5eacf8 505 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
e22bf775 506 timeStamp = 1000000000;
507 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
508 {
509 if( randomTimeStamps )
dc5eacf8 510 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
e22bf775 511 else
dc5eacf8 512 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 513 if( 1000*(gRandom->Rndm()) > 50 )
514 dcsVal = new AliDCSValue((Int_t)1, timeStamp);
515 else
516 dcsVal = new AliDCSValue((Int_t)0, timeStamp);
517 valueSetStTL->Add(dcsVal);
518 } /*for( recLoop )*/
519 aliasMap->Add(new TObjString(aliasName), valueSetStTL);
520 created += nrOfRecords;
521
522 sprintf(dpName,"SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R_STATE", iLay, iLad,iMod);
523 aliasName=dpName;
dc5eacf8 524 nrOfRecords = (Int_t)(maxRecords * ( gRandom->Rndm() ));
e22bf775 525 timeStamp = 1000000000;
526 for( Int_t recLoop = 0; recLoop < nrOfRecords; recLoop ++ )
527 {
528 if( randomTimeStamps )
529 timeStamp = (Int_t)(1200000000*(gRandom->Rndm()));
530 else
dc5eacf8 531 timeStamp += (Int_t)(50*(gRandom->Rndm()) );
e22bf775 532 if( 1000*(gRandom->Rndm()) > 50 )
533 dcsVal = new AliDCSValue((Int_t)1, timeStamp);
534 else
535 dcsVal = new AliDCSValue((Int_t)0, timeStamp);
536 valueSetStTR->Add(dcsVal);
537
538 } /*for( recLoop )*/
539 aliasMap->Add(new TObjString(aliasName), valueSetStTR);
540 created += nrOfRecords;
541
542 } /*for( iMod ) */
543 } /*for( iLad )*/
544
545 } /*for( iLay )*/
546
547 fprintf( stderr, "\nCreated %i objects of type AliDCSValue ... \n", created);
548
dc5eacf8 549 sizeOfMapContent += created * ( sizeof( AliDCSValue ) + sizeof( AliDCSValue * ) );
550
e22bf775 551 return aliasMap;
552}
553
554// -----------------------------------------------------------------------------
555
556void GenerateOutputFiles( TMap *map, char *dir )
557{
558
559 FILE *outputFile;
560 char buffer[100],cmd[100];
561 Int_t nHVEntries, nMVEntries, nTLEntries, nTREntries;
562 Int_t nOKEntries, nStTLEntries, nStTREntries;
dc5eacf8 563
e22bf775 564 sprintf(cmd,"ls -l %s >/dev/null 2>&1",dir);
565 if(gSystem->Exec(cmd)!=0){
566 printf("%s --- NOT EXISTS -- create it\n",dir);
567 sprintf(cmd,"mkdir %s",dir);
568 gSystem->Exec(cmd);
569 }
570
571 for( Int_t iLay = 3; iLay < 5; iLay++ )
572 {
573
574 Int_t maxLad = ( iLay == 3) ? kNladders3 : kNladders4;
575 Int_t maxMod = ( iLay == 3) ? kNmodLad3 : kNmodLad4;
576
577 for(Int_t iLad = 0; iLad < maxLad; iLad++)
578 {
579
580
581 for(Int_t iMod = 0; iMod < maxMod; iMod++)
582 {
583
584 sprintf( buffer, "%s/DCSMapContent_SDD_LAYER%i_LADDER%02d_MODULE%d.txt", dir, iLay, iLad, iMod );
585
586 fprintf( stderr, "Creating file %s ... ", buffer );
587 outputFile = fopen( buffer, "w" );
588 if( outputFile == NULL )
589 {
590 fprintf( stderr, "failed!\n" );
591 return;
592 } /*if*/
593 else
594 fprintf( stderr, "\n" );
595
596
597 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_HV", iLay, iLad, iMod );
598 TObjArray* arrHV = (TObjArray*) map->GetValue( buffer );
599 if( arrHV == NULL )
600 {
601 fprintf( stderr, "Map record %s does not exist!\n", buffer );
602 nHVEntries = 0;
603 }
604 else
605 nHVEntries = arrHV->GetEntries();
606
607 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_MV", iLay, iLad, iMod );
608 TObjArray* arrMV = (TObjArray*) map->GetValue( buffer );
609 if( arrMV == NULL )
610 {
611 fprintf( stderr, "Map record %s does not exist!\n", buffer );
612 nMVEntries = 0;
613 }
614 else
615 nMVEntries = arrMV->GetEntries();
616
617 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L", iLay, iLad, iMod );
618 TObjArray* arrTL = (TObjArray*) map->GetValue( buffer );
619 if( arrTL == NULL )
620 {
621 fprintf( stderr, "Map record %s does not exist!\n", buffer );
622 nTLEntries = 0;
623 }
624 else
625 nTLEntries = arrTL->GetEntries();
626
627 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R", iLay, iLad, iMod );
628 TObjArray* arrTR = (TObjArray*) map->GetValue( buffer );
629 if( arrTR == NULL )
630 {
631 fprintf( stderr, "Map record %s does not exist!\n", buffer );
632 nTREntries = 0;
633 }
634 else
635 nTREntries = arrTR->GetEntries();
636
637 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_L_STATE", iLay, iLad, iMod );
638 TObjArray* arrStTL = (TObjArray*) map->GetValue( buffer );
639 if( arrStTL == NULL )
640 {
641 fprintf( stderr, "Map record %s does not exist!\n", buffer );
642 nStTLEntries = 0;
643 }
644 else
645 nStTLEntries = arrStTL->GetEntries();
646
647 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_TEMP_R_STATE", iLay, iLad, iMod );
648 TObjArray* arrStTR = (TObjArray*) map->GetValue( buffer );
649 if( arrStTR == NULL )
650 {
651 fprintf( stderr, "Map record %s does not exist!\n", buffer );
652 nStTREntries = 0;
653 }
654 else
655 nStTREntries = arrStTR->GetEntries();
656
657 sprintf( buffer, "SDD_LAYER%i_LADDER%02d_MODULE%d_OK", iLay, iLad, iMod );
658 TObjArray* arrOK = (TObjArray*) map->GetValue( buffer );
659 if( arrOK == NULL )
660 {
661 fprintf( stderr, "Map record %s does not exist!\n", buffer );
662 nOKEntries = 0;
663 }
664 else
665 nOKEntries = arrOK->GetEntries();
666
667 fprintf( outputFile, "+-----------------------------------------------------------------------");
668 fprintf( outputFile, "------------------------------------------------------------------------+\n" );
669 fprintf( outputFile, "| DCS Map content for SDD_LAYER%i_LADDER%02d_MODULE%d" , iLay, iLad, iMod);
670 fprintf( outputFile, " |\n" );
671 fprintf( outputFile, "+----------------------+----------------------+---------------------+----------------------+");
672 fprintf( outputFile, "-----------------+-----------------+----------------+\n" );
673 fprintf( outputFile, "| %05i records | %05i records | %05i records | %05i records | %05i records |",
674 nHVEntries, nMVEntries, nTLEntries, nTREntries, nStTLEntries );
675 fprintf( outputFile, " %05i records | %05i records |\n", nStTREntries, nOKEntries );
676
dc5eacf8 677 fprintf( outputFile, "| time (s) HV | time (s) MV | time (s) TL | time (s) TR | time (s) StTL |" );
e22bf775 678 fprintf( outputFile, " time (s) StTR | time (s) OK |\n" );
679 fprintf( outputFile, "+----------------------+----------------------+---------------------+---------------------+");
680 fprintf( outputFile, "-----------------+-----------------+-----------------+\n" );
681
682
683
684 Int_t a = (nHVEntries > nMVEntries ) ? nHVEntries : nMVEntries;
685 Int_t b = (nTLEntries > nTREntries ) ? nTLEntries : nTREntries;
686 Int_t c = (nStTLEntries > nStTREntries ) ? nStTLEntries : nStTREntries;
687 if( a < b ) a = b; if( c < nOKEntries ) c = nOKEntries;
688 Int_t loopMax = ( a > c ) ? a : c ;
689 // Finds maximal entry number
690
691
692
693 for( Int_t entryLoop = 0; entryLoop < loopMax; entryLoop++ )
694 {
695
696 if( entryLoop < nHVEntries )
697 fprintf( outputFile, "| %12i %4.2f | ", ((AliDCSValue*)arrHV->At(entryLoop))->GetTimeStamp(),
698 ((AliDCSValue*)arrHV->At(entryLoop))->GetFloat() );
699 else
700 fprintf( outputFile, "| | ");
701
702 if( entryLoop < nMVEntries )
dc5eacf8 703 fprintf( outputFile, " %12i %2.3f | ", ((AliDCSValue*)arrMV->At(entryLoop))->GetTimeStamp(),
e22bf775 704 ((AliDCSValue*)arrMV->At(entryLoop))->GetFloat() );
705 else
dc5eacf8 706 fprintf( outputFile, " | ");
e22bf775 707
708 if( entryLoop < nTLEntries )
709 fprintf( outputFile, "%12i %2.2f | ", ((AliDCSValue*)arrTL->At(entryLoop))->GetTimeStamp(),
710 ((AliDCSValue*)arrTL->At(entryLoop))->GetFloat() );
711 else
712 fprintf( outputFile, " | ");
713
714 if( entryLoop < nTREntries )
715 fprintf( outputFile, "%12i %2.2f | ", ((AliDCSValue*)arrTR->At(entryLoop))->GetTimeStamp(),
716 ((AliDCSValue*)arrTR->At(entryLoop))->GetFloat() );
717 else
718 fprintf( outputFile, " | ");
719
720 if( entryLoop < nStTLEntries )
721 fprintf( outputFile, "%12i %i | ", ((AliDCSValue*)arrStTL->At(entryLoop))->GetTimeStamp(),
722 ((AliDCSValue*)arrStTL->At(entryLoop))->GetInt() );
723 else
724 fprintf( outputFile, " | ");
725
726 if( entryLoop < nStTREntries )
727 fprintf( outputFile, "%12i %i | ", ((AliDCSValue*)arrStTR->At(entryLoop))->GetTimeStamp(),
728 ((AliDCSValue*)arrStTR->At(entryLoop))->GetInt() );
729 else
730 fprintf( outputFile, " | ");
731
732 if( entryLoop < nOKEntries )
733 fprintf( outputFile, "%12i %i |\n", ((AliDCSValue*)arrOK->At(entryLoop))->GetTimeStamp(),
734 ((AliDCSValue*)arrOK->At(entryLoop))->GetBool() );
735 else
736 fprintf( outputFile, " |\n");
737
738 } /*for( entryLoop )*/
739
740 fclose( outputFile );
741
742
743 } /*for(iMod)*/
744
745
746 } /*for(iLad)*/
747 } /*for(iLay)*/
748
749
750} /*GenerateOutputFiles*/