]>
Commit | Line | Data |
---|---|---|
c335b3c5 | 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 | **************************************************************************/ | |
e7386040 | 15 | /* $Id$ */ |
c335b3c5 | 16 | |
12f6dd57 | 17 | // -- |
18 | // -- | |
19 | // Implementation for TTree output in PHOS DA | |
20 | // for calibrating energy by pi0 and MIP. | |
21 | // -- | |
22 | // -- Author: Hisayuki Torii (Hiroshima Univ.) | |
23 | // -- | |
24 | ||
25 | #include <iostream> | |
26 | #include "AliPHOSDATreeEvent.h" | |
27 | ClassImp(AliPHOSDATreeEvent) | |
28 | //------------------------------------------------------------------------ | |
c335b3c5 | 29 | AliPHOSDATreeEvent::AliPHOSDATreeEvent(const AliPHOSDATreeEvent& evt) |
30 | : fTime(0), | |
31 | fNDigits(0), | |
32 | fDigits(0), | |
33 | fNClusters(0), | |
34 | fClusters(0) | |
35 | { | |
12f6dd57 | 36 | // Copy Constructor |
37 | ||
38 | fNDigits = evt.fNDigits; | |
39 | if( fNDigits > 0 ){ | |
40 | fDigits = new AliPHOSDATreeDigit[fNDigits]; | |
41 | int ndigits = fNDigits; | |
42 | while( ndigits-- ){ | |
43 | fDigits[ndigits] = evt.fDigits[ndigits]; | |
44 | } | |
45 | } else { | |
46 | fDigits = 0; | |
47 | } | |
48 | // | |
49 | fNClusters = evt.fNClusters; | |
50 | if( fNClusters > 0 ){ | |
51 | fClusters = new AliPHOSDATreeCluster[fNClusters]; | |
52 | int nclusters = fNClusters; | |
53 | while( nclusters-- ){ | |
54 | fClusters[nclusters] = evt.fClusters[nclusters]; | |
55 | } | |
56 | } else { | |
57 | fClusters = 0; | |
58 | } | |
59 | } | |
60 | //------------------------------------------------------------------------ | |
61 | AliPHOSDATreeEvent& AliPHOSDATreeEvent::operator=(const AliPHOSDATreeEvent& evt){ | |
62 | // Copy Operator | |
63 | ||
929af5d7 | 64 | if (this != &evt) { |
65 | if( fNDigits > 0 ) delete[] fDigits; | |
66 | fNDigits = evt.fNDigits; | |
67 | if( fNDigits > 0 ){ | |
68 | fDigits = new AliPHOSDATreeDigit[fNDigits]; | |
69 | int ndigits = fNDigits; | |
70 | while( ndigits-- ){ | |
71 | fDigits[ndigits] = evt.fDigits[ndigits]; | |
72 | } | |
73 | } else { | |
74 | fDigits = 0; | |
12f6dd57 | 75 | } |
929af5d7 | 76 | // |
77 | if( fNClusters > 0 ) delete[] fClusters; | |
78 | fNClusters = evt.fNClusters; | |
79 | if( fNClusters > 0 ){ | |
80 | fClusters = new AliPHOSDATreeCluster[fNClusters]; | |
81 | int nclusters = fNClusters; | |
82 | while( nclusters-- ){ | |
83 | fClusters[nclusters] = evt.fClusters[nclusters]; | |
84 | } | |
85 | } else { | |
86 | fClusters = 0; | |
12f6dd57 | 87 | } |
12f6dd57 | 88 | } |
89 | return *this; | |
90 | } | |
91 | //------------------------------------------------------------------------ | |
92 | bool AliPHOSDATreeEvent::Fill(float energy,int row,int col){ | |
93 | // Fill new digit information | |
94 | ||
95 | AliPHOSDATreeDigit digit(energy,row,col); | |
96 | return Fill(digit); | |
97 | } | |
98 | //------------------------------------------------------------------------ | |
99 | bool AliPHOSDATreeEvent::Fill(AliPHOSDATreeDigit& digit){ | |
100 | // Fill new digit information | |
101 | ||
102 | AliPHOSDATreeDigit* newDigits = new AliPHOSDATreeDigit[fNDigits+1]; | |
103 | int ndigits = fNDigits; | |
104 | newDigits[ndigits] = digit; | |
105 | while( ndigits-- ){ | |
106 | newDigits[ndigits] = fDigits[ndigits]; | |
107 | } | |
108 | if( fNDigits>0 ) delete[] fDigits; | |
109 | fDigits = newDigits; | |
110 | fNDigits++; | |
111 | return true; | |
112 | } | |
113 | //------------------------------------------------------------------------ | |
114 | bool AliPHOSDATreeEvent::Clusterize(AliPHOSDATreeDigit& digit){ | |
115 | //Input digit information into clustering | |
116 | ||
117 | bool status = false; | |
118 | int nclusters = fNClusters; | |
119 | while( nclusters-- && !status ){ | |
120 | if( fClusters[nclusters].IsNeighbor(digit) ){ | |
121 | status = fClusters[nclusters].Append(digit); | |
122 | } | |
123 | } | |
124 | //std::cout<<" DEBUGDEBUG:: status = "<<status<<" fNClusters="<<fNClusters<<std::endl; | |
125 | if( !status ){ | |
126 | AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[fNClusters+1]; | |
127 | nclusters = fNClusters; | |
128 | status = newClusters[nclusters].Append(digit); | |
129 | while( nclusters-- ){ | |
130 | newClusters[nclusters] = fClusters[nclusters]; | |
131 | } | |
132 | if( fNClusters>0 ) delete[] fClusters; | |
133 | fClusters = newClusters; | |
134 | fNClusters++; | |
135 | } | |
136 | return status; | |
137 | } | |
138 | //------------------------------------------------------------------------ | |
139 | bool AliPHOSDATreeEvent::ExecuteClustering(){ | |
140 | // Run clustering algorithm. | |
141 | // With the filled digit information | |
142 | // | |
143 | ||
144 | // Loop over all digit information | |
145 | if( fNDigits <= 0 ) return true; | |
146 | bool status = true; | |
147 | int ndigits = fNDigits; | |
148 | while( ndigits-- && status ){ | |
149 | status &= Clusterize(fDigits[ndigits]); | |
150 | } | |
151 | if(! status ) return status; | |
152 | ||
153 | // Cluster merging | |
154 | int nclusters0 = fNClusters; | |
155 | while( nclusters0-- ){ | |
156 | AliPHOSDATreeCluster& cluster0 = fClusters[nclusters0]; | |
157 | int nclusters1 = nclusters0; | |
158 | while( nclusters1-- ){ | |
159 | AliPHOSDATreeCluster& cluster1 = fClusters[nclusters1]; | |
160 | if( cluster0.IsNeighbor(cluster1) ){ | |
161 | cluster0.Append(cluster1); | |
162 | cluster1.Reset(); | |
163 | } | |
164 | } | |
165 | } | |
166 | int nclustersnonzero = 0; | |
167 | int nclusters = fNClusters; | |
168 | while( nclusters-- ){ | |
169 | fClusters[nclusters].CalculateProperty(); | |
170 | if( fClusters[nclusters].GetEnergy()>0 ) nclustersnonzero++; | |
171 | } | |
172 | //std::cout<<" nclustersnonzero = "<<nclustersnonzero<<std::endl; | |
173 | if( nclustersnonzero > 0 ){ | |
174 | AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[nclustersnonzero]; | |
175 | nclusters = fNClusters; | |
176 | fNClusters = nclustersnonzero; | |
177 | while( nclusters-- ){ | |
178 | if( fClusters[nclusters].GetEnergy()>0 ){ | |
179 | newClusters[--nclustersnonzero] = fClusters[nclusters]; | |
180 | //std::cout<<" : "<<nclusters<<" --> "<<nclustersnonzero<<std::endl; | |
181 | } | |
182 | } | |
183 | if( fNClusters>0 ) delete[] fClusters; | |
184 | fClusters = newClusters; | |
185 | } else { | |
186 | if( fNClusters>0 ) delete[] fClusters; | |
187 | fClusters = 0; | |
188 | fNClusters = 0; | |
189 | } | |
190 | return true; | |
191 | } | |
192 | //------------------------------------------------------------------------ | |
c335b3c5 | 193 | void AliPHOSDATreeEvent::Print(Option_t *opt) const |
194 | { | |
12f6dd57 | 195 | // Print Out |
196 | ||
197 | char* when = ctime(&fTime); | |
198 | std::cout<<" AliPHOSDATreeEvent:: fNDigits = "<<fNDigits<<" fNClusters="<<fNClusters<<" : "<<when; | |
199 | int ndigits = fNDigits; | |
200 | while( ndigits-- ){ | |
201 | std::cout<<" =>["<<ndigits<<"] : "; | |
202 | fDigits[ndigits].Print(opt); | |
203 | } | |
204 | int nclusters = fNClusters; | |
205 | while( nclusters-- ){ | |
206 | std::cout<<" =>["<<nclusters<<"] : "; | |
207 | fClusters[nclusters].Print(opt); | |
208 | } | |
209 | } | |
210 | //------------------------------------------------------------------------ | |
211 | std::ostream& operator<<(std::ostream& out, const AliPHOSDATreeEvent& event){ | |
212 | // Print Out | |
213 | ||
214 | char* when = ctime(&(event.fTime)); | |
215 | out<<" AliPHOSDATreeEvent:: fNClusters="<<event.fNClusters<<" : "<<when; | |
216 | int ndigits = event.fNDigits; | |
217 | while( ndigits-- ){ | |
218 | out<<" =>["<<ndigits<<"] : "<<event.fDigits[ndigits]; | |
219 | if( ndigits!=0 ) out<<std::endl; | |
220 | } | |
221 | int nclusters = event.fNClusters; | |
222 | while( nclusters-- ){ | |
223 | out<<" =>["<<nclusters<<"] : "<<event.fClusters[nclusters]; | |
224 | if( nclusters!=0 ) out<<std::endl; | |
225 | } | |
226 | return out; | |
227 | } | |
228 | //------------------------------------------------------------------------ |