1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // Implementation for TTree output in PHOS DA
20 // for calibrating energy by pi0 and MIP.
22 // -- Author: Hisayuki Torii (Hiroshima Univ.)
26 #include "AliPHOSDATreeEvent.h"
27 ClassImp(AliPHOSDATreeEvent)
28 //------------------------------------------------------------------------
29 AliPHOSDATreeEvent::AliPHOSDATreeEvent(const AliPHOSDATreeEvent& evt)
38 fNDigits = evt.fNDigits;
40 fDigits = new AliPHOSDATreeDigit[fNDigits];
41 int ndigits = fNDigits;
43 fDigits[ndigits] = evt.fDigits[ndigits];
49 fNClusters = evt.fNClusters;
51 fClusters = new AliPHOSDATreeCluster[fNClusters];
52 int nclusters = fNClusters;
54 fClusters[nclusters] = evt.fClusters[nclusters];
60 //------------------------------------------------------------------------
61 AliPHOSDATreeEvent& AliPHOSDATreeEvent::operator=(const AliPHOSDATreeEvent& evt){
64 if( fNDigits > 0 ) delete[] fDigits;
65 fNDigits = evt.fNDigits;
67 fDigits = new AliPHOSDATreeDigit[fNDigits];
68 int ndigits = fNDigits;
70 fDigits[ndigits] = evt.fDigits[ndigits];
76 if( fNClusters > 0 ) delete[] fClusters;
77 fNClusters = evt.fNClusters;
79 fClusters = new AliPHOSDATreeCluster[fNClusters];
80 int nclusters = fNClusters;
82 fClusters[nclusters] = evt.fClusters[nclusters];
89 //------------------------------------------------------------------------
90 bool AliPHOSDATreeEvent::Fill(float energy,int row,int col){
91 // Fill new digit information
93 AliPHOSDATreeDigit digit(energy,row,col);
96 //------------------------------------------------------------------------
97 bool AliPHOSDATreeEvent::Fill(AliPHOSDATreeDigit& digit){
98 // Fill new digit information
100 AliPHOSDATreeDigit* newDigits = new AliPHOSDATreeDigit[fNDigits+1];
101 int ndigits = fNDigits;
102 newDigits[ndigits] = digit;
104 newDigits[ndigits] = fDigits[ndigits];
106 if( fNDigits>0 ) delete[] fDigits;
111 //------------------------------------------------------------------------
112 bool AliPHOSDATreeEvent::Clusterize(AliPHOSDATreeDigit& digit){
113 //Input digit information into clustering
116 int nclusters = fNClusters;
117 while( nclusters-- && !status ){
118 if( fClusters[nclusters].IsNeighbor(digit) ){
119 status = fClusters[nclusters].Append(digit);
122 //std::cout<<" DEBUGDEBUG:: status = "<<status<<" fNClusters="<<fNClusters<<std::endl;
124 AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[fNClusters+1];
125 nclusters = fNClusters;
126 status = newClusters[nclusters].Append(digit);
127 while( nclusters-- ){
128 newClusters[nclusters] = fClusters[nclusters];
130 if( fNClusters>0 ) delete[] fClusters;
131 fClusters = newClusters;
136 //------------------------------------------------------------------------
137 bool AliPHOSDATreeEvent::ExecuteClustering(){
138 // Run clustering algorithm.
139 // With the filled digit information
142 // Loop over all digit information
143 if( fNDigits <= 0 ) return true;
145 int ndigits = fNDigits;
146 while( ndigits-- && status ){
147 status &= Clusterize(fDigits[ndigits]);
149 if(! status ) return status;
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);
164 int nclustersnonzero = 0;
165 int nclusters = fNClusters;
166 while( nclusters-- ){
167 fClusters[nclusters].CalculateProperty();
168 if( fClusters[nclusters].GetEnergy()>0 ) nclustersnonzero++;
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;
181 if( fNClusters>0 ) delete[] fClusters;
182 fClusters = newClusters;
184 if( fNClusters>0 ) delete[] fClusters;
190 //------------------------------------------------------------------------
191 void AliPHOSDATreeEvent::Print(Option_t *opt) const
195 char* when = ctime(&fTime);
196 std::cout<<" AliPHOSDATreeEvent:: fNDigits = "<<fNDigits<<" fNClusters="<<fNClusters<<" : "<<when;
197 int ndigits = fNDigits;
199 std::cout<<" =>["<<ndigits<<"] : ";
200 fDigits[ndigits].Print(opt);
202 int nclusters = fNClusters;
203 while( nclusters-- ){
204 std::cout<<" =>["<<nclusters<<"] : ";
205 fClusters[nclusters].Print(opt);
208 //------------------------------------------------------------------------
209 std::ostream& operator<<(std::ostream& out, const AliPHOSDATreeEvent& event){
212 char* when = ctime(&(event.fTime));
213 out<<" AliPHOSDATreeEvent:: fNClusters="<<event.fNClusters<<" : "<<when;
214 int ndigits = event.fNDigits;
216 out<<" =>["<<ndigits<<"] : "<<event.fDigits[ndigits];
217 if( ndigits!=0 ) out<<std::endl;
219 int nclusters = event.fNClusters;
220 while( nclusters-- ){
221 out<<" =>["<<nclusters<<"] : "<<event.fClusters[nclusters];
222 if( nclusters!=0 ) out<<std::endl;
226 //------------------------------------------------------------------------