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.GetLockValue(ic)) Lock(ic);
131 if (a.GetDeadValue(ic)) SetDead(ic);
136 for (Int_t in=1; in<=n; in++)
139 if (s!="") SetSlotName(s,in);
143 for (Int_t icalf=1; icalf<=n; icalf++)
145 TF1* f=a.GetCalFunction(icalf);
146 if (f) SetCalFunction(f,icalf);
149 n=a.GetNdecalfuncs();
150 for (Int_t idecalf=1; idecalf<=n; idecalf++)
152 TF1* f=a.GetDecalFunction(idecalf);
153 if (f) SetDecalFunction(f,idecalf);
156 ///////////////////////////////////////////////////////////////////////////
157 Int_t AliAttrib::GetNgains() const
159 // Provide the number of specified gains for this attribute.
161 if (!fGains) return 0;
164 for (Int_t i=1; i<=fGains->GetSize(); i++)
166 if (GetGainFlag(i)) n=i;
171 ///////////////////////////////////////////////////////////////////////////
172 Int_t AliAttrib::GetNoffsets() const
174 // Provide the number of specified offsets for this attribute.
176 if (!fOffsets) return 0;
179 for (Int_t i=1; i<=fOffsets->GetSize(); i++)
181 if (GetOffsetFlag(i)) n=i;
186 ///////////////////////////////////////////////////////////////////////////
187 Int_t AliAttrib::GetNcalflags() const
189 // Provide the number of specified calib. flags for this attribute.
191 if (!fCalflags) return 0;
194 for (Int_t i=1; i<=fCalflags->GetSize(); i++)
196 if (fCalflags->At(i-1)) n=i;
201 ///////////////////////////////////////////////////////////////////////////
202 Int_t AliAttrib::GetNnames() const
204 // Provide the maximum number of specified names for this attribute.
206 if (!fNames) return 0;
209 for (Int_t i=1; i<=fNames->GetSize(); i++)
211 if (fNames->At(i-1)) n=i;
216 ///////////////////////////////////////////////////////////////////////////
217 void AliAttrib::SetGain(Double_t gain,Int_t j)
219 // Store gain value of the j-th (default j=1) attribute slot.
220 // Note : The first attribute slot is at j=1.
221 // In case the value of the index j exceeds the maximum number of reserved
222 // slots for gain values, the number of reserved slots for the gain
223 // values is increased automatically.
227 cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl;
233 fGains=new TArrayF(j);
236 Int_t size=fGains->GetSize();
243 fGains->AddAt(float(gain),j-1);
245 Int_t oflag=GetOffsetFlag(j);
247 SetCalFlags(1,oflag,j);
249 ///////////////////////////////////////////////////////////////////////////
250 void AliAttrib::SetGain(Double_t gain,TString name)
252 // Store gain value of the name-specified attribute slot.
254 // This procedure involves a slot-index search based on the specified name
255 // at each invokation. This may become slow in case many slots have been
256 // defined and/or when this procedure is invoked many times.
257 // In such cases it is preferable to use indexed addressing in the user code
258 // either directly or via a few invokations of GetSlotIndex().
260 Int_t j=GetSlotIndex(name);
261 if (j>0) SetGain(gain,j);
263 ///////////////////////////////////////////////////////////////////////////
264 void AliAttrib::SetOffset(Double_t off,Int_t j)
266 // Store offset value of the j-th (default j=1) attribute slot.
267 // Note : The first attribute slot is at j=1.
268 // In case the value of the index j exceeds the maximum number of reserved
269 // slots for offset values, the number of reserved slots for the offset
270 // values is increased automatically.
274 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
280 fOffsets=new TArrayF(j);
283 Int_t size=fOffsets->GetSize();
290 fOffsets->AddAt(float(off),j-1);
292 Int_t gflag=GetGainFlag(j);
294 SetCalFlags(gflag,1,j);
296 ///////////////////////////////////////////////////////////////////////////
297 void AliAttrib::SetOffset(Double_t off,TString name)
299 // Store offset value of the name-specified attribute slot.
301 // This procedure involves a slot-index search based on the specified name
302 // at each invokation. This may become slow in case many slots have been
303 // defined and/or when this procedure is invoked many times.
304 // In such cases it is preferable to use indexed addressing in the user code
305 // either directly or via a few invokations of GetSlotIndex().
307 Int_t j=GetSlotIndex(name);
308 if (j>0) SetOffset(off,j);
310 ///////////////////////////////////////////////////////////////////////////
311 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
313 // Store calibration flags of the j-th (default j=1) attribute slot.
314 // Note : The first attribute slot is at j=1.
315 // In case the value of the index j exceeds the maximum number of reserved
316 // slots for the calib. flags, the number of reserved slots for the calib.
317 // flags is increased automatically.
318 // The value stored is : 10000*edge +1000*lock + 100*dead + 10*gainflag + offsetflag.
322 cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
328 fCalflags=new TArrayI(j);
331 Int_t size=fCalflags->GetSize();
338 Int_t edge=GetEdgeValue(j);
339 Int_t lock=GetLockValue(j);
340 Int_t dead=GetDeadValue(j);
342 Int_t word=10000*edge+1000*lock+100*dead+10*gainflag+offsetflag;
344 fCalflags->AddAt(word,j-1);
346 ///////////////////////////////////////////////////////////////////////////
347 Int_t AliAttrib::GetGainFlag(Int_t j) const
349 // Provide gain flag of the j-th (default j=1) attribute slot.
351 // flag = 1 : Gain was set
352 // 0 : Gain was not set
354 // Note : The first attribute slot is at j=1.
355 // In case j is invalid, 0 is returned.
359 cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
365 if (j>0 && j<=(fCalflags->GetSize()))
367 Int_t word=fCalflags->At(j-1);
374 ///////////////////////////////////////////////////////////////////////////
375 Int_t AliAttrib::GetGainFlag(TString name) const
377 // Provide gain flag of the name-specified attribute slot.
379 // flag = 1 : Gain was set
380 // 0 : Gain was not set
383 // This procedure involves a slot-index search based on the specified name
384 // at each invokation. This may become slow in case many slots have been
385 // defined and/or when this procedure is invoked many times.
386 // In such cases it is preferable to use indexed addressing in the user code
387 // either directly or via a few invokations of GetSlotIndex().
389 Int_t j=GetSlotIndex(name);
391 if (j>0) flag=GetGainFlag(j);
394 ///////////////////////////////////////////////////////////////////////////
395 Int_t AliAttrib::GetOffsetFlag(Int_t j) const
397 // Provide offset flag of the j-th (default j=1) attribute slot.
399 // flag = 1 : Offset was set
400 // 0 : Offset was not set
402 // Note : The first attribute slot is at j=1.
403 // In case j is invalid, 0 is returned.
407 cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl;
414 if (j>0 && j<=(fCalflags->GetSize()))
416 Int_t word=fCalflags->At(j-1);
422 ///////////////////////////////////////////////////////////////////////////
423 Int_t AliAttrib::GetOffsetFlag(TString name) const
425 // Provide ofset flag of the name-specified attribute slot.
427 // flag = 1 : Offset was set
428 // 0 : Offset was not set
431 // This procedure involves a slot-index search based on the specified name
432 // at each invokation. This may become slow in case many slots have been
433 // defined and/or when this procedure is invoked many times.
434 // In such cases it is preferable to use indexed addressing in the user code
435 // either directly or via a few invokations of GetSlotIndex().
437 Int_t j=GetSlotIndex(name);
439 if (j>0) flag=GetOffsetFlag(j);
442 ///////////////////////////////////////////////////////////////////////////
443 Int_t AliAttrib::GetCalWord(Int_t j) const
445 // Provide calib. word of the j-th (default j=1) attribute slot.
446 // The word value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
448 // Note : The first attribute slot is at j=1.
449 // In case j is invalid, 0 is returned.
453 cout << " *AliAttrib::GetCalWord* Invalid argument j = " << j << endl;
460 if (j>0 && j<=(fCalflags->GetSize())) word=fCalflags->At(j-1);
464 ///////////////////////////////////////////////////////////////////////////
465 Int_t AliAttrib::GetCalWord(TString name) const
467 // Provide calib. word of the name-specified attribute slot.
468 // The word value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
470 // This procedure involves a slot-index search based on the specified name
471 // at each invokation. This may become slow in case many slots have been
472 // defined and/or when this procedure is invoked many times.
473 // In such cases it is preferable to use indexed addressing in the user code
474 // either directly or via a few invokations of GetSlotIndex().
476 Int_t j=GetSlotIndex(name);
478 if (j>0) word=GetCalWord(j);
481 ///////////////////////////////////////////////////////////////////////////
482 Float_t AliAttrib::GetGain(Int_t j) const
484 // Provide gain value of the j-th (default j=1) attribute slot.
485 // The first attribute slot is at j=1.
486 // In case no gain value was set or the argument j is invalid, 0 is returned.
487 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
491 cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
498 if (j>0 && j<=(fGains->GetSize()))
500 if (GetGainFlag(j)) gain=fGains->At(j-1);
505 ///////////////////////////////////////////////////////////////////////////
506 Float_t AliAttrib::GetGain(TString name) const
508 // Provide gain value of the name-specified attribute slot.
510 // This procedure involves a slot-index search based on the specified name
511 // at each invokation. This may become slow in case many slots have been
512 // defined and/or when this procedure is invoked many times.
513 // In such cases it is preferable to use indexed addressing in the user code
514 // either directly or via a few invokations of GetSlotIndex().
516 Int_t j=GetSlotIndex(name);
518 if (j>0) gain=GetGain(j);
521 ///////////////////////////////////////////////////////////////////////////
522 Float_t AliAttrib::GetOffset(Int_t j) const
524 // Provide offset value of the j-th (default j=1) attribute slot.
525 // The first attribute slot at j=1.
526 // In case no offset value was set or the argument j is invalid, 0 is returned.
527 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
531 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
538 if (j>0 && j<=(fOffsets->GetSize()))
540 if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
545 ///////////////////////////////////////////////////////////////////////////
546 Float_t AliAttrib::GetOffset(TString name) const
548 // Provide offset value of the name-specified attribute slot.
550 // This procedure involves a slot-index search based on the specified name
551 // at each invokation. This may become slow in case many slots have been
552 // defined and/or when this procedure is invoked many times.
553 // In such cases it is preferable to use indexed addressing in the user code
554 // either directly or via a few invokations of GetSlotIndex().
556 Int_t j=GetSlotIndex(name);
558 if (j>0) offset=GetOffset(j);
561 ///////////////////////////////////////////////////////////////////////////
562 void AliAttrib::ResetGain(Int_t j)
564 // Reset the gain value of the j-th (default j=1) attribute slot.
565 // Notes : The first attribute slot is at j=1.
566 // j=0 ==> All gain values will be reset.
570 Int_t size=fGains->GetSize();
572 if ((j>=0) && (j<=size))
576 fGains->AddAt(0,j-1);
577 Int_t oflag=GetOffsetFlag(j);
578 SetCalFlags(0,oflag,j);
582 for (Int_t i=0; i<size; i++)
585 Int_t oflag=GetOffsetFlag(i);
586 SetCalFlags(0,oflag,i);
592 cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
596 ///////////////////////////////////////////////////////////////////////////
597 void AliAttrib::ResetGain(TString name)
599 // Reset the gain value of the name-specified attribute slot.
601 // This procedure involves a slot-index search based on the specified name
602 // at each invokation. This may become slow in case many slots have been
603 // defined and/or when this procedure is invoked many times.
604 // In such cases it is preferable to use indexed addressing in the user code
605 // either directly or via a few invokations of GetSlotIndex().
607 Int_t j=GetSlotIndex(name);
608 if (j>0) ResetGain(j);
610 ///////////////////////////////////////////////////////////////////////////
611 void AliAttrib::ResetOffset(Int_t j)
613 // Reset the offset value of the j-th (default j=1) attribute slot.
614 // Notes : The first attribute slot is at j=1.
615 // j=0 ==> All offset values will be reset.
617 if (!fOffsets) return;
619 Int_t size=fOffsets->GetSize();
621 if ((j>=0) && (j<=size))
625 fOffsets->AddAt(0,j-1);
626 Int_t gflag=GetGainFlag(j);
627 SetCalFlags(gflag,0,j);
631 for (Int_t i=0; i<size; i++)
633 fOffsets->AddAt(0,i);
634 Int_t gflag=GetGainFlag(i);
635 SetCalFlags(gflag,0,i);
641 cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
645 ///////////////////////////////////////////////////////////////////////////
646 void AliAttrib::ResetOffset(TString name)
648 // Reset the offset value of the name-specified attribute slot.
650 // This procedure involves a slot-index search based on the specified name
651 // at each invokation. This may become slow in case many slots have been
652 // defined and/or when this procedure is invoked many times.
653 // In such cases it is preferable to use indexed addressing in the user code
654 // either directly or via a few invokations of GetSlotIndex().
656 Int_t j=GetSlotIndex(name);
657 if (j>0) ResetOffset(j);
659 ///////////////////////////////////////////////////////////////////////////
660 void AliAttrib::DeleteCalibrations(Int_t mode)
662 // User selected delete of all gains and/or offsets.
663 // mode = 0 : All attributes (names,gains,offsets,(de)calfuncs, edge and dead values) are deleted.
664 // 1 : Only the gains are deleted.
665 // 2 : Only the offsets are deleted.
666 // 3 : Gains, offsets and (de)calfuncs are deleted, but names, edge and dead values are kept.
667 // 4 : Only the calib. functions are deleted.
668 // 5 : Only the de-calib. functions are deleted.
669 // 6 : Only the calib. and de-calib. functions are deleted.
671 // The default when invoking DeleteCalibrations() corresponds to mode=0.
673 if (mode<0 || mode>6)
675 cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
676 cout << " Default mode=0 will be used." << endl;
680 if (mode==0 || mode==3)
694 if (fCalflags && mode==0)
699 if (fNames && mode==0)
737 if (mode==4 || mode==6)
746 if (mode==5 || mode==6)
755 ///////////////////////////////////////////////////////////////////////////
756 void AliAttrib::SetDead(Int_t j)
758 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
759 // Note : The first attribute slot is at j=1.
760 // In case the value of the index j exceeds the maximum number of reserved
761 // slots for the flags, the number of reserved slots for the flags
762 // is increased automatically.
763 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
767 cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
773 fCalflags=new TArrayI(j);
776 Int_t size=fCalflags->GetSize();
784 Int_t oflag=GetOffsetFlag(j);
785 Int_t gflag=GetGainFlag(j);
786 Int_t lock=GetLockValue(j);
787 Int_t edge=GetEdgeValue(j);
789 Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
791 fCalflags->AddAt(word,j-1);
793 ///////////////////////////////////////////////////////////////////////////
794 void AliAttrib::SetDead(TString name)
796 // Set the dead flag to 1 for the name-specified attribute slot.
798 // This procedure involves a slot-index search based on the specified name
799 // at each invokation. This may become slow in case many slots have been
800 // defined and/or when this procedure is invoked many times.
801 // In such cases it is preferable to use indexed addressing in the user code
802 // either directly or via a few invokations of GetSlotIndex().
804 Int_t j=GetSlotIndex(name);
807 ///////////////////////////////////////////////////////////////////////////
808 void AliAttrib::SetAlive(Int_t j)
810 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
811 // Note : The first attribute slot is at j=1.
812 // In case the value of the index j exceeds the maximum number of reserved
813 // slots for the flags, no action is taken since by default the dead flag is 0.
814 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
818 cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
822 if (!fCalflags || j>fCalflags->GetSize()) return;
825 Int_t oflag=GetOffsetFlag(j);
826 Int_t gflag=GetGainFlag(j);
827 Int_t lock=GetLockValue(j);
828 Int_t edge=GetEdgeValue(j);
830 Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
832 fCalflags->AddAt(word,j-1);
834 ///////////////////////////////////////////////////////////////////////////
835 void AliAttrib::SetAlive(TString name)
837 // Set the dead flag to 0 for the name-specified attribute slot.
839 // This procedure involves a slot-index search based on the specified name
840 // at each invokation. This may become slow in case many slots have been
841 // defined and/or when this procedure is invoked many times.
842 // In such cases it is preferable to use indexed addressing in the user code
843 // either directly or via a few invokations of GetSlotIndex().
845 Int_t j=GetSlotIndex(name);
846 if (j>0) SetAlive(j);
848 ///////////////////////////////////////////////////////////////////////////
849 void AliAttrib::Lock(Int_t j)
851 // Set the lock flag to 1 for the j-th (default j=1) attribute slot.
852 // Note : The first attribute slot is at j=1.
853 // In case the value of the index j exceeds the maximum number of reserved
854 // slots for the flags, the number of reserved slots for the flags
855 // is increased automatically.
856 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
860 cout << " *AliAttrib::Lock* Invalid argument j = " << j << endl;
866 fCalflags=new TArrayI(j);
869 Int_t size=fCalflags->GetSize();
877 Int_t dead=GetDeadValue(j);
878 Int_t oflag=GetOffsetFlag(j);
879 Int_t gflag=GetGainFlag(j);
880 Int_t edge=GetEdgeValue(j);
882 Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
884 fCalflags->AddAt(word,j-1);
886 ///////////////////////////////////////////////////////////////////////////
887 void AliAttrib::Lock(TString name)
889 // Set the lock flag to 1 for the name-specified attribute slot.
891 // This procedure involves a slot-index search based on the specified name
892 // at each invokation. This may become slow in case many slots have been
893 // defined and/or when this procedure is invoked many times.
894 // In such cases it is preferable to use indexed addressing in the user code
895 // either directly or via a few invokations of GetSlotIndex().
897 Int_t j=GetSlotIndex(name);
900 ///////////////////////////////////////////////////////////////////////////
901 void AliAttrib::Unlock(Int_t j)
903 // Set the lock flag to 0 for the j-th (default j=1) attribute slot.
904 // Note : The first attribute slot is at j=1.
905 // In case the value of the index j exceeds the maximum number of reserved
906 // slots for the flags, no action is taken since by default the dead flag is 0.
907 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
911 cout << " *AliAttrib::Unlock* Invalid argument j = " << j << endl;
915 if (!fCalflags || j>fCalflags->GetSize()) return;
918 Int_t dead=GetDeadValue();
919 Int_t oflag=GetOffsetFlag(j);
920 Int_t gflag=GetGainFlag(j);
921 Int_t edge=GetEdgeValue(j);
923 Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
925 fCalflags->AddAt(word,j-1);
927 ///////////////////////////////////////////////////////////////////////////
928 void AliAttrib::Unlock(TString name)
930 // Set the lock flag to 0 for the name-specified attribute slot.
932 // This procedure involves a slot-index search based on the specified name
933 // at each invokation. This may become slow in case many slots have been
934 // defined and/or when this procedure is invoked many times.
935 // In such cases it is preferable to use indexed addressing in the user code
936 // either directly or via a few invokations of GetSlotIndex().
938 Int_t j=GetSlotIndex(name);
941 ///////////////////////////////////////////////////////////////////////////
942 void AliAttrib::SetEdgeOn(Int_t j)
944 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
945 // Note : The first attribute slot is at j=1.
946 // In case the value of the index j exceeds the maximum number of reserved
947 // slots for the flags, the number of reserved slots for the flags
948 // is increased automatically.
949 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
953 cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
959 ///////////////////////////////////////////////////////////////////////////
960 void AliAttrib::SetEdgeOn(TString name)
962 // Set the edge value to 1 for the name-specified attribute slot.
964 // This procedure involves a slot-index search based on the specified name
965 // at each invokation. This may become slow in case many slots have been
966 // defined and/or when this procedure is invoked many times.
967 // In such cases it is preferable to use indexed addressing in the user code
968 // either directly or via a few invokations of GetSlotIndex().
970 Int_t j=GetSlotIndex(name);
971 if (j>0) SetEdgeOn(j);
973 ///////////////////////////////////////////////////////////////////////////
974 void AliAttrib::SetEdgeOff(Int_t j)
976 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
977 // Note : The first attribute slot is at j=1.
978 // In case the value of the index j exceeds the maximum number of reserved
979 // slots for the flags, no action is taken since by default the edge flag is 0.
980 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
984 cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
988 if (!fCalflags || j>fCalflags->GetSize()) return;
992 ///////////////////////////////////////////////////////////////////////////
993 void AliAttrib::SetEdgeOff(TString name)
995 // Set the edge value to 0 for the name-specified attribute slot.
997 // This procedure involves a slot-index search based on the specified name
998 // at each invokation. This may become slow in case many slots have been
999 // defined and/or when this procedure is invoked many times.
1000 // In such cases it is preferable to use indexed addressing in the user code
1001 // either directly or via a few invokations of GetSlotIndex().
1003 Int_t j=GetSlotIndex(name);
1004 if (j>0) SetEdgeOff(j);
1006 ///////////////////////////////////////////////////////////////////////////
1007 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
1009 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
1010 // Note : The first attribute slot is at j=1.
1011 // In case the value of the index j exceeds the maximum number of reserved
1012 // slots for the flags, the number of reserved slots for the flags
1013 // is increased automatically.
1014 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
1018 cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
1024 fCalflags=new TArrayI(j);
1027 Int_t size=fCalflags->GetSize();
1035 Int_t lock=GetLockValue(j);
1036 Int_t dead=GetDeadValue(j);
1037 Int_t gflag=GetGainFlag(j);
1038 Int_t oflag=GetOffsetFlag(j);
1040 Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
1042 fCalflags->AddAt(word,j-1);
1044 ///////////////////////////////////////////////////////////////////////////
1045 void AliAttrib::SetEdgeValue(Int_t val,TString name)
1047 // Set the edge value to "val" for the name-specified attribute slot.
1049 // This procedure involves a slot-index search based on the specified name
1050 // at each invokation. This may become slow in case many slots have been
1051 // defined and/or when this procedure is invoked many times.
1052 // In such cases it is preferable to use indexed addressing in the user code
1053 // either directly or via a few invokations of GetSlotIndex().
1055 Int_t j=GetSlotIndex(name);
1056 if (j>0) SetEdgeValue(val,j);
1058 ///////////////////////////////////////////////////////////////////////////
1059 void AliAttrib::IncreaseEdgeValue(Int_t j)
1061 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
1062 // Note : The first attribute slot is at j=1.
1063 // In case the value of the index j exceeds the maximum number of reserved
1064 // slots for the flags, the number of reserved slots for the flags
1065 // is increased automatically.
1066 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
1070 cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
1074 Int_t edge=GetEdgeValue();
1075 SetEdgeValue(edge+1,j);
1077 ///////////////////////////////////////////////////////////////////////////
1078 void AliAttrib::IncreaseEdgeValue(TString name)
1080 // Increase the edge value by 1 for the name-specified attribute slot.
1082 // This procedure involves a slot-index search based on the specified name
1083 // at each invokation. This may become slow in case many slots have been
1084 // defined and/or when this procedure is invoked many times.
1085 // In such cases it is preferable to use indexed addressing in the user code
1086 // either directly or via a few invokations of GetSlotIndex().
1088 Int_t j=GetSlotIndex(name);
1089 if (j>0) IncreaseEdgeValue(j);
1091 ///////////////////////////////////////////////////////////////////////////
1092 void AliAttrib::DecreaseEdgeValue(Int_t j)
1094 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
1095 // Note : The first attribute slot is at j=1.
1096 // In case the value of the index j exceeds the maximum number of reserved
1097 // slots for the flags, the number of reserved slots for the flags
1098 // is increased automatically.
1099 // The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
1103 cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
1107 Int_t edge=GetEdgeValue();
1108 SetEdgeValue(edge-1,j);
1110 ///////////////////////////////////////////////////////////////////////////
1111 void AliAttrib::DecreaseEdgeValue(TString name)
1113 // Decrease the edge value by 1 for the name-specified attribute slot.
1115 // This procedure involves a slot-index search based on the specified name
1116 // at each invokation. This may become slow in case many slots have been
1117 // defined and/or when this procedure is invoked many times.
1118 // In such cases it is preferable to use indexed addressing in the user code
1119 // either directly or via a few invokations of GetSlotIndex().
1121 Int_t j=GetSlotIndex(name);
1122 if (j>0) DecreaseEdgeValue(j);
1124 ///////////////////////////////////////////////////////////////////////////
1125 Int_t AliAttrib::GetEdgeValue(Int_t j) const
1127 // Provide edge value of the j-th (default j=1) attribute slot.
1128 // Note : The first attribute slot is at j=1.
1129 // In case j is invalid, 0 is returned.
1133 cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
1140 if (j>0 && j<=(fCalflags->GetSize()))
1142 Int_t word=fCalflags->At(j-1);
1148 ///////////////////////////////////////////////////////////////////////////
1149 Int_t AliAttrib::GetEdgeValue(TString name) const
1151 // Provide edge value of the name-specified attribute slot.
1153 // This procedure involves a slot-index search based on the specified name
1154 // at each invokation. This may become slow in case many slots have been
1155 // defined and/or when this procedure is invoked many times.
1156 // In such cases it is preferable to use indexed addressing in the user code
1157 // either directly or via a few invokations of GetSlotIndex().
1159 Int_t j=GetSlotIndex(name);
1161 if (j>0) val=GetEdgeValue(j);
1164 ///////////////////////////////////////////////////////////////////////////
1165 Int_t AliAttrib::GetDeadValue(Int_t j) const
1167 // Provide dead value of the j-th (default j=1) attribute slot.
1168 // Note : The first attribute slot is at j=1.
1169 // In case j is invalid, 0 is returned.
1173 cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
1180 if (j>0 && j<=(fCalflags->GetSize()))
1182 Int_t word=fCalflags->At(j-1);
1189 ///////////////////////////////////////////////////////////////////////////
1190 Int_t AliAttrib::GetDeadValue(TString name) const
1192 // Provide dead value of the name-specified attribute slot.
1194 // This procedure involves a slot-index search based on the specified name
1195 // at each invokation. This may become slow in case many slots have been
1196 // defined and/or when this procedure is invoked many times.
1197 // In such cases it is preferable to use indexed addressing in the user code
1198 // either directly or via a few invokations of GetSlotIndex().
1200 Int_t j=GetSlotIndex(name);
1202 if (j>0) val=GetDeadValue(j);
1205 ///////////////////////////////////////////////////////////////////////////
1206 Int_t AliAttrib::GetLockValue(Int_t j) const
1208 // Provide lock value of the j-th (default j=1) attribute slot.
1209 // Note : The first attribute slot is at j=1.
1210 // In case j is invalid, 0 is returned.
1214 cout << " *AliAttrib::GetLockValue* Invalid argument j = " << j << endl;
1221 if (j>0 && j<=(fCalflags->GetSize()))
1223 Int_t word=fCalflags->At(j-1);
1230 ///////////////////////////////////////////////////////////////////////////
1231 Int_t AliAttrib::GetLockValue(TString name) const
1233 // Provide lock value of the name-specified attribute slot.
1235 // This procedure involves a slot-index search based on the specified name
1236 // at each invokation. This may become slow in case many slots have been
1237 // defined and/or when this procedure is invoked many times.
1238 // In such cases it is preferable to use indexed addressing in the user code
1239 // either directly or via a few invokations of GetSlotIndex().
1241 Int_t j=GetSlotIndex(name);
1243 if (j>0) val=GetLockValue(j);
1246 ///////////////////////////////////////////////////////////////////////////
1247 Int_t AliAttrib::GetNslots() const
1249 // Provide the number of existing slots.
1251 Int_t n=GetNcalflags();
1252 Int_t nn=GetNnames();
1253 Int_t ncalf=GetNcalfuncs();
1254 Int_t ndecalf=GetNdecalfuncs();
1256 if (n<ncalf) n=ncalf;
1257 if (n<ndecalf) n=ndecalf;
1261 ///////////////////////////////////////////////////////////////////////////
1262 void AliAttrib::AddNamedSlot(TString s)
1264 // Add a new slot with the specified name.
1265 // In case a slot with the specified name already exists, no action is taken.
1267 if (GetSlotIndex(s)) return;
1269 Int_t n=GetNslots();
1272 ///////////////////////////////////////////////////////////////////////////
1273 void AliAttrib::SetSlotName(TString s,Int_t j)
1275 // Set a user defined name for the j-th (default j=1) slot.
1276 // Note : The first attribute slot is at j=1.
1277 // In case the value of the index j exceeds the maximum number of reserved
1278 // slots for the names, the number of reserved slots for the names
1279 // is increased automatically to the corresponding value.
1283 cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
1289 fNames=new TObjArray(j);
1293 if (j>fNames->GetSize()) fNames->Expand(j);
1295 TObjString* so=(TObjString*)fNames->At(j-1);
1298 so=new TObjString(s.Data());
1299 fNames->AddAt(so,j-1);
1306 ///////////////////////////////////////////////////////////////////////////
1307 TString AliAttrib::GetSlotName(Int_t j) const
1309 // Provide the user defined name for the j-th (default j=1) slot.
1310 // Note : The first attribute slot is at j=1.
1315 cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
1321 if (j<=fNames->GetSize())
1323 TObjString* so=(TObjString*)fNames->At(j-1);
1324 if (so) s=so->GetString();
1329 ///////////////////////////////////////////////////////////////////////////
1330 Int_t AliAttrib::GetSlotIndex(TString name) const
1332 // Provide the slot index for the matching name.
1333 // If no matching name is found, 0 is returned.
1334 // Note : The first attribute slot is at j=1.
1341 Int_t size=fNames->GetSize();
1342 for (Int_t i=0; i<size; i++)
1344 TObjString* so=(TObjString*)fNames->At(i);
1345 if (so) s=so->GetString();
1355 ///////////////////////////////////////////////////////////////////////////
1356 void AliAttrib::List(Int_t j) const
1358 // Provide attribute information for the j-th slot.
1359 // The first slot is at j=1.
1360 // In case j=0 (default) the data of all slots will be listed.
1364 cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
1370 if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
1371 if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
1372 if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
1373 if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
1374 if (GetLockValue(j)) cout << " lock : " << GetLockValue(j);
1375 if (GetCalFunction(j)) cout << " *Fcalib*";
1376 if (GetDecalFunction(j)) cout << " *Fdecalib*";
1377 TString s=GetSlotName(j);
1378 if (s!="") cout << " name : " << s.Data();
1382 Int_t ng=GetNgains();
1383 Int_t no=GetNoffsets();
1385 if (fCalflags) nf=fCalflags->GetSize();
1386 Int_t nn=GetNnames();
1393 for (Int_t i=1; i<=n; i++)
1396 if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;}
1397 if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
1398 if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;}
1399 if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;}
1400 if (GetLockValue(i)) {cout << " lock : " << GetLockValue(i); printf=1;}
1401 if (GetCalFunction(i)) {cout << " *Fcalib*"; printf=1;}
1402 if (GetDecalFunction(i)) {cout << " *Fdecalib*"; printf=1;}
1404 if (s!="") {cout << " name : " << s.Data(); printf=1;}
1405 if (printf) cout << endl;
1409 ///////////////////////////////////////////////////////////////////////////
1410 void AliAttrib::List(TString name) const
1412 // Provide attribute information for the name-specified slot.
1414 // This procedure involves a slot-index search based on the specified name
1415 // at each invokation. This may become slow in case many slots have been
1416 // defined and/or when this procedure is invoked many times.
1417 // In such cases it is preferable to use indexed addressing in the user code
1418 // either directly or via a few invokations of GetSlotIndex().
1420 Int_t j=GetSlotIndex(name);
1423 ///////////////////////////////////////////////////////////////////////////
1424 void AliAttrib::Load(AliAttrib& a,Int_t j)
1426 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
1428 // Note : if j=0, then all attributes of all slots are loaded
1430 // The default is j=0.
1434 cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
1440 if (j==0) // load attributes for all slots
1443 for (Int_t ig=1; ig<=n; ig++)
1445 if (a.GetGainFlag(ig))
1447 SetGain(a.GetGain(ig),ig);
1455 for (Int_t io=1; io<=n; io++)
1457 if (a.GetOffsetFlag(io))
1459 SetOffset(a.GetOffset(io),io);
1467 for (Int_t ic=1; ic<=n; ic++)
1469 SetEdgeValue(a.GetEdgeValue(ic),ic);
1470 if (a.GetLockValue(ic))
1478 if (a.GetDeadValue(ic))
1489 for (Int_t in=1; in<=n; in++)
1491 s=a.GetSlotName(in);
1495 for (Int_t icalf=1; icalf<=n; icalf++)
1497 TF1* f=a.GetCalFunction(icalf);
1498 SetCalFunction(f,icalf);
1500 n=a.GetNdecalfuncs();
1501 for (Int_t idecalf=1; idecalf<=n; idecalf++)
1503 TF1* f=a.GetDecalFunction(idecalf);
1504 SetDecalFunction(f,idecalf);
1507 else // load attributes for specified j-th slot only
1512 if (a.GetGainFlag(j))
1514 SetGain(a.GetGain(j),j);
1524 if (a.GetOffsetFlag(j))
1526 SetOffset(a.GetOffset(j),j);
1536 SetEdgeValue(a.GetEdgeValue(j),j);
1537 if (a.GetLockValue(j))
1545 if (a.GetDeadValue(j))
1564 TF1* f=a.GetCalFunction(j);
1565 SetCalFunction(f,j);
1567 n=a.GetNdecalfuncs();
1570 TF1* f=a.GetDecalFunction(j);
1571 SetDecalFunction(f,j);
1575 ///////////////////////////////////////////////////////////////////////////
1576 void AliAttrib::Load(AliAttrib& a,TString name)
1578 // Load attributes of the name-specified slot of the input AliAttrib into
1579 // this AliAttrib object.
1581 // This procedure involves a slot-index search based on the specified name
1582 // at each invokation. This may become slow in case many slots have been
1583 // defined and/or when this procedure is invoked many times.
1584 // In such cases it is preferable to use indexed addressing in the user code
1585 // either directly or via a few invokations of GetSlotIndex().
1587 Int_t j=GetSlotIndex(name);
1590 ///////////////////////////////////////////////////////////////////////////
1591 Int_t AliAttrib::GetNcalfuncs() const
1593 // Provide the number of specified calib. functions for this attribute.
1595 if (!fCalfuncs) return 0;
1598 for (Int_t i=1; i<=fCalfuncs->GetSize(); i++)
1600 if (fCalfuncs->At(i-1)) n=i;
1604 ///////////////////////////////////////////////////////////////////////////
1605 Int_t AliAttrib::GetNdecalfuncs() const
1607 // Provide the number of specified de-calib. functions for this attribute.
1609 if (!fDecalfuncs) return 0;
1612 for (Int_t i=1; i<=fDecalfuncs->GetSize(); i++)
1614 if (fDecalfuncs->At(i-1)) n=i;
1618 ///////////////////////////////////////////////////////////////////////////
1619 TF1* AliAttrib::GetCalFunction(Int_t j) const
1621 // Provide pointer to the calib. function of the j-th (default j=1) slot.
1622 // Note : The first attribute slot is at j=1.
1625 if (j>0 && j<=GetNcalfuncs()) f=(TF1*)fCalfuncs->At(j-1);
1628 ///////////////////////////////////////////////////////////////////////////
1629 TF1* AliAttrib::GetCalFunction(TString name) const
1631 // Provide pointer to the calib. function of the name-specified slot.
1632 // In case no match is found, zero is returned.
1635 Int_t j=GetSlotIndex(name);
1636 if (j>0) f=GetCalFunction(j);
1639 ///////////////////////////////////////////////////////////////////////////
1640 void AliAttrib::SetCalFunction(TF1* f,Int_t j)
1642 // Set the calib. function of the j-th (default j=1) slot.
1643 // Note : The first attribute slot is at j=1.
1645 // In case the value of the index j exceeds the maximum number of reserved
1646 // positions for the functions, the number of reserved positions for the functions
1647 // is increased automatically.
1649 // In case the function pointer argument has the same value as the current function
1650 // pointer value, no action is taken since the user has already modified the actual
1653 // In case the function pointer argument is zero, the current function
1654 // is deleted and the pointer set to zero.
1656 // In all other cases the current function is deleted and a new
1657 // copy of the input function is created which becomes the current function.
1663 fCalfuncs=new TObjArray(j);
1664 fCalfuncs->SetOwner();
1667 if (j > fCalfuncs->GetSize()) fCalfuncs->Expand(j);
1669 TF1* fcur=(TF1*)fCalfuncs->At(j-1);
1674 fCalfuncs->Remove(fcur);
1681 fCalfuncs->AddAt(fcur,j-1);
1685 ///////////////////////////////////////////////////////////////////////////
1686 void AliAttrib::SetCalFunction(TF1* f,TString name)
1688 // Set the calib. function of the name-specified slot.
1690 // In case the function pointer argument has the same value as the current function
1691 // pointer value, no action is taken since the user has already modified the actual
1694 // In case the function pointer argument is zero, the current function
1695 // is deleted and the pointer set to zero.
1697 // In all other cases the current function is deleted and a new
1698 // copy of the input function is created which becomes the current function.
1700 Int_t j=GetSlotIndex(name);
1701 if (j>0) SetCalFunction(f,j);
1703 ///////////////////////////////////////////////////////////////////////////
1704 TF1* AliAttrib::GetDecalFunction(Int_t j) const
1706 // Provide pointer to the de-calib. function of the j-th (default j=1) slot.
1707 // Note : The first attribute slot is at j=1.
1710 if (j>0 && j<=GetNdecalfuncs()) f=(TF1*)fDecalfuncs->At(j-1);
1713 ///////////////////////////////////////////////////////////////////////////
1714 TF1* AliAttrib::GetDecalFunction(TString name) const
1716 // Provide pointer to the de-calib. function of the name-specified slot.
1717 // In case no match is found, zero is returned.
1720 Int_t j=GetSlotIndex(name);
1721 if (j>0) f=GetDecalFunction(j);
1724 ///////////////////////////////////////////////////////////////////////////
1725 void AliAttrib::SetDecalFunction(TF1* f,Int_t j)
1727 // Set the de-calib. function of the j-th (default j=1) slot.
1728 // Note : The first attribute slot is at j=1.
1730 // In case the value of the index j exceeds the maximum number of reserved
1731 // positions for the functions, the number of reserved positions for the functions
1732 // is increased automatically.
1734 // In case the function pointer argument has the same value as the current function
1735 // pointer value, no action is taken since the user has already modified the actual
1738 // In case the function pointer argument is zero, the current function
1739 // is deleted and the pointer set to zero.
1741 // In all other cases the current function is deleted and a new
1742 // copy of the input function is created which becomes the current function.
1748 fDecalfuncs=new TObjArray(j);
1749 fDecalfuncs->SetOwner();
1752 if (j > fDecalfuncs->GetSize()) fDecalfuncs->Expand(j);
1754 TF1* fcur=(TF1*)fDecalfuncs->At(j-1);
1759 fDecalfuncs->Remove(fcur);
1766 fDecalfuncs->AddAt(fcur,j-1);
1770 ///////////////////////////////////////////////////////////////////////////
1771 void AliAttrib::SetDecalFunction(TF1* f,TString name)
1773 // Set the de-calib. function of the name-specified slot.
1775 // In case the function pointer argument has the same value as the current function
1776 // pointer value, no action is taken since the user has already modified the actual
1779 // In case the function pointer argument is zero, the current function
1780 // is deleted and the pointer set to zero.
1782 // In all other cases the current function is deleted and a new
1783 // copy of the input function is created which becomes the current function.
1785 Int_t j=GetSlotIndex(name);
1786 if (j>0) SetDecalFunction(f,j);
1788 ///////////////////////////////////////////////////////////////////////////