]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTCTPData.h
adding support for similar class names (e.g 'mytrigger', 'mytriggerA'). This
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTCTPData.h
CommitLineData
1dbbd625 1//-*- Mode: C++ -*-
2// $Id$
3
4#ifndef ALIHLTCTPDATA_H
5#define ALIHLTCTPDATA_H
6//* This file is property of and copyright by the ALICE HLT Project *
7//* ALICE Experiment at CERN, All rights reserved. *
8//* See cxx source for full Copyright notice *
9
10/** @file AliHLTCTPData.h
11 @author Matthias Richter
12 @date 2009-08-20
13 @brief Container for CTP trigger classes and counters
14*/
15
16#include "TNamed.h"
17#include "TClonesArray.h"
18#include "TArrayL64.h"
19#include "AliHLTLogging.h"
20#include "AliHLTDataTypes.h"
21
22/**
23 * @class AliHLTCTPData
24 * This is a container for the CTP trigger classes, the mapping to the bit
25 * field, and counters.
26 *
1462df14 27 * The class is initialized from CTP_TRIGGER_CLASSES part of the ECS parameters.
28 * and stores internally a list of trigger classes holding the information on bit
29 * position, class name and involved detectors. The general format og the parameter
30 * is as follows:
31 * <pre>
32 * [bit position]:[Trigger class identifier string]:[detector-id-nr]-[detector-id-nr]-...,[bit position]:.....
33 * </pre>
34 *
35 * The list of participating detectors is converted into an AliHLTReadoutList
36 * object named after the trigger class name, and can be used as mask for the
37 * readout list generated by a component.
38 *
1dbbd625 39 * The object is also stored as part of the HLTGlobalTriggerDecision
40 * @ingroup alihlt_trigger
41 */
42class AliHLTCTPData: public TNamed, public AliHLTLogging
43{
44 public:
45 /// default constructor
46 AliHLTCTPData();
47 /// standard constructor including initialization from CTP_TRIGGER_CLASS
48 AliHLTCTPData(const char* parameter);
59be6254 49 /// copy constructor
50 AliHLTCTPData(const AliHLTCTPData&);
51 ///assignment operator
52 AliHLTCTPData& operator=(const AliHLTCTPData&);
1dbbd625 53 /// destructor
54 virtual ~AliHLTCTPData();
55
59be6254 56 /// Add counters
57 AliHLTCTPData& operator += (const AliHLTCTPData&);
58 /// Add counters
59 AliHLTCTPData operator + (const AliHLTCTPData&) const;
60
61 /// Subtract counters
62 AliHLTCTPData& operator -= (const AliHLTCTPData&);
63 /// Subtract counters
64 AliHLTCTPData operator - (const AliHLTCTPData&) const;
65
1dbbd625 66 /**
67 * Init the class ids and mapping from the CTP_TRIGGER_CLASS parameter.
68 * The general format of the parameter is as follows:
69 */
70 int InitCTPTriggerClasses(const char* ctpString);
71
e5339167 72 /// etract the active trigger mask from the trigger data
73 static AliHLTUInt64_t ActiveTriggers(const AliHLTComponentTriggerData& trigData);
74
1dbbd625 75 /**
76 * Evaluate an expression of trigger class ids with respect to the trigger mask.
77 */
edd72347 78 bool EvaluateCTPTriggerClass(const char* expression, const AliHLTComponentTriggerData& trigData) const;
79
80 /**
81 * Evaluate an expression of trigger class ids with respect to the trigger mask.
82 */
83 bool EvaluateCTPTriggerClass(const char* expression, AliHLTUInt64_t triggerMask) const;
84
85 /**
86 * Evaluate an expression of trigger class ids with respect to the current trigger mask.
87 */
88 bool EvaluateCTPTriggerClass(const char* expression) const {
89 return EvaluateCTPTriggerClass(expression, fTriggers);
90 }
1dbbd625 91
92 /**
93 * Reset all counters
94 */
95 void ResetCounters();
96
97 /**
98 * Get index of a trigger class in the tigger pattern
99 */
100 int Index(const char* name) const;
101
ffda78e3 102 /**
103 * Check state of a trigger class.
104 * If the class name is not part of the current trigger setup (i.e. ECS parameter
105 * does not contain a trigger definition for this class name) the function
106 * returns -1
107 * @return -1 class name not initialized,
108 * 0 trigger not active
109 * 1 trigger active
110 */
111 int CheckTrigger(const char* name) const;
112
1dbbd625 113 /**
114 * Increment counter for CTP trigger classes
115 * @param classIds comma separated list of class ids
116 */
117 void Increment(const char* classIds);
118
119 /**
120 * Increment counter for CTP trigger classes
121 * @param triggerPattern corresponds to the 50bit trigger mask in the CDH
122 */
123 void Increment(AliHLTUInt64_t triggerPattern);
124
125 /**
126 * Increment counter for a CTP trigger class
127 * @param classIdx index of the class in the 50bit trigger mask
128 */
129 void Increment(int classIdx);
130
131 /**
132 * Increment counters according to the trigger data struct.
133 * First extract trigger pattern from the CDH and then
134 * increment from the trigger pattern.
135 */
136 int Increment(AliHLTComponentTriggerData& trigData);
137
1462df14 138 /**
139 * Return a readout list for the active trigger classes.
140 * The list is an 'OR' of the active trugger classes.
141 */
142 AliHLTEventDDL ReadoutList(const AliHLTComponentTriggerData& trigData) const;
143
f11febe7 144 /**
145 * Return a readout list for the active trigger classes.
146 * The list is an 'OR' of the active trugger classes.
147 */
148 AliHLTEventDDL ReadoutList(AliHLTUInt64_t triggerMask) const;
149
150 /**
151 * Return a readout list for the active trigger classes.
152 * The list is an 'OR' of the active trugger classes.
153 */
154 AliHLTEventDDL ReadoutList() const {
155 return ReadoutList(fTriggers);
156 }
157
1dbbd625 158 /**
159 * Inherited from TObject, this prints the contents of the trigger decision.
160 */
161 virtual void Print(Option_t* option = "") const;
162
163 AliHLTUInt64_t Mask() const { return fMask; }
edd72347 164 AliHLTUInt64_t Triggers() const { return fTriggers; }
165 void SetTriggers(AliHLTUInt64_t triggers) { fTriggers=triggers; }
166 void SetTriggers(AliHLTComponentTriggerData trigData) {SetTriggers(ActiveTriggers(trigData));}
1dbbd625 167 const TArrayL64& Counters() const { return fCounters; }
168 AliHLTUInt64_t Counter(int index) const;
169 AliHLTUInt64_t Counter(const char* classId) const;
170 const char* Name(int index) const;
171
172 protected:
173 private:
59be6254 174 /**
175 * Add counters.
176 * Base methods for operators.
177 * @param src instance to add
178 * @param factor +1/-1 for addition/subtraction
179 * @skipped target to get the numner of not matching class names
180 */
181 int Add(const AliHLTCTPData& src, int factor, int &skipped);
1dbbd625 182
ffda78e3 183 /**
184 * Read the map of trigger class indexes
185 * The map is used in the generation of the TFormula from the trigger
186 * expression in order to handle similar class names correctly.
187 * For names like 'base', 'baseA', 'baseB' the class with the longer name
188 * has to be replaced first.
189 */
190 int ReadMap(vector<unsigned> &map) const;
191
192 int ReadMap() {return ReadMap(fMap);}
193
1dbbd625 194 AliHLTUInt64_t fMask; /// mask of initialized trigger classes
edd72347 195 AliHLTUInt64_t fTriggers; /// current trigger
1dbbd625 196 TClonesArray fClassIds; /// array of trigger class ids
197 TArrayL64 fCounters; /// trigger class counters
ffda78e3 198 vector<unsigned> fMap; //! index map for trigger expression evaluation
1dbbd625 199
ffda78e3 200 ClassDef(AliHLTCTPData, 2)
1dbbd625 201};
202
203#endif