Changeset 5379 for trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandsCalc.cc
- Timestamp:
- 11/11/04 09:55:25 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandsCalc.cc
r5170 r5379 180 180 fIsl->SetIslNum(numisl); 181 181 182 //cout << "code numisl " << numisl << endl; 182 183 //examine each island... 183 184 … … 196 197 Float_t distS[numisl]; 197 198 198 Float_t size[numisl], sizeLargeIsl, length, width ;199 Float_t size[numisl], sizeLargeIsl, length, width, distance, alpha, alphaW, sizetot; 199 200 200 201 Float_t X = 0; 201 202 Float_t Y = 0; 202 203 sizeLargeIsl = 0; 204 alphaW = 0; 205 sizetot = 0; 203 206 204 207 for(Int_t i = 1; i<=numisl ; i++) … … 292 295 imgIsl->SetMeanY(meanY[i-1]); 293 296 imgIsl->SetDist(dist[i-1]); 297 imgIsl->SetSizeIsl(size[i-1]); 294 298 295 299 fIsl->GetList()->Add(imgIsl); … … 333 337 MImgIsland *imgIsl = new MImgIsland; 334 338 TIter Next(fIsl->GetList()); 335 339 //Next.Reset(); 340 336 341 Int_t i = 1; 337 342 while ((imgIsl=(MImgIsland*)Next())) { … … 344 349 345 350 const Double_t s2 = tand2+1; 346 351 const Double_t s = TMath::Sqrt(s2); 352 353 const Double_t CosDelta = 1.0/s; // need these in derived classes 354 const Double_t SinDelta = tand/s; // like MHillasExt 355 347 356 const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/size[i-1]; 348 357 const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/size[i-1]; … … 359 368 width = axis2<0 ? 0 : TMath::Sqrt(axis2); // [mm] 360 369 361 370 371 // alpha calculation 372 373 const Double_t mx = imgIsl->GetMeanX(); // [mm] 374 const Double_t my = imgIsl->GetMeanY(); // [mm] 375 376 //FIXME: xpos, ypos from MSrcPos 377 const Double_t xpos = 0.; 378 const Double_t ypos = 0.; 379 380 const Double_t sx = mx - xpos; // [mm] 381 const Double_t sy = my - ypos; // [mm] 382 383 const Double_t sd = SinDelta; // [1] 384 const Double_t cd = CosDelta; // [1] 385 386 // 387 // Distance from source position to center of ellipse. 388 // If the distance is 0 distance, Alpha is not specified. 389 // The calculation has failed and returnes kFALSE. 390 // 391 distance = TMath::Sqrt(sx*sx + sy*sy); // [mm] 392 if (distance==0) 393 return 1; 394 395 // 396 // Calculate Alpha and Cosda = cos(d,a) 397 // The sign of Cosda will be used for quantities containing 398 // a head-tail information 399 // 400 // *OLD* const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1)); 401 // *OLD* fAlpha = asin(arg)*kRad2Deg; 402 // 403 const Double_t arg2 = cd*sx + sd*sy; // [mm] 404 if (arg2==0) 405 return 2; 406 407 const Double_t arg1 = cd*sy - sd*sx; // [mm] 408 409 // 410 // Due to numerical uncertanties in the calculation of the 411 // square root (dist) and arg1 it can happen (in less than 1e-5 cases) 412 // that the absolute value of arg exceeds 1. Because this uncertainty 413 // results in an Delta Alpha which is still less than 1e-3 we don't care 414 // about this uncertainty in general and simply set values which exceed 415 // to 1 saving its sign. 416 // 417 const Double_t arg = arg1/distance; 418 alpha = TMath::Abs(arg)>1 ? TMath::Sign(90., arg) : TMath::ASin(arg)*TMath::RadToDeg(); // [deg] 419 420 alphaW += alpha*size[i-1]; 421 sizetot += size[i-1]; 422 423 //////////////////////////////////////// 424 362 425 distL[i-1]=dist[i-1]/length; 363 426 distW[i-1]=dist[i-1]/width; 364 427 distS[i-1]= dist[i-1]/size[i-1]; 428 365 429 imgIsl->SetLength(length); 366 430 imgIsl->SetWidth(width); 431 367 432 imgIsl->SetDistL(distL[i-1]); 368 433 imgIsl->SetDistW(distW[i-1]); 369 434 imgIsl->SetDistS(distS[i-1]); 435 436 imgIsl->SetAlpha(alpha); 370 437 i++; 371 438 } 372 439 440 441 fIsl->SetAlphaW(alphaW/sizetot); 373 442 //fIsl->SetReadyToSave(); 374 443 … … 394 463 395 464 Int_t sflag; 396 Int_t control ;465 Int_t control = 0; 397 466 398 467 Int_t nvect = 0; … … 455 524 numisl = nvect; 456 525 457 526 458 527 // Repeated Chain Corrections 459 528 460 529 Int_t jmin = 0; 461 530 462 for(Int_t i = 1; i <= nvect; i++) 463 { 464 for(Int_t j = i+1; j <= nvect; j++) 465 { 466 control = 0; 467 for(Int_t k = 0; k < npix; k++) 468 { 469 if (vect[i][k] == 1 && vect[j][k] == 1) 470 { 471 control = 1; 472 break; 473 } 474 else if(vect[i][k] == 1 && vect[j][k] == 0){ 475 476 for(Int_t jj=1 ;jj<i ; jj++){ 477 478 if(vect[jj][k]==1){ 479 jmin = jj; 480 control = 2; 481 break; 482 } 483 } 484 } 485 } 486 487 488 if (control == 1) 489 { 490 for(Int_t k = 0; k < npix; k++) 491 { 492 if(vect[j][k] == 1) 493 vect[i][k] = 1; 494 vect[j][k] = 0; 495 zeros[j] = 1; 496 } 497 numisl = numisl-1; 498 } 499 500 if (control == 2) 501 { 502 for (Int_t k = 0; k < npix; k++) 503 { 504 if(vect[i][k]==1) 505 vect[jmin][k]=1; 506 vect[i][k] = 0; 507 zeros[i] = 1; 508 } 509 numisl = numisl-1; 510 } 511 } 512 } 531 for(Int_t i = 1; i <= nvect; i++){ 532 control=0; 533 for(Int_t j = i+1; j <= nvect; j++){ 534 control = 0; 535 for(Int_t k = 0; k < npix; k++){ 536 if (vect[i][k] == 1 && vect[j][k] == 1){ 537 control = 1; 538 k=npix; 539 } 540 } 541 if (control == 1){ 542 for(Int_t k = 0; k < npix; k++){ 543 if(vect[j][k] == 1) vect[i][k] = 1; 544 vect[j][k] = 0; 545 zeros[j] = 1; 546 } 547 numisl = numisl-1; 548 } 549 } 550 551 for(Int_t j = 1; j <= i-1; j++){ 552 for(Int_t k = 0; k < npix; k++){ 553 if (vect[i][k] == 1 && vect[j][k] == 1){ 554 control = 2; 555 jmin=j; 556 k=npix; 557 j=i; 558 } 559 } 560 561 if (control == 2){ 562 for (Int_t k = 0; k < npix; k++){ 563 if(vect[i][k]==1) vect[jmin][k]=1; 564 vect[i][k] = 0; 565 zeros[i] = 1; 566 } 567 numisl = numisl-1; 568 } 569 } 570 } 513 571 514 572 Int_t pixMAX = 0; … … 540 598 } 541 599 } 542 600 601 543 602 //the larger island will correspond to the 1st component of the vector 544 603 … … 657 716 // Repeated Chain Corrections 658 717 659 Int_t jmin = 0; 660 661 for(Int_t i = 1; i <= nvect; i++) 662 { 663 for(Int_t j = i+1; j <= nvect; j++) 664 { 665 control = 0; 666 for(Int_t k = 0; k < npix; k++) 667 { 668 669 if (vect[i][k] == 1 && vect[j][k] == 1) 670 { 671 control = 1; 672 break; 673 } 674 else if(vect[i][k] == 1 && vect[j][k] == 0){ 675 676 for(Int_t jj=1 ;jj<i ; jj++){ 677 678 if(vect[jj][k]==1){ 679 jmin = jj; 680 control = 2; 681 break; 682 } 683 } 684 } 685 } 686 687 688 if (control == 1) 689 { 690 for(Int_t k = 0; k < npix; k++) 691 { 692 if(vect[j][k] == 1) 693 vect[i][k] = 1; 694 vect[j][k] = 0; 695 zeros[j] = 1; 696 } 697 numisl = numisl-1; 698 } 699 700 if (control == 2) 701 { 702 for (Int_t k = 0; k < npix; k++) 703 { 704 if(vect[i][k]==1) 705 vect[jmin][k]=1; 706 vect[i][k] = 0; 707 zeros[i] = 1; 708 } 709 numisl = numisl-1; 710 } 711 712 } 713 } 714 718 Int_t ii, jj; 719 720 for(Int_t i = 1; i <= nvect; i++) { 721 for(Int_t j = 1; j <= nvect; j++) { 722 if (i!=j && zeros[j]!=1){ 723 control = 0; 724 for(Int_t k = 0; k < npix; k++) { 725 if (vect[i][k] == 1 && vect[j][k] == 1) { 726 control = 1; 727 break; 728 } 729 } 730 if(i<j) { 731 ii=i; 732 jj=j; 733 } 734 else{ 735 ii=j; 736 jj=i; 737 } 738 if (control == 1) { 739 for(Int_t k = 0; k < npix; k++) { 740 if(vect[jj][k] == 1) vect[ii][k] = 1; 741 vect[jj][k] = 0; 742 zeros[jj] = 1; 743 } 744 numisl = numisl-1; 745 } 746 } 747 } 748 } 715 749 716 750 Int_t l = 1;
Note:
See TracChangeset
for help on using the changeset viewer.