]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTMuonSpectroScalars.h
bugfix: setting the monitoring event command in the EventDoneData only for the trigge...
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTMuonSpectroScalars.h
CommitLineData
c1550d2c 1//-*- Mode: C++ -*-
2// $Id: $
3#ifndef AliHLTMUONSPECTROSCALARS_H
4#define AliHLTMUONSPECTROSCALARS_H
5/* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
9/// @file AliHLTMuonSpectroScalars.h
10/// @author Artur Szostak <artursz@iafrica.com>
11/// @date 9 Nov 2009
12/// @brief Declares the scalars class for the muon spectrometer.
13
14#include "TObject.h"
15#include "TObjArray.h"
16#include "TClonesArray.h"
17
18/**
19 * @class AliHLTMuonSpectroScalars
20 * @brief Muon spectrometer HLT trigger summary scalars.
21 *
22 * This scalars class contains summary information such as the number of tracks found,
23 * number of pairs found and so on, all within the muon spectrometer.
24 * Objects of this class are generated by the AliHLTMuonSpectroTriggerComponent to
25 * be used in the HLT global trigger and/or added to the AliHLTEventSummary object.
26 *
27 * \ingroup alihlt_trigger_components
28 */
29class AliHLTMuonSpectroScalars : public TObject
30{
31public:
32 /**
33 * Scalar class to store all the required information for a muon spectrometer scalar.
34 */
35 class AliScalar : public TObject
36 {
37 public:
38 /// Default constructor
39 AliScalar() : TObject(), fValue(0), fName(), fDescription() {}
40
41 /// Constructor to set some initial values.
42 AliScalar(Double_t value, const char* name, const char* description) :
43 TObject(), fValue(value), fName(name), fDescription(description)
44 {}
45
46 /// Default destructor
47 virtual ~AliScalar() {}
48
49 /// Inherited from TObject. Returns the name of the scalar.
50 virtual const char* GetName() const { return fName; }
51
52 /// Inherited from TObject. Returns the description of the scalar.
53 virtual const char* GetTitle() const {return fDescription; }
54
55 /// Inherited from TObject. Compares two scalar names.
56 virtual Int_t Compare(const TObject *obj) const
57 {
58 return fName.CompareTo(obj->GetName());
59 }
60
61 /// Inherited from TObject. Returns true.
62 virtual Bool_t IsSortable() const { return kTRUE; }
63
64 /**
65 * Inherited from TObject.
66 * Returns true if the names of the scalars are the same.
67 */
68 virtual Bool_t IsEqual(const TObject *obj) const
69 {
70 return fName == obj->GetName();
71 }
72
73 /// Resets the scalar value.
74 virtual void Clear(Option_t* /*option*/ = "") { fValue = 0; }
75
76 /// Inherited form TObject. Performs a deep copy.
77 virtual void Copy(TObject& object) const;
78
79 /// Returns the value of the scalar.
80 Double_t Value() const { return fValue; }
81
82 /**
83 * Sets a new value for the scalar.
84 * \param value The new value to use. If negative then 0 is used instead.
85 */
86 void Value(Double_t value) { fValue = value >= 0 ? value : 0; }
87
88 /// Increments the scalar value by 'count'.
89 void Increment(UInt_t count = 1) { fValue += count; }
90
91 /// Returns the name of the scalar.
92 const char* Name() const { return fName.Data(); }
93
94 /// Returns the description string for the scalar.
95 const char* Description() const { return fDescription.Data(); }
96
97 /// Checks if two scalar objects are equal.
98 bool operator == (const AliScalar& x) const
99 {
100 return fValue == x.fValue and fName == x.fName
101 and fDescription == x.fDescription;
102 }
103
104 /// Checks if two scalar objects are not equal.
105 bool operator != (const AliScalar& x) const
106 {
107 return not (this->operator == (x));
108 }
109
110 private:
111 Double_t fValue; /// The scalar value.
112 TString fName; /// The name of the scalar.
113 TString fDescription; /// A description of what the scalar represents.
114
115 ClassDef(AliScalar, 1); // A scalar value for the muon spectrometer.
116 };
117
118 /// Default constructor.
119 AliHLTMuonSpectroScalars();
120
121 /// The copy constructor performs a deep copy.
122 AliHLTMuonSpectroScalars(const AliHLTMuonSpectroScalars& obj);
123
124 /// Default destructor.
125 virtual ~AliHLTMuonSpectroScalars();
126
127 /**
128 * Adds a new scalar to the end of the scalars list.
129 * \param name The name of the scalar value.
130 * \param description A short description of the scalar value.
131 * \param value The value of the new scalar.
132 */
133 void Add(const char* name, const char* description, Double_t value = 0);
134
135 /// Returns the number of scalar values.
136 UInt_t NumberOfScalars() const { return UInt_t(fScalars.GetEntriesFast()); }
137
138 /// Checks to see if the named scalar exists.
139 bool Exists(const char* name) const;
140
141 /**
142 * Fetches the n'th scalar object.
143 * \param n The scalar object to fetch.
144 * \returns the n'th scalar object, otherwise NULL if <i>n</i> was out of range.
145 */
146 AliScalar* GetScalarN(UInt_t n);
147 const AliScalar* GetScalarN(UInt_t n) const;
148
149 /**
150 * Fetches the named scalar object. Will apply a binary search for the object.
151 * This means rebuilding the internal index if necessary.
152 * \param name The name of the scalar object.
153 * \returns the found scalar object, otherwise NULL if it was not found.
154 */
155 AliScalar* GetScalar(const char* name);
156 const AliScalar* GetScalar(const char* name) const;
157
158 /**
159 * Fetches the n'th scalar value.
160 * \param n The scalar number to fetch.
161 * \returns the n'th scalar, otherwise 0 if <i>n</i> was out of range.
162 */
163 Double_t GetN(UInt_t n) const;
164
165 /**
166 * Fetches the a scalar value by name.
167 * \param name The name of the scalar.
168 * \returns the scalar's value, otherwise 0 if it could not be found.
169 */
170 Double_t Get(const char* name) const;
171
172 /**
173 * Sets the n'th scalar value.
174 * \param n The scalar number to set.
175 * \param value The new value for the scalar.
176 * \returns true if the scalar could be set, otherwise false which means
177 * that <i>n</i> was out of range.
178 */
179 bool SetN(UInt_t n, Double_t value);
180
181 /**
182 * Sets the named scalar's value.
183 * \param name The name of the scalar to set.
184 * \param value The new value for the scalar.
185 * \returns true if the scalar could be set, otherwise false which means
186 * that it was not found.
187 */
188 bool Set(const char* name, Double_t value);
189
190 /**
191 * Increments the n'th scalar by a value of 'count'.
192 * \param n The scalar number to increment.
193 * \param count The number to increment the scalar by. The default is 1.
194 * \returns true if the scalar could be incremented, otherwise false
195 * which means that <i>n</i> was out of range.
196 */
197 bool IncrementN(UInt_t n, UInt_t count = 1);
198
199 /**
200 * Increments the n'th scalar by a value of 'count'.
201 * \param name The name of the scalar to set.
202 * \param count The number to increment the scalar by. The default is 1.
203 * \returns true if the scalar could be incremented, otherwise false
204 * which means that it could not be found.
205 */
206 bool Increment(const char* name, UInt_t count = 1);
207
208 /**
209 * Returns the name of the n'th scalar.
210 * \param n The scalar number for which to return the name.
211 * \returns the n'th scalar's name, otherwise NULL if <i>n</i> was out of range.
212 */
213 const char* Name(UInt_t n) const;
214
215 /**
216 * Returns the description string for the n'th scalar.
217 * \param n The scalar number for which to return the description.
218 * \returns the n'th scalar's description, otherwise NULL if <i>n</i> was out of range.
219 */
220 const char* Description(UInt_t n) const;
221
222 /// Resets all scalar values to zero.
223 void Reset();
224
225 /**
226 * Removes all the scalars from the internal array.
227 * \param option This is passed onto the internal Delete method.
228 */
229 virtual void Clear(Option_t* option = "");
230
231 /// Inherited form TObject. Performs a deep copy.
232 virtual void Copy(TObject& object) const;
233
234 /// Finds the scalar object by name. Will not apply a binary search if fIndex
235 /// was invalidated.
236 virtual TObject* FindObject(const char* name) const;
237
238 /// Finds the scalar object with the same name as obj->GetName().
239 /// Will not apply a binary search if fIndex was invalidated.
240 virtual TObject* FindObject(const TObject* obj) const;
241
242 /**
243 * Inherited from TObject, this prints the contents of this summary object.
244 * \param option Can be "compact", which will just print all the values on one line.
245 */
246 virtual void Print(Option_t* option = "") const;
247
248 /**
249 * The assignment operator performs a deep copy.
250 */
251 AliHLTMuonSpectroScalars& operator = (const AliHLTMuonSpectroScalars& obj);
252
253 /// Returns the n'th scalar value or -1 if n is out of range.
254 Double_t operator [] (UInt_t n) const { return GetN(n); }
255
256 /// Returns the named scalar value or -1 if not found.
257 Double_t operator [] (const TString& name) const { return Get(name.Data()); }
258
259 /**
260 * Comparison operator to check if two scalar objects have the same values.
261 * \note The description strings are not checked so they could be different
262 * and the order of the scalars does not matter either.
263 */
264 bool operator == (const AliHLTMuonSpectroScalars& obj) const;
265
266 /**
267 * Comparison operator to check if two scalar objects are different.
268 * \note The description strings are not checked, only the values
269 * and the order of the scalars does not matter either.
270 */
271 bool operator != (const AliHLTMuonSpectroScalars& obj) const
272 {
273 return not (this->operator == (obj));
274 }
275
276private:
277
278 /// Creates the index required for faster searches of the fScalars array.
279 void MakeIndex() const;
280
281 TClonesArray fScalars; /// The list of scalars. Contains AliScalar objects.
282 mutable TObjArray fIndex; //! A sorted index of the scalars for faster searches.
283 mutable bool fIndexValid; //! Indicates that the index is valid.
284
285 ClassDef(AliHLTMuonSpectroScalars, 1); // HLT trigger scalars for the muon spectrometer.
286};
287
288#endif // AliHLTMUONSPECTROSCALARS_H