]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONTracksBlockStruct.cxx
memory leak fixed
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONTracksBlockStruct.cxx
CommitLineData
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
34std::ostream& operator << (
35 std::ostream& stream, const AliHLTMUONTrackStruct& track
36 )
37{
38 stream << "{fId = " << track.fFlags
39 << ", fTrigRec = " << track.fTrigRec
40 << ", fFlags = " << std::showbase << std::hex
41 << track.fFlags << std::dec
42 << ", fPx = " << track.fPx
43 << ", fPy = " << track.fPy
44 << ", fPz = " << track.fPz
45 << ", fInverseBendingMomentum = " << track.fInverseBendingMomentum
46 << ", fThetaX = " << track.fThetaX
47 << ", fThetaX = " << track.fThetaY
48 << ", fX = " << track.fX
49 << ", fY = " << track.fY
50 << ", fZ = " << track.fZ
51 << ", fChi2 = " << track.fChi2;
52 for (AliHLTUInt32_t i = 0; i < 16; i++)
53 {
54 stream << ", fHit[" << i << "] = " << track.fHit[0];
55 }
56 stream << "}";
57 return stream;
58}
59
60
61std::ostream& operator << (
62 std::ostream& stream,
63 const AliHLTMUONTracksBlockStruct& block
64 )
65{
66 assert( AliHLTMUONUtils::IntegrityOk(block) );
67
68 const AliHLTMUONTrackStruct* track =
69 reinterpret_cast<const AliHLTMUONTrackStruct*>(&block + 1);
70 stream << "{fHeader = " << block.fHeader << ", fTrack[] = [";
71 if (block.fHeader.fNrecords > 0) stream << track[0];
72 for (AliHLTUInt32_t i = 1; i < block.fHeader.fNrecords; i++)
73 stream << ", " << track[i];
74 stream << "]}";
75 return stream;
76}
77
78
79bool operator == (
80 const AliHLTMUONTrackStruct& a,
81 const AliHLTMUONTrackStruct& b
82 )
83{
84 bool result = a.fId == b.fId and a.fTrigRec == b.fTrigRec
85 and a.fFlags == b.fFlags and a.fPx == b.fPx and a.fPy == b.fPy
86 and a.fPz == b.fPz and a.fInverseBendingMomentum == b.fInverseBendingMomentum
87 and a.fThetaX == b.fThetaX and a.fThetaY == b.fThetaY
88 and a.fX == b.fX and a.fY == b.fY and a.fZ == b.fZ and a.fChi2 == b.fChi2;
89 for (AliHLTUInt32_t i = 0; i < 16; i++)
90 {
91 result &= (a.fHit[i] == b.fHit[i]);
92 }
93 return result;
94}
95
96
97bool operator == (
98 const AliHLTMUONTracksBlockStruct& a,
99 const AliHLTMUONTracksBlockStruct& b
100 )
101{
102 assert( AliHLTMUONUtils::IntegrityOk(a) );
103 assert( AliHLTMUONUtils::IntegrityOk(b) );
104
105 const AliHLTMUONTrackStruct* trackA =
106 reinterpret_cast<const AliHLTMUONTrackStruct*>(&a + 1);
107 const AliHLTMUONTrackStruct* trackB =
108 reinterpret_cast<const AliHLTMUONTrackStruct*>(&b + 1);
109
110 // First check if the blocks have the same header. If they do then check
111 // if every track is the same. In either case if we find a difference
112 // return false.
113 if (a.fHeader != b.fHeader) return false;
114 for (AliHLTUInt32_t i = 0; i < a.fHeader.fNrecords; i++)
115 if (trackA[i] != trackB[i]) return false;
116 return true;
117}