]>
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> | |
cf239357 | 26 | #include <cassert> |
d15a28e7 | 27 | |
28 | // --- AliRoot header files --- | |
29 | ||
30 | #include "AliPHOSDigit.h" | |
31 | ||
32 | ||
33 | ClassImp(AliPHOSDigit) | |
34 | ||
cf239357 | 35 | //____________________________________________________________________________ |
36 | AliPHOSDigit::AliPHOSDigit() : fPrimary(0) | |
37 | { | |
38 | } | |
39 | ||
d15a28e7 | 40 | //____________________________________________________________________________ |
ff4c968a | 41 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy) |
d15a28e7 | 42 | { |
cf239357 | 43 | fId = id ; |
44 | fAmp = DigEnergy ; | |
45 | fPrimary = new Int_t[1] ; | |
ff4c968a | 46 | fPrimary[0] = primary ; |
cf239357 | 47 | fNprimary = 1 ; |
48 | } | |
49 | ||
50 | //____________________________________________________________________________ | |
51 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) | |
52 | { | |
53 | fId = digit.fId; | |
54 | fAmp = digit.fAmp ; | |
55 | fNprimary = digit.GetNprimary() ; | |
56 | fPrimary = new Int_t[fNprimary] ; | |
57 | Int_t * primary = digit.GetPrimary() ; | |
58 | Int_t index ; | |
59 | for ( index = 0 ; index < fNprimary ; index++ ) | |
60 | fPrimary[index] = primary[index] ; | |
ff4c968a | 61 | } |
62 | ||
63 | //____________________________________________________________________________ | |
64 | AliPHOSDigit::~AliPHOSDigit() | |
65 | { | |
66 | delete fPrimary ; | |
d15a28e7 | 67 | } |
68 | ||
69 | //____________________________________________________________________________ | |
cf239357 | 70 | Int_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 | } | |
88 | //____________________________________________________________________________ | |
89 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
90 | { | |
91 | if ( fId == digit.fId ) | |
d15a28e7 | 92 | return kTRUE ; |
93 | else | |
94 | return kFALSE ; | |
95 | } | |
cf239357 | 96 | |
d15a28e7 | 97 | //____________________________________________________________________________ |
cf239357 | 98 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 99 | { |
cf239357 | 100 | fAmp += digit.fAmp ; |
ff4c968a | 101 | |
102 | Int_t * tempo = new Int_t[fNprimary] ; | |
103 | Int_t index ; | |
104 | ||
105 | Int_t oldfNprimary = fNprimary ; | |
106 | ||
107 | for ( index = 0 ; index < oldfNprimary ; index++ ){ | |
ff4c968a | 108 | tempo[index] = fPrimary[index] ; |
109 | } | |
110 | ||
111 | delete fPrimary ; | |
cf239357 | 112 | fNprimary += digit.GetNprimary() ; |
ff4c968a | 113 | fPrimary = new Int_t[fNprimary] ; |
114 | ||
115 | for ( index = 0 ; index < oldfNprimary ; index++ ) { | |
ff4c968a | 116 | fPrimary[index] = tempo[index] ; |
117 | } | |
118 | ||
119 | Int_t jndex = 0 ; | |
120 | for ( index = oldfNprimary ; index < fNprimary ; index++ ) { | |
cf239357 | 121 | fPrimary[index] = digit.fPrimary[jndex] ; |
ff4c968a | 122 | jndex++ ; |
123 | } | |
124 | ||
d15a28e7 | 125 | return *this ; |
126 | } | |
127 | ||
128 | //____________________________________________________________________________ | |
cf239357 | 129 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 130 | { |
cf239357 | 131 | out << "ID " << digit.fId << " Energy = " << digit.fAmp ; |
d15a28e7 | 132 | |
133 | return out ; | |
134 | } | |
135 | ||
cf239357 | 136 | //______________________________________________________________________________ |
137 | void AliPHOSDigit::Streamer(TBuffer &R__b) | |
d15a28e7 | 138 | { |
cf239357 | 139 | assert(0==1) ; |
140 | // Stream an object of class AliPHOSDigit. | |
141 | if (R__b.IsReading()) { | |
142 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
143 | AliDigitNew::Streamer(R__b); | |
144 | R__b.ReadArray(fPrimary); | |
145 | R__b >> fNprimary; | |
146 | } else { | |
147 | R__b.WriteVersion(AliPHOSDigit::IsA()); | |
148 | AliDigitNew::Streamer(R__b); | |
149 | R__b.WriteArray(fPrimary, fNprimary); | |
150 | R__b << fNprimary; | |
151 | ||
152 | } | |
d15a28e7 | 153 | } |
cf239357 | 154 | |
155 |