1 ////////////////////////////////////////////////////////////////////////////////////
2 // Author: Henrik Tydesjo //
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. //
9 ////////////////////////////////////////////////////////////////////////////////////
11 #include "AliITSTriggerAlgorithmConditions.h"
12 #include <TObjString.h>
14 ClassImp(AliITSTriggerAlgorithmConditions)
16 //__________________________________________________________________________
17 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions():
20 fLabel(TString("label")),
21 fDescription(TString("descr")),
23 fParamNames(TObjArray(3)),
24 fParamValues(TArrayI(3))
26 // default constructor
27 fParamNames.SetOwner(kTRUE);
29 //__________________________________________________________________________
30 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr):
36 fParamNames(TObjArray(3)),
37 fParamValues(TArrayI(3))
39 // optional constructor
40 fParamNames.SetOwner(kTRUE);
42 //__________________________________________________________________________
43 AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond):
47 fDescription(cond.fDescription),
48 fNumParam(cond.fNumParam),
49 fParamNames(cond.fParamNames),
50 fParamValues(cond.fParamValues)
52 // default constructor
53 fParamNames.SetOwner(kTRUE);
55 //__________________________________________________________________________
56 AliITSTriggerAlgorithmConditions::~AliITSTriggerAlgorithmConditions()
61 //__________________________________________________________________________
62 AliITSTriggerAlgorithmConditions& AliITSTriggerAlgorithmConditions::operator=(const AliITSTriggerAlgorithmConditions& cond) {
63 // assignment operator
67 fDescription = cond.fDescription;
68 fNumParam = cond.fNumParam;
69 fParamNames = cond.fParamNames;
70 fParamValues = cond.fParamValues;
74 //__________________________________________________________________________
75 void AliITSTriggerAlgorithmConditions::ClearParams() {
76 // clears parameter list
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) {
91 if (findIndex<fNumParam) {
92 fParamValues[findIndex]=value;
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;
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);
109 return ((TObjString*)fParamNames.At(index))->GetString().Data();
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);
118 return fParamValues.At(index);
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) {
130 if (findIndex==fNumParam) {
131 Error("AliITSTriggerAlgorithmConditions::GetParamValueN", "name %s not found", name);
134 return fParamValues.At(findIndex);