Stupid bug fix in new superlight mode (from Zurich airport)
[u/mrichter/AliRoot.git] / ITS / AliITSTriggerAlgorithmConditions.cxx
1 ////////////////////////////////////////////////////////////////////////////////////
2 // Author: Henrik Tydesjo                                                         //
3 //                                                                                //
4 // Class for storing conditions data from Pixel Trigger (PIT) algorithms.         //
5 // This holds a sub set of the conditions data needed.                            //
6 // It is used by AliITSTriggerConditions, which holds all the information.        //
7 // AliITSTriggerConditions contains a TObjArray of this type.                     //
8 //                                                                                //
9 ////////////////////////////////////////////////////////////////////////////////////
10
11 #include "AliITSTriggerAlgorithmConditions.h"
12 #include <TObjString.h>
13
14 ClassImp(AliITSTriggerAlgorithmConditions)
15
16 //__________________________________________________________________________
17 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions():
18 TObject(),
19 fId(0),
20 fLabel(TString("label")),
21 fDescription(TString("descr")),
22 fNumParam(0),
23 fParamNames(TObjArray(3)),
24 fParamValues(TArrayI(3))
25 {
26   // default constructor
27   fParamNames.SetOwner(kTRUE);
28 }
29 //__________________________________________________________________________
30 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr):
31 TObject(),
32 fId(id),
33 fLabel(label),
34 fDescription(descr),
35 fNumParam(0),
36 fParamNames(TObjArray(3)),
37 fParamValues(TArrayI(3))
38 {
39   // optional constructor
40   fParamNames.SetOwner(kTRUE);
41 }
42 //__________________________________________________________________________
43 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond):
44 TObject(),
45 fId(cond.fId),
46 fLabel(cond.fLabel),
47 fDescription(cond.fDescription),
48 fNumParam(cond.fNumParam),
49 fParamNames(cond.fParamNames),
50 fParamValues(cond.fParamValues)
51 {
52   // default constructor
53   fParamNames.SetOwner(kTRUE);
54 }
55 //__________________________________________________________________________
56 AliITSTriggerAlgorithmConditions::~AliITSTriggerAlgorithmConditions() 
57 {
58   // destructor
59   ClearParams();
60 }
61 //__________________________________________________________________________
62 AliITSTriggerAlgorithmConditions& AliITSTriggerAlgorithmConditions::operator=(const AliITSTriggerAlgorithmConditions& cond) {
63   // assignment operator
64   if (this!=&cond) {
65     fId = cond.fId;
66     fLabel = cond.fLabel;
67     fDescription = cond.fDescription;
68     fNumParam = cond.fNumParam;
69     fParamNames = cond.fParamNames;
70     fParamValues = cond.fParamValues;
71   }
72   return *this;
73 }
74 //__________________________________________________________________________
75 void AliITSTriggerAlgorithmConditions::ClearParams() {
76   // clears parameter list
77   fParamNames.Clear();
78   fNumParam=0;
79 }
80 //__________________________________________________________________________
81 void AliITSTriggerAlgorithmConditions::AddParam(const Char_t* name, Int_t value) {
82   // adds a new parameter with name 'name' and value 'value'
83   // if the name is already present in the list, the parameter value will be over-written
84   UShort_t findIndex=fNumParam;
85   for (UInt_t i=0; i<fNumParam; i++) {
86     if (((TObjString*)fParamNames.At(i))->GetString().CompareTo(name, TString::kIgnoreCase) == 0) {
87       findIndex = i;
88       break;
89     }
90   }
91   if (findIndex<fNumParam) {
92     fParamValues[findIndex]=value;
93   }
94   else {
95     fParamNames.AddAtAndExpand(new TObjString(name),fNumParam);
96     Int_t valSize = fParamValues.GetSize();
97     if (valSize<=fNumParam) fParamValues.Set(valSize*2);
98     fParamValues[fNumParam]=value;
99     fNumParam++;
100   }
101 }
102 //__________________________________________________________________________
103 const Char_t* AliITSTriggerAlgorithmConditions::GetParamNameI(UShort_t index) const {
104   // returns parameter name for parameter at position index
105   if (index>=fNumParam) {
106     Error("AliITSTriggerAlgorithmConditions::GetParamNameI", "index %d out of range", index);
107     return "dummy";
108   }
109   return ((TObjString*)fParamNames.At(index))->GetString().Data();
110 }
111 //__________________________________________________________________________
112 Int_t AliITSTriggerAlgorithmConditions::GetParamValueI(UShort_t index) const {
113   // returns paramter value at position index
114   if (index>=fNumParam) {
115     Error("AliITSTriggerAlgorithmConditions::GetParamValueI", "index %d out of range", index);
116     return -1;
117   }
118   return fParamValues.At(index);
119 }
120 //__________________________________________________________________________
121 Int_t AliITSTriggerAlgorithmConditions::GetParamValueN(const Char_t* name) const {
122   // returns parameter value for parameter with name 'name'
123   UShort_t findIndex=fNumParam;
124   for (UInt_t i=0; i<fNumParam; i++) {
125     if (((TObjString*)fParamNames.At(i))->GetString().CompareTo(name, TString::kIgnoreCase) == 0) {
126       findIndex = i;
127       break;
128     }
129   }
130   if (findIndex==fNumParam) {
131     Error("AliITSTriggerAlgorithmConditions::GetParamValueN", "name %s not found", name);
132     return -1;
133   }
134   return fParamValues.At(findIndex);
135 }