1 #ifndef ALIHLTMUONUTILS_H
2 #define ALIHLTMUONUTILS_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
9 * @file AliHLTMUONUtils.h
10 * @author Artur Szostak <artursz@iafrica.com>
12 * @brief Class containing various dimuon HLT utility routines and macros.
15 #include "AliHLTMUONDataTypes.h"
17 // Forward declare structures.
19 struct AliHLTMUONTriggerRecordStruct;
20 struct AliHLTMUONTriggerRecordsBlockStruct;
21 struct AliHLTMUONTrigRecsDebugBlockStruct;
22 struct AliHLTMUONTriggerChannelsBlockStruct;
23 struct AliHLTMUONRecHitsBlockStruct;
24 struct AliHLTMUONClustersBlockStruct;
25 struct AliHLTMUONChannelsBlockStruct;
26 struct AliHLTMUONMansoTrackStruct;
27 struct AliHLTMUONMansoTracksBlockStruct;
28 struct AliHLTMUONMansoCandidatesBlockStruct;
29 struct AliHLTMUONTrackDecisionStruct;
30 struct AliHLTMUONSinglesDecisionBlockStruct;
31 struct AliHLTMUONPairDecisionStruct;
32 struct AliHLTMUONPairsDecisionBlockStruct;
36 * AliHLTMUONUtils contains arbitrary utility methods to be used in various
37 * parts of the dimuon HLT system.
38 * These include methods to perform basic sanity checks on the integrity of
45 * This packs the given parameters into the bits of a word appropriate
46 * for AliHLTMUONTriggerRecordStruct::fFlags.
47 * @param sign The particle sign.
48 * @param hitset Flags to indicate if the corresponding fHits[i] elements
50 * @return Returns the 32 bit packed word.
52 static AliHLTUInt32_t PackTriggerRecordFlags(
53 AliHLTMUONParticleSign sign, bool hitset[4]
57 * This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
58 * its component fields.
59 * @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
60 * @param sign Sets this to the particle sign.
61 * @param hitset Sets the array elements to indicate if the corresponding
62 * fHits[i] element was set/filled.
64 static void UnpackTriggerRecordFlags(
65 AliHLTUInt32_t flags, // [in]
66 AliHLTMUONParticleSign& sign, // [out]
67 bool hitset[4] // [out]
71 * This packs the given parameters into the bits of a word appropriate
72 * for AliHLTMUONMansoTrackStruct::fFlags.
73 * @param sign The particle sign.
74 * @param hitset Flags to indicate if the corresponding fHits[i] elements
76 * @return Returns the 32 bit packed word.
78 static AliHLTUInt32_t PackMansoTrackFlags(
79 AliHLTMUONParticleSign sign, bool hitset[4]
82 return PackTriggerRecordFlags(sign, hitset);
86 * This unpacks the AliHLTMUONMansoTrackStruct::fFlags bits into
87 * its component fields.
88 * @param flags The flags from an AliHLTMUONMansoTrackStruct structure.
89 * @param sign Sets this to the particle sign.
90 * @param hitset Sets the array elements to indicate if the corresponding
91 * fHits[i] element was set/filled.
93 static void UnpackMansoTrackFlags(
94 AliHLTUInt32_t flags, // [in]
95 AliHLTMUONParticleSign& sign, // [out]
96 bool hitset[4] // [out]
99 UnpackTriggerRecordFlags(flags, sign, hitset);
103 * This packs the given parameters into the bits of a word appropriate
104 * for AliHLTMUONTrackDecisionStruct::fTriggerBits.
105 * @param highPt Has the track passed the high pt cut.
106 * @param lowPt Has the track passed the low pt cut.
107 * @return Returns the 32 bit packed word.
109 static AliHLTUInt32_t PackTrackDecisionBits(bool highPt, bool lowPt);
112 * This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
113 * its component fields.
114 * @param bits The trigger bits from an AliHLTMUONTrackDecisionStruct
116 * @param highPt Sets this to the value of the high pt cut bit.
117 * @param lowPt Sets this to the value of the low pt cut bit.
119 static void UnpackTrackDecisionBits(
120 AliHLTUInt32_t bits, // [in]
121 bool& highPt, // [out]
126 * This packs the given parameters into the bits of a word appropriate
127 * for AliHLTMUONPairDecisionStruct::fTriggerBits.
129 * @param highMass Has the track pair passed the high invariant mass cut.
130 * @param lowMass Has the track pair passed the low invariant mass cut.
131 * @param unlike Does the track pair have unlike signs.
132 * @param highPtCount The number of tracks that passed the high pt cut
134 * @param lowPtCount The number of tracks that passed the low pt cut
136 * @return Returns the 32 bit packed word.
138 * Note: Must have highPtCount + lowPtCount <= 2 and unlike == true if
139 * highMass or lowMass is true.
141 static AliHLTUInt32_t PackPairDecisionBits(
142 bool highMass, bool lowMass, bool unlike,
143 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
147 * This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
148 * its component fields.
149 * @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
151 * @param highMass Sets this to the value of the high invariant mass cut bit.
152 * @param lowMass Sets this to the value of the low invariant mass cut bit.
153 * @param unlike Sets this if the pair is unlike sign.
154 * @param highPtCount Sets this to the high pt count bits.
155 * @param lowPtCount Sets this to the low pt count bits.
157 static void UnpackPairDecisionBits(
158 AliHLTUInt32_t bits, // [in]
159 bool& highMass, // [out]
160 bool& lowMass, // [out]
161 bool& unlike, // [out]
162 AliHLTUInt8_t& highPtCount, // [out]
163 AliHLTUInt8_t& lowPtCount // [out]
167 * Methods used to check if the header information corresponds to the
168 * supposed type of the data block.
170 static bool HeaderOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
171 static bool HeaderOk(const AliHLTMUONTrigRecsDebugBlockStruct& block);
172 static bool HeaderOk(const AliHLTMUONTriggerChannelsBlockStruct& block);
173 static bool HeaderOk(const AliHLTMUONRecHitsBlockStruct& block);
174 static bool HeaderOk(const AliHLTMUONClustersBlockStruct& block);
175 static bool HeaderOk(const AliHLTMUONChannelsBlockStruct& block);
176 static bool HeaderOk(const AliHLTMUONMansoTracksBlockStruct& block);
177 static bool HeaderOk(const AliHLTMUONMansoCandidatesBlockStruct& block);
178 static bool HeaderOk(const AliHLTMUONSinglesDecisionBlockStruct& block);
179 static bool HeaderOk(const AliHLTMUONPairsDecisionBlockStruct& block);
182 * Methods used to check more extensively if the integrity of various
183 * types of data blocks are Ok and returns true in that case.
184 * These can be slow and should generally only be used for debugging.
186 static bool IntegrityOk(const AliHLTMUONTriggerRecordStruct& tr);
187 static bool IntegrityOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
188 static bool IntegrityOk(const AliHLTMUONTrigRecsDebugBlockStruct& block);
189 static bool IntegrityOk(const AliHLTMUONTriggerChannelsBlockStruct& block);
190 static bool IntegrityOk(const AliHLTMUONRecHitsBlockStruct& block);
191 static bool IntegrityOk(const AliHLTMUONClustersBlockStruct& block);
192 static bool IntegrityOk(const AliHLTMUONChannelsBlockStruct& block);
193 static bool IntegrityOk(const AliHLTMUONMansoTrackStruct& track);
194 static bool IntegrityOk(const AliHLTMUONMansoTracksBlockStruct& block);
195 static bool IntegrityOk(const AliHLTMUONMansoCandidatesBlockStruct& block);
196 static bool IntegrityOk(const AliHLTMUONTrackDecisionStruct& decision);
197 static bool IntegrityOk(const AliHLTMUONSinglesDecisionBlockStruct& block);
198 static bool IntegrityOk(const AliHLTMUONPairDecisionStruct& decision);
199 static bool IntegrityOk(const AliHLTMUONPairsDecisionBlockStruct& block);
202 // Should never have to create or destroy this object.
207 //_____________________________________________________________________________
209 // Since c++ is missing a finally "keyword" we define one. Its usage is identical
210 // to a try..finally statement in Java etc.. however, since it is officialy a macro
211 // one must use the ( ) brackets instead of { }
212 // If the compiler supports __finally use it otherwise make our own.
213 #if defined(__BORLANDC__)
214 # define finally(str) __finally{str}
216 # define finally(code) \
223 #endif // __BORLANDC__
225 // If we do not already have them, then define logical operators that are easier
226 // to read. 'and' = &&, 'or' = ||, 'not' = !
227 #if ! defined(__GNUC__) && ! defined(__CINT__)
231 #endif // __GNUC__ | __CINT__
234 // Here we define the DebugTrace(message) macro for easy embedding of debug
235 // information into the dimuon HLT code. Its usage is meant to be for generating
236 // traces of the program which are only useful during full scale debugging.
237 // Log messages should use the standard HLT logging mechanisms.
238 // The output is only generated in programs compiled with the DEBUG directive
239 // defined. Here is a usage example:
242 // DebugTrace("some debug information.");
245 // One can also use C++ ostream operators and manipulators like so:
249 // DebugMsg("x = " << x << " and y = 0x" << std::hex << y );
254 # define DebugTrace(message) {std::cout << message << std::endl;}
256 # define DebugTrace(message)
260 #endif // ALIHLTMUONUTILS_H