]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/AliHLTMUONTrigRecsDebugBlockStruct.cxx
3b96b9240916d8599adbdc1810c86955202ced13
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONTrigRecsDebugBlockStruct.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 /**
19  * @file   AliHLTMUONTrigRecsDebugBlockStruct.cxx
20  * @author Artur Szostak <artursz@iafrica.com>
21  * @date   
22  * @brief  Implementation of useful stream and comparison operators.
23  */
24
25 #include "AliHLTMUONTrigRecsDebugBlockStruct.h"
26 #include "AliHLTMUONUtils.h"
27 #include <cassert>
28
29
30 std::ostream& operator << (
31                 std::ostream& stream, const AliHLTMUONTrigRecInfoStruct& info
32         )
33 {
34         stream  << "{fTrigRecId = " << info.fTrigRecId
35                 << ", fDetElemId = [" << info.fDetElemId[0]
36                 << ", " << info.fDetElemId[1]
37                 << ", " << info.fDetElemId[2]
38                 << ", " << info.fDetElemId[3]
39                 << "], fZmiddle = " << info.fZmiddle
40                 << ", fBl = " << info.fBl
41                 << ", fL0Struct = {fX2X1 = " << std::showbase << std::hex
42                 << info.fL0Struct.fX2X1
43                 << ", fX4X3 = " << info.fL0Struct.fX4X3
44                 << ", fY2Y1 = " << info.fL0Struct.fY2Y1
45                 << ", fY4Y3 = " << info.fL0Struct.fY4Y3
46                 << ", fTriggerBits = " << info.fL0Struct.fTriggerBits
47                 << std::dec << "}}";
48         return stream;
49 }
50
51
52 std::ostream& operator << (
53                 std::ostream& stream,
54                 const AliHLTMUONTrigRecsDebugBlockStruct& block
55         )
56 {
57         assert( AliHLTMUONUtils::IntegrityOk(block) );
58
59         const AliHLTMUONTrigRecInfoStruct* trigRecInfo =
60                 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&block + 1);
61         stream  << "{fHeader = " << block.fHeader << ", fTrigRecInfo[] = [";
62         if (block.fHeader.fNrecords > 0) stream << trigRecInfo[0];
63         for (AliHLTUInt32_t i = 1; i < block.fHeader.fNrecords; i++)
64                 stream << ", " << trigRecInfo[i];
65         stream << "]}";
66         return stream;
67 }
68
69
70 bool operator == (
71                 const AliHLTMUONTrigRecsDebugBlockStruct& a,
72                 const AliHLTMUONTrigRecsDebugBlockStruct& b
73         )
74 {
75         assert( AliHLTMUONUtils::IntegrityOk(a) );
76         assert( AliHLTMUONUtils::IntegrityOk(b) );
77
78         const AliHLTMUONTrigRecInfoStruct* trigRecInfoA =
79                 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&a + 1);
80         const AliHLTMUONTrigRecInfoStruct* trigRecInfoB =
81                 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&b + 1);
82         
83         // First check if the blocks have the same header. If they do then check
84         // if all debug information is the same. In either case if we find a
85         // difference return false.
86         if (a.fHeader != b.fHeader) return false;
87         for (AliHLTUInt32_t i = 0; i < a.fHeader.fNrecords; i++)
88                 if (trigRecInfoA[i] != trigRecInfoB[i]) return false;
89         return true;
90 }