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