adding a member for the active CTP trigger mask to the CTP data object and setting...
[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
102 /**
103 * Increment counter for CTP trigger classes
104 * @param classIds comma separated list of class ids
105 */
106 void Increment(const char* classIds);
107
108 /**
109 * Increment counter for CTP trigger classes
110 * @param triggerPattern corresponds to the 50bit trigger mask in the CDH
111 */
112 void Increment(AliHLTUInt64_t triggerPattern);
113
114 /**
115 * Increment counter for a CTP trigger class
116 * @param classIdx index of the class in the 50bit trigger mask
117 */
118 void Increment(int classIdx);
119
120 /**
121 * Increment counters according to the trigger data struct.
122 * First extract trigger pattern from the CDH and then
123 * increment from the trigger pattern.
124 */
125 int Increment(AliHLTComponentTriggerData& trigData);
126
1462df14 127 /**
128 * Return a readout list for the active trigger classes.
129 * The list is an 'OR' of the active trugger classes.
130 */
131 AliHLTEventDDL ReadoutList(const AliHLTComponentTriggerData& trigData) const;
132
1dbbd625 133 /**
134 * Inherited from TObject, this prints the contents of the trigger decision.
135 */
136 virtual void Print(Option_t* option = "") const;
137
138 AliHLTUInt64_t Mask() const { return fMask; }
edd72347 139 AliHLTUInt64_t Triggers() const { return fTriggers; }
140 void SetTriggers(AliHLTUInt64_t triggers) { fTriggers=triggers; }
141 void SetTriggers(AliHLTComponentTriggerData trigData) {SetTriggers(ActiveTriggers(trigData));}
1dbbd625 142 const TArrayL64& Counters() const { return fCounters; }
143 AliHLTUInt64_t Counter(int index) const;
144 AliHLTUInt64_t Counter(const char* classId) const;
145 const char* Name(int index) const;
146
147 protected:
148 private:
59be6254 149 /**
150 * Add counters.
151 * Base methods for operators.
152 * @param src instance to add
153 * @param factor +1/-1 for addition/subtraction
154 * @skipped target to get the numner of not matching class names
155 */
156 int Add(const AliHLTCTPData& src, int factor, int &skipped);
1dbbd625 157
158 AliHLTUInt64_t fMask; /// mask of initialized trigger classes
edd72347 159 AliHLTUInt64_t fTriggers; /// current trigger
1dbbd625 160 TClonesArray fClassIds; /// array of trigger class ids
161 TArrayL64 fCounters; /// trigger class counters
162
edd72347 163 ClassDef(AliHLTCTPData, 1)
1dbbd625 164};
165
166#endif