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 AliHLTMUONTriggerRecordsBlockStruct;
20 struct AliHLTMUONTrigRecsDebugBlockStruct;
21 struct AliHLTMUONTriggerChannelsBlockStruct;
22 struct AliHLTMUONRecHitsBlockStruct;
23 struct AliHLTMUONClustersBlockStruct;
24 struct AliHLTMUONChannelsBlockStruct;
28 * AliHLTMUONUtils contains arbitrary utility methods to be used in various
29 * parts of the dimuon HLT system.
30 * These include methods to perform basic sanity checks on the integrity of
37 * This packs the given parameters into the bits of a word appropriate
38 * for AliHLTMUONTriggerRecordStruct::fFlags.
39 * @param sign The particle sign.
40 * @param hitset Flags to indicate if the corresponding fHits[i] elements
42 * @return Returns the 32 bit packed word.
44 static AliHLTUInt32_t PackTriggerRecordFlags(
45 AliHLTMUONParticleSign sign, bool hitset[4]
49 * This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
50 * its component fields.
51 * @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
52 * @param sign Sets this to the particle sign.
53 * @param hitset Sets the array elements to indicate if the corresponding
54 * fHits[i] element was set/filled.
56 static void UnpackTriggerRecordFlags(
57 AliHLTUInt32_t flags, // [in]
58 AliHLTMUONParticleSign& sign, // [out]
59 bool hitset[4] // [out]
63 * This packs the given parameters into the bits of a word appropriate
64 * for AliHLTMUONMansoTrackStruct::fFlags.
65 * @param sign The particle sign.
66 * @param hitset Flags to indicate if the corresponding fHits[i] elements
68 * @return Returns the 32 bit packed word.
70 static AliHLTUInt32_t PackMansoTrackFlags(
71 AliHLTMUONParticleSign sign, bool hitset[4]
74 return PackTriggerRecordFlags(sign, hitset);
78 * This unpacks the AliHLTMUONMansoTrackStruct::fFlags bits into
79 * its component fields.
80 * @param flags The flags from an AliHLTMUONMansoTrackStruct structure.
81 * @param sign Sets this to the particle sign.
82 * @param hitset Sets the array elements to indicate if the corresponding
83 * fHits[i] element was set/filled.
85 static void UnpackMansoTrackFlags(
86 AliHLTUInt32_t flags, // [in]
87 AliHLTMUONParticleSign& sign, // [out]
88 bool hitset[4] // [out]
91 UnpackTriggerRecordFlags(flags, sign, hitset);
95 * Methods used to check if the header information corresponds to the
96 * supposed type of the data block.
98 static bool HeaderOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
99 static bool HeaderOk(const AliHLTMUONTrigRecsDebugBlockStruct& block);
100 static bool HeaderOk(const AliHLTMUONTriggerChannelsBlockStruct& block);
101 static bool HeaderOk(const AliHLTMUONRecHitsBlockStruct& block);
102 static bool HeaderOk(const AliHLTMUONClustersBlockStruct& block);
103 static bool HeaderOk(const AliHLTMUONChannelsBlockStruct& block);
106 * Methods used to check extensively if the integrity of various types
107 * of data blocks are Ok and returns true in that case.
108 * These can be slow and should generally only be used for debugging.
110 static bool IntegrityOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
111 static bool IntegrityOk(const AliHLTMUONTrigRecsDebugBlockStruct& block);
112 static bool IntegrityOk(const AliHLTMUONTriggerChannelsBlockStruct& block);
113 static bool IntegrityOk(const AliHLTMUONRecHitsBlockStruct& block);
114 static bool IntegrityOk(const AliHLTMUONClustersBlockStruct& block);
115 static bool IntegrityOk(const AliHLTMUONChannelsBlockStruct& block);
118 // Should never have to create or destroy this object.
123 //_____________________________________________________________________________
125 // Since c++ is missing a finally "keyword" we define one. Its usage is identical
126 // to a try..finally statement in Java etc.. however, since it is officialy a macro
127 // one must use the ( ) brackets instead of { }
128 // If the compiler supports __finally use it otherwise make our own.
129 #if defined(__BORLANDC__)
130 # define finally(str) __finally{str}
132 # define finally(code) \
139 #endif // __BORLANDC__
141 // If we do not already have them, then define logical operators that are easier
142 // to read. 'and' = &&, 'or' = ||, 'not' = !
143 #if ! defined(__GNUC__) && ! defined(__CINT__)
147 #endif // __GNUC__ | __CINT__
150 // Here we define the DebugTrace(message) macro for easy embedding of debug
151 // information into the dimuon HLT code. Its usage is meant to be for generating
152 // traces of the program which are only useful during full scale debugging.
153 // Log messages should use the standard HLT logging mechanisms.
154 // The output is only generated in programs compiled with the DEBUG directive
155 // defined. Here is a usage example:
158 // DebugTrace("some debug information.");
161 // One can also use C++ ostream operators and manipulators like so:
165 // DebugMsg("x = " << x << " and y = 0x" << std::hex << y );
170 # define DebugTrace(message) {std::cout << message << std::endl;}
172 # define DebugTrace(message)
176 #endif // ALIHLTMUONUTILS_H