3 // Implementation for TTree output in PHOS DA
4 // for calibrating energy by pi0 and MIP.
6 // -- Author: Hisayuki Torii (Hiroshima Univ.)
10 #include "AliPHOSDATreeEvent.h"
11 ClassImp(AliPHOSDATreeEvent)
12 //------------------------------------------------------------------------
13 AliPHOSDATreeEvent::AliPHOSDATreeEvent(const AliPHOSDATreeEvent& evt){
16 fNDigits = evt.fNDigits;
18 fDigits = new AliPHOSDATreeDigit[fNDigits];
19 int ndigits = fNDigits;
21 fDigits[ndigits] = evt.fDigits[ndigits];
27 fNClusters = evt.fNClusters;
29 fClusters = new AliPHOSDATreeCluster[fNClusters];
30 int nclusters = fNClusters;
32 fClusters[nclusters] = evt.fClusters[nclusters];
38 //------------------------------------------------------------------------
39 AliPHOSDATreeEvent& AliPHOSDATreeEvent::operator=(const AliPHOSDATreeEvent& evt){
42 if( fNDigits > 0 ) delete[] fDigits;
43 fNDigits = evt.fNDigits;
45 fDigits = new AliPHOSDATreeDigit[fNDigits];
46 int ndigits = fNDigits;
48 fDigits[ndigits] = evt.fDigits[ndigits];
54 if( fNClusters > 0 ) delete[] fClusters;
55 fNClusters = evt.fNClusters;
57 fClusters = new AliPHOSDATreeCluster[fNClusters];
58 int nclusters = fNClusters;
60 fClusters[nclusters] = evt.fClusters[nclusters];
67 //------------------------------------------------------------------------
68 bool AliPHOSDATreeEvent::Fill(float energy,int row,int col){
69 // Fill new digit information
71 AliPHOSDATreeDigit digit(energy,row,col);
74 //------------------------------------------------------------------------
75 bool AliPHOSDATreeEvent::Fill(AliPHOSDATreeDigit& digit){
76 // Fill new digit information
78 AliPHOSDATreeDigit* newDigits = new AliPHOSDATreeDigit[fNDigits+1];
79 int ndigits = fNDigits;
80 newDigits[ndigits] = digit;
82 newDigits[ndigits] = fDigits[ndigits];
84 if( fNDigits>0 ) delete[] fDigits;
89 //------------------------------------------------------------------------
90 bool AliPHOSDATreeEvent::Clusterize(AliPHOSDATreeDigit& digit){
91 //Input digit information into clustering
94 int nclusters = fNClusters;
95 while( nclusters-- && !status ){
96 if( fClusters[nclusters].IsNeighbor(digit) ){
97 status = fClusters[nclusters].Append(digit);
100 //std::cout<<" DEBUGDEBUG:: status = "<<status<<" fNClusters="<<fNClusters<<std::endl;
102 AliPHOSDATreeCluster* newClusters = new AliPHOSDATreeCluster[fNClusters+1];
103 nclusters = fNClusters;
104 status = newClusters[nclusters].Append(digit);
105 while( nclusters-- ){
106 newClusters[nclusters] = fClusters[nclusters];
108 if( fNClusters>0 ) delete[] fClusters;
109 fClusters = newClusters;
114 //------------------------------------------------------------------------
115 bool AliPHOSDATreeEvent::ExecuteClustering(){
116 // Run clustering algorithm.
117 // With the filled digit information
120 // Loop over all digit information
121 if( fNDigits <= 0 ) return true;
123 int ndigits = fNDigits;
124 while( ndigits-- && status ){
125 status &= Clusterize(fDigits[ndigits]);
127 if(! status ) return status;
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);
142 int nclustersnonzero = 0;
143 int nclusters = fNClusters;
144 while( nclusters-- ){
145 fClusters[nclusters].CalculateProperty();
146 if( fClusters[nclusters].GetEnergy()>0 ) nclustersnonzero++;
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;
159 if( fNClusters>0 ) delete[] fClusters;
160 fClusters = newClusters;
162 if( fNClusters>0 ) delete[] fClusters;
168 //------------------------------------------------------------------------
169 void AliPHOSDATreeEvent::Print(char* opt){
172 char* when = ctime(&fTime);
173 std::cout<<" AliPHOSDATreeEvent:: fNDigits = "<<fNDigits<<" fNClusters="<<fNClusters<<" : "<<when;
174 int ndigits = fNDigits;
176 std::cout<<" =>["<<ndigits<<"] : ";
177 fDigits[ndigits].Print(opt);
179 int nclusters = fNClusters;
180 while( nclusters-- ){
181 std::cout<<" =>["<<nclusters<<"] : ";
182 fClusters[nclusters].Print(opt);
185 //------------------------------------------------------------------------
186 std::ostream& operator<<(std::ostream& out, const AliPHOSDATreeEvent& event){
189 char* when = ctime(&(event.fTime));
190 out<<" AliPHOSDATreeEvent:: fNClusters="<<event.fNClusters<<" : "<<when;
191 int ndigits = event.fNDigits;
193 out<<" =>["<<ndigits<<"] : "<<event.fDigits[ndigits];
194 if( ndigits!=0 ) out<<std::endl;
196 int nclusters = event.fNClusters;
197 while( nclusters-- ){
198 out<<" =>["<<nclusters<<"] : "<<event.fClusters[nclusters];
199 if( nclusters!=0 ) out<<std::endl;
203 //------------------------------------------------------------------------