Line data Source code
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 118 : ClassImp(AliITSTriggerAlgorithmConditions)
15 :
16 : //__________________________________________________________________________
17 : AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions():
18 50 : TObject(),
19 50 : fId(0),
20 50 : fLabel(TString("label")),
21 50 : fDescription(TString("descr")),
22 50 : fNumParam(0),
23 50 : fParamNames(TObjArray(3)),
24 50 : fParamValues(TArrayI(3))
25 250 : {
26 : // default constructor
27 50 : fParamNames.SetOwner(kTRUE);
28 100 : }
29 : //__________________________________________________________________________
30 : AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr):
31 0 : TObject(),
32 0 : fId(id),
33 0 : fLabel(label),
34 0 : fDescription(descr),
35 0 : fNumParam(0),
36 0 : fParamNames(TObjArray(3)),
37 0 : fParamValues(TArrayI(3))
38 0 : {
39 : // optional constructor
40 0 : fParamNames.SetOwner(kTRUE);
41 0 : }
42 : //__________________________________________________________________________
43 : AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond):
44 0 : TObject(),
45 0 : fId(cond.fId),
46 0 : fLabel(cond.fLabel),
47 0 : fDescription(cond.fDescription),
48 0 : fNumParam(cond.fNumParam),
49 0 : fParamNames(cond.fParamNames),
50 0 : fParamValues(cond.fParamValues)
51 0 : {
52 : // default constructor
53 0 : fParamNames.SetOwner(kTRUE);
54 0 : }
55 : //__________________________________________________________________________
56 : AliITSTriggerAlgorithmConditions::~AliITSTriggerAlgorithmConditions()
57 180 : {
58 : // destructor
59 30 : ClearParams();
60 90 : }
61 : //__________________________________________________________________________
62 : AliITSTriggerAlgorithmConditions& AliITSTriggerAlgorithmConditions::operator=(const AliITSTriggerAlgorithmConditions& cond) {
63 : // assignment operator
64 0 : if (this!=&cond) {
65 0 : fId = cond.fId;
66 0 : fLabel = cond.fLabel;
67 0 : fDescription = cond.fDescription;
68 0 : fNumParam = cond.fNumParam;
69 0 : fParamNames = cond.fParamNames;
70 0 : fParamValues = cond.fParamValues;
71 0 : }
72 0 : return *this;
73 : }
74 : //__________________________________________________________________________
75 : void AliITSTriggerAlgorithmConditions::ClearParams() {
76 : // clears parameter list
77 60 : fParamNames.Clear();
78 30 : fNumParam=0;
79 30 : }
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 0 : UShort_t findIndex=fNumParam;
85 0 : for (UInt_t i=0; i<fNumParam; i++) {
86 0 : if (((TObjString*)fParamNames.At(i))->String().CompareTo(name, TString::kIgnoreCase) == 0) {
87 0 : findIndex = i;
88 0 : break;
89 : }
90 : }
91 0 : if (findIndex<fNumParam) {
92 0 : fParamValues[findIndex]=value;
93 0 : }
94 : else {
95 0 : fParamNames.AddAtAndExpand(new TObjString(name),fNumParam);
96 0 : Int_t valSize = fParamValues.GetSize();
97 0 : if (valSize<=fNumParam) fParamValues.Set(valSize*2);
98 0 : fParamValues[fNumParam]=value;
99 0 : fNumParam++;
100 : }
101 0 : }
102 : //__________________________________________________________________________
103 : const Char_t* AliITSTriggerAlgorithmConditions::GetParamNameI(UShort_t index) const {
104 : // returns parameter name for parameter at position index
105 0 : if (index>=fNumParam) {
106 0 : Error("AliITSTriggerAlgorithmConditions::GetParamNameI", "index %d out of range", index);
107 0 : return "dummy";
108 : }
109 0 : return ((TObjString*)fParamNames.At(index))->String().Data();
110 0 : }
111 : //__________________________________________________________________________
112 : Int_t AliITSTriggerAlgorithmConditions::GetParamValueI(UShort_t index) const {
113 : // returns paramter value at position index
114 0 : if (index>=fNumParam) {
115 0 : Error("AliITSTriggerAlgorithmConditions::GetParamValueI", "index %d out of range", index);
116 0 : return -1;
117 : }
118 0 : return fParamValues.At(index);
119 0 : }
120 : //__________________________________________________________________________
121 : Int_t AliITSTriggerAlgorithmConditions::GetParamValueN(const Char_t* name) const {
122 : // returns parameter value for parameter with name 'name'
123 144 : UShort_t findIndex=fNumParam;
124 224 : for (UInt_t i=0; i<fNumParam; i++) {
125 112 : if (((TObjString*)fParamNames.At(i))->String().CompareTo(name, TString::kIgnoreCase) == 0) {
126 72 : findIndex = i;
127 72 : break;
128 : }
129 : }
130 72 : if (findIndex==fNumParam) {
131 0 : Error("AliITSTriggerAlgorithmConditions::GetParamValueN", "name %s not found", name);
132 0 : return -1;
133 : }
134 72 : return fParamValues.At(findIndex);
135 72 : }
|