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 *
10 /** @file AliHLTCTPData.h
11 @author Matthias Richter
13 @brief Container for CTP trigger classes and counters
17 #include "TClonesArray.h"
18 #include "TArrayL64.h"
19 #include "AliHLTLogging.h"
20 #include "AliHLTDataTypes.h"
21 #include "AliHLTReadoutList.h"
25 * @class AliHLTCTPData
26 * This is a container for the CTP trigger classes, the mapping to the bit
27 * field, and counters.
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
34 * [bit position]:[Trigger class identifier string]:[detector-id-nr]-[detector-id-nr]-...,[bit position]:.....
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.
41 * The object is also stored as part of the HLTGlobalTriggerDecision
42 * @ingroup alihlt_trigger
44 class AliHLTCTPData: public TNamed, public AliHLTLogging
47 /// default constructor
49 /// standard constructor including initialization from CTP_TRIGGER_CLASS
50 AliHLTCTPData(const char* parameter);
52 AliHLTCTPData(const AliHLTCTPData&);
53 ///assignment operator
54 AliHLTCTPData& operator=(const AliHLTCTPData&);
56 virtual ~AliHLTCTPData();
59 AliHLTCTPData& operator += (const AliHLTCTPData&);
61 AliHLTCTPData operator + (const AliHLTCTPData&) const;
64 AliHLTCTPData& operator -= (const AliHLTCTPData&);
66 AliHLTCTPData operator - (const AliHLTCTPData&) const;
69 * Init the class ids and mapping from the CTP_TRIGGER_CLASS parameter.
70 * The general format of the parameter is as follows:
72 int InitCTPTriggerClasses(const char* ctpString);
74 /// etract the active trigger mask from the trigger data
75 static AliHLTUInt64_t ActiveTriggers(const AliHLTComponentTriggerData& trigData);
78 * Evaluate an expression of trigger class ids with respect to the trigger mask.
80 bool EvaluateCTPTriggerClass(const char* expression, const AliHLTComponentTriggerData& trigData) const;
83 * Evaluate an expression of trigger class ids with respect to the trigger mask.
85 bool EvaluateCTPTriggerClass(const char* expression, AliHLTUInt64_t triggerMask) const;
88 * Evaluate an expression of trigger class ids with respect to the current trigger mask.
90 bool EvaluateCTPTriggerClass(const char* expression) const {
91 return EvaluateCTPTriggerClass(expression, fTriggers);
100 * Get index of a trigger class in the tigger pattern
102 int Index(const char* name) const;
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
109 * @return -1 class name not initialized,
110 * 0 trigger not active
113 int CheckTrigger(const char* name) const;
116 * Increment counter for CTP trigger classes
117 * @param classIds comma separated list of class ids
119 void Increment(const char* classIds);
122 * Increment counter for CTP trigger classes
123 * @param triggerPattern corresponds to the 50bit trigger mask in the CDH
125 void Increment(AliHLTUInt64_t triggerPattern);
128 * Increment counter for a CTP trigger class
129 * @param classIdx index of the class in the 50bit trigger mask
131 void Increment(int classIdx);
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.
138 int Increment(AliHLTComponentTriggerData& trigData);
141 * Return a readout list for the active trigger classes.
142 * The list is an 'OR' of the active trugger classes.
144 AliHLTReadoutList ReadoutList(const AliHLTComponentTriggerData& trigData) const;
147 * Return a readout list for the active trigger classes.
148 * The list is an 'OR' of the active trugger classes.
150 AliHLTReadoutList ReadoutList(AliHLTUInt64_t triggerMask) const;
153 * Return a readout list for the active trigger classes.
154 * The list is an 'OR' of the active trugger classes.
156 AliHLTReadoutList ReadoutList() const {
157 return ReadoutList(fTriggers);
161 * Inherited from TObject, this prints the contents of the trigger decision.
163 virtual void Print(Option_t* option = "") const;
165 AliHLTUInt64_t Mask() const { return fMask; }
166 AliHLTUInt64_t Triggers() const { return fTriggers; }
167 void SetTriggers(AliHLTUInt64_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;
178 * Base methods for operators.
179 * @param src instance to add
180 * @param factor +1/-1 for addition/subtraction
181 * @skipped target to get the numner of not matching class names
183 int Add(const AliHLTCTPData& src, int factor, int &skipped);
186 * Read the map of trigger class indexes
187 * The map is used in the generation of the TFormula from the trigger
188 * expression in order to handle similar class names correctly.
189 * For names like 'base', 'baseA', 'baseB' the class with the longer name
190 * has to be replaced first.
192 int ReadMap(vector<unsigned> &map) const;
194 int ReadMap() {return ReadMap(fMap);}
196 AliHLTUInt64_t fMask; /// mask of initialized trigger classes
197 AliHLTUInt64_t fTriggers; /// current trigger
198 TClonesArray fClassIds; /// array of trigger class ids
199 TArrayL64 fCounters; /// trigger class counters
200 vector<unsigned> fMap; //! index map for trigger expression evaluation
202 ClassDef(AliHLTCTPData, 2)