]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliAttrib.cxx
01-sep-2003 NvE Explicit initialisation of TObject() introduced in default constructo...
[u/mrichter/AliRoot.git] / RALICE / AliAttrib.cxx
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);
37 // a.Data();
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 ///////////////////////////////////////////////////////////////////////////
85 AliAttrib::AliAttrib(AliAttrib& a)
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 ///////////////////////////////////////////////////////////////////////////
126 Int_t AliAttrib::GetNgains()
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 ///////////////////////////////////////////////////////////////////////////
134 Int_t AliAttrib::GetNoffsets()
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 ///////////////////////////////////////////////////////////////////////////
142 Int_t AliAttrib::GetNcalflags()
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 ///////////////////////////////////////////////////////////////////////////
150 Int_t AliAttrib::GetNnames()
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 ///////////////////////////////////////////////////////////////////////////
191 void AliAttrib::SetOffset(Double_t off,Int_t j)
192 {
193 // Store offset value of the j-th (default j=1) attribute slot.
194 // Note : The first attribute slot is at j=1.
195 // In case the value of the index j exceeds the maximum number of reserved
196 // slots for offset values, the number of reserved slots for the offset
197 // values is increased automatically.
198
199  if (j<1) 
200  {
201   cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
202   return;
203  }
204
205  if (!fOffsets)
206  {
207   fOffsets=new TArrayF(j);
208  }
209
210  Int_t size=fOffsets->GetSize();
211
212  if (j>size)
213  {
214   fOffsets->Set(j);
215  }
216
217  fOffsets->AddAt(float(off),j-1);
218
219  Int_t gflag=GetGainFlag(j);
220
221  SetCalFlags(gflag,1,j);
222 }
223 ///////////////////////////////////////////////////////////////////////////
224 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
225 {
226 // Store calibration flags of the j-th (default j=1) attribute slot.
227 // Note : The first attribute slot is at j=1.
228 // In case the value of the index j exceeds the maximum number of reserved
229 // slots for the calib. flags, the number of reserved slots for the calib.
230 // flags is increased automatically.
231 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
232
233  if (j<1) 
234  {
235   cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
236   return;
237  }
238
239  if (!fCalflags)
240  {
241   fCalflags=new TArrayI(j);
242  }
243
244  Int_t size=fCalflags->GetSize();
245
246  if (j>size)
247  {
248   fCalflags->Set(j);
249  }
250
251  Int_t edge=GetEdgeValue(j);
252  Int_t dead=GetDeadValue(j);
253
254  Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
255  
256  fCalflags->AddAt(word,j-1);
257 }
258 ///////////////////////////////////////////////////////////////////////////
259 Int_t AliAttrib::GetGainFlag(Int_t j)
260 {
261 // Provide gain flag of the j-th (default j=1) attribute slot.
262 //
263 // flag = 1 : Gain was set
264 //        0 : Gain was not set
265 //
266 // Note : The first attribute slot is at j=1.
267 // In case j is invalid, 0 is returned.
268
269  if (j<1) 
270  {
271   cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
272   return 0;
273  }
274  Int_t gflag=0;
275  if (fCalflags)
276  {
277   if (j>0 && j<=(fCalflags->GetSize()))
278   {
279    Int_t word=fCalflags->At(j-1);
280    word=word%100;
281    gflag=word/10;
282   }
283  }
284  return gflag;
285 }
286 ///////////////////////////////////////////////////////////////////////////
287 Int_t AliAttrib::GetOffsetFlag(Int_t j)
288 {
289 // Provide offset flag of the j-th (default j=1) attribute slot.
290 //
291 // flag = 1 : Offset was set
292 //        0 : Offset 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::GetOffsetFlag* Invalid argument j = " << j << endl;
300   return 0;
301  }
302
303  Int_t oflag=0;
304  if (fCalflags)
305  {
306   if (j>0 && j<=(fCalflags->GetSize()))
307   {
308    Int_t word=fCalflags->At(j-1);
309    oflag=word%10;
310   }
311  }
312  return oflag;
313 }
314 ///////////////////////////////////////////////////////////////////////////
315 Float_t AliAttrib::GetGain(Int_t j)
316 {
317 // Provide gain value of the j-th (default j=1) attribute slot.
318 // The first attribute slot is at j=1.
319 // In case no gain value was set or the argument j is invalid, 0 is returned.
320 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
321
322  if (j<1) 
323  {
324   cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
325   return 0;
326  }
327
328  Float_t gain=0;
329  if (fGains)
330  {
331   if (j>0 && j<=(fGains->GetSize()))
332   {
333    if (GetGainFlag(j)) gain=fGains->At(j-1);
334   }
335  }
336  return gain;
337 }
338 ///////////////////////////////////////////////////////////////////////////
339 Float_t AliAttrib::GetOffset(Int_t j)
340 {
341 // Provide offset value of the j-th (default j=1) attribute slot.
342 // The first attribute slot at j=1.
343 // In case no offset value was set or the argument j is invalid, 0 is returned.
344 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
345
346  if (j<1) 
347  {
348   cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
349   return 0;
350  }
351
352  Float_t offset=0;
353  if (fOffsets)
354  {
355   if (j>0 && j<=(fOffsets->GetSize()))
356   {
357    if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
358   }
359  }
360  return offset;
361 }
362 ///////////////////////////////////////////////////////////////////////////
363 void AliAttrib::ResetGain(Int_t j)
364 {
365 // Reset the gain value of the j-th (default j=1) attribute slot.
366 // Notes : The first attribute slot is at j=1.
367 //         j=0 ==> All gain values will be reset.
368  
369  if (!fGains) return;
370
371  Int_t size=fGains->GetSize();
372
373  if ((j>=0) && (j<=size))
374  {
375   if (j)
376   {
377    fGains->AddAt(0,j-1);
378    Int_t oflag=GetOffsetFlag(j);
379    SetCalFlags(0,oflag,j);
380   }
381   else
382   {
383    for (Int_t i=0; i<size; i++)
384    {
385     fGains->AddAt(0,i);
386     Int_t oflag=GetOffsetFlag(i);
387     SetCalFlags(0,oflag,i);
388    }
389   }
390  }
391  else
392  {
393   cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
394   return;
395  }
396 }
397 ///////////////////////////////////////////////////////////////////////////
398 void AliAttrib::ResetOffset(Int_t j)
399 {
400 // Reset the offset value of the j-th (default j=1) attribute slot.
401 // Notes : The first attribute slot is at j=1.
402 //         j=0 ==> All offset values will be reset.
403  
404  if (!fOffsets) return;
405
406  Int_t size=fOffsets->GetSize();
407
408  if ((j>=0) && (j<=size))
409  {
410   if (j)
411   {
412    fOffsets->AddAt(0,j-1);
413    Int_t gflag=GetGainFlag(j);
414    SetCalFlags(gflag,0,j);
415   }
416   else
417   {
418    for (Int_t i=0; i<size; i++)
419    {
420     fOffsets->AddAt(0,i);
421     Int_t gflag=GetGainFlag(i);
422     SetCalFlags(gflag,0,i);
423    }
424   }
425  }
426  else
427  {
428   cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
429   return;
430  }
431 }
432 ///////////////////////////////////////////////////////////////////////////
433 void AliAttrib::DeleteCalibrations(Int_t mode)
434 {
435 // User selected delete of all gains and/or offsets.
436 // mode = 0 : All attributes (names, gains, offsets, edge and dead values) are deleted.
437 //        1 : Only the gains are deleted.
438 //        2 : Only the offsets are deleted.
439 //        3 : Both gains and offsets are deleted, but names, edge and dead values are kept.
440 //
441 // The default when invoking DeleteCalibrations() corresponds to mode=0.
442
443  if (mode<0 || mode>3)
444  {
445   cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
446   cout << " Default mode=0 will be used." << endl;
447   mode=0;
448  }
449
450  if (mode==0 || mode==3)
451  {
452   ResetGain(0);
453   if (fGains)
454   {
455    delete fGains;
456    fGains=0;
457   }
458   ResetOffset(0);
459   if (fOffsets)
460   {
461    delete fOffsets;
462    fOffsets=0;
463   }
464   if (fCalflags && mode==0)
465   {
466    delete fCalflags;
467    fCalflags=0;
468   }
469   if (fNames && mode==0)
470   {
471    delete fNames;
472    fNames=0;
473   }
474   return;
475  }
476
477  if (mode==1)
478  {
479   ResetGain(0);
480   if (fGains)
481   {
482    delete fGains;
483    fGains=0;
484   }
485  }
486  else
487  {
488   ResetOffset(0);
489   if (fOffsets)
490   {
491    delete fOffsets;
492    fOffsets=0;
493   }
494  }
495 }
496 ///////////////////////////////////////////////////////////////////////////
497 void AliAttrib::SetDead(Int_t j)
498 {
499 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
500 // Note : The first attribute slot is at j=1.
501 // In case the value of the index j exceeds the maximum number of reserved
502 // slots for the flags, the number of reserved slots for the flags
503 // is increased automatically.
504 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
505
506  if (j<1) 
507  {
508   cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
509   return;
510  }
511
512  if (!fCalflags)
513  {
514   fCalflags=new TArrayI(j);
515  }
516
517  Int_t size=fCalflags->GetSize();
518
519  if (j>size)
520  {
521   fCalflags->Set(j);
522  }
523
524  Int_t dead=1;
525  Int_t oflag=GetOffsetFlag(j);
526  Int_t gflag=GetGainFlag(j);
527  Int_t edge=GetEdgeValue(j);
528
529  Int_t word=1000*edge+100*dead+10*gflag+oflag;
530  
531  fCalflags->AddAt(word,j-1);
532 }
533 ///////////////////////////////////////////////////////////////////////////
534 void AliAttrib::SetAlive(Int_t j)
535 {
536 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
537 // Note : The first attribute slot is at j=1.
538 // In case the value of the index j exceeds the maximum number of reserved
539 // slots for the flags, no action is taken since by default the dead flag is 0.
540 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
541
542  if (j<1) 
543  {
544   cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
545   return;
546  }
547
548  if (!fCalflags || j>fCalflags->GetSize()) return;
549
550  Int_t dead=0;
551  Int_t oflag=GetOffsetFlag(j);
552  Int_t gflag=GetGainFlag(j);
553  Int_t edge=GetEdgeValue(j);
554
555  Int_t word=1000*edge+100*dead+10*gflag+oflag;
556  
557  fCalflags->AddAt(word,j-1);
558 }
559 ///////////////////////////////////////////////////////////////////////////
560 void AliAttrib::SetEdgeOn(Int_t j)
561 {
562 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
563 // Note : The first attribute slot is at j=1.
564 // In case the value of the index j exceeds the maximum number of reserved
565 // slots for the flags, the number of reserved slots for the flags
566 // is increased automatically.
567 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
568
569  if (j<1) 
570  {
571   cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
572   return;
573  }
574
575  SetEdgeValue(1,j);
576 }
577 ///////////////////////////////////////////////////////////////////////////
578 void AliAttrib::SetEdgeOff(Int_t j)
579 {
580 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
581 // Note : The first attribute slot is at j=1.
582 // In case the value of the index j exceeds the maximum number of reserved
583 // slots for the flags, no action is taken since by default the edge flag is 0.
584 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
585
586  if (j<1) 
587  {
588   cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
589   return;
590  }
591
592  if (!fCalflags || j>fCalflags->GetSize()) return;
593
594  SetEdgeValue(0,j);
595 }
596 ///////////////////////////////////////////////////////////////////////////
597 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
598 {
599 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
600 // Note : The first attribute slot is at j=1.
601 // In case the value of the index j exceeds the maximum number of reserved
602 // slots for the flags, the number of reserved slots for the flags
603 // is increased automatically.
604 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
605
606  if (j<1) 
607  {
608   cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
609   return;
610  }
611
612  if (!fCalflags)
613  {
614   fCalflags=new TArrayI(j);
615  }
616
617  Int_t size=fCalflags->GetSize();
618
619  if (j>size)
620  {
621   fCalflags->Set(j);
622  }
623
624  Int_t edge=val;
625  Int_t dead=GetDeadValue(j);
626  Int_t gflag=GetGainFlag(j);
627  Int_t oflag=GetOffsetFlag(j);
628
629  Int_t word=1000*edge+100*dead+10*gflag+oflag;
630  
631  fCalflags->AddAt(word,j-1);
632 }
633 ///////////////////////////////////////////////////////////////////////////
634 void AliAttrib::IncreaseEdgeValue(Int_t j)
635 {
636 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
637 // Note : The first attribute slot is at j=1.
638 // In case the value of the index j exceeds the maximum number of reserved
639 // slots for the flags, the number of reserved slots for the flags
640 // is increased automatically.
641 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
642
643  if (j<1) 
644  {
645   cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
646   return;
647  }
648
649  Int_t edge=GetEdgeValue();
650  SetEdgeValue(edge+1,j);
651 }
652 ///////////////////////////////////////////////////////////////////////////
653 void AliAttrib::DecreaseEdgeValue(Int_t j)
654 {
655 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
656 // Note : The first attribute slot is at j=1.
657 // In case the value of the index j exceeds the maximum number of reserved
658 // slots for the flags, the number of reserved slots for the flags
659 // is increased automatically.
660 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
661
662  if (j<1) 
663  {
664   cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
665   return;
666  }
667
668  Int_t edge=GetEdgeValue();
669  SetEdgeValue(edge-1,j);
670 }
671 ///////////////////////////////////////////////////////////////////////////
672 Int_t AliAttrib::GetEdgeValue(Int_t j)
673 {
674 // Provide edge value of the j-th (default j=1) attribute slot.
675 // Note : The first attribute slot is at j=1.
676 // In case j is invalid, 0 is returned.
677
678  if (j<1) 
679  {
680   cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
681   return 0;
682  }
683
684  Int_t edge=0;
685  if (fCalflags)
686  {
687   if (j>0 && j<=(fCalflags->GetSize()))
688   {
689    Int_t word=fCalflags->At(j-1);
690    edge=word/1000;
691   }
692  }
693  return edge;
694 }
695 ///////////////////////////////////////////////////////////////////////////
696 Int_t AliAttrib::GetDeadValue(Int_t j)
697 {
698 // Provide dead value of the j-th (default j=1) attribute slot.
699 // Note : The first attribute slot is at j=1.
700 // In case j is invalid, 0 is returned.
701
702  if (j<1) 
703  {
704   cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
705   return 0;
706  }
707
708  Int_t dead=0;
709  if (fCalflags)
710  {
711   if (j>0 && j<=(fCalflags->GetSize()))
712   {
713    Int_t word=fCalflags->At(j-1);
714    word=word%1000;
715    dead=word/100;
716   }
717  }
718  return dead;
719 }
720 ///////////////////////////////////////////////////////////////////////////
721 AliAttrib* AliAttrib::MakeCopy(AliAttrib& a)
722 {
723 // Make a deep copy of the input object and provide the pointer to the copy.
724 // This memberfunction enables automatic creation of new objects of the
725 // correct type depending on the argument type, a feature which may be very useful
726 // for containers when adding objects in case the container owns the objects.
727
728  AliAttrib* att=new AliAttrib(a);
729  return att;
730 }
731 ///////////////////////////////////////////////////////////////////////////
732 void AliAttrib::SetSlotName(TString s,Int_t j)
733 {
734 // Set a user defined name for the j-th (default j=1) slot. 
735 // Note : The first attribute slot is at j=1.
736
737  if (j<1) 
738  {
739   cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
740   return;
741  }
742
743  if (!fNames)
744  {
745   fNames=new TObjArray(j);
746   fNames->SetOwner();
747  }
748
749  if (j>fNames->GetSize()) fNames->Expand(j);
750
751  TObjString* so=(TObjString*)fNames->At(j-1);
752  if (!so)
753  {
754   so=new TObjString(s.Data());
755   fNames->AddAt(so,j-1);
756  }
757  else
758  {
759   so->SetString(s);
760  }
761 }
762 ///////////////////////////////////////////////////////////////////////////
763 TString AliAttrib::GetSlotName(Int_t j)
764 {
765 // Provide the user defined name for the j-th (default j=1) slot. 
766 // Note : The first attribute slot is at j=1.
767
768  TString s="";
769  if (j<1) 
770  {
771   cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
772   return s;
773  }
774
775  if (fNames)
776  {
777   if (j<=fNames->GetSize())
778   {
779    TObjString* so=(TObjString*)fNames->At(j-1);
780    if (so) s=so->GetString();
781   }
782  }
783  return s;
784 }
785 ///////////////////////////////////////////////////////////////////////////
786 Int_t AliAttrib::GetSlotIndex(TString name)
787 {
788 // Provide the slot index for the matching name.
789 // If no matching name is found, 0 is returned.
790 // Note : The first attribute slot is at j=1.
791
792  Int_t index=0;
793
794  if (fNames)
795  {
796   TString s;
797   Int_t size=fNames->GetSize();
798   for (Int_t i=0; i<size; i++)
799   {
800    TObjString* so=(TObjString*)fNames->At(i);
801    s=so->GetString();
802    if (s==name) index=i+1;
803   }
804  }
805  return index;
806 }
807 ///////////////////////////////////////////////////////////////////////////
808 void AliAttrib::Data(Int_t j)
809 {
810 // Provide attribute information for the j-th slot.
811 // The first slot is at j=1.
812 // In case j=0 (default) the data of all slots will be listed.
813
814  if (j<0) 
815  {
816   cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
817   return;
818  }
819
820  if (j>0)
821  {
822   if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
823   if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
824   if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
825   if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
826   TString s=GetSlotName(j);
827   if (s!="") cout << " name : " << s.Data();
828  }
829  else
830  {
831   Int_t ng=GetNgains();
832   Int_t no=GetNoffsets();
833   Int_t nf=0;
834   if (fCalflags) nf=fCalflags->GetSize();
835   Int_t nn=GetNnames();
836   Int_t n=ng;
837   if (n<no) n=no;
838   if (n<nn) n=nn;
839   if (n<nf) n=nf;
840   Int_t printf=0;
841   TString s;
842   for (Int_t i=1; i<=n; i++)
843   {
844    printf=0;
845    if (GetGainFlag(i))   {cout << " gain : " << GetGain(i); printf=1;}
846    if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
847    if (GetEdgeValue(i))  {cout << " edge : " << GetEdgeValue(i); printf=1;}
848    if (GetDeadValue(i))  {cout << " dead : " << GetDeadValue(i); printf=1;}
849    s=GetSlotName(i);
850    if (s!="") {cout << " name : " << s.Data(); printf=1;}
851    if (printf) cout << endl;
852   }
853  }
854
855 ///////////////////////////////////////////////////////////////////////////
856 void AliAttrib::Load(AliAttrib& a,Int_t j)
857 {
858 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
859 // 
860 // Note : if j=0, then all attributes of all slots are loaded
861 //
862 // The default is j=0.
863
864  if (j<0) 
865  {
866   cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
867   return;
868  }
869
870  Int_t n=0;
871
872  if (j==0) // load attributes for all slots
873  {
874   n=a.GetNgains();
875   for (Int_t ig=1; ig<=n; ig++)
876   {
877    if (a.GetGainFlag(ig))
878    {
879     SetGain(a.GetGain(ig),ig);
880    }
881    else
882    {
883     ResetGain(ig);
884    }
885   }
886   n=a.GetNoffsets();
887   for (Int_t io=1; io<=n; io++)
888   {
889    if (a.GetOffsetFlag(io))
890    {
891     SetOffset(a.GetOffset(io),io);
892    }
893    else
894    {
895     ResetOffset(io);
896    }
897   }
898   n=a.GetNcalflags();
899   for (Int_t ic=1; ic<=n; ic++)
900   {
901    SetEdgeValue(a.GetEdgeValue(ic),ic);
902    if (a.GetDeadValue(ic))
903    {
904     SetDead(ic);
905    }
906    else
907    {
908     SetAlive(ic);
909    }
910   }
911   n=a.GetNnames();
912   {
913    TString s;
914    for (Int_t in=1; in<=n; in++)
915    {
916     s=a.GetSlotName(in);
917     if (s!="") SetSlotName(s,in);
918    }
919   }
920  }
921  else // load attributes for specified j-th slot only
922  {
923   n=a.GetNgains();
924   if (j<=n)
925   {
926    if (a.GetGainFlag(j))
927    {
928     SetGain(a.GetGain(j),j);
929    }
930    else
931    {
932     ResetGain(j);
933    }
934   }
935   n=a.GetNoffsets();
936   if (j<=n)
937   {
938    if (a.GetOffsetFlag(j))
939    {
940     SetOffset(a.GetOffset(j),j);
941    }
942    else
943    {
944     ResetOffset(j);
945    } 
946   }
947   n=a.GetNcalflags();
948   if (j<=n)
949   {
950    SetEdgeValue(a.GetEdgeValue(j),j);
951    if (a.GetDeadValue(j))
952    {
953     SetDead(j);
954    }
955    else
956    {
957     SetAlive(j);
958    }
959   }
960   n=a.GetNnames();
961   {
962    TString s;
963    if (j<=n)
964    {
965     s=a.GetSlotName(j);
966     if (s!="") SetSlotName(s,j);
967    }
968   }
969  }
970 }
971 ///////////////////////////////////////////////////////////////////////////