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.
61 ///////////////////////////////////////////////////////////////////////////
62 AliAttrib::~AliAttrib()
64 // Destructor to delete dynamically allocated memory
86 ///////////////////////////////////////////////////////////////////////////
87 AliAttrib::AliAttrib(const AliAttrib& a)
99 for (Int_t ig=1; ig<=n; ig++)
102 if (a.GetGainFlag(ig)) SetGain(val,ig);
106 for (Int_t io=1; io<=n; io++)
109 if (a.GetOffsetFlag(io)) SetOffset(val,io);
113 for (Int_t ic=1; ic<=n; ic++)
115 SetEdgeValue(a.GetEdgeValue(ic),ic);
116 if (a.GetDeadValue(ic)) SetDead(ic);
121 for (Int_t in=1; in<=n; in++)
124 if (s!="") SetSlotName(s,in);
127 ///////////////////////////////////////////////////////////////////////////
128 Int_t AliAttrib::GetNgains() const
130 // Provide the number of specified gains for this attribute.
132 if (fGains) n=fGains->GetSize();
135 ///////////////////////////////////////////////////////////////////////////
136 Int_t AliAttrib::GetNoffsets() const
138 // Provide the number of specified offsets for this attribute.
140 if (fOffsets) n=fOffsets->GetSize();
143 ///////////////////////////////////////////////////////////////////////////
144 Int_t AliAttrib::GetNcalflags() const
146 // Provide the number of specified calib. flags for this attribute.
148 if (fCalflags) n=fCalflags->GetSize();
151 ///////////////////////////////////////////////////////////////////////////
152 Int_t AliAttrib::GetNnames() const
154 // Provide the maximum number of specified names for this attribute.
156 if (fNames) n=fNames->GetSize();
159 ///////////////////////////////////////////////////////////////////////////
160 void AliAttrib::SetGain(Double_t gain,Int_t j)
162 // Store gain value of the j-th (default j=1) attribute slot.
163 // Note : The first attribute slot is at j=1.
164 // In case the value of the index j exceeds the maximum number of reserved
165 // slots for gain values, the number of reserved slots for the gain
166 // values is increased automatically.
170 cout << " *AliAttrib::SetGain* Invalid argument j = " << j << endl;
176 fGains=new TArrayF(j);
179 Int_t size=fGains->GetSize();
186 fGains->AddAt(float(gain),j-1);
188 Int_t oflag=GetOffsetFlag(j);
190 SetCalFlags(1,oflag,j);
192 ///////////////////////////////////////////////////////////////////////////
193 void AliAttrib::SetGain(Double_t gain,TString name)
195 // Store gain value of the name-specified attribute slot.
197 // This procedure involves a slot-index search based on the specified name
198 // at each invokation. This may become slow in case many slots have been
199 // defined and/or when this procedure is invoked many times.
200 // In such cases it is preferable to use indexed addressing in the user code
201 // either directly or via a few invokations of GetSlotIndex().
203 Int_t j=GetSlotIndex(name);
204 if (j>0) SetGain(gain,j);
206 ///////////////////////////////////////////////////////////////////////////
207 void AliAttrib::SetOffset(Double_t off,Int_t j)
209 // Store offset value of the j-th (default j=1) attribute slot.
210 // Note : The first attribute slot is at j=1.
211 // In case the value of the index j exceeds the maximum number of reserved
212 // slots for offset values, the number of reserved slots for the offset
213 // values is increased automatically.
217 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
223 fOffsets=new TArrayF(j);
226 Int_t size=fOffsets->GetSize();
233 fOffsets->AddAt(float(off),j-1);
235 Int_t gflag=GetGainFlag(j);
237 SetCalFlags(gflag,1,j);
239 ///////////////////////////////////////////////////////////////////////////
240 void AliAttrib::SetOffset(Double_t off,TString name)
242 // Store offset value of the name-specified attribute slot.
244 // This procedure involves a slot-index search based on the specified name
245 // at each invokation. This may become slow in case many slots have been
246 // defined and/or when this procedure is invoked many times.
247 // In such cases it is preferable to use indexed addressing in the user code
248 // either directly or via a few invokations of GetSlotIndex().
250 Int_t j=GetSlotIndex(name);
251 if (j>0) SetOffset(off,j);
253 ///////////////////////////////////////////////////////////////////////////
254 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
256 // Store calibration flags of the j-th (default j=1) attribute slot.
257 // Note : The first attribute slot is at j=1.
258 // In case the value of the index j exceeds the maximum number of reserved
259 // slots for the calib. flags, the number of reserved slots for the calib.
260 // flags is increased automatically.
261 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
265 cout << " *AliAttrib::GetCalFlags* Invalid argument j = " << j << endl;
271 fCalflags=new TArrayI(j);
274 Int_t size=fCalflags->GetSize();
281 Int_t edge=GetEdgeValue(j);
282 Int_t dead=GetDeadValue(j);
284 Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
286 fCalflags->AddAt(word,j-1);
288 ///////////////////////////////////////////////////////////////////////////
289 Int_t AliAttrib::GetGainFlag(Int_t j) const
291 // Provide gain flag of the j-th (default j=1) attribute slot.
293 // flag = 1 : Gain was set
294 // 0 : Gain was not set
296 // Note : The first attribute slot is at j=1.
297 // In case j is invalid, 0 is returned.
301 cout << " *AliAttrib::GetGainFlag* Invalid argument j = " << j << endl;
307 if (j>0 && j<=(fCalflags->GetSize()))
309 Int_t word=fCalflags->At(j-1);
316 ///////////////////////////////////////////////////////////////////////////
317 Int_t AliAttrib::GetGainFlag(TString name) const
319 // Provide gain flag of the name-specified attribute slot.
321 // flag = 1 : Gain was set
322 // 0 : Gain was not set
325 // This procedure involves a slot-index search based on the specified name
326 // at each invokation. This may become slow in case many slots have been
327 // defined and/or when this procedure is invoked many times.
328 // In such cases it is preferable to use indexed addressing in the user code
329 // either directly or via a few invokations of GetSlotIndex().
331 Int_t j=GetSlotIndex(name);
333 if (j>0) flag=GetGainFlag(j);
336 ///////////////////////////////////////////////////////////////////////////
337 Int_t AliAttrib::GetOffsetFlag(Int_t j) const
339 // Provide offset flag of the j-th (default j=1) attribute slot.
341 // flag = 1 : Offset was set
342 // 0 : Offset was not set
344 // Note : The first attribute slot is at j=1.
345 // In case j is invalid, 0 is returned.
349 cout << " *AliAttrib::GetOffsetFlag* Invalid argument j = " << j << endl;
356 if (j>0 && j<=(fCalflags->GetSize()))
358 Int_t word=fCalflags->At(j-1);
364 ///////////////////////////////////////////////////////////////////////////
365 Int_t AliAttrib::GetOffsetFlag(TString name) const
367 // Provide ofset flag of the name-specified attribute slot.
369 // flag = 1 : Offset was set
370 // 0 : Offset was not set
373 // This procedure involves a slot-index search based on the specified name
374 // at each invokation. This may become slow in case many slots have been
375 // defined and/or when this procedure is invoked many times.
376 // In such cases it is preferable to use indexed addressing in the user code
377 // either directly or via a few invokations of GetSlotIndex().
379 Int_t j=GetSlotIndex(name);
381 if (j>0) flag=GetOffsetFlag(j);
384 ///////////////////////////////////////////////////////////////////////////
385 Float_t AliAttrib::GetGain(Int_t j) const
387 // Provide gain value of the j-th (default j=1) attribute slot.
388 // The first attribute slot is at j=1.
389 // In case no gain value was set or the argument j is invalid, 0 is returned.
390 // Note : Use GetGainFlag(j) to check whether this gain was set or not.
394 cout << " *AliAttrib::GetGain* Invalid argument j = " << j << endl;
401 if (j>0 && j<=(fGains->GetSize()))
403 if (GetGainFlag(j)) gain=fGains->At(j-1);
408 ///////////////////////////////////////////////////////////////////////////
409 Float_t AliAttrib::GetGain(TString name) const
411 // Provide gain value of the name-specified attribute slot.
413 // This procedure involves a slot-index search based on the specified name
414 // at each invokation. This may become slow in case many slots have been
415 // defined and/or when this procedure is invoked many times.
416 // In such cases it is preferable to use indexed addressing in the user code
417 // either directly or via a few invokations of GetSlotIndex().
419 Int_t j=GetSlotIndex(name);
421 if (j>0) gain=GetGain(j);
424 ///////////////////////////////////////////////////////////////////////////
425 Float_t AliAttrib::GetOffset(Int_t j) const
427 // Provide offset value of the j-th (default j=1) attribute slot.
428 // The first attribute slot at j=1.
429 // In case no offset value was set or the argument j is invalid, 0 is returned.
430 // Note : Use GetOffsetFlag(j) to check whether this offset was set or not.
434 cout << " *AliAttrib::GetOffset* Invalid argument j = " << j << endl;
441 if (j>0 && j<=(fOffsets->GetSize()))
443 if (GetOffsetFlag(j)) offset=fOffsets->At(j-1);
448 ///////////////////////////////////////////////////////////////////////////
449 Float_t AliAttrib::GetOffset(TString name) const
451 // Provide offset value of the name-specified attribute slot.
453 // This procedure involves a slot-index search based on the specified name
454 // at each invokation. This may become slow in case many slots have been
455 // defined and/or when this procedure is invoked many times.
456 // In such cases it is preferable to use indexed addressing in the user code
457 // either directly or via a few invokations of GetSlotIndex().
459 Int_t j=GetSlotIndex(name);
461 if (j>0) offset=GetOffset(j);
464 ///////////////////////////////////////////////////////////////////////////
465 void AliAttrib::ResetGain(Int_t j)
467 // Reset the gain value of the j-th (default j=1) attribute slot.
468 // Notes : The first attribute slot is at j=1.
469 // j=0 ==> All gain values will be reset.
473 Int_t size=fGains->GetSize();
475 if ((j>=0) && (j<=size))
479 fGains->AddAt(0,j-1);
480 Int_t oflag=GetOffsetFlag(j);
481 SetCalFlags(0,oflag,j);
485 for (Int_t i=0; i<size; i++)
488 Int_t oflag=GetOffsetFlag(i);
489 SetCalFlags(0,oflag,i);
495 cout << " *AliAttrib::ResetGain* Index j = " << j << " invalid." << endl;
499 ///////////////////////////////////////////////////////////////////////////
500 void AliAttrib::ResetGain(TString name)
502 // Reset the gain value of the name-specified attribute slot.
504 // This procedure involves a slot-index search based on the specified name
505 // at each invokation. This may become slow in case many slots have been
506 // defined and/or when this procedure is invoked many times.
507 // In such cases it is preferable to use indexed addressing in the user code
508 // either directly or via a few invokations of GetSlotIndex().
510 Int_t j=GetSlotIndex(name);
511 if (j>0) ResetGain(j);
513 ///////////////////////////////////////////////////////////////////////////
514 void AliAttrib::ResetOffset(Int_t j)
516 // Reset the offset value of the j-th (default j=1) attribute slot.
517 // Notes : The first attribute slot is at j=1.
518 // j=0 ==> All offset values will be reset.
520 if (!fOffsets) return;
522 Int_t size=fOffsets->GetSize();
524 if ((j>=0) && (j<=size))
528 fOffsets->AddAt(0,j-1);
529 Int_t gflag=GetGainFlag(j);
530 SetCalFlags(gflag,0,j);
534 for (Int_t i=0; i<size; i++)
536 fOffsets->AddAt(0,i);
537 Int_t gflag=GetGainFlag(i);
538 SetCalFlags(gflag,0,i);
544 cout << " *AliAttrib::ResetOffset* Index j = " << j << " invalid." << endl;
548 ///////////////////////////////////////////////////////////////////////////
549 void AliAttrib::ResetOffset(TString name)
551 // Reset the offset value of the name-specified attribute slot.
553 // This procedure involves a slot-index search based on the specified name
554 // at each invokation. This may become slow in case many slots have been
555 // defined and/or when this procedure is invoked many times.
556 // In such cases it is preferable to use indexed addressing in the user code
557 // either directly or via a few invokations of GetSlotIndex().
559 Int_t j=GetSlotIndex(name);
560 if (j>0) ResetOffset(j);
562 ///////////////////////////////////////////////////////////////////////////
563 void AliAttrib::DeleteCalibrations(Int_t mode)
565 // User selected delete of all gains and/or offsets.
566 // mode = 0 : All attributes (names, gains, offsets, edge and dead values) are deleted.
567 // 1 : Only the gains are deleted.
568 // 2 : Only the offsets are deleted.
569 // 3 : Both gains and offsets are deleted, but names, edge and dead values are kept.
571 // The default when invoking DeleteCalibrations() corresponds to mode=0.
573 if (mode<0 || mode>3)
575 cout << " *AliAttrib::DeleteCalibrations* Unknown mode : " << mode << endl;
576 cout << " Default mode=0 will be used." << endl;
580 if (mode==0 || mode==3)
594 if (fCalflags && mode==0)
599 if (fNames && mode==0)
626 ///////////////////////////////////////////////////////////////////////////
627 void AliAttrib::SetDead(Int_t j)
629 // Set the dead flag to 1 for the j-th (default j=1) attribute slot.
630 // Note : The first attribute slot is at j=1.
631 // In case the value of the index j exceeds the maximum number of reserved
632 // slots for the flags, the number of reserved slots for the flags
633 // is increased automatically.
634 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
638 cout << " *AliAttrib::SetDead* Invalid argument j = " << j << endl;
644 fCalflags=new TArrayI(j);
647 Int_t size=fCalflags->GetSize();
655 Int_t oflag=GetOffsetFlag(j);
656 Int_t gflag=GetGainFlag(j);
657 Int_t edge=GetEdgeValue(j);
659 Int_t word=1000*edge+100*dead+10*gflag+oflag;
661 fCalflags->AddAt(word,j-1);
663 ///////////////////////////////////////////////////////////////////////////
664 void AliAttrib::SetDead(TString name)
666 // Set the dead flag to 1 for the name-specified attribute slot.
668 // This procedure involves a slot-index search based on the specified name
669 // at each invokation. This may become slow in case many slots have been
670 // defined and/or when this procedure is invoked many times.
671 // In such cases it is preferable to use indexed addressing in the user code
672 // either directly or via a few invokations of GetSlotIndex().
674 Int_t j=GetSlotIndex(name);
677 ///////////////////////////////////////////////////////////////////////////
678 void AliAttrib::SetAlive(Int_t j)
680 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
681 // Note : The first attribute slot is at j=1.
682 // In case the value of the index j exceeds the maximum number of reserved
683 // slots for the flags, no action is taken since by default the dead flag is 0.
684 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
688 cout << " *AliAttrib::SetAlive* Invalid argument j = " << j << endl;
692 if (!fCalflags || j>fCalflags->GetSize()) return;
695 Int_t oflag=GetOffsetFlag(j);
696 Int_t gflag=GetGainFlag(j);
697 Int_t edge=GetEdgeValue(j);
699 Int_t word=1000*edge+100*dead+10*gflag+oflag;
701 fCalflags->AddAt(word,j-1);
703 ///////////////////////////////////////////////////////////////////////////
704 void AliAttrib::SetAlive(TString name)
706 // Set the dead flag to 0 for the name-specified attribute slot.
708 // This procedure involves a slot-index search based on the specified name
709 // at each invokation. This may become slow in case many slots have been
710 // defined and/or when this procedure is invoked many times.
711 // In such cases it is preferable to use indexed addressing in the user code
712 // either directly or via a few invokations of GetSlotIndex().
714 Int_t j=GetSlotIndex(name);
715 if (j>0) SetAlive(j);
717 ///////////////////////////////////////////////////////////////////////////
718 void AliAttrib::SetEdgeOn(Int_t j)
720 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
721 // Note : The first attribute slot is at j=1.
722 // In case the value of the index j exceeds the maximum number of reserved
723 // slots for the flags, the number of reserved slots for the flags
724 // is increased automatically.
725 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
729 cout << " *AliAttrib::SetEdgeOn* Invalid argument j = " << j << endl;
735 ///////////////////////////////////////////////////////////////////////////
736 void AliAttrib::SetEdgeOn(TString name)
738 // Set the edge value to 1 for the name-specified attribute slot.
740 // This procedure involves a slot-index search based on the specified name
741 // at each invokation. This may become slow in case many slots have been
742 // defined and/or when this procedure is invoked many times.
743 // In such cases it is preferable to use indexed addressing in the user code
744 // either directly or via a few invokations of GetSlotIndex().
746 Int_t j=GetSlotIndex(name);
747 if (j>0) SetEdgeOn(j);
749 ///////////////////////////////////////////////////////////////////////////
750 void AliAttrib::SetEdgeOff(Int_t j)
752 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
753 // Note : The first attribute slot is at j=1.
754 // In case the value of the index j exceeds the maximum number of reserved
755 // slots for the flags, no action is taken since by default the edge flag is 0.
756 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
760 cout << " *AliAttrib::SetEdgeOff* Invalid argument j = " << j << endl;
764 if (!fCalflags || j>fCalflags->GetSize()) return;
768 ///////////////////////////////////////////////////////////////////////////
769 void AliAttrib::SetEdgeOff(TString name)
771 // Set the edge value to 0 for the name-specified attribute slot.
773 // This procedure involves a slot-index search based on the specified name
774 // at each invokation. This may become slow in case many slots have been
775 // defined and/or when this procedure is invoked many times.
776 // In such cases it is preferable to use indexed addressing in the user code
777 // either directly or via a few invokations of GetSlotIndex().
779 Int_t j=GetSlotIndex(name);
780 if (j>0) SetEdgeOff(j);
782 ///////////////////////////////////////////////////////////////////////////
783 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
785 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
786 // Note : The first attribute slot is at j=1.
787 // In case the value of the index j exceeds the maximum number of reserved
788 // slots for the flags, the number of reserved slots for the flags
789 // is increased automatically.
790 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
794 cout << " *AliAttrib::SetEdgeValue* Invalid argument j = " << j << endl;
800 fCalflags=new TArrayI(j);
803 Int_t size=fCalflags->GetSize();
811 Int_t dead=GetDeadValue(j);
812 Int_t gflag=GetGainFlag(j);
813 Int_t oflag=GetOffsetFlag(j);
815 Int_t word=1000*edge+100*dead+10*gflag+oflag;
817 fCalflags->AddAt(word,j-1);
819 ///////////////////////////////////////////////////////////////////////////
820 void AliAttrib::SetEdgeValue(Int_t val,TString name)
822 // Set the edge value to "val" for the name-specified attribute slot.
824 // This procedure involves a slot-index search based on the specified name
825 // at each invokation. This may become slow in case many slots have been
826 // defined and/or when this procedure is invoked many times.
827 // In such cases it is preferable to use indexed addressing in the user code
828 // either directly or via a few invokations of GetSlotIndex().
830 Int_t j=GetSlotIndex(name);
831 if (j>0) SetEdgeValue(val,j);
833 ///////////////////////////////////////////////////////////////////////////
834 void AliAttrib::IncreaseEdgeValue(Int_t j)
836 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
837 // Note : The first attribute slot is at j=1.
838 // In case the value of the index j exceeds the maximum number of reserved
839 // slots for the flags, the number of reserved slots for the flags
840 // is increased automatically.
841 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
845 cout << " *AliAttrib::IncreaseEdgeValue* Invalid argument j = " << j << endl;
849 Int_t edge=GetEdgeValue();
850 SetEdgeValue(edge+1,j);
852 ///////////////////////////////////////////////////////////////////////////
853 void AliAttrib::IncreaseEdgeValue(TString name)
855 // Increase the edge value by 1 for the name-specified attribute slot.
857 // This procedure involves a slot-index search based on the specified name
858 // at each invokation. This may become slow in case many slots have been
859 // defined and/or when this procedure is invoked many times.
860 // In such cases it is preferable to use indexed addressing in the user code
861 // either directly or via a few invokations of GetSlotIndex().
863 Int_t j=GetSlotIndex(name);
864 if (j>0) IncreaseEdgeValue(j);
866 ///////////////////////////////////////////////////////////////////////////
867 void AliAttrib::DecreaseEdgeValue(Int_t j)
869 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
870 // Note : The first attribute slot is at j=1.
871 // In case the value of the index j exceeds the maximum number of reserved
872 // slots for the flags, the number of reserved slots for the flags
873 // is increased automatically.
874 // The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
878 cout << " *AliAttrib::DecreaseEdgeValue* Invalid argument j = " << j << endl;
882 Int_t edge=GetEdgeValue();
883 SetEdgeValue(edge-1,j);
885 ///////////////////////////////////////////////////////////////////////////
886 void AliAttrib::DecreaseEdgeValue(TString name)
888 // Decrease the edge value by 1 for the name-specified attribute slot.
890 // This procedure involves a slot-index search based on the specified name
891 // at each invokation. This may become slow in case many slots have been
892 // defined and/or when this procedure is invoked many times.
893 // In such cases it is preferable to use indexed addressing in the user code
894 // either directly or via a few invokations of GetSlotIndex().
896 Int_t j=GetSlotIndex(name);
897 if (j>0) DecreaseEdgeValue(j);
899 ///////////////////////////////////////////////////////////////////////////
900 Int_t AliAttrib::GetEdgeValue(Int_t j) const
902 // Provide edge value of the j-th (default j=1) attribute slot.
903 // Note : The first attribute slot is at j=1.
904 // In case j is invalid, 0 is returned.
908 cout << " *AliAttrib::GetEdgeValue* Invalid argument j = " << j << endl;
915 if (j>0 && j<=(fCalflags->GetSize()))
917 Int_t word=fCalflags->At(j-1);
923 ///////////////////////////////////////////////////////////////////////////
924 Int_t AliAttrib::GetEdgeValue(TString name) const
926 // Provide edge value of the name-specified attribute slot.
928 // This procedure involves a slot-index search based on the specified name
929 // at each invokation. This may become slow in case many slots have been
930 // defined and/or when this procedure is invoked many times.
931 // In such cases it is preferable to use indexed addressing in the user code
932 // either directly or via a few invokations of GetSlotIndex().
934 Int_t j=GetSlotIndex(name);
936 if (j>0) val=GetEdgeValue(j);
939 ///////////////////////////////////////////////////////////////////////////
940 Int_t AliAttrib::GetDeadValue(Int_t j) const
942 // Provide dead value of the j-th (default j=1) attribute slot.
943 // Note : The first attribute slot is at j=1.
944 // In case j is invalid, 0 is returned.
948 cout << " *AliAttrib::GetDeadValue* Invalid argument j = " << j << endl;
955 if (j>0 && j<=(fCalflags->GetSize()))
957 Int_t word=fCalflags->At(j-1);
964 ///////////////////////////////////////////////////////////////////////////
965 Int_t AliAttrib::GetDeadValue(TString name) const
967 // Provide dead value of the name-specified attribute slot.
969 // This procedure involves a slot-index search based on the specified name
970 // at each invokation. This may become slow in case many slots have been
971 // defined and/or when this procedure is invoked many times.
972 // In such cases it is preferable to use indexed addressing in the user code
973 // either directly or via a few invokations of GetSlotIndex().
975 Int_t j=GetSlotIndex(name);
977 if (j>0) val=GetDeadValue(j);
980 ///////////////////////////////////////////////////////////////////////////
981 void AliAttrib::SetSlotName(TString s,Int_t j)
983 // Set a user defined name for the j-th (default j=1) slot.
984 // Note : The first attribute slot is at j=1.
988 cout << " *AliAttrib::SetSlotName* Invalid argument j = " << j << endl;
994 fNames=new TObjArray(j);
998 if (j>fNames->GetSize()) fNames->Expand(j);
1000 TObjString* so=(TObjString*)fNames->At(j-1);
1003 so=new TObjString(s.Data());
1004 fNames->AddAt(so,j-1);
1011 ///////////////////////////////////////////////////////////////////////////
1012 TString AliAttrib::GetSlotName(Int_t j) const
1014 // Provide the user defined name for the j-th (default j=1) slot.
1015 // Note : The first attribute slot is at j=1.
1020 cout << " *AliAttrib::GetSlotName* Invalid argument j = " << j << endl;
1026 if (j<=fNames->GetSize())
1028 TObjString* so=(TObjString*)fNames->At(j-1);
1029 if (so) s=so->GetString();
1034 ///////////////////////////////////////////////////////////////////////////
1035 Int_t AliAttrib::GetSlotIndex(TString name) const
1037 // Provide the slot index for the matching name.
1038 // If no matching name is found, 0 is returned.
1039 // Note : The first attribute slot is at j=1.
1046 Int_t size=fNames->GetSize();
1047 for (Int_t i=0; i<size; i++)
1049 TObjString* so=(TObjString*)fNames->At(i);
1050 if (so) s=so->GetString();
1060 ///////////////////////////////////////////////////////////////////////////
1061 void AliAttrib::List(Int_t j) const
1063 // Provide attribute information for the j-th slot.
1064 // The first slot is at j=1.
1065 // In case j=0 (default) the data of all slots will be listed.
1069 cout << " *AliAttrib::Data* Invalid argument j = " << j << endl;
1075 if (GetGainFlag(j)) cout << " gain : " << GetGain(j);
1076 if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
1077 if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
1078 if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
1079 TString s=GetSlotName(j);
1080 if (s!="") cout << " name : " << s.Data();
1084 Int_t ng=GetNgains();
1085 Int_t no=GetNoffsets();
1087 if (fCalflags) nf=fCalflags->GetSize();
1088 Int_t nn=GetNnames();
1095 for (Int_t i=1; i<=n; i++)
1098 if (GetGainFlag(i)) {cout << " gain : " << GetGain(i); printf=1;}
1099 if (GetOffsetFlag(i)) {cout << " offset : " << GetOffset(i); printf=1;}
1100 if (GetEdgeValue(i)) {cout << " edge : " << GetEdgeValue(i); printf=1;}
1101 if (GetDeadValue(i)) {cout << " dead : " << GetDeadValue(i); printf=1;}
1103 if (s!="") {cout << " name : " << s.Data(); printf=1;}
1104 if (printf) cout << endl;
1108 ///////////////////////////////////////////////////////////////////////////
1109 void AliAttrib::List(TString name) const
1111 // Provide attribute information for the name-specified slot.
1113 // This procedure involves a slot-index search based on the specified name
1114 // at each invokation. This may become slow in case many slots have been
1115 // defined and/or when this procedure is invoked many times.
1116 // In such cases it is preferable to use indexed addressing in the user code
1117 // either directly or via a few invokations of GetSlotIndex().
1119 Int_t j=GetSlotIndex(name);
1122 ///////////////////////////////////////////////////////////////////////////
1123 void AliAttrib::Load(AliAttrib& a,Int_t j)
1125 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
1127 // Note : if j=0, then all attributes of all slots are loaded
1129 // The default is j=0.
1133 cout << " *AliAttrib::Load* Invalid argument j = " << j << endl;
1139 if (j==0) // load attributes for all slots
1142 for (Int_t ig=1; ig<=n; ig++)
1144 if (a.GetGainFlag(ig))
1146 SetGain(a.GetGain(ig),ig);
1154 for (Int_t io=1; io<=n; io++)
1156 if (a.GetOffsetFlag(io))
1158 SetOffset(a.GetOffset(io),io);
1166 for (Int_t ic=1; ic<=n; ic++)
1168 SetEdgeValue(a.GetEdgeValue(ic),ic);
1169 if (a.GetDeadValue(ic))
1181 for (Int_t in=1; in<=n; in++)
1183 s=a.GetSlotName(in);
1184 if (s!="") SetSlotName(s,in);
1188 else // load attributes for specified j-th slot only
1193 if (a.GetGainFlag(j))
1195 SetGain(a.GetGain(j),j);
1205 if (a.GetOffsetFlag(j))
1207 SetOffset(a.GetOffset(j),j);
1217 SetEdgeValue(a.GetEdgeValue(j),j);
1218 if (a.GetDeadValue(j))
1233 if (s!="") SetSlotName(s,j);
1238 ///////////////////////////////////////////////////////////////////////////
1239 void AliAttrib::Load(AliAttrib& a,TString name)
1241 // Load attributes of the name-specified slot of the input AliAttrib into
1242 // this AliAttrib object.
1244 // This procedure involves a slot-index search based on the specified name
1245 // at each invokation. This may become slow in case many slots have been
1246 // defined and/or when this procedure is invoked many times.
1247 // In such cases it is preferable to use indexed addressing in the user code
1248 // either directly or via a few invokations of GetSlotIndex().
1250 Int_t j=GetSlotIndex(name);
1253 ///////////////////////////////////////////////////////////////////////////