]>
Commit | Line | Data |
---|---|---|
1fbffa23 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | // Class AliAttrib | |
20 | // Generic handling of detector signal (calibration) attributes. | |
21 | // Normally this class is only used as a base class to provide the various | |
22 | // attributes to the derived class. An example of this is AliSignal. | |
23 | // However, one can of course also use this class on its own as shown | |
24 | // in the simple example hereafter. | |
25 | // | |
26 | // Example : | |
27 | // --------- | |
28 | // AliAttrib a; | |
29 | // a.SetGain(250.7); | |
30 | // a.SetSlotName("PMT amplitude in Volt"); | |
31 | // a.SetGain(1340,3); | |
32 | // a.SetSlotName("PMT amplitude in ADC",3); | |
33 | // a.SetEdgeOn(3); | |
34 | // a.SetOffset(-22.5,2); | |
35 | // a.SetSlotName("Time of flight in ns",2); | |
36 | // a.SetDead(1); | |
387a745b | 37 | // a.List(); |
1fbffa23 | 38 | // |
39 | //--- Author: Nick van Eijndhoven 18-sep-2003 Utrecht University | |
40 | //- Modified: NvE $Date$ Utrecht University | |
41 | /////////////////////////////////////////////////////////////////////////// | |
42 | ||
43 | #include "AliAttrib.h" | |
44 | #include "Riostream.h" | |
45 | ||
46 | ClassImp(AliAttrib) // Class implementation to enable ROOT I/O | |
47 | ||
48 | AliAttrib::AliAttrib() | |
49 | { | |
50 | // Creation of an AliAttrib object and initialisation of parameters. | |
51 | // Several values of the same type (e.g. gain) can be stored in different slots. | |
52 | // If needed, the storage for values will be expanded automatically | |
53 | // when entering values. | |
54 | fGains=0; | |
55 | fOffsets=0; | |
56 | fCalflags=0; | |
57 | fNames=0; | |
58 | } | |
59 | /////////////////////////////////////////////////////////////////////////// | |
60 | AliAttrib::~AliAttrib() | |
61 | { | |
62 | // Destructor to delete dynamically allocated memory | |
63 | if (fGains) | |
64 | { | |
65 | delete fGains; | |
66 | fGains=0; | |
67 | } | |
68 | if (fOffsets) | |
69 | { | |
70 | delete fOffsets; | |
71 | fOffsets=0; | |
72 | } | |
73 | if (fCalflags) | |
74 | { | |
75 | delete fCalflags; | |
76 | fCalflags=0; | |
77 | } | |
78 | if (fNames) | |
79 | { | |
80 | delete fNames; | |
81 | fNames=0; | |
82 | } | |
83 | } | |
84 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 85 | AliAttrib::AliAttrib(const AliAttrib& a) |
1fbffa23 | 86 | { |
87 | // Copy constructor | |
88 | fGains=0; | |
89 | fOffsets=0; | |
90 | fCalflags=0; | |
91 | fNames=0; | |
92 | ||
93 | Int_t n=0; | |
94 | Double_t val=0; | |
95 | ||
96 | n=a.GetNgains(); | |
97 | for (Int_t ig=1; ig<=n; ig++) | |
98 | { | |
99 | val=a.GetGain(ig); | |
100 | if (a.GetGainFlag(ig)) SetGain(val,ig); | |
101 | } | |
102 | ||
103 | n=a.GetNoffsets(); | |
104 | for (Int_t io=1; io<=n; io++) | |
105 | { | |
106 | val=a.GetOffset(io); | |
107 | if (a.GetOffsetFlag(io)) SetOffset(val,io); | |
108 | } | |
109 | ||
110 | n=a.GetNcalflags(); | |
111 | for (Int_t ic=1; ic<=n; ic++) | |
112 | { | |
113 | SetEdgeValue(a.GetEdgeValue(ic),ic); | |
114 | if (a.GetDeadValue(ic)) SetDead(ic); | |
115 | } | |
116 | ||
117 | n=a.GetNnames(); | |
118 | TString s; | |
119 | for (Int_t in=1; in<=n; in++) | |
120 | { | |
121 | s=a.GetSlotName(in); | |
122 | if (s!="") SetSlotName(s,in); | |
123 | } | |
124 | } | |
125 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 126 | Int_t AliAttrib::GetNgains() const |
1fbffa23 | 127 | { |
128 | // Provide the number of specified gains for this attribute. | |
129 | Int_t n=0; | |
130 | if (fGains) n=fGains->GetSize(); | |
131 | return n; | |
132 | } | |
133 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 134 | Int_t AliAttrib::GetNoffsets() const |
1fbffa23 | 135 | { |
136 | // Provide the number of specified offsets for this attribute. | |
137 | Int_t n=0; | |
138 | if (fOffsets) n=fOffsets->GetSize(); | |
139 | return n; | |
140 | } | |
141 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 142 | Int_t AliAttrib::GetNcalflags() const |
1fbffa23 | 143 | { |
144 | // Provide the number of specified calib. flags for this attribute. | |
145 | Int_t n=0; | |
146 | if (fCalflags) n=fCalflags->GetSize(); | |
147 | return n; | |
148 | } | |
149 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 150 | Int_t AliAttrib::GetNnames() const |
1fbffa23 | 151 | { |
152 | // Provide the maximum number of specified names for this attribute. | |
153 | Int_t n=0; | |
154 | if (fNames) n=fNames->GetSize(); | |
155 | return n; | |
156 | } | |
157 | /////////////////////////////////////////////////////////////////////////// | |
158 | void AliAttrib::SetGain(Double_t gain,Int_t j) | |
159 | { | |
160 | // Store gain value of the j-th (default j=1) attribute slot. | |
161 | // Note : The first attribute slot is at j=1. | |
162 | // In case the value of the index j exceeds the maximum number of reserved | |
163 | // slots for gain values, the number of reserved slots for the gain | |
164 | // values is increased automatically. | |
165 | ||
166 | if (j<1) | |
167 | { | |
168 | cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl; | |
169 | return; | |
170 | } | |
171 | ||
172 | if (!fGains) | |
173 | { | |
174 | fGains=new TArrayF(j); | |
175 | } | |
176 | ||
177 | Int_t size=fGains->GetSize(); | |
178 | ||
179 | if (j>size) | |
180 | { | |
181 | fGains->Set(j); | |
182 | } | |
183 | ||
184 | fGains->AddAt(float(gain),j-1); | |
185 | ||
186 | Int_t oflag=GetOffsetFlag(j); | |
187 | ||
188 | SetCalFlags(1,oflag,j); | |
189 | } | |
190 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 191 | void AliAttrib::SetGain(Double_t gain,TString name) |
192 | { | |
193 | // Store gain value of the name-specified attribute slot. | |
194 | // | |
195 | // This procedure involves a slot-index search based on the specified name | |
196 | // at each invokation. This may become slow in case many slots have been | |
197 | // defined and/or when this procedure is invoked many times. | |
198 | // In such cases it is preferable to use indexed addressing in the user code | |
199 | // either directly or via a few invokations of GetSlotIndex(). | |
200 | ||
201 | Int_t j=GetSlotIndex(name); | |
202 | if (j>0) SetGain(gain,j); | |
203 | } | |
204 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 205 | void AliAttrib::SetOffset(Double_t off,Int_t j) |
206 | { | |
207 | // Store offset value of the j-th (default j=1) attribute slot. | |
208 | // Note : The first attribute slot is at j=1. | |
209 | // In case the value of the index j exceeds the maximum number of reserved | |
210 | // slots for offset values, the number of reserved slots for the offset | |
211 | // values is increased automatically. | |
212 | ||
213 | if (j<1) | |
214 | { | |
215 | cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl; | |
216 | return; | |
217 | } | |
218 | ||
219 | if (!fOffsets) | |
220 | { | |
221 | fOffsets=new TArrayF(j); | |
222 | } | |
223 | ||
224 | Int_t size=fOffsets->GetSize(); | |
225 | ||
226 | if (j>size) | |
227 | { | |
228 | fOffsets->Set(j); | |
229 | } | |
230 | ||
231 | fOffsets->AddAt(float(off),j-1); | |
232 | ||
233 | Int_t gflag=GetGainFlag(j); | |
234 | ||
235 | SetCalFlags(gflag,1,j); | |
236 | } | |
237 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 238 | void AliAttrib::SetOffset(Double_t off,TString name) |
239 | { | |
240 | // Store offset value of the name-specified attribute slot. | |
241 | // | |
242 | // This procedure involves a slot-index search based on the specified name | |
243 | // at each invokation. This may become slow in case many slots have been | |
244 | // defined and/or when this procedure is invoked many times. | |
245 | // In such cases it is preferable to use indexed addressing in the user code | |
246 | // either directly or via a few invokations of GetSlotIndex(). | |
247 | ||
248 | Int_t j=GetSlotIndex(name); | |
249 | if (j>0) SetOffset(off,j); | |
250 | } | |
251 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 252 | void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j) |
253 | { | |
254 | // Store calibration flags of the j-th (default j=1) attribute slot. | |
255 | // Note : The first attribute slot is at j=1. | |
256 | // In case the value of the index j exceeds the maximum number of reserved | |
257 | // slots for the calib. flags, the number of reserved slots for the calib. | |
258 | // flags is increased automatically. | |
259 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
260 | ||
261 | if (j<1) | |
262 | { | |
263 | cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl; | |
264 | return; | |
265 | } | |
266 | ||
267 | if (!fCalflags) | |
268 | { | |
269 | fCalflags=new TArrayI(j); | |
270 | } | |
271 | ||
272 | Int_t size=fCalflags->GetSize(); | |
273 | ||
274 | if (j>size) | |
275 | { | |
276 | fCalflags->Set(j); | |
277 | } | |
278 | ||
279 | Int_t edge=GetEdgeValue(j); | |
280 | Int_t dead=GetDeadValue(j); | |
281 | ||
282 | Int_t word=1000*edge+100*dead+10*gainflag+offsetflag; | |
283 | ||
284 | fCalflags->AddAt(word,j-1); | |
285 | } | |
286 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 287 | Int_t AliAttrib::GetGainFlag(Int_t j) const |
1fbffa23 | 288 | { |
289 | // Provide gain flag of the j-th (default j=1) attribute slot. | |
290 | // | |
291 | // flag = 1 : Gain was set | |
292 | // 0 : Gain was not set | |
293 | // | |
294 | // Note : The first attribute slot is at j=1. | |
295 | // In case j is invalid, 0 is returned. | |
296 | ||
297 | if (j<1) | |
298 | { | |
299 | cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl; | |
300 | return 0; | |
301 | } | |
302 | Int_t gflag=0; | |
303 | if (fCalflags) | |
304 | { | |
305 | if (j>0 && j<=(fCalflags->GetSize())) | |
306 | { | |
307 | Int_t word=fCalflags->At(j-1); | |
308 | word=word%100; | |
309 | gflag=word/10; | |
310 | } | |
311 | } | |
312 | return gflag; | |
313 | } | |
314 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 315 | Int_t AliAttrib::GetGainFlag(TString name) const |
316 | { | |
317 | // Provide gain flag of the name-specified attribute slot. | |
318 | // | |
319 | // flag = 1 : Gain was set | |
320 | // 0 : Gain was not set | |
321 | // | |
322 | // | |
323 | // This procedure involves a slot-index search based on the specified name | |
324 | // at each invokation. This may become slow in case many slots have been | |
325 | // defined and/or when this procedure is invoked many times. | |
326 | // In such cases it is preferable to use indexed addressing in the user code | |
327 | // either directly or via a few invokations of GetSlotIndex(). | |
328 | ||
329 | Int_t j=GetSlotIndex(name); | |
330 | Int_t flag=0; | |
331 | if (j>0) flag=GetGainFlag(j); | |
332 | return flag; | |
333 | } | |
334 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 335 | Int_t AliAttrib::GetOffsetFlag(Int_t j) const |
1fbffa23 | 336 | { |
337 | // Provide offset flag of the j-th (default j=1) attribute slot. | |
338 | // | |
339 | // flag = 1 : Offset was set | |
340 | // 0 : Offset was not set | |
341 | // | |
342 | // Note : The first attribute slot is at j=1. | |
343 | // In case j is invalid, 0 is returned. | |
344 | ||
345 | if (j<1) | |
346 | { | |
347 | cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl; | |
348 | return 0; | |
349 | } | |
350 | ||
351 | Int_t oflag=0; | |
352 | if (fCalflags) | |
353 | { | |
354 | if (j>0 && j<=(fCalflags->GetSize())) | |
355 | { | |
356 | Int_t word=fCalflags->At(j-1); | |
357 | oflag=word%10; | |
358 | } | |
359 | } | |
360 | return oflag; | |
361 | } | |
362 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 363 | Int_t AliAttrib::GetOffsetFlag(TString name) const |
364 | { | |
365 | // Provide ofset flag of the name-specified attribute slot. | |
366 | // | |
367 | // flag = 1 : Offset was set | |
368 | // 0 : Offset was not set | |
369 | // | |
370 | // | |
371 | // This procedure involves a slot-index search based on the specified name | |
372 | // at each invokation. This may become slow in case many slots have been | |
373 | // defined and/or when this procedure is invoked many times. | |
374 | // In such cases it is preferable to use indexed addressing in the user code | |
375 | // either directly or via a few invokations of GetSlotIndex(). | |
376 | ||
377 | Int_t j=GetSlotIndex(name); | |
378 | Int_t flag=0; | |
379 | if (j>0) flag=GetOffsetFlag(j); | |
380 | return flag; | |
381 | } | |
382 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 383 | Float_t AliAttrib::GetGain(Int_t j) const |
1fbffa23 | 384 | { |
385 | // Provide gain value of the j-th (default j=1) attribute slot. | |
386 | // The first attribute slot is at j=1. | |
387 | // In case no gain value was set or the argument j is invalid, 0 is returned. | |
388 | // Note : Use GetGainFlag(j) to check whether this gain was set or not. | |
389 | ||
390 | if (j<1) | |
391 | { | |
392 | cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl; | |
393 | return 0; | |
394 | } | |
395 | ||
396 | Float_t gain=0; | |
397 | if (fGains) | |
398 | { | |
399 | if (j>0 && j<=(fGains->GetSize())) | |
400 | { | |
401 | if (GetGainFlag(j)) gain=fGains->At(j-1); | |
402 | } | |
403 | } | |
404 | return gain; | |
405 | } | |
406 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 407 | Float_t AliAttrib::GetGain(TString name) const |
408 | { | |
409 | // Provide gain value of the name-specified attribute slot. | |
410 | // | |
411 | // This procedure involves a slot-index search based on the specified name | |
412 | // at each invokation. This may become slow in case many slots have been | |
413 | // defined and/or when this procedure is invoked many times. | |
414 | // In such cases it is preferable to use indexed addressing in the user code | |
415 | // either directly or via a few invokations of GetSlotIndex(). | |
416 | ||
417 | Int_t j=GetSlotIndex(name); | |
418 | Float_t gain=0; | |
419 | if (j>0) gain=GetGain(j); | |
420 | return gain; | |
421 | } | |
422 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 423 | Float_t AliAttrib::GetOffset(Int_t j) const |
1fbffa23 | 424 | { |
425 | // Provide offset value of the j-th (default j=1) attribute slot. | |
426 | // The first attribute slot at j=1. | |
427 | // In case no offset value was set or the argument j is invalid, 0 is returned. | |
428 | // Note : Use GetOffsetFlag(j) to check whether this offset was set or not. | |
429 | ||
430 | if (j<1) | |
431 | { | |
432 | cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl; | |
433 | return 0; | |
434 | } | |
435 | ||
436 | Float_t offset=0; | |
437 | if (fOffsets) | |
438 | { | |
439 | if (j>0 && j<=(fOffsets->GetSize())) | |
440 | { | |
441 | if (GetOffsetFlag(j)) offset=fOffsets->At(j-1); | |
442 | } | |
443 | } | |
444 | return offset; | |
445 | } | |
446 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 447 | Float_t AliAttrib::GetOffset(TString name) const |
448 | { | |
449 | // Provide offset value of the name-specified attribute slot. | |
450 | // | |
451 | // This procedure involves a slot-index search based on the specified name | |
452 | // at each invokation. This may become slow in case many slots have been | |
453 | // defined and/or when this procedure is invoked many times. | |
454 | // In such cases it is preferable to use indexed addressing in the user code | |
455 | // either directly or via a few invokations of GetSlotIndex(). | |
456 | ||
457 | Int_t j=GetSlotIndex(name); | |
458 | Float_t offset=0; | |
459 | if (j>0) offset=GetOffset(j); | |
460 | return offset; | |
461 | } | |
462 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 463 | void AliAttrib::ResetGain(Int_t j) |
464 | { | |
465 | // Reset the gain value of the j-th (default j=1) attribute slot. | |
466 | // Notes : The first attribute slot is at j=1. | |
467 | // j=0 ==> All gain values will be reset. | |
468 | ||
469 | if (!fGains) return; | |
470 | ||
471 | Int_t size=fGains->GetSize(); | |
472 | ||
473 | if ((j>=0) && (j<=size)) | |
474 | { | |
475 | if (j) | |
476 | { | |
477 | fGains->AddAt(0,j-1); | |
478 | Int_t oflag=GetOffsetFlag(j); | |
479 | SetCalFlags(0,oflag,j); | |
480 | } | |
481 | else | |
482 | { | |
483 | for (Int_t i=0; i<size; i++) | |
484 | { | |
485 | fGains->AddAt(0,i); | |
486 | Int_t oflag=GetOffsetFlag(i); | |
487 | SetCalFlags(0,oflag,i); | |
488 | } | |
489 | } | |
490 | } | |
491 | else | |
492 | { | |
493 | cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl; | |
494 | return; | |
495 | } | |
496 | } | |
497 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 498 | void AliAttrib::ResetGain(TString name) |
499 | { | |
500 | // Reset the gain value of the name-specified attribute slot. | |
501 | // | |
502 | // This procedure involves a slot-index search based on the specified name | |
503 | // at each invokation. This may become slow in case many slots have been | |
504 | // defined and/or when this procedure is invoked many times. | |
505 | // In such cases it is preferable to use indexed addressing in the user code | |
506 | // either directly or via a few invokations of GetSlotIndex(). | |
507 | ||
508 | Int_t j=GetSlotIndex(name); | |
509 | if (j>0) ResetGain(j); | |
510 | } | |
511 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 512 | void AliAttrib::ResetOffset(Int_t j) |
513 | { | |
514 | // Reset the offset value of the j-th (default j=1) attribute slot. | |
515 | // Notes : The first attribute slot is at j=1. | |
516 | // j=0 ==> All offset values will be reset. | |
517 | ||
518 | if (!fOffsets) return; | |
519 | ||
520 | Int_t size=fOffsets->GetSize(); | |
521 | ||
522 | if ((j>=0) && (j<=size)) | |
523 | { | |
524 | if (j) | |
525 | { | |
526 | fOffsets->AddAt(0,j-1); | |
527 | Int_t gflag=GetGainFlag(j); | |
528 | SetCalFlags(gflag,0,j); | |
529 | } | |
530 | else | |
531 | { | |
532 | for (Int_t i=0; i<size; i++) | |
533 | { | |
534 | fOffsets->AddAt(0,i); | |
535 | Int_t gflag=GetGainFlag(i); | |
536 | SetCalFlags(gflag,0,i); | |
537 | } | |
538 | } | |
539 | } | |
540 | else | |
541 | { | |
542 | cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl; | |
543 | return; | |
544 | } | |
545 | } | |
546 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 547 | void AliAttrib::ResetOffset(TString name) |
548 | { | |
549 | // Reset the offset value of the name-specified attribute slot. | |
550 | // | |
551 | // This procedure involves a slot-index search based on the specified name | |
552 | // at each invokation. This may become slow in case many slots have been | |
553 | // defined and/or when this procedure is invoked many times. | |
554 | // In such cases it is preferable to use indexed addressing in the user code | |
555 | // either directly or via a few invokations of GetSlotIndex(). | |
556 | ||
557 | Int_t j=GetSlotIndex(name); | |
558 | if (j>0) ResetOffset(j); | |
559 | } | |
560 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 561 | void AliAttrib::DeleteCalibrations(Int_t mode) |
562 | { | |
563 | // User selected delete of all gains and/or offsets. | |
564 | // mode = 0 : All attributes (names, gains, offsets, edge and dead values) are deleted. | |
565 | // 1 : Only the gains are deleted. | |
566 | // 2 : Only the offsets are deleted. | |
567 | // 3 : Both gains and offsets are deleted, but names, edge and dead values are kept. | |
568 | // | |
569 | // The default when invoking DeleteCalibrations() corresponds to mode=0. | |
570 | ||
571 | if (mode<0 || mode>3) | |
572 | { | |
573 | cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl; | |
574 | cout << " Default mode=0 will be used." << endl; | |
575 | mode=0; | |
576 | } | |
577 | ||
578 | if (mode==0 || mode==3) | |
579 | { | |
580 | ResetGain(0); | |
581 | if (fGains) | |
582 | { | |
583 | delete fGains; | |
584 | fGains=0; | |
585 | } | |
586 | ResetOffset(0); | |
587 | if (fOffsets) | |
588 | { | |
589 | delete fOffsets; | |
590 | fOffsets=0; | |
591 | } | |
592 | if (fCalflags && mode==0) | |
593 | { | |
594 | delete fCalflags; | |
595 | fCalflags=0; | |
596 | } | |
597 | if (fNames && mode==0) | |
598 | { | |
599 | delete fNames; | |
600 | fNames=0; | |
601 | } | |
602 | return; | |
603 | } | |
604 | ||
605 | if (mode==1) | |
606 | { | |
607 | ResetGain(0); | |
608 | if (fGains) | |
609 | { | |
610 | delete fGains; | |
611 | fGains=0; | |
612 | } | |
613 | } | |
614 | else | |
615 | { | |
616 | ResetOffset(0); | |
617 | if (fOffsets) | |
618 | { | |
619 | delete fOffsets; | |
620 | fOffsets=0; | |
621 | } | |
622 | } | |
623 | } | |
624 | /////////////////////////////////////////////////////////////////////////// | |
625 | void AliAttrib::SetDead(Int_t j) | |
626 | { | |
627 | // Set the dead flag to 1 for the j-th (default j=1) attribute slot. | |
628 | // Note : The first attribute slot is at j=1. | |
629 | // In case the value of the index j exceeds the maximum number of reserved | |
630 | // slots for the flags, the number of reserved slots for the flags | |
631 | // is increased automatically. | |
632 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
633 | ||
634 | if (j<1) | |
635 | { | |
636 | cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl; | |
637 | return; | |
638 | } | |
639 | ||
640 | if (!fCalflags) | |
641 | { | |
642 | fCalflags=new TArrayI(j); | |
643 | } | |
644 | ||
645 | Int_t size=fCalflags->GetSize(); | |
646 | ||
647 | if (j>size) | |
648 | { | |
649 | fCalflags->Set(j); | |
650 | } | |
651 | ||
652 | Int_t dead=1; | |
653 | Int_t oflag=GetOffsetFlag(j); | |
654 | Int_t gflag=GetGainFlag(j); | |
655 | Int_t edge=GetEdgeValue(j); | |
656 | ||
657 | Int_t word=1000*edge+100*dead+10*gflag+oflag; | |
658 | ||
659 | fCalflags->AddAt(word,j-1); | |
660 | } | |
661 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 662 | void AliAttrib::SetDead(TString name) |
663 | { | |
664 | // Set the dead flag to 1 for the name-specified attribute slot. | |
665 | // | |
666 | // This procedure involves a slot-index search based on the specified name | |
667 | // at each invokation. This may become slow in case many slots have been | |
668 | // defined and/or when this procedure is invoked many times. | |
669 | // In such cases it is preferable to use indexed addressing in the user code | |
670 | // either directly or via a few invokations of GetSlotIndex(). | |
671 | ||
672 | Int_t j=GetSlotIndex(name); | |
673 | if (j>0) SetDead(j); | |
674 | } | |
675 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 676 | void AliAttrib::SetAlive(Int_t j) |
677 | { | |
678 | // Set the dead flag to 0 for the j-th (default j=1) attribute slot. | |
679 | // Note : The first attribute slot is at j=1. | |
680 | // In case the value of the index j exceeds the maximum number of reserved | |
681 | // slots for the flags, no action is taken since by default the dead flag is 0. | |
682 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
683 | ||
684 | if (j<1) | |
685 | { | |
686 | cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl; | |
687 | return; | |
688 | } | |
689 | ||
690 | if (!fCalflags || j>fCalflags->GetSize()) return; | |
691 | ||
692 | Int_t dead=0; | |
693 | Int_t oflag=GetOffsetFlag(j); | |
694 | Int_t gflag=GetGainFlag(j); | |
695 | Int_t edge=GetEdgeValue(j); | |
696 | ||
697 | Int_t word=1000*edge+100*dead+10*gflag+oflag; | |
698 | ||
699 | fCalflags->AddAt(word,j-1); | |
700 | } | |
701 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 702 | void AliAttrib::SetAlive(TString name) |
703 | { | |
704 | // Set the dead flag to 0 for the name-specified attribute slot. | |
705 | // | |
706 | // This procedure involves a slot-index search based on the specified name | |
707 | // at each invokation. This may become slow in case many slots have been | |
708 | // defined and/or when this procedure is invoked many times. | |
709 | // In such cases it is preferable to use indexed addressing in the user code | |
710 | // either directly or via a few invokations of GetSlotIndex(). | |
711 | ||
712 | Int_t j=GetSlotIndex(name); | |
713 | if (j>0) SetAlive(j); | |
714 | } | |
715 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 716 | void AliAttrib::SetEdgeOn(Int_t j) |
717 | { | |
718 | // Set the edge value to 1 for the j-th (default j=1) attribute slot. | |
719 | // Note : The first attribute slot is at j=1. | |
720 | // In case the value of the index j exceeds the maximum number of reserved | |
721 | // slots for the flags, the number of reserved slots for the flags | |
722 | // is increased automatically. | |
723 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
724 | ||
725 | if (j<1) | |
726 | { | |
727 | cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl; | |
728 | return; | |
729 | } | |
730 | ||
731 | SetEdgeValue(1,j); | |
732 | } | |
733 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 734 | void AliAttrib::SetEdgeOn(TString name) |
735 | { | |
736 | // Set the edge value to 1 for the name-specified attribute slot. | |
737 | // | |
738 | // This procedure involves a slot-index search based on the specified name | |
739 | // at each invokation. This may become slow in case many slots have been | |
740 | // defined and/or when this procedure is invoked many times. | |
741 | // In such cases it is preferable to use indexed addressing in the user code | |
742 | // either directly or via a few invokations of GetSlotIndex(). | |
743 | ||
744 | Int_t j=GetSlotIndex(name); | |
745 | if (j>0) SetEdgeOn(j); | |
746 | } | |
747 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 748 | void AliAttrib::SetEdgeOff(Int_t j) |
749 | { | |
750 | // Set the edge value to 0 for the j-th (default j=1) attribute slot. | |
751 | // Note : The first attribute slot is at j=1. | |
752 | // In case the value of the index j exceeds the maximum number of reserved | |
753 | // slots for the flags, no action is taken since by default the edge flag is 0. | |
754 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
755 | ||
756 | if (j<1) | |
757 | { | |
758 | cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl; | |
759 | return; | |
760 | } | |
761 | ||
762 | if (!fCalflags || j>fCalflags->GetSize()) return; | |
763 | ||
764 | SetEdgeValue(0,j); | |
765 | } | |
766 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 767 | void AliAttrib::SetEdgeOff(TString name) |
768 | { | |
769 | // Set the edge value to 0 for the name-specified attribute slot. | |
770 | // | |
771 | // This procedure involves a slot-index search based on the specified name | |
772 | // at each invokation. This may become slow in case many slots have been | |
773 | // defined and/or when this procedure is invoked many times. | |
774 | // In such cases it is preferable to use indexed addressing in the user code | |
775 | // either directly or via a few invokations of GetSlotIndex(). | |
776 | ||
777 | Int_t j=GetSlotIndex(name); | |
778 | if (j>0) SetEdgeOff(j); | |
779 | } | |
780 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 781 | void AliAttrib::SetEdgeValue(Int_t val,Int_t j) |
782 | { | |
783 | // Set the edge value to "val" for the j-th (default j=1) attribute slot. | |
784 | // Note : The first attribute slot is at j=1. | |
785 | // In case the value of the index j exceeds the maximum number of reserved | |
786 | // slots for the flags, the number of reserved slots for the flags | |
787 | // is increased automatically. | |
788 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
789 | ||
790 | if (j<1) | |
791 | { | |
792 | cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl; | |
793 | return; | |
794 | } | |
795 | ||
796 | if (!fCalflags) | |
797 | { | |
798 | fCalflags=new TArrayI(j); | |
799 | } | |
800 | ||
801 | Int_t size=fCalflags->GetSize(); | |
802 | ||
803 | if (j>size) | |
804 | { | |
805 | fCalflags->Set(j); | |
806 | } | |
807 | ||
808 | Int_t edge=val; | |
809 | Int_t dead=GetDeadValue(j); | |
810 | Int_t gflag=GetGainFlag(j); | |
811 | Int_t oflag=GetOffsetFlag(j); | |
812 | ||
813 | Int_t word=1000*edge+100*dead+10*gflag+oflag; | |
814 | ||
815 | fCalflags->AddAt(word,j-1); | |
816 | } | |
817 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 818 | void AliAttrib::SetEdgeValue(Int_t val,TString name) |
819 | { | |
820 | // Set the edge value to "val" for the name-specified attribute slot. | |
821 | // | |
822 | // This procedure involves a slot-index search based on the specified name | |
823 | // at each invokation. This may become slow in case many slots have been | |
824 | // defined and/or when this procedure is invoked many times. | |
825 | // In such cases it is preferable to use indexed addressing in the user code | |
826 | // either directly or via a few invokations of GetSlotIndex(). | |
827 | ||
828 | Int_t j=GetSlotIndex(name); | |
829 | if (j>0) SetEdgeValue(val,j); | |
830 | } | |
831 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 832 | void AliAttrib::IncreaseEdgeValue(Int_t j) |
833 | { | |
834 | // Increase the edge value by 1 for the j-th (default j=1) attribute slot. | |
835 | // Note : The first attribute slot is at j=1. | |
836 | // In case the value of the index j exceeds the maximum number of reserved | |
837 | // slots for the flags, the number of reserved slots for the flags | |
838 | // is increased automatically. | |
839 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
840 | ||
841 | if (j<1) | |
842 | { | |
843 | cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl; | |
844 | return; | |
845 | } | |
846 | ||
847 | Int_t edge=GetEdgeValue(); | |
848 | SetEdgeValue(edge+1,j); | |
849 | } | |
850 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 851 | void AliAttrib::IncreaseEdgeValue(TString name) |
852 | { | |
853 | // Increase the edge value by 1 for the name-specified attribute slot. | |
854 | // | |
855 | // This procedure involves a slot-index search based on the specified name | |
856 | // at each invokation. This may become slow in case many slots have been | |
857 | // defined and/or when this procedure is invoked many times. | |
858 | // In such cases it is preferable to use indexed addressing in the user code | |
859 | // either directly or via a few invokations of GetSlotIndex(). | |
860 | ||
861 | Int_t j=GetSlotIndex(name); | |
862 | if (j>0) IncreaseEdgeValue(j); | |
863 | } | |
864 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 865 | void AliAttrib::DecreaseEdgeValue(Int_t j) |
866 | { | |
867 | // Decrease the edge value by 1 for the j-th (default j=1) attribute slot. | |
868 | // Note : The first attribute slot is at j=1. | |
869 | // In case the value of the index j exceeds the maximum number of reserved | |
870 | // slots for the flags, the number of reserved slots for the flags | |
871 | // is increased automatically. | |
872 | // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag. | |
873 | ||
874 | if (j<1) | |
875 | { | |
876 | cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl; | |
877 | return; | |
878 | } | |
879 | ||
880 | Int_t edge=GetEdgeValue(); | |
881 | SetEdgeValue(edge-1,j); | |
882 | } | |
883 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 884 | void AliAttrib::DecreaseEdgeValue(TString name) |
885 | { | |
886 | // Decrease the edge value by 1 for the name-specified attribute slot. | |
887 | // | |
888 | // This procedure involves a slot-index search based on the specified name | |
889 | // at each invokation. This may become slow in case many slots have been | |
890 | // defined and/or when this procedure is invoked many times. | |
891 | // In such cases it is preferable to use indexed addressing in the user code | |
892 | // either directly or via a few invokations of GetSlotIndex(). | |
893 | ||
894 | Int_t j=GetSlotIndex(name); | |
895 | if (j>0) DecreaseEdgeValue(j); | |
896 | } | |
897 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 898 | Int_t AliAttrib::GetEdgeValue(Int_t j) const |
1fbffa23 | 899 | { |
900 | // Provide edge value of the j-th (default j=1) attribute slot. | |
901 | // Note : The first attribute slot is at j=1. | |
902 | // In case j is invalid, 0 is returned. | |
903 | ||
904 | if (j<1) | |
905 | { | |
906 | cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl; | |
907 | return 0; | |
908 | } | |
909 | ||
910 | Int_t edge=0; | |
911 | if (fCalflags) | |
912 | { | |
913 | if (j>0 && j<=(fCalflags->GetSize())) | |
914 | { | |
915 | Int_t word=fCalflags->At(j-1); | |
916 | edge=word/1000; | |
917 | } | |
918 | } | |
919 | return edge; | |
920 | } | |
921 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 922 | Int_t AliAttrib::GetEdgeValue(TString name) const |
923 | { | |
924 | // Provide edge value of the name-specified attribute slot. | |
925 | // | |
926 | // This procedure involves a slot-index search based on the specified name | |
927 | // at each invokation. This may become slow in case many slots have been | |
928 | // defined and/or when this procedure is invoked many times. | |
929 | // In such cases it is preferable to use indexed addressing in the user code | |
930 | // either directly or via a few invokations of GetSlotIndex(). | |
931 | ||
932 | Int_t j=GetSlotIndex(name); | |
933 | Int_t val=0; | |
934 | if (j>0) val=GetEdgeValue(j); | |
935 | return val; | |
936 | } | |
937 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 938 | Int_t AliAttrib::GetDeadValue(Int_t j) const |
1fbffa23 | 939 | { |
940 | // Provide dead value of the j-th (default j=1) attribute slot. | |
941 | // Note : The first attribute slot is at j=1. | |
942 | // In case j is invalid, 0 is returned. | |
943 | ||
944 | if (j<1) | |
945 | { | |
946 | cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl; | |
947 | return 0; | |
948 | } | |
949 | ||
950 | Int_t dead=0; | |
951 | if (fCalflags) | |
952 | { | |
953 | if (j>0 && j<=(fCalflags->GetSize())) | |
954 | { | |
955 | Int_t word=fCalflags->At(j-1); | |
956 | word=word%1000; | |
957 | dead=word/100; | |
958 | } | |
959 | } | |
960 | return dead; | |
961 | } | |
962 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 963 | Int_t AliAttrib::GetDeadValue(TString name) const |
964 | { | |
965 | // Provide dead value of the name-specified attribute slot. | |
966 | // | |
967 | // This procedure involves a slot-index search based on the specified name | |
968 | // at each invokation. This may become slow in case many slots have been | |
969 | // defined and/or when this procedure is invoked many times. | |
970 | // In such cases it is preferable to use indexed addressing in the user code | |
971 | // either directly or via a few invokations of GetSlotIndex(). | |
972 | ||
973 | Int_t j=GetSlotIndex(name); | |
974 | Int_t val=0; | |
975 | if (j>0) val=GetDeadValue(j); | |
976 | return val; | |
977 | } | |
978 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 979 | void AliAttrib::SetSlotName(TString s,Int_t j) |
980 | { | |
981 | // Set a user defined name for the j-th (default j=1) slot. | |
982 | // Note : The first attribute slot is at j=1. | |
983 | ||
984 | if (j<1) | |
985 | { | |
986 | cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl; | |
987 | return; | |
988 | } | |
989 | ||
990 | if (!fNames) | |
991 | { | |
992 | fNames=new TObjArray(j); | |
993 | fNames->SetOwner(); | |
994 | } | |
995 | ||
996 | if (j>fNames->GetSize()) fNames->Expand(j); | |
997 | ||
998 | TObjString* so=(TObjString*)fNames->At(j-1); | |
999 | if (!so) | |
1000 | { | |
1001 | so=new TObjString(s.Data()); | |
1002 | fNames->AddAt(so,j-1); | |
1003 | } | |
1004 | else | |
1005 | { | |
1006 | so->SetString(s); | |
1007 | } | |
1008 | } | |
1009 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1010 | TString AliAttrib::GetSlotName(Int_t j) const |
1fbffa23 | 1011 | { |
1012 | // Provide the user defined name for the j-th (default j=1) slot. | |
1013 | // Note : The first attribute slot is at j=1. | |
1014 | ||
1015 | TString s=""; | |
1016 | if (j<1) | |
1017 | { | |
1018 | cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl; | |
1019 | return s; | |
1020 | } | |
1021 | ||
1022 | if (fNames) | |
1023 | { | |
1024 | if (j<=fNames->GetSize()) | |
1025 | { | |
1026 | TObjString* so=(TObjString*)fNames->At(j-1); | |
1027 | if (so) s=so->GetString(); | |
1028 | } | |
1029 | } | |
1030 | return s; | |
1031 | } | |
1032 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1033 | Int_t AliAttrib::GetSlotIndex(TString name) const |
1fbffa23 | 1034 | { |
1035 | // Provide the slot index for the matching name. | |
1036 | // If no matching name is found, 0 is returned. | |
1037 | // Note : The first attribute slot is at j=1. | |
1038 | ||
1039 | Int_t index=0; | |
1040 | ||
1041 | if (fNames) | |
1042 | { | |
1043 | TString s; | |
1044 | Int_t size=fNames->GetSize(); | |
1045 | for (Int_t i=0; i<size; i++) | |
1046 | { | |
1047 | TObjString* so=(TObjString*)fNames->At(i); | |
387a745b | 1048 | if (so) s=so->GetString(); |
1fbffa23 | 1049 | if (s==name) index=i+1; |
1050 | } | |
1051 | } | |
1052 | return index; | |
1053 | } | |
1054 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1055 | void AliAttrib::List(Int_t j) const |
1fbffa23 | 1056 | { |
1057 | // Provide attribute information for the j-th slot. | |
1058 | // The first slot is at j=1. | |
1059 | // In case j=0 (default) the data of all slots will be listed. | |
1060 | ||
1061 | if (j<0) | |
1062 | { | |
1063 | cout << " *AliAttrib::Data* Invalid argument j = " << j << endl; | |
1064 | return; | |
1065 | } | |
1066 | ||
1067 | if (j>0) | |
1068 | { | |
1069 | if (GetGainFlag(j)) cout << " gain : " << GetGain(j); | |
1070 | if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j); | |
1071 | if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j); | |
1072 | if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j); | |
1073 | TString s=GetSlotName(j); | |
1074 | if (s!="") cout << " name : " << s.Data(); | |
1075 | } | |
1076 | else | |
1077 | { | |
1078 | Int_t ng=GetNgains(); | |
1079 | Int_t no=GetNoffsets(); | |
1080 | Int_t nf=0; | |
1081 | if (fCalflags) nf=fCalflags->GetSize(); | |
1082 | Int_t nn=GetNnames(); | |
1083 | Int_t n=ng; | |
1084 | if (n<no) n=no; | |
1085 | if (n<nn) n=nn; | |
1086 | if (n<nf) n=nf; | |
1087 | Int_t printf=0; | |
1088 | TString s; | |
1089 | for (Int_t i=1; i<=n; i++) | |
1090 | { | |
1091 | printf=0; | |
1092 | if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;} | |
1093 | if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;} | |
1094 | if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;} | |
1095 | if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;} | |
1096 | s=GetSlotName(i); | |
1097 | if (s!="") {cout << " name : " << s.Data(); printf=1;} | |
1098 | if (printf) cout << endl; | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1103 | void AliAttrib::List(TString name) const |
1104 | { | |
1105 | // Provide attribute information for the name-specified slot. | |
1106 | // | |
1107 | // This procedure involves a slot-index search based on the specified name | |
1108 | // at each invokation. This may become slow in case many slots have been | |
1109 | // defined and/or when this procedure is invoked many times. | |
1110 | // In such cases it is preferable to use indexed addressing in the user code | |
1111 | // either directly or via a few invokations of GetSlotIndex(). | |
1112 | ||
1113 | Int_t j=GetSlotIndex(name); | |
1114 | if (j>0) List(j); | |
1115 | } | |
1116 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 1117 | void AliAttrib::Load(AliAttrib& a,Int_t j) |
1118 | { | |
1119 | // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object. | |
1120 | // | |
1121 | // Note : if j=0, then all attributes of all slots are loaded | |
1122 | // | |
1123 | // The default is j=0. | |
1124 | ||
1125 | if (j<0) | |
1126 | { | |
1127 | cout << " *AliAttrib::Load* Invalid argument j = " << j << endl; | |
1128 | return; | |
1129 | } | |
1130 | ||
1131 | Int_t n=0; | |
1132 | ||
1133 | if (j==0) // load attributes for all slots | |
1134 | { | |
1135 | n=a.GetNgains(); | |
1136 | for (Int_t ig=1; ig<=n; ig++) | |
1137 | { | |
1138 | if (a.GetGainFlag(ig)) | |
1139 | { | |
1140 | SetGain(a.GetGain(ig),ig); | |
1141 | } | |
1142 | else | |
1143 | { | |
1144 | ResetGain(ig); | |
1145 | } | |
1146 | } | |
1147 | n=a.GetNoffsets(); | |
1148 | for (Int_t io=1; io<=n; io++) | |
1149 | { | |
1150 | if (a.GetOffsetFlag(io)) | |
1151 | { | |
1152 | SetOffset(a.GetOffset(io),io); | |
1153 | } | |
1154 | else | |
1155 | { | |
1156 | ResetOffset(io); | |
1157 | } | |
1158 | } | |
1159 | n=a.GetNcalflags(); | |
1160 | for (Int_t ic=1; ic<=n; ic++) | |
1161 | { | |
1162 | SetEdgeValue(a.GetEdgeValue(ic),ic); | |
1163 | if (a.GetDeadValue(ic)) | |
1164 | { | |
1165 | SetDead(ic); | |
1166 | } | |
1167 | else | |
1168 | { | |
1169 | SetAlive(ic); | |
1170 | } | |
1171 | } | |
1172 | n=a.GetNnames(); | |
1173 | { | |
1174 | TString s; | |
1175 | for (Int_t in=1; in<=n; in++) | |
1176 | { | |
1177 | s=a.GetSlotName(in); | |
1178 | if (s!="") SetSlotName(s,in); | |
1179 | } | |
1180 | } | |
1181 | } | |
1182 | else // load attributes for specified j-th slot only | |
1183 | { | |
1184 | n=a.GetNgains(); | |
1185 | if (j<=n) | |
1186 | { | |
1187 | if (a.GetGainFlag(j)) | |
1188 | { | |
1189 | SetGain(a.GetGain(j),j); | |
1190 | } | |
1191 | else | |
1192 | { | |
1193 | ResetGain(j); | |
1194 | } | |
1195 | } | |
1196 | n=a.GetNoffsets(); | |
1197 | if (j<=n) | |
1198 | { | |
1199 | if (a.GetOffsetFlag(j)) | |
1200 | { | |
1201 | SetOffset(a.GetOffset(j),j); | |
1202 | } | |
1203 | else | |
1204 | { | |
1205 | ResetOffset(j); | |
1206 | } | |
1207 | } | |
1208 | n=a.GetNcalflags(); | |
1209 | if (j<=n) | |
1210 | { | |
1211 | SetEdgeValue(a.GetEdgeValue(j),j); | |
1212 | if (a.GetDeadValue(j)) | |
1213 | { | |
1214 | SetDead(j); | |
1215 | } | |
1216 | else | |
1217 | { | |
1218 | SetAlive(j); | |
1219 | } | |
1220 | } | |
1221 | n=a.GetNnames(); | |
1222 | { | |
1223 | TString s; | |
1224 | if (j<=n) | |
1225 | { | |
1226 | s=a.GetSlotName(j); | |
1227 | if (s!="") SetSlotName(s,j); | |
1228 | } | |
1229 | } | |
1230 | } | |
1231 | } | |
1232 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1233 | void AliAttrib::Load(AliAttrib& a,TString name) |
1234 | { | |
1235 | // Load attributes of the name-specified slot of the input AliAttrib into | |
1236 | // this AliAttrib object. | |
1237 | // | |
1238 | // This procedure involves a slot-index search based on the specified name | |
1239 | // at each invokation. This may become slow in case many slots have been | |
1240 | // defined and/or when this procedure is invoked many times. | |
1241 | // In such cases it is preferable to use indexed addressing in the user code | |
1242 | // either directly or via a few invokations of GetSlotIndex(). | |
1243 | ||
1244 | Int_t j=GetSlotIndex(name); | |
1245 | if (j>0) Load(a,j); | |
1246 | } | |
1247 | /////////////////////////////////////////////////////////////////////////// |