]>
Commit | Line | Data |
---|---|---|
a8982f78 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | // $Id: AliHLTMUONTracksBlockStruct.cxx 36627 2009-11-10 19:21:49Z aszostak $ | |
18 | ||
19 | /// | |
20 | /// @file AliHLTMUONTracksBlockStruct.cxx | |
21 | /// @author Artur Szostak <artursz@iafrica.com> | |
22 | /// @date 10 Feb 2010 | |
23 | /// @brief Implementation of useful stream and comparison operators. | |
24 | /// | |
25 | /// The tracks data block is an internal dimuon HLT data block structure | |
26 | /// generated by the tracker components. | |
27 | /// | |
28 | ||
29 | #include "AliHLTMUONTracksBlockStruct.h" | |
30 | #include "AliHLTMUONUtils.h" | |
31 | #include <cassert> | |
32 | ||
33 | ||
34 | std::ostream& operator << ( | |
35 | std::ostream& stream, const AliHLTMUONTrackStruct& track | |
36 | ) | |
37 | { | |
710ddf4b | 38 | std::ios::fmtflags oldflags = stream.flags(); |
a8982f78 | 39 | stream << "{fId = " << track.fFlags |
40 | << ", fTrigRec = " << track.fTrigRec | |
41 | << ", fFlags = " << std::showbase << std::hex | |
42 | << track.fFlags << std::dec | |
43 | << ", fPx = " << track.fPx | |
44 | << ", fPy = " << track.fPy | |
45 | << ", fPz = " << track.fPz | |
46 | << ", fInverseBendingMomentum = " << track.fInverseBendingMomentum | |
47 | << ", fThetaX = " << track.fThetaX | |
48 | << ", fThetaX = " << track.fThetaY | |
49 | << ", fX = " << track.fX | |
50 | << ", fY = " << track.fY | |
51 | << ", fZ = " << track.fZ | |
52 | << ", fChi2 = " << track.fChi2; | |
53 | for (AliHLTUInt32_t i = 0; i < 16; i++) | |
54 | { | |
55 | stream << ", fHit[" << i << "] = " << track.fHit[0]; | |
56 | } | |
57 | stream << "}"; | |
710ddf4b | 58 | stream.flags(oldflags); |
a8982f78 | 59 | return stream; |
60 | } | |
61 | ||
62 | ||
63 | std::ostream& operator << ( | |
64 | std::ostream& stream, | |
65 | const AliHLTMUONTracksBlockStruct& block | |
66 | ) | |
67 | { | |
68 | assert( AliHLTMUONUtils::IntegrityOk(block) ); | |
69 | ||
70 | const AliHLTMUONTrackStruct* track = | |
71 | reinterpret_cast<const AliHLTMUONTrackStruct*>(&block + 1); | |
72 | stream << "{fHeader = " << block.fHeader << ", fTrack[] = ["; | |
73 | if (block.fHeader.fNrecords > 0) stream << track[0]; | |
74 | for (AliHLTUInt32_t i = 1; i < block.fHeader.fNrecords; i++) | |
75 | stream << ", " << track[i]; | |
76 | stream << "]}"; | |
77 | return stream; | |
78 | } | |
79 | ||
80 | ||
81 | bool operator == ( | |
82 | const AliHLTMUONTrackStruct& a, | |
83 | const AliHLTMUONTrackStruct& b | |
84 | ) | |
85 | { | |
86 | bool result = a.fId == b.fId and a.fTrigRec == b.fTrigRec | |
87 | and a.fFlags == b.fFlags and a.fPx == b.fPx and a.fPy == b.fPy | |
88 | and a.fPz == b.fPz and a.fInverseBendingMomentum == b.fInverseBendingMomentum | |
89 | and a.fThetaX == b.fThetaX and a.fThetaY == b.fThetaY | |
90 | and a.fX == b.fX and a.fY == b.fY and a.fZ == b.fZ and a.fChi2 == b.fChi2; | |
91 | for (AliHLTUInt32_t i = 0; i < 16; i++) | |
92 | { | |
93 | result &= (a.fHit[i] == b.fHit[i]); | |
94 | } | |
95 | return result; | |
96 | } | |
97 | ||
98 | ||
99 | bool operator == ( | |
100 | const AliHLTMUONTracksBlockStruct& a, | |
101 | const AliHLTMUONTracksBlockStruct& b | |
102 | ) | |
103 | { | |
104 | assert( AliHLTMUONUtils::IntegrityOk(a) ); | |
105 | assert( AliHLTMUONUtils::IntegrityOk(b) ); | |
106 | ||
107 | const AliHLTMUONTrackStruct* trackA = | |
108 | reinterpret_cast<const AliHLTMUONTrackStruct*>(&a + 1); | |
109 | const AliHLTMUONTrackStruct* trackB = | |
110 | reinterpret_cast<const AliHLTMUONTrackStruct*>(&b + 1); | |
111 | ||
112 | // First check if the blocks have the same header. If they do then check | |
113 | // if every track is the same. In either case if we find a difference | |
114 | // return false. | |
115 | if (a.fHeader != b.fHeader) return false; | |
116 | for (AliHLTUInt32_t i = 0; i < a.fHeader.fNrecords; i++) | |
117 | if (trackA[i] != trackB[i]) return false; | |
118 | return true; | |
119 | } |