]>
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 | ||
64 | if( fNDigits > 0 ) delete[] fDigits; | |
65 | fNDigits = evt.fNDigits; | |
66 | if( fNDigits > 0 ){ | |
67 | fDigits = new AliPHOSDATreeDigit[fNDigits]; | |
68 | int ndigits = fNDigits; | |
69 | while( ndigits-- ){ | |
70 | fDigits[ndigits] = evt.fDigits[ndigits]; | |
71 | } | |
72 | } else { | |
73 | fDigits = 0; | |
74 | } | |
75 | // | |
76 | if( fNClusters > 0 ) delete[] fClusters; | |
77 | fNClusters = evt.fNClusters; | |
78 | if( fNClusters > 0 ){ | |
79 | fClusters = new AliPHOSDATreeCluster[fNClusters]; | |
80 | int nclusters = fNClusters; | |
81 | while( nclusters-- ){ | |
82 | fClusters[nclusters] = evt.fClusters[nclusters]; | |
83 | } | |
84 | } else { | |
85 | fClusters = 0; | |
86 | } | |
87 | return *this; | |
88 | } | |
89 | //------------------------------------------------------------------------ | |
90 | bool AliPHOSDATreeEvent::Fill(float energy,int row,int col){ | |
91 | // Fill new digit information | |
92 | ||
93 | AliPHOSDATreeDigit digit(energy,row,col); | |
94 | return Fill(digit); | |
95 | } | |
96 | //------------------------------------------------------------------------ | |
97 | bool AliPHOSDATreeEvent::Fill(AliPHOSDATreeDigit& digit){ | |
98 | // Fill new digit information | |
99 | ||
100 | AliPHOSDATreeDigit* newDigits = new AliPHOSDATreeDigit[fNDigits+1]; | |
101 | int ndigits = fNDigits; | |
102 | newDigits[ndigits] = digit; | |
103 | while( ndigits-- ){ | |
104 | newDigits[ndigits] = fDigits[ndigits]; | |
105 | } | |
106 | if( fNDigits>0 ) delete[] fDigits; | |
107 | fDigits = newDigits; | |
108 | fNDigits++; | |
109 | return true; | |
110 | } | |
111 | //------------------------------------------------------------------------ | |
112 | bool AliPHOSDATreeEvent::Clusterize(AliPHOSDATreeDigit& digit){ | |
113 | //Input digit information into clustering | |
114 | ||
115 | bool status = false; | |
116 | int nclusters = fNClusters; | |
117 | while( nclusters-- && !status ){ | |
118 | if( fClusters[nclusters].IsNeighbor(digit) ){ | |
119 | status = fClusters[nclusters].Append(digit); | |
120 | } | |
121 | } | |
122 | //std::cout<<" DEBUGDEBUG:: status = "<<status<<" fNClusters="<<fNClusters<<std::endl; | |
123 | if( !status ){ | |
124 | AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[fNClusters+1]; | |
125 | nclusters = fNClusters; | |
126 | status = newClusters[nclusters].Append(digit); | |
127 | while( nclusters-- ){ | |
128 | newClusters[nclusters] = fClusters[nclusters]; | |
129 | } | |
130 | if( fNClusters>0 ) delete[] fClusters; | |
131 | fClusters = newClusters; | |
132 | fNClusters++; | |
133 | } | |
134 | return status; | |
135 | } | |
136 | //------------------------------------------------------------------------ | |
137 | bool AliPHOSDATreeEvent::ExecuteClustering(){ | |
138 | // Run clustering algorithm. | |
139 | // With the filled digit information | |
140 | // | |
141 | ||
142 | // Loop over all digit information | |
143 | if( fNDigits <= 0 ) return true; | |
144 | bool status = true; | |
145 | int ndigits = fNDigits; | |
146 | while( ndigits-- && status ){ | |
147 | status &= Clusterize(fDigits[ndigits]); | |
148 | } | |
149 | if(! status ) return status; | |
150 | ||
151 | // Cluster merging | |
152 | int nclusters0 = fNClusters; | |
153 | while( nclusters0-- ){ | |
154 | AliPHOSDATreeCluster& cluster0 = fClusters[nclusters0]; | |
155 | int nclusters1 = nclusters0; | |
156 | while( nclusters1-- ){ | |
157 | AliPHOSDATreeCluster& cluster1 = fClusters[nclusters1]; | |
158 | if( cluster0.IsNeighbor(cluster1) ){ | |
159 | cluster0.Append(cluster1); | |
160 | cluster1.Reset(); | |
161 | } | |
162 | } | |
163 | } | |
164 | int nclustersnonzero = 0; | |
165 | int nclusters = fNClusters; | |
166 | while( nclusters-- ){ | |
167 | fClusters[nclusters].CalculateProperty(); | |
168 | if( fClusters[nclusters].GetEnergy()>0 ) nclustersnonzero++; | |
169 | } | |
170 | //std::cout<<" nclustersnonzero = "<<nclustersnonzero<<std::endl; | |
171 | if( nclustersnonzero > 0 ){ | |
172 | AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[nclustersnonzero]; | |
173 | nclusters = fNClusters; | |
174 | fNClusters = nclustersnonzero; | |
175 | while( nclusters-- ){ | |
176 | if( fClusters[nclusters].GetEnergy()>0 ){ | |
177 | newClusters[--nclustersnonzero] = fClusters[nclusters]; | |
178 | //std::cout<<" : "<<nclusters<<" --> "<<nclustersnonzero<<std::endl; | |
179 | } | |
180 | } | |
181 | if( fNClusters>0 ) delete[] fClusters; | |
182 | fClusters = newClusters; | |
183 | } else { | |
184 | if( fNClusters>0 ) delete[] fClusters; | |
185 | fClusters = 0; | |
186 | fNClusters = 0; | |
187 | } | |
188 | return true; | |
189 | } | |
190 | //------------------------------------------------------------------------ | |
c335b3c5 | 191 | void AliPHOSDATreeEvent::Print(Option_t *opt) const |
192 | { | |
12f6dd57 | 193 | // Print Out |
194 | ||
195 | char* when = ctime(&fTime); | |
196 | std::cout<<" AliPHOSDATreeEvent:: fNDigits = "<<fNDigits<<" fNClusters="<<fNClusters<<" : "<<when; | |
197 | int ndigits = fNDigits; | |
198 | while( ndigits-- ){ | |
199 | std::cout<<" =>["<<ndigits<<"] : "; | |
200 | fDigits[ndigits].Print(opt); | |
201 | } | |
202 | int nclusters = fNClusters; | |
203 | while( nclusters-- ){ | |
204 | std::cout<<" =>["<<nclusters<<"] : "; | |
205 | fClusters[nclusters].Print(opt); | |
206 | } | |
207 | } | |
208 | //------------------------------------------------------------------------ | |
209 | std::ostream& operator<<(std::ostream& out, const AliPHOSDATreeEvent& event){ | |
210 | // Print Out | |
211 | ||
212 | char* when = ctime(&(event.fTime)); | |
213 | out<<" AliPHOSDATreeEvent:: fNClusters="<<event.fNClusters<<" : "<<when; | |
214 | int ndigits = event.fNDigits; | |
215 | while( ndigits-- ){ | |
216 | out<<" =>["<<ndigits<<"] : "<<event.fDigits[ndigits]; | |
217 | if( ndigits!=0 ) out<<std::endl; | |
218 | } | |
219 | int nclusters = event.fNClusters; | |
220 | while( nclusters-- ){ | |
221 | out<<" =>["<<nclusters<<"] : "<<event.fClusters[nclusters]; | |
222 | if( nclusters!=0 ) out<<std::endl; | |
223 | } | |
224 | return out; | |
225 | } | |
226 | //------------------------------------------------------------------------ |