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