]>
Commit | Line | Data |
---|---|---|
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> | |
26 | ||
27 | // --- AliRoot header files --- | |
28 | ||
29 | #include "AliPHOSDigit.h" | |
30 | ||
31 | ||
32 | ClassImp(AliPHOSDigit) | |
33 | ||
34 | //____________________________________________________________________________ | |
ff4c968a | 35 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy) |
d15a28e7 | 36 | { |
d15a28e7 | 37 | fId = id; |
38 | fAmp = DigEnergy ; | |
ff4c968a | 39 | fPrimary = new Int_t[1] ; |
40 | fPrimary[0] = primary ; | |
41 | fNprimary = 1 ; | |
42 | } | |
43 | ||
44 | //____________________________________________________________________________ | |
45 | AliPHOSDigit::~AliPHOSDigit() | |
46 | { | |
47 | delete fPrimary ; | |
d15a28e7 | 48 | } |
49 | ||
50 | //____________________________________________________________________________ | |
51 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const &Digit) const | |
52 | { | |
53 | if ( fId == Digit.fId ) | |
54 | return kTRUE ; | |
55 | else | |
56 | return kFALSE ; | |
57 | } | |
58 | ||
59 | //____________________________________________________________________________ | |
60 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const &Digit) | |
61 | { | |
62 | fAmp += Digit.fAmp ; | |
ff4c968a | 63 | |
64 | Int_t * tempo = new Int_t[fNprimary] ; | |
65 | Int_t index ; | |
66 | ||
67 | Int_t oldfNprimary = fNprimary ; | |
68 | ||
69 | for ( index = 0 ; index < oldfNprimary ; index++ ){ | |
70 | cout << " 1 " << index << endl ; | |
71 | tempo[index] = fPrimary[index] ; | |
72 | } | |
73 | ||
74 | delete fPrimary ; | |
75 | fNprimary += Digit.GetNprimary() ; | |
76 | fPrimary = new Int_t[fNprimary] ; | |
77 | ||
78 | for ( index = 0 ; index < oldfNprimary ; index++ ) { | |
79 | cout << " 2 " << index << endl ; | |
80 | fPrimary[index] = tempo[index] ; | |
81 | } | |
82 | ||
83 | Int_t jndex = 0 ; | |
84 | for ( index = oldfNprimary ; index < fNprimary ; index++ ) { | |
85 | cout << " 1 " << index << " " << jndex << endl ; | |
86 | fPrimary[index] = Digit.fPrimary[jndex] ; | |
87 | jndex++ ; | |
88 | } | |
89 | ||
d15a28e7 | 90 | return *this ; |
91 | } | |
92 | ||
93 | //____________________________________________________________________________ | |
94 | ostream& operator << ( ostream& out , const AliPHOSDigit& Digit) | |
95 | { | |
96 | out << "ID " << Digit.fId << " Energy = " << Digit.fAmp ; | |
97 | ||
98 | return out ; | |
99 | } | |
100 | ||
101 | //____________________________________________________________________________ | |
102 | Int_t AliPHOSDigit::Compare(TObject * obj) | |
103 | { | |
104 | Int_t rv ; | |
105 | ||
106 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
107 | ||
108 | Int_t iddiff = fId - digit->GetId() ; | |
109 | ||
110 | if ( iddiff > 0 ) | |
111 | rv = 1 ; | |
112 | else if ( iddiff < 0 ) | |
113 | rv = -1 ; | |
114 | else | |
115 | rv = 0 ; | |
116 | ||
117 | return rv ; | |
118 | ||
119 | } |