]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONUtils.h
Adding more checking and some bit packing routines.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONUtils.h
CommitLineData
26a4668d 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 */
5
6/* $Id$ */
7
8/**
9 * @file AliHLTMUONUtils.h
10 * @author Artur Szostak <artursz@iafrica.com>
11 * @date
b727f838 12 * @brief Class containing various dimuon HLT utility routines and macros.
26a4668d 13 */
14
b727f838 15#include "AliHLTMUONTriggerRecordsBlockStruct.h"
16#include "AliHLTMUONRecHitsBlockStruct.h"
17#include "AliHLTMUONClustersBlockStruct.h"
18#include "AliHLTMUONChannelsBlockStruct.h"
26a4668d 19
20/**
21 * AliHLTMUONUtils contains arbitrary utility methods to be used in various
22 * parts of the dimuon HLT system.
23 * These include methods to perform basic sanity checks on the integrity of
24 * data blocks.
25 */
26class AliHLTMUONUtils
27{
28public:
b727f838 29 /**
30 * This packs the given parameters into the bits of a word appropriate
31 * for AliHLTMUONTriggerRecordStruct::fFlags.
32 * @param sign The particle sign.
33 * @param hitset Flags to indicate if the corresponding fHits[i] elements
34 * was set/filled.
35 * @return Returns the 32 bit packed word.
36 */
37 static AliHLTUInt32_t PackTriggerRecordFlags(
38 AliHLTMUONParticleSign sign, bool hitset[4]
39 );
40
41 /**
42 * This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
43 * its component fields.
44 * @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
45 * @param sign Sets this to the particle sign.
46 * @param hitset Sets the array elements to indicate if the corresponding
47 * fHits[i] element was set/filled.
48 */
49 static void UnpackTriggerRecordFlags(
50 AliHLTUInt32_t flags, // [in]
51 AliHLTMUONParticleSign& sign, // [out]
52 bool hitset[4] // [out]
53 );
54
55 /**
56 * This packs the given parameters into the bits of a word appropriate
57 * for AliHLTMUONMansoTrackStruct::fFlags.
58 * @param sign The particle sign.
59 * @param hitset Flags to indicate if the corresponding fHits[i] elements
60 * was set/filled.
61 * @return Returns the 32 bit packed word.
62 */
63 static AliHLTUInt32_t PackMansoTrackFlags(
64 AliHLTMUONParticleSign sign, bool hitset[4]
65 )
66 {
67 return PackTriggerRecordFlags(sign, hitset);
68 }
69
70 /**
71 * This unpacks the AliHLTMUONMansoTrackStruct::fFlags bits into
72 * its component fields.
73 * @param flags The flags from an AliHLTMUONMansoTrackStruct structure.
74 * @param sign Sets this to the particle sign.
75 * @param hitset Sets the array elements to indicate if the corresponding
76 * fHits[i] element was set/filled.
77 */
78 static void UnpackMansoTrackFlags(
79 AliHLTUInt32_t flags, // [in]
80 AliHLTMUONParticleSign& sign, // [out]
81 bool hitset[4] // [out]
82 )
83 {
84 UnpackTriggerRecordFlags(flags, sign, hitset);
85 }
26a4668d 86
87 /**
b727f838 88 * Methods used to check if the header information corresponds to the
89 * supposed type of the data block.
26a4668d 90 */
b727f838 91 static bool HeaderOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
92 static bool HeaderOk(const AliHLTMUONRecHitsBlockStruct& block);
93 static bool HeaderOk(const AliHLTMUONClustersBlockStruct& block);
94 static bool HeaderOk(const AliHLTMUONChannelsBlockStruct& block);
95
96 /**
97 * Methods used to check extensively if the integrity of various types
98 * of data blocks are Ok and returns true in that case.
99 * These can be slow and should generally only be used for debugging.
100 */
101 static bool IntegrityOk(const AliHLTMUONTriggerRecordsBlockStruct& block);
102 static bool IntegrityOk(const AliHLTMUONRecHitsBlockStruct& block);
103 static bool IntegrityOk(const AliHLTMUONClustersBlockStruct& block);
104 static bool IntegrityOk(const AliHLTMUONChannelsBlockStruct& block);
26a4668d 105
106private:
107 // Should never have to create or destroy this object.
108 AliHLTMUONUtils();
109 ~AliHLTMUONUtils();
110};
111
b727f838 112//_____________________________________________________________________________
113
114// Since c++ is missing a finally "keyword" we define one. Its usage is identical
115// to a try..finally statement in Java etc.. however, since it is officialy a macro
116// one must use the ( ) brackets instead of { }
117// If the compiler supports __finally use it otherwise make our own.
118#if defined(__BORLANDC__)
119# define finally(str) __finally{str}
120#else
121# define finally(code) \
122 catch(...) \
123 { \
124 code \
125 throw; \
126 }; \
127 code
128#endif // __BORLANDC__
129
130// If we do not already have them, then define logical operators that are easier
131// to read. 'and' = &&, 'or' = ||, 'not' = !
132#if ! defined(__GNUC__) && ! defined(__CINT__)
133# define and &&
134# define or ||
135# define not !
136#endif // __GNUC__ | __CINT__
137
138
139// Here we define the DebugTrace(message) macro for easy embedding of debug
140// information into the dimuon HLT code. Its usage is meant to be for generating
141// traces of the program which are only useful during full scale debugging.
142// Log messages should use the standard HLT logging mechanisms.
143// The output is only generated in programs compiled with the DEBUG directive
144// defined. Here is a usage example:
145//
146// // statements...
147// DebugTrace("some debug information.");
148// // statements...
149//
150// One can also use C++ ostream operators and manipulators like so:
151//
152// // statements...
153// int x, y;
154// DebugMsg("x = " << x << " and y = 0x" << std::hex << y );
155// // statements...
156//
157#ifdef DEBUG
158# include <ostream>
159# define DebugTrace(message) {std::cout << message << std::endl;}
160#else // DEBUG
161# define DebugTrace(message)
162#endif // DEBUG
163
164
26a4668d 165#endif // ALIHLTMUONUTILS_H