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) return 0;
163 for (Int_t i=1; i<=fGains->GetSize(); i++)
165 if (GetGainFlag(i)) n=i;
170 ///////////////////////////////////////////////////////////////////////////
171 Int_t AliAttrib::GetNoffsets() const
173 // Provide the number of specified offsets for this attribute.
175 if (!fOffsets) return 0;
178 for (Int_t i=1; i<=fOffsets->GetSize(); i++)
180 if (GetOffsetFlag(i)) n=i;
185 ///////////////////////////////////////////////////////////////////////////
186 Int_t AliAttrib::GetNcalflags() const
188 // Provide the number of specified calib. flags for this attribute.
190 if (!fCalflags) return 0;
193 for (Int_t i=1; i<=fCalflags->GetSize(); i++)
195 if (fCalflags->At(i-1)) n=i;
200 ///////////////////////////////////////////////////////////////////////////
201 Int_t AliAttrib::GetNnames() const
203 // Provide the maximum number of specified names for this attribute.
205 if (!fNames) return 0;
208 for (Int_t i=1; i<=fNames->GetSize(); i++)
210 if (fNames->At(i-1)) n=i;
215 ///////////////////////////////////////////////////////////////////////////
216 void AliAttrib::SetGain(Double_t gain,Int_t j)
218 // Store gain value of the j-th (default j=1) attribute slot.
219 // Note : The first attribute slot is at j=1.
220 // In case the value of the index j exceeds the maximum number of reserved
221 // slots for gain values, the number of reserved slots for the gain
222 // values is increased automatically.
226 cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl;
232 fGains=new TArrayF(j);
235 Int_t size=fGains->GetSize();
242 fGains->AddAt(float(gain),j-1);
244 Int_t oflag=GetOffsetFlag(j);
246 SetCalFlags(1,oflag,j);
248 ///////////////////////////////////////////////////////////////////////////
249 void AliAttrib::SetGain(Double_t gain,TString name)
251 // Store gain value of the name-specified attribute slot.
253 // This procedure involves a slot-index search based on the specified name
254 // at each invokation. This may become slow in case many slots have been
255 // defined and/or when this procedure is invoked many times.
256 // In such cases it is preferable to use indexed addressing in the user code
257 // either directly or via a few invokations of GetSlotIndex().
259 Int_t j=GetSlotIndex(name);
260 if (j>0) SetGain(gain,j);
262 ///////////////////////////////////////////////////////////////////////////
263 void AliAttrib::SetOffset(Double_t off,Int_t j)
265 // Store offset value of the j-th (default j=1) attribute slot.
266 // Note : The first attribute slot is at j=1.
267 // In case the value of the index j exceeds the maximum number of reserved
268 // slots for offset values, the number of reserved slots for the offset
269 // values is increased automatically.
273 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
279 fOffsets=new TArrayF(j);
282 Int_t size=fOffsets->GetSize();
289 fOffsets->AddAt(float(off),j-1);
291 Int_t gflag=GetGainFlag(j);
293 SetCalFlags(gflag,1,j);
295 ///////////////////////////////////////////////////////////////////////////
296 void AliAttrib::SetOffset(Double_t off,TString name)
298 // Store offset value of the name-specified attribute slot.
300 // This procedure involves a slot-index search based on the specified name
301 // at each invokation. This may become slow in case many slots have been
302 // defined and/or when this procedure is invoked many times.
303 // In such cases it is preferable to use indexed addressing in the user code
304 // either directly or via a few invokations of GetSlotIndex().
306 Int_t j=GetSlotIndex(name);
307 if (j>0) SetOffset(off,j);
309 ///////////////////////////////////////////////////////////////////////////
310 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
312 // Store calibration flags of the j-th (default j=1) attribute slot.
313 // Note : The first attribute slot is at j=1.
314 // In case the value of the index j exceeds the maximum number of reserved
315 // slots for the calib. flags, the number of reserved slots for the calib.
316 // flags is increased automatically.
317 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
321 cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
327 fCalflags=new TArrayI(j);
330 Int_t size=fCalflags->GetSize();
337 Int_t edge=GetEdgeValue(j);
338 Int_t dead=GetDeadValue(j);
340 Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
342 fCalflags->AddAt(word,j-1);
344 ///////////////////////////////////////////////////////////////////////////
345 Int_t AliAttrib::GetGainFlag(Int_t j) const
347 // Provide gain flag of the j-th (default j=1) attribute slot.
349 // flag = 1 : Gain was set
350 // 0 : Gain was not set
352 // Note : The first attribute slot is at j=1.
353 // In case j is invalid, 0 is returned.
357 cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
363 if (j>0 && j<=(fCalflags->GetSize()))
365 Int_t word=fCalflags->At(j-1);
372 ///////////////////////////////////////////////////////////////////////////
373 Int_t AliAttrib::GetGainFlag(TString name) const
375 // Provide gain flag of the name-specified attribute slot.
377 // flag = 1 : Gain was set
378 // 0 : Gain was not set
381 // This procedure involves a slot-index search based on the specified name
382 // at each invokation. This may become slow in case many slots have been
383 // defined and/or when this procedure is invoked many times.
384 // In such cases it is preferable to use indexed addressing in the user code
385 // either directly or via a few invokations of GetSlotIndex().
387 Int_t j=GetSlotIndex(name);
389 if (j>0) flag=GetGainFlag(j);
392 ///////////////////////////////////////////////////////////////////////////
393 Int_t AliAttrib::GetOffsetFlag(Int_t j) const
395 // Provide offset flag of the j-th (default j=1) attribute slot.
397 // flag = 1 : Offset was set
398 // 0 : Offset was not set
400 // Note : The first attribute slot is at j=1.
401 // In case j is invalid, 0 is returned.
405 cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl;
412 if (j>0 && j<=(fCalflags->GetSize()))
414 Int_t word=fCalflags->At(j-1);
420 ///////////////////////////////////////////////////////////////////////////
421 Int_t AliAttrib::GetOffsetFlag(TString name) const
423 // Provide ofset flag of the name-specified attribute slot.
425 // flag = 1 : Offset was set
426 // 0 : Offset was not set
429 // This procedure involves a slot-index search based on the specified name
430 // at each invokation. This may become slow in case many slots have been
431 // defined and/or when this procedure is invoked many times.
432 // In such cases it is preferable to use indexed addressing in the user code
433 // either directly or via a few invokations of GetSlotIndex().
435 Int_t j=GetSlotIndex(name);
437 if (j>0) flag=GetOffsetFlag(j);
440 ///////////////////////////////////////////////////////////////////////////
441 Int_t AliAttrib::GetCalWord(Int_t j) const
443 // Provide calib. word of the j-th (default j=1) attribute slot.
444 // The word value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
446 // Note : The first attribute slot is at j=1.
447 // In case j is invalid, 0 is returned.
451 cout << " *AliAttrib::GetCalWord* Invalid argument j = " << j << endl;
458 if (j>0 && j<=(fCalflags->GetSize())) word=fCalflags->At(j-1);
462 ///////////////////////////////////////////////////////////////////////////
463 Int_t AliAttrib::GetCalWord(TString name) const
465 // Provide calib. word of the name-specified attribute slot.
466 // The word value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
468 // This procedure involves a slot-index search based on the specified name
469 // at each invokation. This may become slow in case many slots have been
470 // defined and/or when this procedure is invoked many times.
471 // In such cases it is preferable to use indexed addressing in the user code
472 // either directly or via a few invokations of GetSlotIndex().
474 Int_t j=GetSlotIndex(name);
476 if (j>0) word=GetCalWord(j);
479 ///////////////////////////////////////////////////////////////////////////
480 Float_t AliAttrib::GetGain(Int_t j) const
482 // Provide gain value of the j-th (default j=1) attribute slot.
483 // The first attribute slot is at j=1.
484 // In case no gain value was set or the argument j is invalid, 0 is returned.
485 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
489 cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
496 if (j>0 && j<=(fGains->GetSize()))
498 if (GetGainFlag(j)) gain=fGains->At(j-1);
503 ///////////////////////////////////////////////////////////////////////////
504 Float_t AliAttrib::GetGain(TString name) const
506 // Provide gain value of the name-specified attribute slot.
508 // This procedure involves a slot-index search based on the specified name
509 // at each invokation. This may become slow in case many slots have been
510 // defined and/or when this procedure is invoked many times.
511 // In such cases it is preferable to use indexed addressing in the user code
512 // either directly or via a few invokations of GetSlotIndex().
514 Int_t j=GetSlotIndex(name);
516 if (j>0) gain=GetGain(j);
519 ///////////////////////////////////////////////////////////////////////////
520 Float_t AliAttrib::GetOffset(Int_t j) const
522 // Provide offset value of the j-th (default j=1) attribute slot.
523 // The first attribute slot at j=1.
524 // In case no offset value was set or the argument j is invalid, 0 is returned.
525 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
529 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
536 if (j>0 && j<=(fOffsets->GetSize()))
538 if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
543 ///////////////////////////////////////////////////////////////////////////
544 Float_t AliAttrib::GetOffset(TString name) const
546 // Provide offset value of the name-specified attribute slot.
548 // This procedure involves a slot-index search based on the specified name
549 // at each invokation. This may become slow in case many slots have been
550 // defined and/or when this procedure is invoked many times.
551 // In such cases it is preferable to use indexed addressing in the user code
552 // either directly or via a few invokations of GetSlotIndex().
554 Int_t j=GetSlotIndex(name);
556 if (j>0) offset=GetOffset(j);
559 ///////////////////////////////////////////////////////////////////////////
560 void AliAttrib::ResetGain(Int_t j)
562 // Reset the gain value of the j-th (default j=1) attribute slot.
563 // Notes : The first attribute slot is at j=1.
564 // j=0 ==> All gain values will be reset.
568 Int_t size=fGains->GetSize();
570 if ((j>=0) && (j<=size))
574 fGains->AddAt(0,j-1);
575 Int_t oflag=GetOffsetFlag(j);
576 SetCalFlags(0,oflag,j);
580 for (Int_t i=0; i<size; i++)
583 Int_t oflag=GetOffsetFlag(i);
584 SetCalFlags(0,oflag,i);
590 cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
594 ///////////////////////////////////////////////////////////////////////////
595 void AliAttrib::ResetGain(TString name)
597 // Reset the gain value of the name-specified attribute slot.
599 // This procedure involves a slot-index search based on the specified name
600 // at each invokation. This may become slow in case many slots have been
601 // defined and/or when this procedure is invoked many times.
602 // In such cases it is preferable to use indexed addressing in the user code
603 // either directly or via a few invokations of GetSlotIndex().
605 Int_t j=GetSlotIndex(name);
606 if (j>0) ResetGain(j);
608 ///////////////////////////////////////////////////////////////////////////
609 void AliAttrib::ResetOffset(Int_t j)
611 // Reset the offset value of the j-th (default j=1) attribute slot.
612 // Notes : The first attribute slot is at j=1.
613 // j=0 ==> All offset values will be reset.
615 if (!fOffsets) return;
617 Int_t size=fOffsets->GetSize();
619 if ((j>=0) && (j<=size))
623 fOffsets->AddAt(0,j-1);
624 Int_t gflag=GetGainFlag(j);
625 SetCalFlags(gflag,0,j);
629 for (Int_t i=0; i<size; i++)
631 fOffsets->AddAt(0,i);
632 Int_t gflag=GetGainFlag(i);
633 SetCalFlags(gflag,0,i);
639 cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
643 ///////////////////////////////////////////////////////////////////////////
644 void AliAttrib::ResetOffset(TString name)
646 // Reset the offset value of the name-specified attribute slot.
648 // This procedure involves a slot-index search based on the specified name
649 // at each invokation. This may become slow in case many slots have been
650 // defined and/or when this procedure is invoked many times.
651 // In such cases it is preferable to use indexed addressing in the user code
652 // either directly or via a few invokations of GetSlotIndex().
654 Int_t j=GetSlotIndex(name);
655 if (j>0) ResetOffset(j);
657 ///////////////////////////////////////////////////////////////////////////
658 void AliAttrib::DeleteCalibrations(Int_t mode)
660 // User selected delete of all gains and/or offsets.
661 // mode = 0 : All attributes (names,gains,offsets,(de)calfuncs, edge and dead values) are deleted.
662 // 1 : Only the gains are deleted.
663 // 2 : Only the offsets are deleted.
664 // 3 : Gains, offsets and (de)calfuncs are deleted, but names, edge and dead values are kept.
665 // 4 : Only the calib. functions are deleted.
666 // 5 : Only the de-calib. functions are deleted.
667 // 6 : Only the calib. and de-calib. functions are deleted.
669 // The default when invoking DeleteCalibrations() corresponds to mode=0.
671 if (mode<0 || mode>6)
673 cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
674 cout << " Default mode=0 will be used." << endl;
678 if (mode==0 || mode==3)
692 if (fCalflags && mode==0)
697 if (fNames && mode==0)
735 if (mode==4 || mode==6)
744 if (mode==5 || mode==6)
753 ///////////////////////////////////////////////////////////////////////////
754 void AliAttrib::SetDead(Int_t j)
756 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
757 // Note : The first attribute slot is at j=1.
758 // In case the value of the index j exceeds the maximum number of reserved
759 // slots for the flags, the number of reserved slots for the flags
760 // is increased automatically.
761 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
765 cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
771 fCalflags=new TArrayI(j);
774 Int_t size=fCalflags->GetSize();
782 Int_t oflag=GetOffsetFlag(j);
783 Int_t gflag=GetGainFlag(j);
784 Int_t edge=GetEdgeValue(j);
786 Int_t word=1000*edge+100*dead+10*gflag+oflag;
788 fCalflags->AddAt(word,j-1);
790 ///////////////////////////////////////////////////////////////////////////
791 void AliAttrib::SetDead(TString name)
793 // Set the dead flag to 1 for the name-specified attribute slot.
795 // This procedure involves a slot-index search based on the specified name
796 // at each invokation. This may become slow in case many slots have been
797 // defined and/or when this procedure is invoked many times.
798 // In such cases it is preferable to use indexed addressing in the user code
799 // either directly or via a few invokations of GetSlotIndex().
801 Int_t j=GetSlotIndex(name);
804 ///////////////////////////////////////////////////////////////////////////
805 void AliAttrib::SetAlive(Int_t j)
807 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
808 // Note : The first attribute slot is at j=1.
809 // In case the value of the index j exceeds the maximum number of reserved
810 // slots for the flags, no action is taken since by default the dead flag is 0.
811 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
815 cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
819 if (!fCalflags || j>fCalflags->GetSize()) return;
822 Int_t oflag=GetOffsetFlag(j);
823 Int_t gflag=GetGainFlag(j);
824 Int_t edge=GetEdgeValue(j);
826 Int_t word=1000*edge+100*dead+10*gflag+oflag;
828 fCalflags->AddAt(word,j-1);
830 ///////////////////////////////////////////////////////////////////////////
831 void AliAttrib::SetAlive(TString name)
833 // Set the dead flag to 0 for the name-specified attribute slot.
835 // This procedure involves a slot-index search based on the specified name
836 // at each invokation. This may become slow in case many slots have been
837 // defined and/or when this procedure is invoked many times.
838 // In such cases it is preferable to use indexed addressing in the user code
839 // either directly or via a few invokations of GetSlotIndex().
841 Int_t j=GetSlotIndex(name);
842 if (j>0) SetAlive(j);
844 ///////////////////////////////////////////////////////////////////////////
845 void AliAttrib::SetEdgeOn(Int_t j)
847 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
848 // Note : The first attribute slot is at j=1.
849 // In case the value of the index j exceeds the maximum number of reserved
850 // slots for the flags, the number of reserved slots for the flags
851 // is increased automatically.
852 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
856 cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
862 ///////////////////////////////////////////////////////////////////////////
863 void AliAttrib::SetEdgeOn(TString name)
865 // Set the edge value to 1 for the name-specified attribute slot.
867 // This procedure involves a slot-index search based on the specified name
868 // at each invokation. This may become slow in case many slots have been
869 // defined and/or when this procedure is invoked many times.
870 // In such cases it is preferable to use indexed addressing in the user code
871 // either directly or via a few invokations of GetSlotIndex().
873 Int_t j=GetSlotIndex(name);
874 if (j>0) SetEdgeOn(j);
876 ///////////////////////////////////////////////////////////////////////////
877 void AliAttrib::SetEdgeOff(Int_t j)
879 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
880 // Note : The first attribute slot is at j=1.
881 // In case the value of the index j exceeds the maximum number of reserved
882 // slots for the flags, no action is taken since by default the edge flag is 0.
883 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
887 cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
891 if (!fCalflags || j>fCalflags->GetSize()) return;
895 ///////////////////////////////////////////////////////////////////////////
896 void AliAttrib::SetEdgeOff(TString name)
898 // Set the edge value to 0 for the name-specified attribute slot.
900 // This procedure involves a slot-index search based on the specified name
901 // at each invokation. This may become slow in case many slots have been
902 // defined and/or when this procedure is invoked many times.
903 // In such cases it is preferable to use indexed addressing in the user code
904 // either directly or via a few invokations of GetSlotIndex().
906 Int_t j=GetSlotIndex(name);
907 if (j>0) SetEdgeOff(j);
909 ///////////////////////////////////////////////////////////////////////////
910 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
912 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
913 // Note : The first attribute slot is at j=1.
914 // In case the value of the index j exceeds the maximum number of reserved
915 // slots for the flags, the number of reserved slots for the flags
916 // is increased automatically.
917 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
921 cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
927 fCalflags=new TArrayI(j);
930 Int_t size=fCalflags->GetSize();
938 Int_t dead=GetDeadValue(j);
939 Int_t gflag=GetGainFlag(j);
940 Int_t oflag=GetOffsetFlag(j);
942 Int_t word=1000*edge+100*dead+10*gflag+oflag;
944 fCalflags->AddAt(word,j-1);
946 ///////////////////////////////////////////////////////////////////////////
947 void AliAttrib::SetEdgeValue(Int_t val,TString name)
949 // Set the edge value to "val" for the name-specified attribute slot.
951 // This procedure involves a slot-index search based on the specified name
952 // at each invokation. This may become slow in case many slots have been
953 // defined and/or when this procedure is invoked many times.
954 // In such cases it is preferable to use indexed addressing in the user code
955 // either directly or via a few invokations of GetSlotIndex().
957 Int_t j=GetSlotIndex(name);
958 if (j>0) SetEdgeValue(val,j);
960 ///////////////////////////////////////////////////////////////////////////
961 void AliAttrib::IncreaseEdgeValue(Int_t j)
963 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
964 // Note : The first attribute slot is at j=1.
965 // In case the value of the index j exceeds the maximum number of reserved
966 // slots for the flags, the number of reserved slots for the flags
967 // is increased automatically.
968 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
972 cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
976 Int_t edge=GetEdgeValue();
977 SetEdgeValue(edge+1,j);
979 ///////////////////////////////////////////////////////////////////////////
980 void AliAttrib::IncreaseEdgeValue(TString name)
982 // Increase the edge value by 1 for the name-specified attribute slot.
984 // This procedure involves a slot-index search based on the specified name
985 // at each invokation. This may become slow in case many slots have been
986 // defined and/or when this procedure is invoked many times.
987 // In such cases it is preferable to use indexed addressing in the user code
988 // either directly or via a few invokations of GetSlotIndex().
990 Int_t j=GetSlotIndex(name);
991 if (j>0) IncreaseEdgeValue(j);
993 ///////////////////////////////////////////////////////////////////////////
994 void AliAttrib::DecreaseEdgeValue(Int_t j)
996 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
997 // Note : The first attribute slot is at j=1.
998 // In case the value of the index j exceeds the maximum number of reserved
999 // slots for the flags, the number of reserved slots for the flags
1000 // is increased automatically.
1001 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
1005 cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
1009 Int_t edge=GetEdgeValue();
1010 SetEdgeValue(edge-1,j);
1012 ///////////////////////////////////////////////////////////////////////////
1013 void AliAttrib::DecreaseEdgeValue(TString name)
1015 // Decrease the edge value by 1 for the name-specified attribute slot.
1017 // This procedure involves a slot-index search based on the specified name
1018 // at each invokation. This may become slow in case many slots have been
1019 // defined and/or when this procedure is invoked many times.
1020 // In such cases it is preferable to use indexed addressing in the user code
1021 // either directly or via a few invokations of GetSlotIndex().
1023 Int_t j=GetSlotIndex(name);
1024 if (j>0) DecreaseEdgeValue(j);
1026 ///////////////////////////////////////////////////////////////////////////
1027 Int_t AliAttrib::GetEdgeValue(Int_t j) const
1029 // Provide edge value of the j-th (default j=1) attribute slot.
1030 // Note : The first attribute slot is at j=1.
1031 // In case j is invalid, 0 is returned.
1035 cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
1042 if (j>0 && j<=(fCalflags->GetSize()))
1044 Int_t word=fCalflags->At(j-1);
1050 ///////////////////////////////////////////////////////////////////////////
1051 Int_t AliAttrib::GetEdgeValue(TString name) const
1053 // Provide edge value of the name-specified attribute slot.
1055 // This procedure involves a slot-index search based on the specified name
1056 // at each invokation. This may become slow in case many slots have been
1057 // defined and/or when this procedure is invoked many times.
1058 // In such cases it is preferable to use indexed addressing in the user code
1059 // either directly or via a few invokations of GetSlotIndex().
1061 Int_t j=GetSlotIndex(name);
1063 if (j>0) val=GetEdgeValue(j);
1066 ///////////////////////////////////////////////////////////////////////////
1067 Int_t AliAttrib::GetDeadValue(Int_t j) const
1069 // Provide dead value of the j-th (default j=1) attribute slot.
1070 // Note : The first attribute slot is at j=1.
1071 // In case j is invalid, 0 is returned.
1075 cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
1082 if (j>0 && j<=(fCalflags->GetSize()))
1084 Int_t word=fCalflags->At(j-1);
1091 ///////////////////////////////////////////////////////////////////////////
1092 Int_t AliAttrib::GetDeadValue(TString name) const
1094 // Provide dead value of the name-specified attribute slot.
1096 // This procedure involves a slot-index search based on the specified name
1097 // at each invokation. This may become slow in case many slots have been
1098 // defined and/or when this procedure is invoked many times.
1099 // In such cases it is preferable to use indexed addressing in the user code
1100 // either directly or via a few invokations of GetSlotIndex().
1102 Int_t j=GetSlotIndex(name);
1104 if (j>0) val=GetDeadValue(j);
1107 ///////////////////////////////////////////////////////////////////////////
1108 Int_t AliAttrib::GetNslots() const
1110 // Provide the number of existing slots.
1112 Int_t n=GetNcalflags();
1113 Int_t nn=GetNnames();
1114 Int_t ncalf=GetNcalfuncs();
1115 Int_t ndecalf=GetNdecalfuncs();
1117 if (n<ncalf) n=ncalf;
1118 if (n<ndecalf) n=ndecalf;
1122 ///////////////////////////////////////////////////////////////////////////
1123 void AliAttrib::AddNamedSlot(TString s)
1125 // Add a new slot with the specified name.
1126 // In case a slot with the specified name already exists, no action is taken.
1128 if (GetSlotIndex(s)) return;
1130 Int_t n=GetNslots();
1133 ///////////////////////////////////////////////////////////////////////////
1134 void AliAttrib::SetSlotName(TString s,Int_t j)
1136 // Set a user defined name for the j-th (default j=1) slot.
1137 // Note : The first attribute slot is at j=1.
1138 // In case the value of the index j exceeds the maximum number of reserved
1139 // slots for the names, the number of reserved slots for the names
1140 // is increased automatically to the corresponding value.
1144 cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
1150 fNames=new TObjArray(j);
1154 if (j>fNames->GetSize()) fNames->Expand(j);
1156 TObjString* so=(TObjString*)fNames->At(j-1);
1159 so=new TObjString(s.Data());
1160 fNames->AddAt(so,j-1);
1167 ///////////////////////////////////////////////////////////////////////////
1168 TString AliAttrib::GetSlotName(Int_t j) const
1170 // Provide the user defined name for the j-th (default j=1) slot.
1171 // Note : The first attribute slot is at j=1.
1176 cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
1182 if (j<=fNames->GetSize())
1184 TObjString* so=(TObjString*)fNames->At(j-1);
1185 if (so) s=so->GetString();
1190 ///////////////////////////////////////////////////////////////////////////
1191 Int_t AliAttrib::GetSlotIndex(TString name) const
1193 // Provide the slot index for the matching name.
1194 // If no matching name is found, 0 is returned.
1195 // Note : The first attribute slot is at j=1.
1202 Int_t size=fNames->GetSize();
1203 for (Int_t i=0; i<size; i++)
1205 TObjString* so=(TObjString*)fNames->At(i);
1206 if (so) s=so->GetString();
1216 ///////////////////////////////////////////////////////////////////////////
1217 void AliAttrib::List(Int_t j) const
1219 // Provide attribute information for the j-th slot.
1220 // The first slot is at j=1.
1221 // In case j=0 (default) the data of all slots will be listed.
1225 cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
1231 if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
1232 if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
1233 if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
1234 if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
1235 if (GetCalFunction(j)) cout << " *Fcalib*";
1236 if (GetDecalFunction(j)) cout << " *Fdecalib*";
1237 TString s=GetSlotName(j);
1238 if (s!="") cout << " name : " << s.Data();
1242 Int_t ng=GetNgains();
1243 Int_t no=GetNoffsets();
1245 if (fCalflags) nf=fCalflags->GetSize();
1246 Int_t nn=GetNnames();
1253 for (Int_t i=1; i<=n; i++)
1256 if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;}
1257 if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
1258 if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;}
1259 if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;}
1260 if (GetCalFunction(i)) {cout << " *Fcalib*"; printf=1;}
1261 if (GetDecalFunction(i)) {cout << " *Fdecalib*"; printf=1;}
1263 if (s!="") {cout << " name : " << s.Data(); printf=1;}
1264 if (printf) cout << endl;
1268 ///////////////////////////////////////////////////////////////////////////
1269 void AliAttrib::List(TString name) const
1271 // Provide attribute information for the name-specified slot.
1273 // This procedure involves a slot-index search based on the specified name
1274 // at each invokation. This may become slow in case many slots have been
1275 // defined and/or when this procedure is invoked many times.
1276 // In such cases it is preferable to use indexed addressing in the user code
1277 // either directly or via a few invokations of GetSlotIndex().
1279 Int_t j=GetSlotIndex(name);
1282 ///////////////////////////////////////////////////////////////////////////
1283 void AliAttrib::Load(AliAttrib& a,Int_t j)
1285 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
1287 // Note : if j=0, then all attributes of all slots are loaded
1289 // The default is j=0.
1293 cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
1299 if (j==0) // load attributes for all slots
1302 for (Int_t ig=1; ig<=n; ig++)
1304 if (a.GetGainFlag(ig))
1306 SetGain(a.GetGain(ig),ig);
1314 for (Int_t io=1; io<=n; io++)
1316 if (a.GetOffsetFlag(io))
1318 SetOffset(a.GetOffset(io),io);
1326 for (Int_t ic=1; ic<=n; ic++)
1328 SetEdgeValue(a.GetEdgeValue(ic),ic);
1329 if (a.GetDeadValue(ic))
1340 for (Int_t in=1; in<=n; in++)
1342 s=a.GetSlotName(in);
1346 for (Int_t icalf=1; icalf<=n; icalf++)
1348 TF1* f=a.GetCalFunction(icalf);
1349 SetCalFunction(f,icalf);
1351 n=a.GetNdecalfuncs();
1352 for (Int_t idecalf=1; idecalf<=n; idecalf++)
1354 TF1* f=a.GetDecalFunction(idecalf);
1355 SetDecalFunction(f,idecalf);
1358 else // load attributes for specified j-th slot only
1363 if (a.GetGainFlag(j))
1365 SetGain(a.GetGain(j),j);
1375 if (a.GetOffsetFlag(j))
1377 SetOffset(a.GetOffset(j),j);
1387 SetEdgeValue(a.GetEdgeValue(j),j);
1388 if (a.GetDeadValue(j))
1407 TF1* f=a.GetCalFunction(j);
1408 SetCalFunction(f,j);
1410 n=a.GetNdecalfuncs();
1413 TF1* f=a.GetDecalFunction(j);
1414 SetDecalFunction(f,j);
1418 ///////////////////////////////////////////////////////////////////////////
1419 void AliAttrib::Load(AliAttrib& a,TString name)
1421 // Load attributes of the name-specified slot of the input AliAttrib into
1422 // this AliAttrib object.
1424 // This procedure involves a slot-index search based on the specified name
1425 // at each invokation. This may become slow in case many slots have been
1426 // defined and/or when this procedure is invoked many times.
1427 // In such cases it is preferable to use indexed addressing in the user code
1428 // either directly or via a few invokations of GetSlotIndex().
1430 Int_t j=GetSlotIndex(name);
1433 ///////////////////////////////////////////////////////////////////////////
1434 Int_t AliAttrib::GetNcalfuncs() const
1436 // Provide the number of specified calib. functions for this attribute.
1438 if (!fCalfuncs) return 0;
1441 for (Int_t i=1; i<=fCalfuncs->GetSize(); i++)
1443 if (fCalfuncs->At(i-1)) n=i;
1447 ///////////////////////////////////////////////////////////////////////////
1448 Int_t AliAttrib::GetNdecalfuncs() const
1450 // Provide the number of specified de-calib. functions for this attribute.
1452 if (!fDecalfuncs) return 0;
1455 for (Int_t i=1; i<=fDecalfuncs->GetSize(); i++)
1457 if (fDecalfuncs->At(i-1)) n=i;
1461 ///////////////////////////////////////////////////////////////////////////
1462 TF1* AliAttrib::GetCalFunction(Int_t j) const
1464 // Provide pointer to the calib. function of the j-th (default j=1) slot.
1465 // Note : The first attribute slot is at j=1.
1468 if (j>0 && j<=GetNcalfuncs()) f=(TF1*)fCalfuncs->At(j-1);
1471 ///////////////////////////////////////////////////////////////////////////
1472 TF1* AliAttrib::GetCalFunction(TString name) const
1474 // Provide pointer to the calib. function of the name-specified slot.
1475 // In case no match is found, zero is returned.
1478 Int_t j=GetSlotIndex(name);
1479 if (j>0) f=GetCalFunction(j);
1482 ///////////////////////////////////////////////////////////////////////////
1483 void AliAttrib::SetCalFunction(TF1* f,Int_t j)
1485 // Set the calib. function of the j-th (default j=1) slot.
1486 // Note : The first attribute slot is at j=1.
1488 // In case the value of the index j exceeds the maximum number of reserved
1489 // positions for the functions, the number of reserved positions for the functions
1490 // is increased automatically.
1492 // In case the function pointer argument has the same value as the current function
1493 // pointer value, no action is taken since the user has already modified the actual
1496 // In case the function pointer argument is zero, the current function
1497 // is deleted and the pointer set to zero.
1499 // In all other cases the current function is deleted and a new
1500 // copy of the input function is created which becomes the current function.
1506 fCalfuncs=new TObjArray(j);
1507 fCalfuncs->SetOwner();
1510 if (j > fCalfuncs->GetSize()) fCalfuncs->Expand(j);
1512 TF1* fcur=(TF1*)fCalfuncs->At(j-1);
1517 fCalfuncs->Remove(fcur);
1524 fCalfuncs->AddAt(fcur,j-1);
1528 ///////////////////////////////////////////////////////////////////////////
1529 void AliAttrib::SetCalFunction(TF1* f,TString name)
1531 // Set the calib. function of the name-specified slot.
1533 // In case the function pointer argument has the same value as the current function
1534 // pointer value, no action is taken since the user has already modified the actual
1537 // In case the function pointer argument is zero, the current function
1538 // is deleted and the pointer set to zero.
1540 // In all other cases the current function is deleted and a new
1541 // copy of the input function is created which becomes the current function.
1543 Int_t j=GetSlotIndex(name);
1544 if (j>0) SetCalFunction(f,j);
1546 ///////////////////////////////////////////////////////////////////////////
1547 TF1* AliAttrib::GetDecalFunction(Int_t j) const
1549 // Provide pointer to the de-calib. function of the j-th (default j=1) slot.
1550 // Note : The first attribute slot is at j=1.
1553 if (j>0 && j<=GetNdecalfuncs()) f=(TF1*)fDecalfuncs->At(j-1);
1556 ///////////////////////////////////////////////////////////////////////////
1557 TF1* AliAttrib::GetDecalFunction(TString name) const
1559 // Provide pointer to the de-calib. function of the name-specified slot.
1560 // In case no match is found, zero is returned.
1563 Int_t j=GetSlotIndex(name);
1564 if (j>0) f=GetDecalFunction(j);
1567 ///////////////////////////////////////////////////////////////////////////
1568 void AliAttrib::SetDecalFunction(TF1* f,Int_t j)
1570 // Set the de-calib. function of the j-th (default j=1) slot.
1571 // Note : The first attribute slot is at j=1.
1573 // In case the value of the index j exceeds the maximum number of reserved
1574 // positions for the functions, the number of reserved positions for the functions
1575 // is increased automatically.
1577 // In case the function pointer argument has the same value as the current function
1578 // pointer value, no action is taken since the user has already modified the actual
1581 // In case the function pointer argument is zero, the current function
1582 // is deleted and the pointer set to zero.
1584 // In all other cases the current function is deleted and a new
1585 // copy of the input function is created which becomes the current function.
1591 fDecalfuncs=new TObjArray(j);
1592 fDecalfuncs->SetOwner();
1595 if (j > fDecalfuncs->GetSize()) fDecalfuncs->Expand(j);
1597 TF1* fcur=(TF1*)fDecalfuncs->At(j-1);
1602 fDecalfuncs->Remove(fcur);
1609 fDecalfuncs->AddAt(fcur,j-1);
1613 ///////////////////////////////////////////////////////////////////////////
1614 void AliAttrib::SetDecalFunction(TF1* f,TString name)
1616 // Set the de-calib. function of the name-specified slot.
1618 // In case the function pointer argument has the same value as the current function
1619 // pointer value, no action is taken since the user has already modified the actual
1622 // In case the function pointer argument is zero, the current function
1623 // is deleted and the pointer set to zero.
1625 // In all other cases the current function is deleted and a new
1626 // copy of the input function is created which becomes the current function.
1628 Int_t j=GetSlotIndex(name);
1629 if (j>0) SetDecalFunction(f,j);
1631 ///////////////////////////////////////////////////////////////////////////