]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSDigit.cxx
Merged ITS-working with HEAD. Improved some of the documentation and
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
CommitLineData
d15a28e7 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//_________________________________________________________________________
17// Digit class for PHOS that contains an absolute ID and an energy
18//*-- Author : Laurent Aphecetche SUBATECH
19//////////////////////////////////////////////////////////////////////////////
20
21// --- ROOT system ---
22
23// --- Standard library ---
24
25#include <iostream>
cf239357 26#include <cassert>
d15a28e7 27
28// --- AliRoot header files ---
29
30#include "AliPHOSDigit.h"
31
32
33ClassImp(AliPHOSDigit)
34
cf239357 35//____________________________________________________________________________
f741ce93 36 AliPHOSDigit::AliPHOSDigit()
cf239357 37{
26d4b141 38 fNprimary = 0 ;
f741ce93 39 fPrimary1 = -1 ;
40 fPrimary2 = -1 ;
41 fPrimary3 = -1 ;
cf239357 42}
43
d15a28e7 44//____________________________________________________________________________
ff4c968a 45AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy)
d15a28e7 46{
cf239357 47 fId = id ;
48 fAmp = DigEnergy ;
f741ce93 49 fPrimary1 = primary ;
cf239357 50 fNprimary = 1 ;
51}
52
53//____________________________________________________________________________
54AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
55{
56 fId = digit.fId;
57 fAmp = digit.fAmp ;
f741ce93 58 fNprimary = digit.fNprimary ;
59 fPrimary1 = digit.fPrimary1 ;
60 fPrimary2 = digit.fPrimary2 ;
61 fPrimary3 = digit.fPrimary3 ;
ff4c968a 62}
63
64//____________________________________________________________________________
65AliPHOSDigit::~AliPHOSDigit()
66{
d15a28e7 67}
68
69//____________________________________________________________________________
cf239357 70Int_t AliPHOSDigit::Compare(TObject * obj)
d15a28e7 71{
cf239357 72 Int_t rv ;
73
74 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
75
76 Int_t iddiff = fId - digit->GetId() ;
77
78 if ( iddiff > 0 )
79 rv = 1 ;
80 else if ( iddiff < 0 )
81 rv = -1 ;
82 else
83 rv = 0 ;
84
85 return rv ;
86
87}
26d4b141 88
89//____________________________________________________________________________
90Int_t AliPHOSDigit::GetPrimary(Int_t index) const
91{
92 Int_t rv = -1 ;
93 if ( index > 3 )
94 cout << "AliPHOSDigit ERROR > only 3 primaries allowed" << endl ;
95 else {
96 switch (index) {
97 case 1 :
98 rv = fPrimary1 ;
99 break ;
100 case 2 :
101 rv = fPrimary2 ;
102 break ;
103 case 3 :
104 rv = fPrimary3 ;
105 break ;
106 }
107 }
108
109 return rv ;
110
111}
112
cf239357 113//____________________________________________________________________________
114Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
115{
116 if ( fId == digit.fId )
d15a28e7 117 return kTRUE ;
118 else
119 return kFALSE ;
120}
cf239357 121
d15a28e7 122//____________________________________________________________________________
cf239357 123AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
d15a28e7 124{
cf239357 125 fAmp += digit.fAmp ;
ff4c968a 126
26d4b141 127 // Here comes something crummy ... but I do not know how to stream pointers
128 // because AliPHOSDigit is in a TCLonesArray
f741ce93 129
130 Int_t tempo1[3] ;
131 tempo1[0] = fPrimary1 ;
132 tempo1[1] = fPrimary2 ;
133 tempo1[2] = fPrimary3 ;
134
135 Int_t tempo2[3] ;
136 tempo2[0] = digit.fPrimary1 ;
137 tempo2[1] = digit.fPrimary2 ;
138 tempo2[2] = digit.fPrimary3 ;
139
140 Int_t max1 = fNprimary ;
141 Int_t max2 = digit.fNprimary ;
142
143 if ( fNprimary >= 3 ) {
144 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
145 }
146 else {
147 fNprimary += digit.fNprimary ;
148 if ( fNprimary > 3 ) {
26d4b141 149 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
6a3f1304 150 fNprimary = 3 ;
26d4b141 151 }
f741ce93 152
153 Int_t tempo3[3] ;
154 Int_t index ;
155 for (index = 0 ; index < max1 ; index++)
156 tempo3[index] = tempo1[index] ;
157 for (index = 0 ; index < max2 ; index++)
158 tempo3[index+max1] = tempo2[index] ;
159
160 fPrimary1 = tempo3[0] ;
161 fPrimary2 = tempo3[1] ;
162 fPrimary3 = tempo3[2] ;
26d4b141 163
f741ce93 164 }
26d4b141 165 // end of crummy stuff
166
d15a28e7 167 return *this ;
168}
169
170//____________________________________________________________________________
cf239357 171ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
d15a28e7 172{
cf239357 173 out << "ID " << digit.fId << " Energy = " << digit.fAmp ;
d15a28e7 174
175 return out ;
176}
177
cf239357 178