00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include <cstdlib>
00012 #include <cmath>
00013
00014 #include "Cluster3D/CellListKG.h"
00015 #include "Algorithm/AlgConfig.h"
00016 #include "Cluster3D/StripListKG.h"
00017 #include "MessageService/MsgService.h"
00018 #include "Cluster3D/StripKG.h"
00019 #include "Cluster3D/PlaneKG.h"
00020
00021 ClassImp(CellListKG)
00022
00023 CVSID("$Id: CellListKG.cxx,v 1.6 2009/02/28 21:46:11 gmieg Exp $");
00024
00025 CellListKG::CellListKG(){
00026
00027
00028
00029 MSG("Cluster3D", Msg::kDebug)
00030 << "Default constructor " << endl;
00031 }
00032
00033
00034
00035 void CellListKG::GetCells(vector<CellKG> &allcell) const{
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 allcell=allcells;
00051 }
00052
00053
00054
00055 UInt_t CellListKG::GetNCells() const{
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 return allcells.size();
00070 }
00071
00072
00073
00074 void CellListKG::CreateCells(AlgConfig &ac, StripListKG &all1){
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 Int_t cellnb=0;
00091
00092 Int_t nstrips=all1.GetNStrips();
00093
00094 vector<PlaneKG> allpl;
00095
00096 allpl.clear();
00097
00098 for(Int_t i=0;i<nstrips;++i){
00099
00100 Int_t ithPlaneNb=all1.GetStripPlane(i);
00101
00102 PlaneKG p;
00103
00104 if(i==0){
00105 p.Create(all1,ithPlaneNb);
00106 allpl.push_back(p);
00107 }
00108 else{
00109 Int_t i1thPlaneNb=all1.GetStripPlane(i-1);
00110 if(ithPlaneNb != i1thPlaneNb){
00111 p.Create(all1,ithPlaneNb);
00112 allpl.push_back(p);
00113 }
00114 }
00115 }
00116
00117 const Int_t crosstalk = ac.GetInt("xTalk");
00118 const Int_t cdist = ac.GetInt("maxDist");
00119 const Int_t timing = ac.GetInt("timeInfo");
00120
00121 Int_t fNbStpInNextPl=0;
00122 Int_t fNbStpInThisPl=0;
00123
00124 for(Int_t i=0;i<nstrips;++i){
00125
00126 Int_t ithPlaneNb=all1.GetStripPlane(i);
00127 Int_t ithPlaneXTalk=all1.GetStripXTalk(i);
00128 Int_t ithStripNb=all1.GetStripStrip(i);
00129
00130 MSG("Cluster3D", Msg::kDebug) << "i= " << i
00131 << " ithPlaneNb = " << ithPlaneNb
00132 << " ithStripNb = " << ithStripNb
00133 << " ithPlaneXTalk = " << ithPlaneXTalk << endl;
00134
00135 fNbStpInThisPl=all1.NbStpInPlane(ithPlaneNb,allpl);
00136
00137 if(crosstalk && ithPlaneXTalk){
00138 continue;
00139 }
00140
00141 Float_t t1t2,timPos,hBox;
00142 Float_t t1t2f,timPosf,hBoxf;
00143
00144 Int_t counter=0;
00145
00146 for(Int_t j=i+1;j<nstrips;++j){
00147
00148 Int_t jthPlaneNb=all1.GetStripPlane(j);
00149 Int_t jthPlaneXTalk=all1.GetStripXTalk(j);
00150 Int_t jthStripNb=all1.GetStripStrip(j);
00151
00152 if(crosstalk && jthPlaneXTalk){
00153 continue;
00154 }
00155
00156
00157
00158 if( abs(ithPlaneNb-jthPlaneNb) > cdist ){
00159 break;
00160 }
00161
00162 if(all1.OppViewNeighbours(ithPlaneNb,jthPlaneNb,cdist)){
00163 ++counter;
00164
00165 fNbStpInNextPl=all1.NbStpInPlane(jthPlaneNb,allpl);
00166
00167
00168 Bool_t oneStp;
00169
00170 if(fNbStpInNextPl==1 && timing){
00171 oneStp=true;
00172 all1.GetTimePos(j,ac,oneStp,t1t2, timPos, hBox);
00173 }
00174 else{
00175 oneStp=false;
00176 all1.GetTimePos(j,ac,oneStp,t1t2, timPos, hBox);
00177 }
00178
00179
00180 if(fNbStpInThisPl==1 && timing){
00181 oneStp=true;
00182 all1.GetTimePos(i,ac,oneStp,t1t2f, timPosf, hBoxf);
00183 }
00184 else{
00185 oneStp=false;
00186 all1.GetTimePos(i,ac,oneStp,t1t2f, timPosf, hBoxf);
00187 }
00188
00189
00190 if( ( ithStripNb < Int_t(timPos+hBox+1)
00191 && ithStripNb > Int_t(timPos-hBox-1)
00192 && jthStripNb < Int_t(timPosf+hBoxf+1)
00193 && jthStripNb > Int_t(timPosf-hBoxf-1) )
00194 ){
00195 CellKG c1,c2;
00196
00197 if(c1.Create(i,j,all1,1,allcells,cellnb)){
00198 allcells.push_back(c1);
00199 }
00200 if(c2.Create(i,j,all1,2,allcells,cellnb)){
00201 allcells.push_back(c2);
00202 }
00203 }
00204
00205
00206
00207 if(counter==fNbStpInNextPl) break;
00208 }
00209
00210
00211
00212
00213
00214 }
00215
00216
00217
00218 if(counter==0){
00219 CellKG c;
00220
00221 if(c.Create(i,all1,allcells,cellnb)){
00222 allcells.push_back(c);
00223 }
00224 }
00225
00226
00227 }
00228 for(UInt_t ij=0;ij<allcells.size();++ij){
00229 MSG("Cluster3D", Msg::kDebug)
00230 << "allcells[ij].index= "
00231 << allcells[ij].index
00232 << " allcells[ij].plane= "
00233 << allcells[ij].plane
00234 << " allcells[ij].v= "
00235 << allcells[ij].v
00236 << " allcells[ij].u= "
00237 << allcells[ij].u
00238 << endl;
00239
00240 }
00241 }
00242
00243
00244 Bool_t CellListKG::IsNeighbour(Int_t index1, Int_t index2, Int_t plnDistInp, Int_t stpDistInp){
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 const Float_t plnDist = plnDistInp*(5.94*0.01+0.01);
00260 const Float_t stpDist = stpDistInp*(4.1*0.01+0.01);
00261
00262 Float_t distU = 0.;
00263 if( (fabs(this->GetCellU(index1)) == 9999) || (fabs(this->GetCellU(index2)) == 9999) ){
00264 distU = -9999;
00265 }
00266 else{
00267 distU = fabs((this->GetCellU(index1))-(this->GetCellU(index2)));
00268 }
00269
00270 Float_t distV = 0.;
00271 if( (fabs(this->GetCellV(index1)) == 9999) || (fabs(this->GetCellV(index2)) == 9999) ){
00272 distV = -9999;
00273 }
00274 else{
00275 distV = fabs((this->GetCellV(index1))-(this->GetCellV(index2)));
00276 }
00277
00278 Float_t distZ = fabs((this->GetCellZ(index1))-(this->GetCellZ(index2)));
00279
00280
00281
00282 Int_t c1pos=this->GetCellPlane(index1);
00283 Int_t c2pos=this->GetCellPlane(index2);
00284
00285 Bool_t gap = false;
00286
00287
00288 if( (c1pos == 248 && c2pos == 250) || (c2pos == 248 && c1pos == 250) ){
00289 gap=true;
00290 }
00291
00292
00293
00294 if((fabs(distU-stpDist)<0.001) && (fabs(distV-stpDist)<0.001)
00295 && (fabs(distZ-plnDist)<0.001) ){
00296 return false;
00297 }
00298
00299 if( gap && (distU < stpDist) && (distV < stpDist) ){
00300 return true;
00301 }
00302 else{
00303 if((distU < stpDist) && (distV < stpDist) && (distZ < plnDist) ){
00304 return true;
00305 }
00306 else{
00307 return false;
00308 }
00309 }
00310 }
00311
00312
00313
00314 Int_t CellListKG::GetCellIndex(UInt_t index) const{
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 return allcells[index].index;
00331 }
00332
00333
00334
00335 Int_t CellListKG::GetCellPlane(UInt_t index) const{
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 return allcells[index].plane;
00352 }
00353
00354
00355
00356 Float_t CellListKG::GetCellU(UInt_t index) const{
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372 return allcells[index].u;
00373 }
00374
00375
00376
00377 Float_t CellListKG::GetCellV(UInt_t index) const{
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 return allcells[index].v;
00394 }
00395
00396
00397
00398 Float_t CellListKG::GetCellZ(UInt_t index) const{
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414 return allcells[index].z;
00415 }
00416
00417
00418
00419 Int_t CellListKG::GetCellView(UInt_t index) const{
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 return allcells[index].planeview;
00436 }
00437
00438
00439
00440 UInt_t CellListKG::GetCellElem1(UInt_t index) const{
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 return allcells[index].elem1;
00457 }
00458
00459
00460
00461 UInt_t CellListKG::GetCellElem2(UInt_t index) const{
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 return allcells[index].elem2;
00478 }