Update HFE v2 analyses
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpEncodePair.cxx
CommitLineData
168e9c4d 1/**************************************************************************
2* Copyright(c) 1998-1999, 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
40a42243 18// AliMp::Pair functions:
19// The functions for encoding the pair of integers to another integer,
20// defined withing a namespace AliMp.
21// The encoded pairs can be added and subtracted.
22// Author Laurent Aphecetche
23
168e9c4d 24#include "AliMpEncodePair.h"
25
26#include <Riostream.h>
27
28//_______________________________________________________________________
29MpPair_t AliMp::Pair(Int_t first, Int_t second)
30{
31/// See also AliMp::PairFirst(), AliMp::PairSecond()
32/// \author L. Aphecetche, SUBATECH
33
34 return (( first << 16 ) | second);
35}
36
37//_______________________________________________________________________
38Int_t AliMp::PairFirst(MpPair_t pair )
39{
40/// See also AliMp::Pair(), AliMp::PairSecond()
41/// \author L. Aphecetche, SUBATECH
42
43 return ( pair & 0xFFFF0000 ) >> 16;
44}
45
46//_______________________________________________________________________
47Int_t AliMp::PairSecond(MpPair_t pair)
48{
49/// See also AliMp::Pair(), AliMp::PairFirst()
50/// \author L. Aphecetche, SUBATECH
51
52 return pair & 0xFFFF;
53}
54
55//_______________________________________________________________________
56ostream& AliMp::PairPut(ostream& stream, MpPair_t pair)
57{
40a42243 58/// A special printing for encoded pair.
59
168e9c4d 60 if ( pair >= 0 ) {
61 stream << '(' << AliMp::PairFirst(pair)
62 << ',' << AliMp::PairSecond(pair) << ')';
63 return stream;
64 }
65 else {
66 stream << "AliMpIntPair::Invalid";
67 return stream;
68 }
69}