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