00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include <algorithm>
00012 #include <cstdlib>
00013
00014 #include "Cluster3D/StripListKG.h"
00015 #include "Algorithm/AlgConfig.h"
00016 #include "MessageService/MsgService.h"
00017 #include "Cluster3D/StripKG.h"
00018 #include "Cluster3D/PlaneKG.h"
00019 #include "RecoBase/CandStripHandle.h"
00020 #include "RecoBase/CandSliceHandle.h"
00021 #include "UgliGeometry/UgliGeomHandle.h"
00022
00023 ClassImp(StripListKG)
00024
00025 CVSID("$Id: StripListKG.cxx,v 1.4 2009/02/28 21:46:11 gmieg Exp $");
00026
00027
00028
00029 Bool_t StripSortCriterion (const StripKG &s1, const StripKG &s2){
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 if(s1.plane == s2.plane){
00049 return (s1.strip < s2.strip);
00050 }
00051 else{
00052 return (s1.plane < s2.plane);
00053 }
00054 }
00055
00056
00057
00058 StripListKG::StripListKG():energyRaw(0.),energyPe(0.),energyGeV(0.){
00059
00060
00061
00062 }
00063
00064
00065
00066 void StripListKG::GetStrips(vector<StripKG> &allstp) const{
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 allstp=allstps;
00082 }
00083
00084
00085
00086 UInt_t StripListKG::GetNStrips() const{
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 return allstps.size();
00102 }
00103
00104
00105
00106 void StripListKG::SetEnergy(){
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 for(UInt_t i=0; i<allstps.size(); ++i){
00121 energyPe=energyPe+allstps[i].peE+allstps[i].peW;
00122 energyRaw=energyRaw+allstps[i].rawE+allstps[i].rawW;
00123 }
00124 }
00125
00126
00127
00128 Double_t StripListKG::GetEnergy(Int_t whatKind) const{
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 if(whatKind==0){
00144 return energyRaw;
00145 }
00146 else if(whatKind==1){
00147 return energyPe;
00148 }
00149 else if(whatKind==2){
00150 return energyGeV;
00151 }
00152 else{
00153 return energyPe;
00154 }
00155
00156 return energyPe;
00157 }
00158
00159
00160
00161 Bool_t StripListKG::OppViewNeighbours(Int_t planeNbInp1, Int_t planeNbInp2, Int_t cdist){
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 Int_t dist = abs(planeNbInp1-planeNbInp2);
00177
00178 if(dist%2!=0 && dist <= cdist){
00179 return true;
00180 }
00181 else{
00182 return false;
00183 }
00184 }
00185
00186
00187
00188 Int_t StripListKG::NbStpInPlane(Int_t planeNbInp, const std::vector<PlaneKG> &p){
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 Int_t flag=0;
00204 Int_t ile=0;
00205 for(UInt_t j=0; j<p.size(); ++j){
00206 if(planeNbInp==p[j].number){
00207 flag=1;
00208 ile = p[j].nstppplane;
00209 break;
00210 }
00211 else{
00212 continue;
00213 }
00214 }
00215 if(flag==1){
00216 return ile;
00217 }
00218 else{
00219 cout << "NbStpInPlane : Strip belongs to an unknown plane " << endl;
00220 return 0;
00221 }
00222 }
00223
00224
00225
00226 void StripListKG::CreateStrips(AlgConfig &ac, const CandSliceHandle* slice, UgliGeomHandle *ugh){
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 const Int_t xtalkmod = ac.GetInt("xTalkMode");
00242
00243
00244 CandStripHandleItr stripItr(slice->GetDaughterIterator());
00245
00246 Int_t nstrips = slice->GetNStrip();
00247
00248 MSG("Cluster3D", Msg::kDebug)
00249 << "Create strip list"
00250 << "nstrips = " << nstrips
00251 << endl;
00252
00253 Int_t i=0;
00254 StripKG s;
00255
00256 while (stripItr.IsValid()) {
00257
00258 CandStripHandle *strip = stripItr.Ptr();
00259
00260 s.Set(strip,ugh,i);
00261 allstps.push_back(s);
00262
00263 ++i;
00264 stripItr.Next();
00265 }
00266 stable_sort(allstps.begin(),allstps.end(),StripSortCriterion);
00267
00268 for(UInt_t ii=0;ii<allstps.size();++ii){
00269
00270 if(xtalkmod==1){
00271 allstps[i].XTalk(ac);
00272 }
00273 else{
00274 if(FirstInPlane(ii) && LastInPlane(ii)){
00275 allstps[ii].XTalk(ac);
00276 }
00277 else if(FirstInPlane(ii)){
00278 Int_t dist1 = allstps[ii+1].strip-allstps[ii].strip;
00279 if(dist1>5){
00280 allstps[ii].XTalk(ac);
00281 }
00282 }
00283 else if(LastInPlane(ii)){
00284 Int_t dist2 = allstps[ii].strip-allstps[ii-1].strip;
00285 if(dist2>5){
00286 allstps[ii].XTalk(ac);
00287 }
00288 }
00289 else{
00290 Int_t dist1 = allstps[ii+1].strip-allstps[ii].strip;
00291 Int_t dist2 = allstps[ii].strip-allstps[ii-1].strip;
00292 if(dist1>5 && dist2>5){
00293 allstps[ii].XTalk(ac);
00294 }
00295 }
00296 MSG("Cluster3D", Msg::kDebug)
00297 << " allstps[ii].plane= "
00298 << allstps[ii].plane
00299 << " allstps[ii].strip= "
00300 << allstps[ii].strip
00301 << " allstps[ii].xtalk= "
00302 << allstps[ii].xtalk
00303 << endl;
00304 }
00305 }
00306 }
00307
00308
00309
00310 CandStripHandle* StripListKG::GetStripHandle(UInt_t index) const{
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 return allstps[index].handle;
00327 }
00328
00329
00330
00331 Int_t StripListKG::GetStripIndex(UInt_t index) const{
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 return allstps[index].index;
00348 }
00349
00350
00351
00352 Int_t StripListKG::GetStripStrip(UInt_t index) const{
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368 return allstps[index].strip;
00369 }
00370
00371
00372
00373 Int_t StripListKG::GetStripPlane(UInt_t index) const{
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389 return allstps[index].plane;
00390 }
00391
00392
00393
00394 Float_t StripListKG::GetStripTPos(UInt_t index) const{
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 return allstps[index].tpos;
00411 }
00412
00413
00414
00415 Float_t StripListKG::GetStripZPos(UInt_t index) const{
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431 return allstps[index].zpos;
00432 }
00433
00434
00435
00436 Int_t StripListKG::GetStripView(UInt_t index) const{
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 return allstps[index].planeview;
00453 }
00454
00455
00456
00457 Double_t StripListKG::GetStripRawE(UInt_t index) const{
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 return allstps[index].rawE;
00474 }
00475
00476
00477
00478 Double_t StripListKG::GetStripRawW(UInt_t index) const{
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 return allstps[index].rawW;
00495 }
00496
00497
00498
00499 Double_t StripListKG::GetStripPeE(UInt_t index) const{
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 return allstps[index].peE;
00516 }
00517
00518
00519
00520 Double_t StripListKG::GetStripPeW(UInt_t index) const{
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536 return allstps[index].peW;
00537 }
00538
00539
00540
00541 Int_t StripListKG::GetStripXTalk(UInt_t index) const{
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 return allstps[index].xtalk;
00558 }
00559
00560
00561
00562 void StripListKG::GetTimePos(UInt_t index, AlgConfig &ac, Bool_t oneStp, Float_t &dt, Float_t &timpos, Float_t &halflength){
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581 allstps[index].TimePos(ac, oneStp, dt, timpos, halflength);
00582 }
00583
00584
00585
00586 Bool_t StripListKG::FirstInPlane(UInt_t index){
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601 if(index==0){
00602 return true;
00603 }
00604 else{
00605 if(allstps[index-1].plane != allstps[index].plane){
00606 return true;
00607 }
00608 else{
00609 return false;
00610 }
00611 }
00612 }
00613
00614
00615
00616 Bool_t StripListKG::LastInPlane(UInt_t index){
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631 if(index == allstps.size()-1){
00632 return true;
00633 }
00634 else{
00635 if(allstps[index].plane != allstps[index+1].plane){
00636 return true;
00637 }
00638 else{
00639 return false;
00640 }
00641 }
00642 }
00643
00644
00645
00646 void StripListKG::SetStripAmbiguity(UInt_t index){
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662 allstps[index].ambig=allstps[index].ambig+1;
00663
00664 }
00665
00666
00667
00668 Int_t StripListKG::GetStripAmbiguity(UInt_t index) const{
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684 return allstps[index].ambig;
00685
00686 }