]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSTriggerAlgorithmConditions.cxx
Extend q_ij range for pp and pPb
[u/mrichter/AliRoot.git] / ITS / AliITSTriggerAlgorithmConditions.cxx
CommitLineData
ad7f2bfa 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
14ClassImp(AliITSTriggerAlgorithmConditions)
15
16//__________________________________________________________________________
17AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions():
18TObject(),
19fId(0),
20fLabel(TString("label")),
21fDescription(TString("descr")),
22fNumParam(0),
23fParamNames(TObjArray(3)),
24fParamValues(TArrayI(3))
25{
26 // default constructor
27 fParamNames.SetOwner(kTRUE);
28}
29//__________________________________________________________________________
30AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr):
31TObject(),
32fId(id),
33fLabel(label),
34fDescription(descr),
35fNumParam(0),
36fParamNames(TObjArray(3)),
37fParamValues(TArrayI(3))
38{
39 // optional constructor
40 fParamNames.SetOwner(kTRUE);
41}
42//__________________________________________________________________________
43AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond):
44TObject(),
45fId(cond.fId),
46fLabel(cond.fLabel),
47fDescription(cond.fDescription),
48fNumParam(cond.fNumParam),
49fParamNames(cond.fParamNames),
50fParamValues(cond.fParamValues)
51{
52 // default constructor
53 fParamNames.SetOwner(kTRUE);
54}
55//__________________________________________________________________________
56AliITSTriggerAlgorithmConditions::~AliITSTriggerAlgorithmConditions()
57{
58 // destructor
59 ClearParams();
60}
61//__________________________________________________________________________
62AliITSTriggerAlgorithmConditions& 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//__________________________________________________________________________
75void AliITSTriggerAlgorithmConditions::ClearParams() {
76 // clears parameter list
77 fParamNames.Clear();
78 fNumParam=0;
79}
80//__________________________________________________________________________
81void 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//__________________________________________________________________________
103const 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//__________________________________________________________________________
112Int_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//__________________________________________________________________________
121Int_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}