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.
29 // a.SetSlotName("PMT amplitude in Volt");
31 // a.SetSlotName("Time of flight in ns",2);
32 // a.SetOffset(-22.5,2);
33 // a.SetSlotName("PMT amplitude in ADC",3);
35 // a.SetSlotName("TDC",4);
36 // a.SetOffset(10.75,"TDC");
41 //--- Author: Nick van Eijndhoven 18-sep-2003 Utrecht University
42 //- Modified: NvE $Date$ Utrecht University
43 ///////////////////////////////////////////////////////////////////////////
45 #include "AliAttrib.h"
46 #include "Riostream.h"
48 ClassImp(AliAttrib) // Class implementation to enable ROOT I/O
50 AliAttrib::AliAttrib()
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.
63 ///////////////////////////////////////////////////////////////////////////
64 AliAttrib::~AliAttrib()
66 // Destructor to delete dynamically allocated memory
98 ///////////////////////////////////////////////////////////////////////////
99 AliAttrib::AliAttrib(const AliAttrib& a)
113 for (Int_t ig=1; ig<=n; ig++)
116 if (a.GetGainFlag(ig)) SetGain(val,ig);
120 for (Int_t io=1; io<=n; io++)
123 if (a.GetOffsetFlag(io)) SetOffset(val,io);
127 for (Int_t ic=1; ic<=n; ic++)
129 SetEdgeValue(a.GetEdgeValue(ic),ic);
130 if (a.GetDeadValue(ic)) SetDead(ic);
135 for (Int_t in=1; in<=n; in++)
138 if (s!="") SetSlotName(s,in);
142 for (Int_t icalf=1; icalf<=n; icalf++)
144 TF1* f=a.GetCalFunction(icalf);
145 if (f) SetCalFunction(f,icalf);
148 n=a.GetNdecalfuncs();
149 for (Int_t idecalf=1; idecalf<=n; idecalf++)
151 TF1* f=a.GetDecalFunction(idecalf);
152 if (f) SetDecalFunction(f,idecalf);
155 ///////////////////////////////////////////////////////////////////////////
156 Int_t AliAttrib::GetNgains() const
158 // Provide the number of specified gains for this attribute.
160 if (fGains) n=fGains->GetSize();
163 ///////////////////////////////////////////////////////////////////////////
164 Int_t AliAttrib::GetNoffsets() const
166 // Provide the number of specified offsets for this attribute.
168 if (fOffsets) n=fOffsets->GetSize();
171 ///////////////////////////////////////////////////////////////////////////
172 Int_t AliAttrib::GetNcalflags() const
174 // Provide the number of specified calib. flags for this attribute.
176 if (fCalflags) n=fCalflags->GetSize();
179 ///////////////////////////////////////////////////////////////////////////
180 Int_t AliAttrib::GetNnames() const
182 // Provide the maximum number of specified names for this attribute.
184 if (fNames) n=fNames->GetSize();
187 ///////////////////////////////////////////////////////////////////////////
188 void AliAttrib::SetGain(Double_t gain,Int_t j)
190 // Store gain value of the j-th (default j=1) attribute slot.
191 // Note : The first attribute slot is at j=1.
192 // In case the value of the index j exceeds the maximum number of reserved
193 // slots for gain values, the number of reserved slots for the gain
194 // values is increased automatically.
198 cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl;
204 fGains=new TArrayF(j);
207 Int_t size=fGains->GetSize();
214 fGains->AddAt(float(gain),j-1);
216 Int_t oflag=GetOffsetFlag(j);
218 SetCalFlags(1,oflag,j);
220 ///////////////////////////////////////////////////////////////////////////
221 void AliAttrib::SetGain(Double_t gain,TString name)
223 // Store gain value of the name-specified attribute slot.
225 // This procedure involves a slot-index search based on the specified name
226 // at each invokation. This may become slow in case many slots have been
227 // defined and/or when this procedure is invoked many times.
228 // In such cases it is preferable to use indexed addressing in the user code
229 // either directly or via a few invokations of GetSlotIndex().
231 Int_t j=GetSlotIndex(name);
232 if (j>0) SetGain(gain,j);
234 ///////////////////////////////////////////////////////////////////////////
235 void AliAttrib::SetOffset(Double_t off,Int_t j)
237 // Store offset value of the j-th (default j=1) attribute slot.
238 // Note : The first attribute slot is at j=1.
239 // In case the value of the index j exceeds the maximum number of reserved
240 // slots for offset values, the number of reserved slots for the offset
241 // values is increased automatically.
245 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
251 fOffsets=new TArrayF(j);
254 Int_t size=fOffsets->GetSize();
261 fOffsets->AddAt(float(off),j-1);
263 Int_t gflag=GetGainFlag(j);
265 SetCalFlags(gflag,1,j);
267 ///////////////////////////////////////////////////////////////////////////
268 void AliAttrib::SetOffset(Double_t off,TString name)
270 // Store offset value of the name-specified attribute slot.
272 // This procedure involves a slot-index search based on the specified name
273 // at each invokation. This may become slow in case many slots have been
274 // defined and/or when this procedure is invoked many times.
275 // In such cases it is preferable to use indexed addressing in the user code
276 // either directly or via a few invokations of GetSlotIndex().
278 Int_t j=GetSlotIndex(name);
279 if (j>0) SetOffset(off,j);
281 ///////////////////////////////////////////////////////////////////////////
282 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
284 // Store calibration flags of the j-th (default j=1) attribute slot.
285 // Note : The first attribute slot is at j=1.
286 // In case the value of the index j exceeds the maximum number of reserved
287 // slots for the calib. flags, the number of reserved slots for the calib.
288 // flags is increased automatically.
289 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
293 cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
299 fCalflags=new TArrayI(j);
302 Int_t size=fCalflags->GetSize();
309 Int_t edge=GetEdgeValue(j);
310 Int_t dead=GetDeadValue(j);
312 Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
314 fCalflags->AddAt(word,j-1);
316 ///////////////////////////////////////////////////////////////////////////
317 Int_t AliAttrib::GetGainFlag(Int_t j) const
319 // Provide gain flag of the j-th (default j=1) attribute slot.
321 // flag = 1 : Gain was set
322 // 0 : Gain was not set
324 // Note : The first attribute slot is at j=1.
325 // In case j is invalid, 0 is returned.
329 cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
335 if (j>0 && j<=(fCalflags->GetSize()))
337 Int_t word=fCalflags->At(j-1);
344 ///////////////////////////////////////////////////////////////////////////
345 Int_t AliAttrib::GetGainFlag(TString name) const
347 // Provide gain flag of the name-specified attribute slot.
349 // flag = 1 : Gain was set
350 // 0 : Gain was not set
353 // This procedure involves a slot-index search based on the specified name
354 // at each invokation. This may become slow in case many slots have been
355 // defined and/or when this procedure is invoked many times.
356 // In such cases it is preferable to use indexed addressing in the user code
357 // either directly or via a few invokations of GetSlotIndex().
359 Int_t j=GetSlotIndex(name);
361 if (j>0) flag=GetGainFlag(j);
364 ///////////////////////////////////////////////////////////////////////////
365 Int_t AliAttrib::GetOffsetFlag(Int_t j) const
367 // Provide offset flag of the j-th (default j=1) attribute slot.
369 // flag = 1 : Offset was set
370 // 0 : Offset was not set
372 // Note : The first attribute slot is at j=1.
373 // In case j is invalid, 0 is returned.
377 cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl;
384 if (j>0 && j<=(fCalflags->GetSize()))
386 Int_t word=fCalflags->At(j-1);
392 ///////////////////////////////////////////////////////////////////////////
393 Int_t AliAttrib::GetOffsetFlag(TString name) const
395 // Provide ofset flag of the name-specified attribute slot.
397 // flag = 1 : Offset was set
398 // 0 : Offset was not set
401 // This procedure involves a slot-index search based on the specified name
402 // at each invokation. This may become slow in case many slots have been
403 // defined and/or when this procedure is invoked many times.
404 // In such cases it is preferable to use indexed addressing in the user code
405 // either directly or via a few invokations of GetSlotIndex().
407 Int_t j=GetSlotIndex(name);
409 if (j>0) flag=GetOffsetFlag(j);
412 ///////////////////////////////////////////////////////////////////////////
413 Float_t AliAttrib::GetGain(Int_t j) const
415 // Provide gain value of the j-th (default j=1) attribute slot.
416 // The first attribute slot is at j=1.
417 // In case no gain value was set or the argument j is invalid, 0 is returned.
418 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
422 cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
429 if (j>0 && j<=(fGains->GetSize()))
431 if (GetGainFlag(j)) gain=fGains->At(j-1);
436 ///////////////////////////////////////////////////////////////////////////
437 Float_t AliAttrib::GetGain(TString name) const
439 // Provide gain value of the name-specified attribute slot.
441 // This procedure involves a slot-index search based on the specified name
442 // at each invokation. This may become slow in case many slots have been
443 // defined and/or when this procedure is invoked many times.
444 // In such cases it is preferable to use indexed addressing in the user code
445 // either directly or via a few invokations of GetSlotIndex().
447 Int_t j=GetSlotIndex(name);
449 if (j>0) gain=GetGain(j);
452 ///////////////////////////////////////////////////////////////////////////
453 Float_t AliAttrib::GetOffset(Int_t j) const
455 // Provide offset value of the j-th (default j=1) attribute slot.
456 // The first attribute slot at j=1.
457 // In case no offset value was set or the argument j is invalid, 0 is returned.
458 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
462 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
469 if (j>0 && j<=(fOffsets->GetSize()))
471 if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
476 ///////////////////////////////////////////////////////////////////////////
477 Float_t AliAttrib::GetOffset(TString name) const
479 // Provide offset value of the name-specified attribute slot.
481 // This procedure involves a slot-index search based on the specified name
482 // at each invokation. This may become slow in case many slots have been
483 // defined and/or when this procedure is invoked many times.
484 // In such cases it is preferable to use indexed addressing in the user code
485 // either directly or via a few invokations of GetSlotIndex().
487 Int_t j=GetSlotIndex(name);
489 if (j>0) offset=GetOffset(j);
492 ///////////////////////////////////////////////////////////////////////////
493 void AliAttrib::ResetGain(Int_t j)
495 // Reset the gain value of the j-th (default j=1) attribute slot.
496 // Notes : The first attribute slot is at j=1.
497 // j=0 ==> All gain values will be reset.
501 Int_t size=fGains->GetSize();
503 if ((j>=0) && (j<=size))
507 fGains->AddAt(0,j-1);
508 Int_t oflag=GetOffsetFlag(j);
509 SetCalFlags(0,oflag,j);
513 for (Int_t i=0; i<size; i++)
516 Int_t oflag=GetOffsetFlag(i);
517 SetCalFlags(0,oflag,i);
523 cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
527 ///////////////////////////////////////////////////////////////////////////
528 void AliAttrib::ResetGain(TString name)
530 // Reset the gain value of the name-specified attribute slot.
532 // This procedure involves a slot-index search based on the specified name
533 // at each invokation. This may become slow in case many slots have been
534 // defined and/or when this procedure is invoked many times.
535 // In such cases it is preferable to use indexed addressing in the user code
536 // either directly or via a few invokations of GetSlotIndex().
538 Int_t j=GetSlotIndex(name);
539 if (j>0) ResetGain(j);
541 ///////////////////////////////////////////////////////////////////////////
542 void AliAttrib::ResetOffset(Int_t j)
544 // Reset the offset value of the j-th (default j=1) attribute slot.
545 // Notes : The first attribute slot is at j=1.
546 // j=0 ==> All offset values will be reset.
548 if (!fOffsets) return;
550 Int_t size=fOffsets->GetSize();
552 if ((j>=0) && (j<=size))
556 fOffsets->AddAt(0,j-1);
557 Int_t gflag=GetGainFlag(j);
558 SetCalFlags(gflag,0,j);
562 for (Int_t i=0; i<size; i++)
564 fOffsets->AddAt(0,i);
565 Int_t gflag=GetGainFlag(i);
566 SetCalFlags(gflag,0,i);
572 cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
576 ///////////////////////////////////////////////////////////////////////////
577 void AliAttrib::ResetOffset(TString name)
579 // Reset the offset value of the name-specified attribute slot.
581 // This procedure involves a slot-index search based on the specified name
582 // at each invokation. This may become slow in case many slots have been
583 // defined and/or when this procedure is invoked many times.
584 // In such cases it is preferable to use indexed addressing in the user code
585 // either directly or via a few invokations of GetSlotIndex().
587 Int_t j=GetSlotIndex(name);
588 if (j>0) ResetOffset(j);
590 ///////////////////////////////////////////////////////////////////////////
591 void AliAttrib::DeleteCalibrations(Int_t mode)
593 // User selected delete of all gains and/or offsets.
594 // mode = 0 : All attributes (names,gains,offsets,(de)calfuncs, edge and dead values) are deleted.
595 // 1 : Only the gains are deleted.
596 // 2 : Only the offsets are deleted.
597 // 3 : Gains, offsets and (de)calfuncs are deleted, but names, edge and dead values are kept.
598 // 4 : Only the calib. functions are deleted.
599 // 5 : Only the de-calib. functions are deleted.
600 // 6 : Only the calib. and de-calib. functions are deleted.
602 // The default when invoking DeleteCalibrations() corresponds to mode=0.
604 if (mode<0 || mode>6)
606 cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
607 cout << " Default mode=0 will be used." << endl;
611 if (mode==0 || mode==3)
625 if (fCalflags && mode==0)
630 if (fNames && mode==0)
668 if (mode==4 || mode==6)
677 if (mode==5 || mode==6)
686 ///////////////////////////////////////////////////////////////////////////
687 void AliAttrib::SetDead(Int_t j)
689 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
690 // Note : The first attribute slot is at j=1.
691 // In case the value of the index j exceeds the maximum number of reserved
692 // slots for the flags, the number of reserved slots for the flags
693 // is increased automatically.
694 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
698 cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
704 fCalflags=new TArrayI(j);
707 Int_t size=fCalflags->GetSize();
715 Int_t oflag=GetOffsetFlag(j);
716 Int_t gflag=GetGainFlag(j);
717 Int_t edge=GetEdgeValue(j);
719 Int_t word=1000*edge+100*dead+10*gflag+oflag;
721 fCalflags->AddAt(word,j-1);
723 ///////////////////////////////////////////////////////////////////////////
724 void AliAttrib::SetDead(TString name)
726 // Set the dead flag to 1 for the name-specified attribute slot.
728 // This procedure involves a slot-index search based on the specified name
729 // at each invokation. This may become slow in case many slots have been
730 // defined and/or when this procedure is invoked many times.
731 // In such cases it is preferable to use indexed addressing in the user code
732 // either directly or via a few invokations of GetSlotIndex().
734 Int_t j=GetSlotIndex(name);
737 ///////////////////////////////////////////////////////////////////////////
738 void AliAttrib::SetAlive(Int_t j)
740 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
741 // Note : The first attribute slot is at j=1.
742 // In case the value of the index j exceeds the maximum number of reserved
743 // slots for the flags, no action is taken since by default the dead flag is 0.
744 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
748 cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
752 if (!fCalflags || j>fCalflags->GetSize()) return;
755 Int_t oflag=GetOffsetFlag(j);
756 Int_t gflag=GetGainFlag(j);
757 Int_t edge=GetEdgeValue(j);
759 Int_t word=1000*edge+100*dead+10*gflag+oflag;
761 fCalflags->AddAt(word,j-1);
763 ///////////////////////////////////////////////////////////////////////////
764 void AliAttrib::SetAlive(TString name)
766 // Set the dead flag to 0 for the name-specified attribute slot.
768 // This procedure involves a slot-index search based on the specified name
769 // at each invokation. This may become slow in case many slots have been
770 // defined and/or when this procedure is invoked many times.
771 // In such cases it is preferable to use indexed addressing in the user code
772 // either directly or via a few invokations of GetSlotIndex().
774 Int_t j=GetSlotIndex(name);
775 if (j>0) SetAlive(j);
777 ///////////////////////////////////////////////////////////////////////////
778 void AliAttrib::SetEdgeOn(Int_t j)
780 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
781 // Note : The first attribute slot is at j=1.
782 // In case the value of the index j exceeds the maximum number of reserved
783 // slots for the flags, the number of reserved slots for the flags
784 // is increased automatically.
785 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
789 cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
795 ///////////////////////////////////////////////////////////////////////////
796 void AliAttrib::SetEdgeOn(TString name)
798 // Set the edge value to 1 for the name-specified attribute slot.
800 // This procedure involves a slot-index search based on the specified name
801 // at each invokation. This may become slow in case many slots have been
802 // defined and/or when this procedure is invoked many times.
803 // In such cases it is preferable to use indexed addressing in the user code
804 // either directly or via a few invokations of GetSlotIndex().
806 Int_t j=GetSlotIndex(name);
807 if (j>0) SetEdgeOn(j);
809 ///////////////////////////////////////////////////////////////////////////
810 void AliAttrib::SetEdgeOff(Int_t j)
812 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
813 // Note : The first attribute slot is at j=1.
814 // In case the value of the index j exceeds the maximum number of reserved
815 // slots for the flags, no action is taken since by default the edge flag is 0.
816 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
820 cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
824 if (!fCalflags || j>fCalflags->GetSize()) return;
828 ///////////////////////////////////////////////////////////////////////////
829 void AliAttrib::SetEdgeOff(TString name)
831 // Set the edge value to 0 for the name-specified attribute slot.
833 // This procedure involves a slot-index search based on the specified name
834 // at each invokation. This may become slow in case many slots have been
835 // defined and/or when this procedure is invoked many times.
836 // In such cases it is preferable to use indexed addressing in the user code
837 // either directly or via a few invokations of GetSlotIndex().
839 Int_t j=GetSlotIndex(name);
840 if (j>0) SetEdgeOff(j);
842 ///////////////////////////////////////////////////////////////////////////
843 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
845 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
846 // Note : The first attribute slot is at j=1.
847 // In case the value of the index j exceeds the maximum number of reserved
848 // slots for the flags, the number of reserved slots for the flags
849 // is increased automatically.
850 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
854 cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
860 fCalflags=new TArrayI(j);
863 Int_t size=fCalflags->GetSize();
871 Int_t dead=GetDeadValue(j);
872 Int_t gflag=GetGainFlag(j);
873 Int_t oflag=GetOffsetFlag(j);
875 Int_t word=1000*edge+100*dead+10*gflag+oflag;
877 fCalflags->AddAt(word,j-1);
879 ///////////////////////////////////////////////////////////////////////////
880 void AliAttrib::SetEdgeValue(Int_t val,TString name)
882 // Set the edge value to "val" for the name-specified attribute slot.
884 // This procedure involves a slot-index search based on the specified name
885 // at each invokation. This may become slow in case many slots have been
886 // defined and/or when this procedure is invoked many times.
887 // In such cases it is preferable to use indexed addressing in the user code
888 // either directly or via a few invokations of GetSlotIndex().
890 Int_t j=GetSlotIndex(name);
891 if (j>0) SetEdgeValue(val,j);
893 ///////////////////////////////////////////////////////////////////////////
894 void AliAttrib::IncreaseEdgeValue(Int_t j)
896 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
897 // Note : The first attribute slot is at j=1.
898 // In case the value of the index j exceeds the maximum number of reserved
899 // slots for the flags, the number of reserved slots for the flags
900 // is increased automatically.
901 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
905 cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
909 Int_t edge=GetEdgeValue();
910 SetEdgeValue(edge+1,j);
912 ///////////////////////////////////////////////////////////////////////////
913 void AliAttrib::IncreaseEdgeValue(TString name)
915 // Increase the edge value by 1 for the name-specified attribute slot.
917 // This procedure involves a slot-index search based on the specified name
918 // at each invokation. This may become slow in case many slots have been
919 // defined and/or when this procedure is invoked many times.
920 // In such cases it is preferable to use indexed addressing in the user code
921 // either directly or via a few invokations of GetSlotIndex().
923 Int_t j=GetSlotIndex(name);
924 if (j>0) IncreaseEdgeValue(j);
926 ///////////////////////////////////////////////////////////////////////////
927 void AliAttrib::DecreaseEdgeValue(Int_t j)
929 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
930 // Note : The first attribute slot is at j=1.
931 // In case the value of the index j exceeds the maximum number of reserved
932 // slots for the flags, the number of reserved slots for the flags
933 // is increased automatically.
934 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
938 cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
942 Int_t edge=GetEdgeValue();
943 SetEdgeValue(edge-1,j);
945 ///////////////////////////////////////////////////////////////////////////
946 void AliAttrib::DecreaseEdgeValue(TString name)
948 // Decrease the edge value by 1 for the name-specified attribute slot.
950 // This procedure involves a slot-index search based on the specified name
951 // at each invokation. This may become slow in case many slots have been
952 // defined and/or when this procedure is invoked many times.
953 // In such cases it is preferable to use indexed addressing in the user code
954 // either directly or via a few invokations of GetSlotIndex().
956 Int_t j=GetSlotIndex(name);
957 if (j>0) DecreaseEdgeValue(j);
959 ///////////////////////////////////////////////////////////////////////////
960 Int_t AliAttrib::GetEdgeValue(Int_t j) const
962 // Provide edge value of the j-th (default j=1) attribute slot.
963 // Note : The first attribute slot is at j=1.
964 // In case j is invalid, 0 is returned.
968 cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
975 if (j>0 && j<=(fCalflags->GetSize()))
977 Int_t word=fCalflags->At(j-1);
983 ///////////////////////////////////////////////////////////////////////////
984 Int_t AliAttrib::GetEdgeValue(TString name) const
986 // Provide edge value of the name-specified attribute slot.
988 // This procedure involves a slot-index search based on the specified name
989 // at each invokation. This may become slow in case many slots have been
990 // defined and/or when this procedure is invoked many times.
991 // In such cases it is preferable to use indexed addressing in the user code
992 // either directly or via a few invokations of GetSlotIndex().
994 Int_t j=GetSlotIndex(name);
996 if (j>0) val=GetEdgeValue(j);
999 ///////////////////////////////////////////////////////////////////////////
1000 Int_t AliAttrib::GetDeadValue(Int_t j) const
1002 // Provide dead value of the j-th (default j=1) attribute slot.
1003 // Note : The first attribute slot is at j=1.
1004 // In case j is invalid, 0 is returned.
1008 cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
1015 if (j>0 && j<=(fCalflags->GetSize()))
1017 Int_t word=fCalflags->At(j-1);
1024 ///////////////////////////////////////////////////////////////////////////
1025 Int_t AliAttrib::GetDeadValue(TString name) const
1027 // Provide dead value of the name-specified attribute slot.
1029 // This procedure involves a slot-index search based on the specified name
1030 // at each invokation. This may become slow in case many slots have been
1031 // defined and/or when this procedure is invoked many times.
1032 // In such cases it is preferable to use indexed addressing in the user code
1033 // either directly or via a few invokations of GetSlotIndex().
1035 Int_t j=GetSlotIndex(name);
1037 if (j>0) val=GetDeadValue(j);
1040 ///////////////////////////////////////////////////////////////////////////
1041 void AliAttrib::SetSlotName(TString s,Int_t j)
1043 // Set a user defined name for the j-th (default j=1) slot.
1044 // Note : The first attribute slot is at j=1.
1048 cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
1054 fNames=new TObjArray(j);
1058 if (j>fNames->GetSize()) fNames->Expand(j);
1060 TObjString* so=(TObjString*)fNames->At(j-1);
1063 so=new TObjString(s.Data());
1064 fNames->AddAt(so,j-1);
1071 ///////////////////////////////////////////////////////////////////////////
1072 TString AliAttrib::GetSlotName(Int_t j) const
1074 // Provide the user defined name for the j-th (default j=1) slot.
1075 // Note : The first attribute slot is at j=1.
1080 cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
1086 if (j<=fNames->GetSize())
1088 TObjString* so=(TObjString*)fNames->At(j-1);
1089 if (so) s=so->GetString();
1094 ///////////////////////////////////////////////////////////////////////////
1095 Int_t AliAttrib::GetSlotIndex(TString name) const
1097 // Provide the slot index for the matching name.
1098 // If no matching name is found, 0 is returned.
1099 // Note : The first attribute slot is at j=1.
1106 Int_t size=fNames->GetSize();
1107 for (Int_t i=0; i<size; i++)
1109 TObjString* so=(TObjString*)fNames->At(i);
1110 if (so) s=so->GetString();
1120 ///////////////////////////////////////////////////////////////////////////
1121 void AliAttrib::List(Int_t j) const
1123 // Provide attribute information for the j-th slot.
1124 // The first slot is at j=1.
1125 // In case j=0 (default) the data of all slots will be listed.
1129 cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
1135 if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
1136 if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
1137 if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
1138 if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
1139 if (GetCalFunction(j)) cout << " *Fcalib*";
1140 if (GetDecalFunction(j)) cout << " *Fdecalib*";
1141 TString s=GetSlotName(j);
1142 if (s!="") cout << " name : " << s.Data();
1146 Int_t ng=GetNgains();
1147 Int_t no=GetNoffsets();
1149 if (fCalflags) nf=fCalflags->GetSize();
1150 Int_t nn=GetNnames();
1157 for (Int_t i=1; i<=n; i++)
1160 if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;}
1161 if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
1162 if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;}
1163 if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;}
1164 if (GetCalFunction(i)) {cout << " *Fcalib*"; printf=1;}
1165 if (GetDecalFunction(i)) {cout << " *Fdecalib*"; printf=1;}
1167 if (s!="") {cout << " name : " << s.Data(); printf=1;}
1168 if (printf) cout << endl;
1172 ///////////////////////////////////////////////////////////////////////////
1173 void AliAttrib::List(TString name) const
1175 // Provide attribute information for the name-specified slot.
1177 // This procedure involves a slot-index search based on the specified name
1178 // at each invokation. This may become slow in case many slots have been
1179 // defined and/or when this procedure is invoked many times.
1180 // In such cases it is preferable to use indexed addressing in the user code
1181 // either directly or via a few invokations of GetSlotIndex().
1183 Int_t j=GetSlotIndex(name);
1186 ///////////////////////////////////////////////////////////////////////////
1187 void AliAttrib::Load(AliAttrib& a,Int_t j)
1189 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
1191 // Note : if j=0, then all attributes of all slots are loaded
1193 // The default is j=0.
1197 cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
1203 if (j==0) // load attributes for all slots
1206 for (Int_t ig=1; ig<=n; ig++)
1208 if (a.GetGainFlag(ig))
1210 SetGain(a.GetGain(ig),ig);
1218 for (Int_t io=1; io<=n; io++)
1220 if (a.GetOffsetFlag(io))
1222 SetOffset(a.GetOffset(io),io);
1230 for (Int_t ic=1; ic<=n; ic++)
1232 SetEdgeValue(a.GetEdgeValue(ic),ic);
1233 if (a.GetDeadValue(ic))
1244 for (Int_t in=1; in<=n; in++)
1246 s=a.GetSlotName(in);
1250 for (Int_t icalf=1; icalf<=n; icalf++)
1252 TF1* f=a.GetCalFunction(icalf);
1253 SetCalFunction(f,icalf);
1255 n=a.GetNdecalfuncs();
1256 for (Int_t idecalf=1; idecalf<=n; idecalf++)
1258 TF1* f=a.GetDecalFunction(idecalf);
1259 SetDecalFunction(f,idecalf);
1262 else // load attributes for specified j-th slot only
1267 if (a.GetGainFlag(j))
1269 SetGain(a.GetGain(j),j);
1279 if (a.GetOffsetFlag(j))
1281 SetOffset(a.GetOffset(j),j);
1291 SetEdgeValue(a.GetEdgeValue(j),j);
1292 if (a.GetDeadValue(j))
1311 TF1* f=a.GetCalFunction(j);
1312 SetCalFunction(f,j);
1314 n=a.GetNdecalfuncs();
1317 TF1* f=a.GetDecalFunction(j);
1318 SetDecalFunction(f,j);
1322 ///////////////////////////////////////////////////////////////////////////
1323 void AliAttrib::Load(AliAttrib& a,TString name)
1325 // Load attributes of the name-specified slot of the input AliAttrib into
1326 // this AliAttrib object.
1328 // This procedure involves a slot-index search based on the specified name
1329 // at each invokation. This may become slow in case many slots have been
1330 // defined and/or when this procedure is invoked many times.
1331 // In such cases it is preferable to use indexed addressing in the user code
1332 // either directly or via a few invokations of GetSlotIndex().
1334 Int_t j=GetSlotIndex(name);
1337 ///////////////////////////////////////////////////////////////////////////
1338 Int_t AliAttrib::GetNcalfuncs() const
1340 // Provide the number of specified calib. functions for this attribute.
1343 if (fCalfuncs) n=fCalfuncs->GetSize();
1346 ///////////////////////////////////////////////////////////////////////////
1347 Int_t AliAttrib::GetNdecalfuncs() const
1349 // Provide the number of specified de-calib. functions for this attribute.
1352 if (fDecalfuncs) n=fDecalfuncs->GetSize();
1355 ///////////////////////////////////////////////////////////////////////////
1356 TF1* AliAttrib::GetCalFunction(Int_t j) const
1358 // Provide pointer to the calib. function of the j-th (default j=1) slot.
1359 // Note : The first attribute slot is at j=1.
1362 if (j>0 && j<=GetNcalfuncs()) f=(TF1*)fCalfuncs->At(j-1);
1365 ///////////////////////////////////////////////////////////////////////////
1366 TF1* AliAttrib::GetCalFunction(TString name) const
1368 // Provide pointer to the calib. function of the name-specified slot.
1369 // In case no match is found, zero is returned.
1372 Int_t j=GetSlotIndex(name);
1373 if (j>0) GetCalFunction(j);
1376 ///////////////////////////////////////////////////////////////////////////
1377 void AliAttrib::SetCalFunction(TF1* f,Int_t j)
1379 // Set the calib. function of the j-th (default j=1) slot.
1380 // Note : The first attribute slot is at j=1.
1382 // In case the value of the index j exceeds the maximum number of reserved
1383 // positions for the functions, the number of reserved positions for the functions
1384 // is increased automatically.
1386 // In case the function pointer argument has the same value as the current function
1387 // pointer value, no action is taken since the user has already modified the actual
1390 // In case the function pointer argument is zero, the current function
1391 // is deleted and the pointer set to zero.
1393 // In all other cases the current function is deleted and a new
1394 // copy of the input function is created which becomes the current function.
1400 fCalfuncs=new TObjArray(j);
1401 fCalfuncs->SetOwner();
1404 if (j > fCalfuncs->GetSize()) fCalfuncs->Expand(j);
1406 TF1* fcur=(TF1*)fCalfuncs->At(j-1);
1411 fCalfuncs->Remove(fcur);
1418 fCalfuncs->AddAt(fcur,j-1);
1422 ///////////////////////////////////////////////////////////////////////////
1423 void AliAttrib::SetCalFunction(TF1* f,TString name)
1425 // Set the calib. function of the name-specified slot.
1427 // In case the function pointer argument has the same value as the current function
1428 // pointer value, no action is taken since the user has already modified the actual
1431 // In case the function pointer argument is zero, the current function
1432 // is deleted and the pointer set to zero.
1434 // In all other cases the current function is deleted and a new
1435 // copy of the input function is created which becomes the current function.
1437 Int_t j=GetSlotIndex(name);
1438 if (j>0) SetCalFunction(f,j);
1440 ///////////////////////////////////////////////////////////////////////////
1441 TF1* AliAttrib::GetDecalFunction(Int_t j) const
1443 // Provide pointer to the de-calib. function of the j-th (default j=1) slot.
1444 // Note : The first attribute slot is at j=1.
1447 if (j>0 && j<=GetNdecalfuncs()) f=(TF1*)fDecalfuncs->At(j-1);
1450 ///////////////////////////////////////////////////////////////////////////
1451 TF1* AliAttrib::GetDecalFunction(TString name) const
1453 // Provide pointer to the de-calib. function of the name-specified slot.
1454 // In case no match is found, zero is returned.
1457 Int_t j=GetSlotIndex(name);
1458 if (j>0) GetDecalFunction(j);
1461 ///////////////////////////////////////////////////////////////////////////
1462 void AliAttrib::SetDecalFunction(TF1* f,Int_t j)
1464 // Set the de-calib. function of the j-th (default j=1) slot.
1465 // Note : The first attribute slot is at j=1.
1467 // In case the value of the index j exceeds the maximum number of reserved
1468 // positions for the functions, the number of reserved positions for the functions
1469 // is increased automatically.
1471 // In case the function pointer argument has the same value as the current function
1472 // pointer value, no action is taken since the user has already modified the actual
1475 // In case the function pointer argument is zero, the current function
1476 // is deleted and the pointer set to zero.
1478 // In all other cases the current function is deleted and a new
1479 // copy of the input function is created which becomes the current function.
1485 fDecalfuncs=new TObjArray(j);
1486 fDecalfuncs->SetOwner();
1489 if (j > fDecalfuncs->GetSize()) fDecalfuncs->Expand(j);
1491 TF1* fcur=(TF1*)fDecalfuncs->At(j-1);
1496 fDecalfuncs->Remove(fcur);
1503 fDecalfuncs->AddAt(fcur,j-1);
1507 ///////////////////////////////////////////////////////////////////////////
1508 void AliAttrib::SetDecalFunction(TF1* f,TString name)
1510 // Set the de-calib. function of the name-specified slot.
1512 // In case the function pointer argument has the same value as the current function
1513 // pointer value, no action is taken since the user has already modified the actual
1516 // In case the function pointer argument is zero, the current function
1517 // is deleted and the pointer set to zero.
1519 // In all other cases the current function is deleted and a new
1520 // copy of the input function is created which becomes the current function.
1522 Int_t j=GetSlotIndex(name);
1523 if (j>0) SetDecalFunction(f,j);
1525 ///////////////////////////////////////////////////////////////////////////