1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // Digit class for PHOS that contains an absolute ID and an energy
18 //*-- Author : Laurent Aphecetche SUBATECH
19 //////////////////////////////////////////////////////////////////////////////
21 // --- ROOT system ---
23 // --- Standard library ---
28 // --- AliRoot header files ---
30 #include "AliPHOSDigit.h"
33 ClassImp(AliPHOSDigit)
35 //____________________________________________________________________________
36 AliPHOSDigit::AliPHOSDigit() : fPrimary(0)
40 for (index = 1 ; index <= 3 ; index++)
41 SetPrimary(index, 0) ;
44 //____________________________________________________________________________
45 AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy)
49 fPrimary = new Int_t[1] ;
50 fPrimary[0] = primary ;
52 SetPrimary(1, primary) ;
56 //____________________________________________________________________________
57 AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
61 fNprimary = digit.GetNprimary() ;
62 fPrimary = new Int_t[fNprimary] ;
63 Int_t * primary = digit.GetPrimary() ;
65 for ( index = 0 ; index < fNprimary ; index++ ) {
66 fPrimary[index] = primary[index] ;
67 SetPrimary( index+1, digit.GetPrimary(index+1) ) ;
72 //____________________________________________________________________________
73 AliPHOSDigit::~AliPHOSDigit()
79 //____________________________________________________________________________
80 Int_t AliPHOSDigit::Compare(TObject * obj)
84 AliPHOSDigit * digit = (AliPHOSDigit *)obj ;
86 Int_t iddiff = fId - digit->GetId() ;
90 else if ( iddiff < 0 )
99 //____________________________________________________________________________
100 Int_t AliPHOSDigit::GetPrimary(Int_t index) const
104 cout << "AliPHOSDigit ERROR > only 3 primaries allowed" << endl ;
123 //____________________________________________________________________________
124 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const
126 if ( fId == digit.fId )
132 //____________________________________________________________________________
133 AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
137 Int_t * tempo = new Int_t[fNprimary] ;
140 Int_t oldfNprimary = fNprimary ;
142 for ( index = 0 ; index < oldfNprimary ; index++ ){
143 tempo[index] = fPrimary[index] ;
147 fNprimary += digit.GetNprimary() ;
148 fPrimary = new Int_t[fNprimary] ;
150 for ( index = 0 ; index < oldfNprimary ; index++ ) {
151 fPrimary[index] = tempo[index] ;
155 for ( index = oldfNprimary ; index < fNprimary ; index++ ) {
156 fPrimary[index] = digit.fPrimary[jndex] ;
160 // Here comes something crummy ... but I do not know how to stream pointers
161 // because AliPHOSDigit is in a TCLonesArray
164 cout << "AliPHOSDigit + operator ERROR > too many primaries, modify AliPHOSDigit" << endl ;
168 SetPrimary(1, fPrimary[0]) ;
171 SetPrimary(2, fPrimary[1]) ;
174 SetPrimary(3, fPrimary[2]) ;
179 // end of crummy stuff
184 //____________________________________________________________________________
185 ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
187 out << "ID " << digit.fId << " Energy = " << digit.fAmp ;
192 //____________________________________________________________________________
193 void AliPHOSDigit::SetPrimary(Int_t index, Int_t value)