00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include <algorithm>
00012
00013 #include "Cluster3D/ClusterListKG.h"
00014 #include "Algorithm/AlgConfig.h"
00015 #include "MessageService/MsgService.h"
00016 #include "Cluster3D/ClusterKG.h"
00017 #include "Cluster3D/CellKG.h"
00018 #include "Cluster3D/StripListKG.h"
00019 #include "Cluster3D/CellListKG.h"
00020
00021 ClassImp(ClusterListKG)
00022
00023 CVSID("$Id: ClusterListKG.cxx,v 1.4 2009/02/28 21:46:11 gmieg Exp $");
00024
00025 ClusterListKG::ClusterListKG():energyRaw(0.),energyPe(0.),energyGeV(0.){
00026
00027
00028
00029 }
00030
00031
00032
00033 void ClusterListKG::GetClusters(vector<ClusterKG> &allclust){
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 allclust=allclsts;
00048 }
00049
00050
00051
00052 UInt_t ClusterListKG::GetNClusters(){
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 return allclsts.size();
00067
00068 }
00069
00070
00071
00072 void ClusterListKG::SetEnergy(){
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 for(UInt_t i=0; i<allclsts.size(); ++i){
00087 energyRaw=energyRaw+allclsts[i].GetEnergy(0);
00088 energyPe=energyPe+allclsts[i].GetEnergy(1);
00089 }
00090 }
00091
00092
00093
00094 Double_t ClusterListKG::GetEnergy(Int_t whatKind){
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 if(whatKind==0){
00111 return energyRaw;
00112 }
00113 else if(whatKind==1){
00114 return energyPe;
00115 }
00116 else if(whatKind==2){
00117 return energyGeV;
00118 }
00119 else{
00120 return energyPe;
00121 }
00122
00123
00124 }
00125
00126
00127
00128 void ClusterListKG::CreateClusters(AlgConfig &ac, StripListKG &all1, CellListKG &all2){
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 const Int_t planeDist = ac.GetInt("plnDist");
00144 const Int_t stripDist = ac.GetInt("stpDist");
00145
00146 vector <Int_t> arr1[200];
00147
00148 vector<Int_t> marked;
00149
00150 vector<Int_t> left;
00151
00152 std::vector<Int_t>::iterator pos;
00153
00154 Int_t allc = all2.GetNCells();
00155
00156 for(Int_t jj=0;jj<allc;++jj){
00157 marked.push_back(0);
00158 left.push_back(jj);
00159 }
00160
00161 Int_t notMarked=allc;
00162
00163
00164 MSG("Cluster3D", Msg::kDebug)
00165 << "notMarked = " << notMarked << endl;
00166
00167 Int_t iclust=-1;
00168 Int_t icell=0;
00169
00170
00171 while(notMarked!=0){
00172 bool neighbours=true;
00173
00174 ++iclust;
00175
00176 MSG("Cluster3D", Msg::kDebug)
00177 << "i-th cluster = " << iclust << endl;
00178
00179 MSG("Cluster3D", Msg::kDebug)
00180 << "icell= " << icell << endl;
00181
00182 icell=left[0];
00183
00184 arr1[iclust].push_back(icell);
00185
00186 MSG("Cluster3D", Msg::kDebug)
00187 << "all2.GetCellIndex(icell)= " << all2.GetCellIndex(icell)
00188 << "all2.GetCellPlane(icell)= " << all2.GetCellPlane(icell) << endl;
00189
00190 pos=find(left.begin(),left.end(),icell);
00191
00192 if (pos != left.end()){
00193 left.erase(pos);
00194 }
00195
00196 marked[icell]=1;
00197 --notMarked;
00198
00199
00200
00201 Int_t icolu=-1;
00202 while(neighbours){
00203 ++icolu;
00204
00205
00206 for(Int_t kk=icell+1;kk<allc;++kk){
00207
00208 if(marked[kk]==0){
00209
00210 if(all2.IsNeighbour(arr1[iclust][icolu],kk,planeDist,stripDist)){
00211
00212 marked[kk]=1;
00213 --notMarked;
00214
00215 MSG("Cluster3D", Msg::kDebug)
00216 << "all2.GetCellIndex(kk)= " << all2.GetCellIndex(kk)
00217 << "all2.GetCellPlane(kk)= " << all2.GetCellPlane(kk) << endl;
00218
00219
00220 arr1[iclust].push_back(kk);
00221
00222 pos=find(left.begin(),left.end(),kk);
00223
00224 if (pos != left.end()){
00225 left.erase(pos);
00226 }
00227 }
00228 }
00229 }
00230 if(icolu==((Int_t)arr1[iclust].size()-1) || notMarked==0) {
00231 neighbours=false;
00232 }
00233 }
00234 }
00235
00236 MSG("Cluster3D", Msg::kDebug)
00237 << "CreateClusters: Number of clusters= " << (iclust+1) << endl;
00238
00239 ClusterKG ctmp;
00240 for(Int_t ii=0; ii<(iclust+1); ++ii){
00241 MSG("Cluster3D", Msg::kDebug)
00242 << "arr1[ii].size()= " << arr1[ii].size() << endl;
00243 if(ctmp.Create(ac,all1,all2,arr1[ii])){
00244 allclsts.push_back(ctmp);
00245 }
00246 }
00247 }