1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
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.
30 // a.SetSlotName("PMT amplitude in Volt");
32 // a.SetSlotName("PMT amplitude in ADC",3);
34 // a.SetOffset(-22.5,2);
35 // a.SetSlotName("Time of flight in ns",2);
39 //--- Author: Nick van Eijndhoven 18-sep-2003 Utrecht University
40 //- Modified: NvE $Date$ Utrecht University
41 ///////////////////////////////////////////////////////////////////////////
43 #include "AliAttrib.h"
44 #include "Riostream.h"
46 ClassImp(AliAttrib) // Class implementation to enable ROOT I/O
48 AliAttrib::AliAttrib()
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.
59 ///////////////////////////////////////////////////////////////////////////
60 AliAttrib::~AliAttrib()
62 // Destructor to delete dynamically allocated memory
84 ///////////////////////////////////////////////////////////////////////////
85 AliAttrib::AliAttrib(const AliAttrib& a)
97 for (Int_t ig=1; ig<=n; ig++)
100 if (a.GetGainFlag(ig)) SetGain(val,ig);
104 for (Int_t io=1; io<=n; io++)
107 if (a.GetOffsetFlag(io)) SetOffset(val,io);
111 for (Int_t ic=1; ic<=n; ic++)
113 SetEdgeValue(a.GetEdgeValue(ic),ic);
114 if (a.GetDeadValue(ic)) SetDead(ic);
119 for (Int_t in=1; in<=n; in++)
122 if (s!="") SetSlotName(s,in);
125 ///////////////////////////////////////////////////////////////////////////
126 Int_t AliAttrib::GetNgains() const
128 // Provide the number of specified gains for this attribute.
130 if (fGains) n=fGains->GetSize();
133 ///////////////////////////////////////////////////////////////////////////
134 Int_t AliAttrib::GetNoffsets() const
136 // Provide the number of specified offsets for this attribute.
138 if (fOffsets) n=fOffsets->GetSize();
141 ///////////////////////////////////////////////////////////////////////////
142 Int_t AliAttrib::GetNcalflags() const
144 // Provide the number of specified calib. flags for this attribute.
146 if (fCalflags) n=fCalflags->GetSize();
149 ///////////////////////////////////////////////////////////////////////////
150 Int_t AliAttrib::GetNnames() const
152 // Provide the maximum number of specified names for this attribute.
154 if (fNames) n=fNames->GetSize();
157 ///////////////////////////////////////////////////////////////////////////
158 void AliAttrib::SetGain(Double_t gain,Int_t j)
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.
168 cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl;
174 fGains=new TArrayF(j);
177 Int_t size=fGains->GetSize();
184 fGains->AddAt(float(gain),j-1);
186 Int_t oflag=GetOffsetFlag(j);
188 SetCalFlags(1,oflag,j);
190 ///////////////////////////////////////////////////////////////////////////
191 void AliAttrib::SetGain(Double_t gain,TString name)
193 // Store gain value of the name-specified attribute slot.
195 // This procedure involves a slot-index search based on the specified name
196 // at each invokation. This may become slow in case many slots have been
197 // defined and/or when this procedure is invoked many times.
198 // In such cases it is preferable to use indexed addressing in the user code
199 // either directly or via a few invokations of GetSlotIndex().
201 Int_t j=GetSlotIndex(name);
202 if (j>0) SetGain(gain,j);
204 ///////////////////////////////////////////////////////////////////////////
205 void AliAttrib::SetOffset(Double_t off,Int_t j)
207 // Store offset value of the j-th (default j=1) attribute slot.
208 // Note : The first attribute slot is at j=1.
209 // In case the value of the index j exceeds the maximum number of reserved
210 // slots for offset values, the number of reserved slots for the offset
211 // values is increased automatically.
215 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
221 fOffsets=new TArrayF(j);
224 Int_t size=fOffsets->GetSize();
231 fOffsets->AddAt(float(off),j-1);
233 Int_t gflag=GetGainFlag(j);
235 SetCalFlags(gflag,1,j);
237 ///////////////////////////////////////////////////////////////////////////
238 void AliAttrib::SetOffset(Double_t off,TString name)
240 // Store offset value of the name-specified attribute slot.
242 // This procedure involves a slot-index search based on the specified name
243 // at each invokation. This may become slow in case many slots have been
244 // defined and/or when this procedure is invoked many times.
245 // In such cases it is preferable to use indexed addressing in the user code
246 // either directly or via a few invokations of GetSlotIndex().
248 Int_t j=GetSlotIndex(name);
249 if (j>0) SetOffset(off,j);
251 ///////////////////////////////////////////////////////////////////////////
252 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
254 // Store calibration flags of the j-th (default j=1) attribute slot.
255 // Note : The first attribute slot is at j=1.
256 // In case the value of the index j exceeds the maximum number of reserved
257 // slots for the calib. flags, the number of reserved slots for the calib.
258 // flags is increased automatically.
259 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
263 cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
269 fCalflags=new TArrayI(j);
272 Int_t size=fCalflags->GetSize();
279 Int_t edge=GetEdgeValue(j);
280 Int_t dead=GetDeadValue(j);
282 Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
284 fCalflags->AddAt(word,j-1);
286 ///////////////////////////////////////////////////////////////////////////
287 Int_t AliAttrib::GetGainFlag(Int_t j) const
289 // Provide gain flag of the j-th (default j=1) attribute slot.
291 // flag = 1 : Gain was set
292 // 0 : Gain was not set
294 // Note : The first attribute slot is at j=1.
295 // In case j is invalid, 0 is returned.
299 cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
305 if (j>0 && j<=(fCalflags->GetSize()))
307 Int_t word=fCalflags->At(j-1);
314 ///////////////////////////////////////////////////////////////////////////
315 Int_t AliAttrib::GetGainFlag(TString name) const
317 // Provide gain flag of the name-specified attribute slot.
319 // flag = 1 : Gain was set
320 // 0 : Gain was not set
323 // This procedure involves a slot-index search based on the specified name
324 // at each invokation. This may become slow in case many slots have been
325 // defined and/or when this procedure is invoked many times.
326 // In such cases it is preferable to use indexed addressing in the user code
327 // either directly or via a few invokations of GetSlotIndex().
329 Int_t j=GetSlotIndex(name);
331 if (j>0) flag=GetGainFlag(j);
334 ///////////////////////////////////////////////////////////////////////////
335 Int_t AliAttrib::GetOffsetFlag(Int_t j) const
337 // Provide offset flag of the j-th (default j=1) attribute slot.
339 // flag = 1 : Offset was set
340 // 0 : Offset was not set
342 // Note : The first attribute slot is at j=1.
343 // In case j is invalid, 0 is returned.
347 cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl;
354 if (j>0 && j<=(fCalflags->GetSize()))
356 Int_t word=fCalflags->At(j-1);
362 ///////////////////////////////////////////////////////////////////////////
363 Int_t AliAttrib::GetOffsetFlag(TString name) const
365 // Provide ofset flag of the name-specified attribute slot.
367 // flag = 1 : Offset was set
368 // 0 : Offset was not set
371 // This procedure involves a slot-index search based on the specified name
372 // at each invokation. This may become slow in case many slots have been
373 // defined and/or when this procedure is invoked many times.
374 // In such cases it is preferable to use indexed addressing in the user code
375 // either directly or via a few invokations of GetSlotIndex().
377 Int_t j=GetSlotIndex(name);
379 if (j>0) flag=GetOffsetFlag(j);
382 ///////////////////////////////////////////////////////////////////////////
383 Float_t AliAttrib::GetGain(Int_t j) const
385 // Provide gain value of the j-th (default j=1) attribute slot.
386 // The first attribute slot is at j=1.
387 // In case no gain value was set or the argument j is invalid, 0 is returned.
388 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
392 cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
399 if (j>0 && j<=(fGains->GetSize()))
401 if (GetGainFlag(j)) gain=fGains->At(j-1);
406 ///////////////////////////////////////////////////////////////////////////
407 Float_t AliAttrib::GetGain(TString name) const
409 // Provide gain value of the name-specified attribute slot.
411 // This procedure involves a slot-index search based on the specified name
412 // at each invokation. This may become slow in case many slots have been
413 // defined and/or when this procedure is invoked many times.
414 // In such cases it is preferable to use indexed addressing in the user code
415 // either directly or via a few invokations of GetSlotIndex().
417 Int_t j=GetSlotIndex(name);
419 if (j>0) gain=GetGain(j);
422 ///////////////////////////////////////////////////////////////////////////
423 Float_t AliAttrib::GetOffset(Int_t j) const
425 // Provide offset value of the j-th (default j=1) attribute slot.
426 // The first attribute slot at j=1.
427 // In case no offset value was set or the argument j is invalid, 0 is returned.
428 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
432 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
439 if (j>0 && j<=(fOffsets->GetSize()))
441 if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
446 ///////////////////////////////////////////////////////////////////////////
447 Float_t AliAttrib::GetOffset(TString name) const
449 // Provide offset value of the name-specified attribute slot.
451 // This procedure involves a slot-index search based on the specified name
452 // at each invokation. This may become slow in case many slots have been
453 // defined and/or when this procedure is invoked many times.
454 // In such cases it is preferable to use indexed addressing in the user code
455 // either directly or via a few invokations of GetSlotIndex().
457 Int_t j=GetSlotIndex(name);
459 if (j>0) offset=GetOffset(j);
462 ///////////////////////////////////////////////////////////////////////////
463 void AliAttrib::ResetGain(Int_t j)
465 // Reset the gain value of the j-th (default j=1) attribute slot.
466 // Notes : The first attribute slot is at j=1.
467 // j=0 ==> All gain values will be reset.
471 Int_t size=fGains->GetSize();
473 if ((j>=0) && (j<=size))
477 fGains->AddAt(0,j-1);
478 Int_t oflag=GetOffsetFlag(j);
479 SetCalFlags(0,oflag,j);
483 for (Int_t i=0; i<size; i++)
486 Int_t oflag=GetOffsetFlag(i);
487 SetCalFlags(0,oflag,i);
493 cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
497 ///////////////////////////////////////////////////////////////////////////
498 void AliAttrib::ResetGain(TString name)
500 // Reset the gain value of the name-specified attribute slot.
502 // This procedure involves a slot-index search based on the specified name
503 // at each invokation. This may become slow in case many slots have been
504 // defined and/or when this procedure is invoked many times.
505 // In such cases it is preferable to use indexed addressing in the user code
506 // either directly or via a few invokations of GetSlotIndex().
508 Int_t j=GetSlotIndex(name);
509 if (j>0) ResetGain(j);
511 ///////////////////////////////////////////////////////////////////////////
512 void AliAttrib::ResetOffset(Int_t j)
514 // Reset the offset value of the j-th (default j=1) attribute slot.
515 // Notes : The first attribute slot is at j=1.
516 // j=0 ==> All offset values will be reset.
518 if (!fOffsets) return;
520 Int_t size=fOffsets->GetSize();
522 if ((j>=0) && (j<=size))
526 fOffsets->AddAt(0,j-1);
527 Int_t gflag=GetGainFlag(j);
528 SetCalFlags(gflag,0,j);
532 for (Int_t i=0; i<size; i++)
534 fOffsets->AddAt(0,i);
535 Int_t gflag=GetGainFlag(i);
536 SetCalFlags(gflag,0,i);
542 cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
546 ///////////////////////////////////////////////////////////////////////////
547 void AliAttrib::ResetOffset(TString name)
549 // Reset the offset value of the name-specified attribute slot.
551 // This procedure involves a slot-index search based on the specified name
552 // at each invokation. This may become slow in case many slots have been
553 // defined and/or when this procedure is invoked many times.
554 // In such cases it is preferable to use indexed addressing in the user code
555 // either directly or via a few invokations of GetSlotIndex().
557 Int_t j=GetSlotIndex(name);
558 if (j>0) ResetOffset(j);
560 ///////////////////////////////////////////////////////////////////////////
561 void AliAttrib::DeleteCalibrations(Int_t mode)
563 // User selected delete of all gains and/or offsets.
564 // mode = 0 : All attributes (names, gains, offsets, edge and dead values) are deleted.
565 // 1 : Only the gains are deleted.
566 // 2 : Only the offsets are deleted.
567 // 3 : Both gains and offsets are deleted, but names, edge and dead values are kept.
569 // The default when invoking DeleteCalibrations() corresponds to mode=0.
571 if (mode<0 || mode>3)
573 cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
574 cout << " Default mode=0 will be used." << endl;
578 if (mode==0 || mode==3)
592 if (fCalflags && mode==0)
597 if (fNames && mode==0)
624 ///////////////////////////////////////////////////////////////////////////
625 void AliAttrib::SetDead(Int_t j)
627 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
628 // Note : The first attribute slot is at j=1.
629 // In case the value of the index j exceeds the maximum number of reserved
630 // slots for the flags, the number of reserved slots for the flags
631 // is increased automatically.
632 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
636 cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
642 fCalflags=new TArrayI(j);
645 Int_t size=fCalflags->GetSize();
653 Int_t oflag=GetOffsetFlag(j);
654 Int_t gflag=GetGainFlag(j);
655 Int_t edge=GetEdgeValue(j);
657 Int_t word=1000*edge+100*dead+10*gflag+oflag;
659 fCalflags->AddAt(word,j-1);
661 ///////////////////////////////////////////////////////////////////////////
662 void AliAttrib::SetDead(TString name)
664 // Set the dead flag to 1 for the name-specified attribute slot.
666 // This procedure involves a slot-index search based on the specified name
667 // at each invokation. This may become slow in case many slots have been
668 // defined and/or when this procedure is invoked many times.
669 // In such cases it is preferable to use indexed addressing in the user code
670 // either directly or via a few invokations of GetSlotIndex().
672 Int_t j=GetSlotIndex(name);
675 ///////////////////////////////////////////////////////////////////////////
676 void AliAttrib::SetAlive(Int_t j)
678 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
679 // Note : The first attribute slot is at j=1.
680 // In case the value of the index j exceeds the maximum number of reserved
681 // slots for the flags, no action is taken since by default the dead flag is 0.
682 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
686 cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
690 if (!fCalflags || j>fCalflags->GetSize()) return;
693 Int_t oflag=GetOffsetFlag(j);
694 Int_t gflag=GetGainFlag(j);
695 Int_t edge=GetEdgeValue(j);
697 Int_t word=1000*edge+100*dead+10*gflag+oflag;
699 fCalflags->AddAt(word,j-1);
701 ///////////////////////////////////////////////////////////////////////////
702 void AliAttrib::SetAlive(TString name)
704 // Set the dead flag to 0 for the name-specified attribute slot.
706 // This procedure involves a slot-index search based on the specified name
707 // at each invokation. This may become slow in case many slots have been
708 // defined and/or when this procedure is invoked many times.
709 // In such cases it is preferable to use indexed addressing in the user code
710 // either directly or via a few invokations of GetSlotIndex().
712 Int_t j=GetSlotIndex(name);
713 if (j>0) SetAlive(j);
715 ///////////////////////////////////////////////////////////////////////////
716 void AliAttrib::SetEdgeOn(Int_t j)
718 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
719 // Note : The first attribute slot is at j=1.
720 // In case the value of the index j exceeds the maximum number of reserved
721 // slots for the flags, the number of reserved slots for the flags
722 // is increased automatically.
723 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
727 cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
733 ///////////////////////////////////////////////////////////////////////////
734 void AliAttrib::SetEdgeOn(TString name)
736 // Set the edge value to 1 for the name-specified attribute slot.
738 // This procedure involves a slot-index search based on the specified name
739 // at each invokation. This may become slow in case many slots have been
740 // defined and/or when this procedure is invoked many times.
741 // In such cases it is preferable to use indexed addressing in the user code
742 // either directly or via a few invokations of GetSlotIndex().
744 Int_t j=GetSlotIndex(name);
745 if (j>0) SetEdgeOn(j);
747 ///////////////////////////////////////////////////////////////////////////
748 void AliAttrib::SetEdgeOff(Int_t j)
750 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
751 // Note : The first attribute slot is at j=1.
752 // In case the value of the index j exceeds the maximum number of reserved
753 // slots for the flags, no action is taken since by default the edge flag is 0.
754 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
758 cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
762 if (!fCalflags || j>fCalflags->GetSize()) return;
766 ///////////////////////////////////////////////////////////////////////////
767 void AliAttrib::SetEdgeOff(TString name)
769 // Set the edge value to 0 for the name-specified attribute slot.
771 // This procedure involves a slot-index search based on the specified name
772 // at each invokation. This may become slow in case many slots have been
773 // defined and/or when this procedure is invoked many times.
774 // In such cases it is preferable to use indexed addressing in the user code
775 // either directly or via a few invokations of GetSlotIndex().
777 Int_t j=GetSlotIndex(name);
778 if (j>0) SetEdgeOff(j);
780 ///////////////////////////////////////////////////////////////////////////
781 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
783 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
784 // Note : The first attribute slot is at j=1.
785 // In case the value of the index j exceeds the maximum number of reserved
786 // slots for the flags, the number of reserved slots for the flags
787 // is increased automatically.
788 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
792 cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
798 fCalflags=new TArrayI(j);
801 Int_t size=fCalflags->GetSize();
809 Int_t dead=GetDeadValue(j);
810 Int_t gflag=GetGainFlag(j);
811 Int_t oflag=GetOffsetFlag(j);
813 Int_t word=1000*edge+100*dead+10*gflag+oflag;
815 fCalflags->AddAt(word,j-1);
817 ///////////////////////////////////////////////////////////////////////////
818 void AliAttrib::SetEdgeValue(Int_t val,TString name)
820 // Set the edge value to "val" for the name-specified attribute slot.
822 // This procedure involves a slot-index search based on the specified name
823 // at each invokation. This may become slow in case many slots have been
824 // defined and/or when this procedure is invoked many times.
825 // In such cases it is preferable to use indexed addressing in the user code
826 // either directly or via a few invokations of GetSlotIndex().
828 Int_t j=GetSlotIndex(name);
829 if (j>0) SetEdgeValue(val,j);
831 ///////////////////////////////////////////////////////////////////////////
832 void AliAttrib::IncreaseEdgeValue(Int_t j)
834 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
835 // Note : The first attribute slot is at j=1.
836 // In case the value of the index j exceeds the maximum number of reserved
837 // slots for the flags, the number of reserved slots for the flags
838 // is increased automatically.
839 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
843 cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
847 Int_t edge=GetEdgeValue();
848 SetEdgeValue(edge+1,j);
850 ///////////////////////////////////////////////////////////////////////////
851 void AliAttrib::IncreaseEdgeValue(TString name)
853 // Increase the edge value by 1 for the name-specified attribute slot.
855 // This procedure involves a slot-index search based on the specified name
856 // at each invokation. This may become slow in case many slots have been
857 // defined and/or when this procedure is invoked many times.
858 // In such cases it is preferable to use indexed addressing in the user code
859 // either directly or via a few invokations of GetSlotIndex().
861 Int_t j=GetSlotIndex(name);
862 if (j>0) IncreaseEdgeValue(j);
864 ///////////////////////////////////////////////////////////////////////////
865 void AliAttrib::DecreaseEdgeValue(Int_t j)
867 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
868 // Note : The first attribute slot is at j=1.
869 // In case the value of the index j exceeds the maximum number of reserved
870 // slots for the flags, the number of reserved slots for the flags
871 // is increased automatically.
872 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
876 cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
880 Int_t edge=GetEdgeValue();
881 SetEdgeValue(edge-1,j);
883 ///////////////////////////////////////////////////////////////////////////
884 void AliAttrib::DecreaseEdgeValue(TString name)
886 // Decrease the edge value by 1 for the name-specified attribute slot.
888 // This procedure involves a slot-index search based on the specified name
889 // at each invokation. This may become slow in case many slots have been
890 // defined and/or when this procedure is invoked many times.
891 // In such cases it is preferable to use indexed addressing in the user code
892 // either directly or via a few invokations of GetSlotIndex().
894 Int_t j=GetSlotIndex(name);
895 if (j>0) DecreaseEdgeValue(j);
897 ///////////////////////////////////////////////////////////////////////////
898 Int_t AliAttrib::GetEdgeValue(Int_t j) const
900 // Provide edge value of the j-th (default j=1) attribute slot.
901 // Note : The first attribute slot is at j=1.
902 // In case j is invalid, 0 is returned.
906 cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
913 if (j>0 && j<=(fCalflags->GetSize()))
915 Int_t word=fCalflags->At(j-1);
921 ///////////////////////////////////////////////////////////////////////////
922 Int_t AliAttrib::GetEdgeValue(TString name) const
924 // Provide edge value of the name-specified attribute slot.
926 // This procedure involves a slot-index search based on the specified name
927 // at each invokation. This may become slow in case many slots have been
928 // defined and/or when this procedure is invoked many times.
929 // In such cases it is preferable to use indexed addressing in the user code
930 // either directly or via a few invokations of GetSlotIndex().
932 Int_t j=GetSlotIndex(name);
934 if (j>0) val=GetEdgeValue(j);
937 ///////////////////////////////////////////////////////////////////////////
938 Int_t AliAttrib::GetDeadValue(Int_t j) const
940 // Provide dead value of the j-th (default j=1) attribute slot.
941 // Note : The first attribute slot is at j=1.
942 // In case j is invalid, 0 is returned.
946 cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
953 if (j>0 && j<=(fCalflags->GetSize()))
955 Int_t word=fCalflags->At(j-1);
962 ///////////////////////////////////////////////////////////////////////////
963 Int_t AliAttrib::GetDeadValue(TString name) const
965 // Provide dead value of the name-specified attribute slot.
967 // This procedure involves a slot-index search based on the specified name
968 // at each invokation. This may become slow in case many slots have been
969 // defined and/or when this procedure is invoked many times.
970 // In such cases it is preferable to use indexed addressing in the user code
971 // either directly or via a few invokations of GetSlotIndex().
973 Int_t j=GetSlotIndex(name);
975 if (j>0) val=GetDeadValue(j);
978 ///////////////////////////////////////////////////////////////////////////
979 void AliAttrib::SetSlotName(TString s,Int_t j)
981 // Set a user defined name for the j-th (default j=1) slot.
982 // Note : The first attribute slot is at j=1.
986 cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
992 fNames=new TObjArray(j);
996 if (j>fNames->GetSize()) fNames->Expand(j);
998 TObjString* so=(TObjString*)fNames->At(j-1);
1001 so=new TObjString(s.Data());
1002 fNames->AddAt(so,j-1);
1009 ///////////////////////////////////////////////////////////////////////////
1010 TString AliAttrib::GetSlotName(Int_t j) const
1012 // Provide the user defined name for the j-th (default j=1) slot.
1013 // Note : The first attribute slot is at j=1.
1018 cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
1024 if (j<=fNames->GetSize())
1026 TObjString* so=(TObjString*)fNames->At(j-1);
1027 if (so) s=so->GetString();
1032 ///////////////////////////////////////////////////////////////////////////
1033 Int_t AliAttrib::GetSlotIndex(TString name) const
1035 // Provide the slot index for the matching name.
1036 // If no matching name is found, 0 is returned.
1037 // Note : The first attribute slot is at j=1.
1044 Int_t size=fNames->GetSize();
1045 for (Int_t i=0; i<size; i++)
1047 TObjString* so=(TObjString*)fNames->At(i);
1048 if (so) s=so->GetString();
1049 if (s==name) index=i+1;
1054 ///////////////////////////////////////////////////////////////////////////
1055 void AliAttrib::List(Int_t j) const
1057 // Provide attribute information for the j-th slot.
1058 // The first slot is at j=1.
1059 // In case j=0 (default) the data of all slots will be listed.
1063 cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
1069 if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
1070 if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
1071 if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
1072 if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
1073 TString s=GetSlotName(j);
1074 if (s!="") cout << " name : " << s.Data();
1078 Int_t ng=GetNgains();
1079 Int_t no=GetNoffsets();
1081 if (fCalflags) nf=fCalflags->GetSize();
1082 Int_t nn=GetNnames();
1089 for (Int_t i=1; i<=n; i++)
1092 if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;}
1093 if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
1094 if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;}
1095 if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;}
1097 if (s!="") {cout << " name : " << s.Data(); printf=1;}
1098 if (printf) cout << endl;
1102 ///////////////////////////////////////////////////////////////////////////
1103 void AliAttrib::List(TString name) const
1105 // Provide attribute information for the name-specified slot.
1107 // This procedure involves a slot-index search based on the specified name
1108 // at each invokation. This may become slow in case many slots have been
1109 // defined and/or when this procedure is invoked many times.
1110 // In such cases it is preferable to use indexed addressing in the user code
1111 // either directly or via a few invokations of GetSlotIndex().
1113 Int_t j=GetSlotIndex(name);
1116 ///////////////////////////////////////////////////////////////////////////
1117 void AliAttrib::Load(AliAttrib& a,Int_t j)
1119 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
1121 // Note : if j=0, then all attributes of all slots are loaded
1123 // The default is j=0.
1127 cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
1133 if (j==0) // load attributes for all slots
1136 for (Int_t ig=1; ig<=n; ig++)
1138 if (a.GetGainFlag(ig))
1140 SetGain(a.GetGain(ig),ig);
1148 for (Int_t io=1; io<=n; io++)
1150 if (a.GetOffsetFlag(io))
1152 SetOffset(a.GetOffset(io),io);
1160 for (Int_t ic=1; ic<=n; ic++)
1162 SetEdgeValue(a.GetEdgeValue(ic),ic);
1163 if (a.GetDeadValue(ic))
1175 for (Int_t in=1; in<=n; in++)
1177 s=a.GetSlotName(in);
1178 if (s!="") SetSlotName(s,in);
1182 else // load attributes for specified j-th slot only
1187 if (a.GetGainFlag(j))
1189 SetGain(a.GetGain(j),j);
1199 if (a.GetOffsetFlag(j))
1201 SetOffset(a.GetOffset(j),j);
1211 SetEdgeValue(a.GetEdgeValue(j),j);
1212 if (a.GetDeadValue(j))
1227 if (s!="") SetSlotName(s,j);
1232 ///////////////////////////////////////////////////////////////////////////
1233 void AliAttrib::Load(AliAttrib& a,TString name)
1235 // Load attributes of the name-specified slot of the input AliAttrib into
1236 // this AliAttrib object.
1238 // This procedure involves a slot-index search based on the specified name
1239 // at each invokation. This may become slow in case many slots have been
1240 // defined and/or when this procedure is invoked many times.
1241 // In such cases it is preferable to use indexed addressing in the user code
1242 // either directly or via a few invokations of GetSlotIndex().
1244 Int_t j=GetSlotIndex(name);
1247 ///////////////////////////////////////////////////////////////////////////