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){
65 if( fNDigits > 0 ) delete[] fDigits;
66 fNDigits = evt.fNDigits;
68 fDigits = new AliPHOSDATreeDigit[fNDigits];
69 int ndigits = fNDigits;
71 fDigits[ndigits] = evt.fDigits[ndigits];
77 if( fNClusters > 0 ) delete[] fClusters;
78 fNClusters = evt.fNClusters;
80 fClusters = new AliPHOSDATreeCluster[fNClusters];
81 int nclusters = fNClusters;
83 fClusters[nclusters] = evt.fClusters[nclusters];
91 //------------------------------------------------------------------------
92 bool AliPHOSDATreeEvent::Fill(float energy,int row,int col){
93 // Fill new digit information
95 AliPHOSDATreeDigit digit(energy,row,col);
98 //------------------------------------------------------------------------
99 bool AliPHOSDATreeEvent::Fill(AliPHOSDATreeDigit& digit){
100 // Fill new digit information
102 AliPHOSDATreeDigit* newDigits = new AliPHOSDATreeDigit[fNDigits+1];
103 int ndigits = fNDigits;
104 newDigits[ndigits] = digit;
106 newDigits[ndigits] = fDigits[ndigits];
108 if( fNDigits>0 ) delete[] fDigits;
113 //------------------------------------------------------------------------
114 bool AliPHOSDATreeEvent::Clusterize(AliPHOSDATreeDigit& digit){
115 //Input digit information into clustering
118 int nclusters = fNClusters;
119 while( nclusters-- && !status ){
120 if( fClusters[nclusters].IsNeighbor(digit) ){
121 status = fClusters[nclusters].Append(digit);
124 //std::cout<<" DEBUGDEBUG:: status = "<<status<<" fNClusters="<<fNClusters<<std::endl;
126 AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[fNClusters+1];
127 nclusters = fNClusters;
128 status = newClusters[nclusters].Append(digit);
129 while( nclusters-- ){
130 newClusters[nclusters] = fClusters[nclusters];
132 if( fNClusters>0 ) delete[] fClusters;
133 fClusters = newClusters;
138 //------------------------------------------------------------------------
139 bool AliPHOSDATreeEvent::ExecuteClustering(){
140 // Run clustering algorithm.
141 // With the filled digit information
144 // Loop over all digit information
145 if( fNDigits <= 0 ) return true;
147 int ndigits = fNDigits;
148 while( ndigits-- && status ){
149 status &= Clusterize(fDigits[ndigits]);
151 if(! status ) return status;
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);
166 int nclustersnonzero = 0;
167 int nclusters = fNClusters;
168 while( nclusters-- ){
169 fClusters[nclusters].CalculateProperty();
170 if( fClusters[nclusters].GetEnergy()>0 ) nclustersnonzero++;
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;
183 if( fNClusters>0 ) delete[] fClusters;
184 fClusters = newClusters;
186 if( fNClusters>0 ) delete[] fClusters;
192 //------------------------------------------------------------------------
193 void AliPHOSDATreeEvent::Print(Option_t *opt) const
197 char* when = ctime(&fTime);
198 std::cout<<" AliPHOSDATreeEvent:: fNDigits = "<<fNDigits<<" fNClusters="<<fNClusters<<" : "<<when;
199 int ndigits = fNDigits;
201 std::cout<<" =>["<<ndigits<<"] : ";
202 fDigits[ndigits].Print(opt);
204 int nclusters = fNClusters;
205 while( nclusters-- ){
206 std::cout<<" =>["<<nclusters<<"] : ";
207 fClusters[nclusters].Print(opt);
210 //------------------------------------------------------------------------
211 std::ostream& operator<<(std::ostream& out, const AliPHOSDATreeEvent& event){
214 char* when = ctime(&(event.fTime));
215 out<<" AliPHOSDATreeEvent:: fNClusters="<<event.fNClusters<<" : "<<when;
216 int ndigits = event.fNDigits;
218 out<<" =>["<<ndigits<<"] : "<<event.fDigits[ndigits];
219 if( ndigits!=0 ) out<<std::endl;
221 int nclusters = event.fNClusters;
222 while( nclusters-- ){
223 out<<" =>["<<nclusters<<"] : "<<event.fClusters[nclusters];
224 if( nclusters!=0 ) out<<std::endl;
228 //------------------------------------------------------------------------