]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliAttrib.cxx
04-apr-2004 NvE SetMass() invoked from AliTrack::Set3Momentum to get also the energy...
[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.List();
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(const 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() const
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() const
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() const
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() const
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) const
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) const
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) const
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) const
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) const
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) const
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 void AliAttrib::SetSlotName(TString s,Int_t j)
722 {
723 // Set a user defined name for the j-th (default j=1) slot. 
724 // Note : The first attribute slot is at j=1.
725
726  if (j<1) 
727  {
728   cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
729   return;
730  }
731
732  if (!fNames)
733  {
734   fNames=new TObjArray(j);
735   fNames->SetOwner();
736  }
737
738  if (j>fNames->GetSize()) fNames->Expand(j);
739
740  TObjString* so=(TObjString*)fNames->At(j-1);
741  if (!so)
742  {
743   so=new TObjString(s.Data());
744   fNames->AddAt(so,j-1);
745  }
746  else
747  {
748   so->SetString(s);
749  }
750 }
751 ///////////////////////////////////////////////////////////////////////////
752 TString AliAttrib::GetSlotName(Int_t j) const
753 {
754 // Provide the user defined name for the j-th (default j=1) slot. 
755 // Note : The first attribute slot is at j=1.
756
757  TString s="";
758  if (j<1) 
759  {
760   cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
761   return s;
762  }
763
764  if (fNames)
765  {
766   if (j<=fNames->GetSize())
767   {
768    TObjString* so=(TObjString*)fNames->At(j-1);
769    if (so) s=so->GetString();
770   }
771  }
772  return s;
773 }
774 ///////////////////////////////////////////////////////////////////////////
775 Int_t AliAttrib::GetSlotIndex(TString name) const
776 {
777 // Provide the slot index for the matching name.
778 // If no matching name is found, 0 is returned.
779 // Note : The first attribute slot is at j=1.
780
781  Int_t index=0;
782
783  if (fNames)
784  {
785   TString s;
786   Int_t size=fNames->GetSize();
787   for (Int_t i=0; i<size; i++)
788   {
789    TObjString* so=(TObjString*)fNames->At(i);
790    if (so) s=so->GetString();
791    if (s==name) index=i+1;
792   }
793  }
794  return index;
795 }
796 ///////////////////////////////////////////////////////////////////////////
797 void AliAttrib::List(Int_t j) const
798 {
799 // Provide attribute information for the j-th slot.
800 // The first slot is at j=1.
801 // In case j=0 (default) the data of all slots will be listed.
802
803  if (j<0) 
804  {
805   cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
806   return;
807  }
808
809  if (j>0)
810  {
811   if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
812   if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
813   if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
814   if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
815   TString s=GetSlotName(j);
816   if (s!="") cout << " name : " << s.Data();
817  }
818  else
819  {
820   Int_t ng=GetNgains();
821   Int_t no=GetNoffsets();
822   Int_t nf=0;
823   if (fCalflags) nf=fCalflags->GetSize();
824   Int_t nn=GetNnames();
825   Int_t n=ng;
826   if (n<no) n=no;
827   if (n<nn) n=nn;
828   if (n<nf) n=nf;
829   Int_t printf=0;
830   TString s;
831   for (Int_t i=1; i<=n; i++)
832   {
833    printf=0;
834    if (GetGainFlag(i))   {cout << " gain : " << GetGain(i); printf=1;}
835    if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
836    if (GetEdgeValue(i))  {cout << " edge : " << GetEdgeValue(i); printf=1;}
837    if (GetDeadValue(i))  {cout << " dead : " << GetDeadValue(i); printf=1;}
838    s=GetSlotName(i);
839    if (s!="") {cout << " name : " << s.Data(); printf=1;}
840    if (printf) cout << endl;
841   }
842  }
843
844 ///////////////////////////////////////////////////////////////////////////
845 void AliAttrib::Load(AliAttrib& a,Int_t j)
846 {
847 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
848 // 
849 // Note : if j=0, then all attributes of all slots are loaded
850 //
851 // The default is j=0.
852
853  if (j<0) 
854  {
855   cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
856   return;
857  }
858
859  Int_t n=0;
860
861  if (j==0) // load attributes for all slots
862  {
863   n=a.GetNgains();
864   for (Int_t ig=1; ig<=n; ig++)
865   {
866    if (a.GetGainFlag(ig))
867    {
868     SetGain(a.GetGain(ig),ig);
869    }
870    else
871    {
872     ResetGain(ig);
873    }
874   }
875   n=a.GetNoffsets();
876   for (Int_t io=1; io<=n; io++)
877   {
878    if (a.GetOffsetFlag(io))
879    {
880     SetOffset(a.GetOffset(io),io);
881    }
882    else
883    {
884     ResetOffset(io);
885    }
886   }
887   n=a.GetNcalflags();
888   for (Int_t ic=1; ic<=n; ic++)
889   {
890    SetEdgeValue(a.GetEdgeValue(ic),ic);
891    if (a.GetDeadValue(ic))
892    {
893     SetDead(ic);
894    }
895    else
896    {
897     SetAlive(ic);
898    }
899   }
900   n=a.GetNnames();
901   {
902    TString s;
903    for (Int_t in=1; in<=n; in++)
904    {
905     s=a.GetSlotName(in);
906     if (s!="") SetSlotName(s,in);
907    }
908   }
909  }
910  else // load attributes for specified j-th slot only
911  {
912   n=a.GetNgains();
913   if (j<=n)
914   {
915    if (a.GetGainFlag(j))
916    {
917     SetGain(a.GetGain(j),j);
918    }
919    else
920    {
921     ResetGain(j);
922    }
923   }
924   n=a.GetNoffsets();
925   if (j<=n)
926   {
927    if (a.GetOffsetFlag(j))
928    {
929     SetOffset(a.GetOffset(j),j);
930    }
931    else
932    {
933     ResetOffset(j);
934    } 
935   }
936   n=a.GetNcalflags();
937   if (j<=n)
938   {
939    SetEdgeValue(a.GetEdgeValue(j),j);
940    if (a.GetDeadValue(j))
941    {
942     SetDead(j);
943    }
944    else
945    {
946     SetAlive(j);
947    }
948   }
949   n=a.GetNnames();
950   {
951    TString s;
952    if (j<=n)
953    {
954     s=a.GetSlotName(j);
955     if (s!="") SetSlotName(s,j);
956    }
957   }
958  }
959 }
960 ///////////////////////////////////////////////////////////////////////////