| 25 |
Float_t rig[18]; |
Float_t rig[18]; |
| 26 |
Float_t rmean[17]; |
Float_t rmean[17]; |
| 27 |
Int_t ntot[17]; |
Int_t ntot[17]; |
| 28 |
|
Int_t MDIM = 8213; |
| 29 |
|
//Int_t MDIM = 4128; |
| 30 |
//Float_t qqplane[17][43]; |
//Float_t qqplane[17][43]; |
| 31 |
//Int_t nnqplane[17][43]; |
//Int_t nnqplane[17][43]; |
| 32 |
|
|
| 35 |
TMatrixD *matrix[17]; |
TMatrixD *matrix[17]; |
| 36 |
TMatrixD *nmat[17]; |
TMatrixD *nmat[17]; |
| 37 |
|
|
| 38 |
|
//TMatrixD *fqplane; |
| 39 |
|
//TMatrixD *fnqplane; |
| 40 |
TMatrixD *fqplane[17]; |
TMatrixD *fqplane[17]; |
| 41 |
TMatrixD *fnqplane[17]; |
TMatrixD *fnqplane[17]; |
| 42 |
TMatrixF *fmatrix[17]; |
TMatrixD *fmatrix[17]; |
| 43 |
|
//TMatrixF *fnmat[17]; |
| 44 |
|
//TMatrixD *fmatrix; |
| 45 |
|
//TMatrixD *fnmat; |
| 46 |
|
//TMatrixF *fmatrix; |
| 47 |
|
//TMatrixF *fnmat; |
| 48 |
TMatrixF *fnmat[17]; |
TMatrixF *fnmat[17]; |
| 49 |
|
//Int_t finmat[43][191]; |
| 50 |
|
|
| 51 |
//=============================================================================== |
//=============================================================================== |
| 52 |
bool Select( PamLevel2* event ){ |
bool Select( PamLevel2* event ){ |
| 250 |
if ( view == 1 && (plane >0 || strip > ti0) ) break; |
if ( view == 1 && (plane >0 || strip > ti0) ) break; |
| 251 |
}; |
}; |
| 252 |
// if ( event->GetCaloLevel1()->qtotpl(0) > 7. ) return false; |
// if ( event->GetCaloLevel1()->qtotpl(0) > 7. ) return false; |
| 253 |
|
|
| 254 |
|
// if ( rigidity > 2.2 || rigidity < 1.5 ) return false; |
| 255 |
|
// printf(" rig %f CRIG %i SRIG %i \n",rigidity,CRIG,SRIG); |
| 256 |
// |
// |
| 257 |
return true; |
return true; |
| 258 |
} |
} |
| 303 |
// |
// |
| 304 |
memset(rmean, 0, 17*sizeof(Float_t)); |
memset(rmean, 0, 17*sizeof(Float_t)); |
| 305 |
memset(ntot, 0, 17*sizeof(Int_t)); |
memset(ntot, 0, 17*sizeof(Int_t)); |
| 306 |
|
// memset(finmat, 0, 43*191*sizeof(Int_t)); |
| 307 |
|
// Double_t tol = 1E-20; |
| 308 |
// |
// |
| 309 |
for (Int_t i=0; i < 17 ; i++){ |
for (Int_t i=0; i < 17 ; i++){ |
| 310 |
|
// for (Int_t i=3; i < 4 ; i++){ |
| 311 |
if ( !FULL ){ |
if ( !FULL ){ |
| 312 |
matrix[i] = new TMatrixD(43,43); |
matrix[i] = new TMatrixD(43,43); |
| 313 |
qplane[i] = new TArrayF(43); |
qplane[i] = new TArrayF(43); |
| 315 |
nmat[i] = new TMatrixD(43,43); |
nmat[i] = new TMatrixD(43,43); |
| 316 |
} else { |
} else { |
| 317 |
if ( MATRIX ){ |
if ( MATRIX ){ |
| 318 |
fmatrix[i] = new TMatrixF(4128,4128); |
// fmatrix = new TMatrixF(4128,4128); |
| 319 |
fnmat[i] = new TMatrixF(4128,4128); |
// fnmat = new TMatrixF(4128,4128); |
| 320 |
|
// fmatrix = new TMatrixF(8213,8213); |
| 321 |
|
// fnmat = new TMatrixF(8213,8213); |
| 322 |
|
// fmatrix = new TMatrixF(MDIM,MDIM); |
| 323 |
|
// fnmat = new TMatrixF(MDIM,MDIM); |
| 324 |
|
// fmatrix[i] = new TMatrixF(1849,1849); |
| 325 |
|
// fnmat[i] = new TMatrixF(43,43); |
| 326 |
|
fmatrix[i] = new TMatrixD(1333,1333); |
| 327 |
|
// fmatrix[i]->SetTol(tol); |
| 328 |
|
fnmat[i] = new TMatrixF(43,31); |
| 329 |
|
// cf->WriteFullMatrix(fmatrix, i); |
| 330 |
|
// cf->WriteFullNMatrix(fnmat, i); |
| 331 |
|
// delete fmatrix; |
| 332 |
|
// delete fnmat; |
| 333 |
//fnmat[i] = new TMatrixI(8213,8213); |
//fnmat[i] = new TMatrixI(8213,8213); |
| 334 |
} else { |
} else { |
| 335 |
fqplane[i] = new TMatrixD(43,191); // 43 planes x 191 strip (= 1 + 95 x 2, one strip is the one transversed by the track that could be on the extreme right or left) |
// fqplane = new TMatrixD(43,191); // 43 planes x 191 strip (= 1 + 95 x 2, one strip is the one transversed by the track that could be on the extreme right or left) |
| 336 |
fnqplane[i] = new TMatrixD(43,191);// |
// fnqplane = new TMatrixD(43,191);// |
| 337 |
|
// fqplane[i] = new TMatrixD(43,43); // 43 planes x 43 "strip", where 43 = 50 + 14 + 5 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + [1] + ... |
| 338 |
|
// fnqplane[i] = new TMatrixD(43,43);// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
| 339 |
|
// |
| 340 |
|
fqplane[i] = new TMatrixD(43,31); // 43 planes x 43 "strip", where 43 = 50 + 14 + 6 + 5 + 3 + 3 + 3 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + [1] + 1 + 1 + 1 + 1 + ... |
| 341 |
|
fnqplane[i] = new TMatrixD(43,31);// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... |
| 342 |
|
// |
| 343 |
|
// cf->WriteFullMean(fqplane, i); |
| 344 |
|
// cf->WriteFullNMean(fnqplane, i); |
| 345 |
|
// delete fqplane; |
| 346 |
|
// delete fnqplane; |
| 347 |
|
// |
| 348 |
}; |
}; |
| 349 |
}; |
}; |
| 350 |
}; |
}; |
| 404 |
// |
// |
| 405 |
// FULL CALORIMETER |
// FULL CALORIMETER |
| 406 |
// |
// |
| 407 |
|
// fqplane = cf->LoadFullAverage(rbi); |
| 408 |
|
// fnqplane = cf->LoadFullNAverage(rbi); |
| 409 |
CaloTrkVar *ct = L2->GetTrack(0)->GetCaloTrack(); |
CaloTrkVar *ct = L2->GetTrack(0)->GetCaloTrack(); |
| 410 |
// |
// |
| 411 |
Int_t nplane = 0; |
Int_t nplane = 0; |
| 419 |
Int_t mstrip = 0; |
Int_t mstrip = 0; |
| 420 |
// |
// |
| 421 |
for (Int_t j=0; j<2; j++){ |
for (Int_t j=0; j<2; j++){ |
| 422 |
for (Int_t i=0; i<21; i++){ |
for (Int_t i=0; i<22; i++){ |
| 423 |
nplane = 1 - j + 2*i; |
nplane = 1 - j + 2*i; |
| 424 |
if ( nplane > 37 ) nplane--; |
if ( nplane > 37 ) nplane--; |
| 425 |
// |
// |
| 427 |
// |
// |
| 428 |
cd = 95 - cs; |
cd = 95 - cs; |
| 429 |
// |
// |
| 430 |
|
Int_t oldstr = -1; |
| 431 |
for (Int_t k=0; k<191; k++){ |
for (Int_t k=0; k<191; k++){ |
| 432 |
mstrip = cd + k; |
mstrip = cd + k; |
| 433 |
if ( mstrip < (191-cs) ) (*fnqplane[rbi])[nplane][mstrip] += 1.; |
// if ( mstrip < (191-cs) ) (*fnqplane[rbi])[nplane][mstrip] += 1.; |
| 434 |
|
// if ( mstrip < (191-cs) ) (*fnqplane)[nplane][mstrip] += 1.; |
| 435 |
|
Int_t lstr = cf->ConvertStrip(mstrip); |
| 436 |
|
if ( oldstr != lstr ){ |
| 437 |
|
(*fnqplane[rbi])[nplane][lstr] += 1.; |
| 438 |
|
oldstr = lstr; |
| 439 |
|
}; |
| 440 |
}; |
}; |
| 441 |
}; |
}; |
| 442 |
}; |
}; |
| 455 |
// |
// |
| 456 |
mstrip = cd + strip; |
mstrip = cd + strip; |
| 457 |
// |
// |
| 458 |
(*fqplane[rbi])[nplane][mstrip] += mip; |
Int_t lstr = cf->ConvertStrip(mstrip); |
| 459 |
|
// (*fqplane[rbi])[nplane][mstrip] += mip; |
| 460 |
|
// (*fqplane)[nplane][mstrip] += mip; |
| 461 |
|
(*fqplane[rbi])[nplane][lstr] += mip; |
| 462 |
// |
// |
| 463 |
}; |
}; |
| 464 |
|
// |
| 465 |
|
// cf->WriteFullMean(fqplane, rbi); |
| 466 |
|
// cf->WriteFullNMean(fnqplane, rbi); |
| 467 |
|
// cf->UnLoadFullAverage(rbi); |
| 468 |
|
// cf->UnLoadFullNAverage(rbi); |
| 469 |
|
// delete fqplane; |
| 470 |
|
// delete fnqplane; |
| 471 |
// |
// |
| 472 |
}; |
}; |
| 473 |
} |
} |
| 492 |
// |
// |
| 493 |
}; |
}; |
| 494 |
} else { |
} else { |
| 495 |
|
// |
| 496 |
for (Int_t i=0; i<nbin-1; i++){ |
for (Int_t i=0; i<nbin-1; i++){ |
| 497 |
|
// fqplane = cf->LoadFullAverage(i); |
| 498 |
|
// fnqplane = cf->LoadFullNAverage(i); |
| 499 |
if ( ntot[i] > 0 ) rmean[i] /= (Float_t)(ntot[i]); |
if ( ntot[i] > 0 ) rmean[i] /= (Float_t)(ntot[i]); |
| 500 |
// |
// |
| 501 |
for (Int_t j=0; j<43 ; j++){ |
for (Int_t j=0; j<43 ; j++){ |
| 502 |
for (Int_t k=0; k<191; k++){ |
// for (Int_t k=0; k<191; k++){ |
| 503 |
|
// for (Int_t k=0; k<43; k++){ |
| 504 |
|
for (Int_t k=0; k<31; k++){ |
| 505 |
|
// if ( (*fnqplane[i])[j][k] > 0 ){ |
| 506 |
|
// (*fqplane[i])[j][k] /= (Float_t)(*fnqplane[i])[j][k]; |
| 507 |
|
// } else { |
| 508 |
|
// (*fqplane[i])[j][k] = 0.; |
| 509 |
|
// }; |
| 510 |
|
// printf(" BIN %i plane %i strip %i average energy %f qplane %f nqplane %f \n",i,j,k,rmean[i],(*fqplane[i])[j][k],(*fnqplane[i])[j][k]); |
| 511 |
if ( (*fnqplane[i])[j][k] > 0 ){ |
if ( (*fnqplane[i])[j][k] > 0 ){ |
| 512 |
|
if ( (*fqplane[i])[j][k] == 0. ) (*fqplane[i])[j][k] = 0.7; |
| 513 |
(*fqplane[i])[j][k] /= (Float_t)(*fnqplane[i])[j][k]; |
(*fqplane[i])[j][k] /= (Float_t)(*fnqplane[i])[j][k]; |
| 514 |
} else { |
} else { |
| 515 |
(*fqplane[i])[j][k] = 0.; |
(*fqplane[i])[j][k] = 0.; |
| 516 |
}; |
}; |
| 517 |
printf(" BIN %i plane %i strip %i average energy %f qplane %f nqplane %f \n",i,j,k,rmean[i],(*fqplane[i])[j][k],(*fnqplane[i])[j][k]); |
// printf(" BIN %i plane %i strip %i average energy %f qplane %f nqplane %f \n",i,j,k,rmean[i],(*fqplane)[j][k],(*fnqplane)[j][k]); |
| 518 |
}; |
}; |
| 519 |
}; |
}; |
|
}; |
|
|
for (Int_t i=0; i<nbin-1; i++){ |
|
|
// |
|
| 520 |
cf->WriteFullMean(fqplane[i], i); |
cf->WriteFullMean(fqplane[i], i); |
| 521 |
// |
cf->WriteFullNMean(fnqplane[i], i); |
| 522 |
|
// cf->UnLoadFullAverage(i); |
| 523 |
|
// cf->UnLoadFullNAverage(i); |
| 524 |
|
// delete fqplane; |
| 525 |
|
// delete fnqplane; |
| 526 |
}; |
}; |
| 527 |
|
// |
| 528 |
|
// for (Int_t i=0; i<nbin-1; i++){ |
| 529 |
|
// // |
| 530 |
|
// cf->WriteFullMean(fqplane[i], i); |
| 531 |
|
// // |
| 532 |
|
// }; |
| 533 |
}; |
}; |
| 534 |
// |
// |
| 535 |
cf->WriteNumBin(nbin); |
cf->WriteNumBin(nbin); |
| 602 |
// |
// |
| 603 |
// FULL CALORIMETER |
// FULL CALORIMETER |
| 604 |
// |
// |
| 605 |
|
// if ( rbi != 3 ) return; |
| 606 |
|
printf(" matrix %i IEV %i \n",rbi,iev); |
| 607 |
|
// fmatrix = cf->LoadFullMatrix(rbi); |
| 608 |
|
// cf->LoadFullMatrix(rbi,fmatrix); |
| 609 |
|
// fnmat = cf->LoadFullNMatrix(rbi); |
| 610 |
|
// printf(" done \n"); |
| 611 |
|
// printf(" start loop \n"); |
| 612 |
|
// |
| 613 |
CaloTrkVar *ct = L2->GetTrack(0)->GetCaloTrack(); |
CaloTrkVar *ct = L2->GetTrack(0)->GetCaloTrack(); |
| 614 |
// |
// |
| 615 |
Int_t nplane = 0; |
Int_t nplane = 0; |
| 618 |
Int_t strip = 0; |
Int_t strip = 0; |
| 619 |
Float_t mip = 0.; |
Float_t mip = 0.; |
| 620 |
// |
// |
| 621 |
Int_t mindgf = 48; |
// Int_t mindgf = 48; |
| 622 |
Int_t dgf = 143; |
// Int_t dgf = 143; |
| 623 |
|
// Int_t mindgf = 0; //tutto |
| 624 |
|
// Int_t dgf = 191; //tutto |
| 625 |
|
// Int_t mindgf = 94; |
| 626 |
|
// Int_t dgf = 96; |
| 627 |
|
// Int_t mindgf = 84; |
| 628 |
|
// Int_t dgf = 106; |
| 629 |
|
Int_t mindgf = 0; |
| 630 |
|
Int_t dgf = 43; |
| 631 |
Int_t cs = 0; |
Int_t cs = 0; |
| 632 |
Int_t cd = 0; |
Int_t cd = 0; |
| 633 |
Int_t mstrip = 0; |
Int_t mstrip = 0; |
| 634 |
// |
// |
| 635 |
Float_t mipv[43][191]; |
// Float_t mipv[43][43]; |
| 636 |
memset(mipv,0,43*191*sizeof(Float_t)); |
// memset(mipv,0,43*43*sizeof(Float_t)); |
| 637 |
|
Float_t mipv[43][31]; |
| 638 |
|
memset(mipv,0,43*31*sizeof(Float_t)); |
| 639 |
// |
// |
| 640 |
for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){ |
for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){ |
| 641 |
// |
// |
| 650 |
// |
// |
| 651 |
mstrip = cd + strip; |
mstrip = cd + strip; |
| 652 |
// |
// |
| 653 |
mipv[nplane][mstrip] = mip; |
Int_t lstr = cf->ConvertStrip(mstrip); |
| 654 |
|
mipv[nplane][lstr] += mip; |
| 655 |
// |
// |
| 656 |
}; |
}; |
| 657 |
// |
// |
| 658 |
Float_t mip1; |
Float_t mip1 = 1.; |
| 659 |
Int_t cs1; |
Int_t cs1; |
| 660 |
Int_t cd1; |
Int_t cd1; |
| 661 |
Float_t mip2; |
Float_t mip2 = 1.; |
| 662 |
Int_t cs2; |
Int_t cs2; |
| 663 |
Int_t cd2; |
Int_t cd2; |
| 664 |
Int_t mi = -1; |
Int_t mi = -1; |
| 674 |
Int_t mstrip2min = 0; |
Int_t mstrip2min = 0; |
| 675 |
Int_t mstrip2max = 0; |
Int_t mstrip2max = 0; |
| 676 |
// |
// |
| 677 |
|
Int_t toto = 0; |
| 678 |
|
// |
| 679 |
for (Int_t nplane1=0; nplane1<43; nplane1++){ |
for (Int_t nplane1=0; nplane1<43; nplane1++){ |
| 680 |
for (Int_t mstrip1=0; mstrip1<191; mstrip1++){ |
if ( nplane1 >= 37 ) nn1 = nplane1 + 1; |
| 681 |
|
vi1 = 1; |
| 682 |
|
if ( nn1%2 ) vi1 = 0; |
| 683 |
|
pl1 = (nn1 - 1 + vi1)/2; |
| 684 |
|
// |
| 685 |
|
cs1 = ct->tibar[pl1][vi1] - 1; // convertire nplane in pl1 e vi1 |
| 686 |
|
// |
| 687 |
|
cd1 = 95 - cs1; |
| 688 |
|
// |
| 689 |
|
Int_t at1 = TMath::Max(0,(cd1+0)); |
| 690 |
|
Int_t at2 = TMath::Min(190,(cd1+95)); |
| 691 |
|
mstrip1min = cf->ConvertStrip(at1); |
| 692 |
|
mstrip1max = cf->ConvertStrip(at2) + 1; |
| 693 |
|
// mstrip1min = cf->ConvertStrip(TMath::Max(mindgf,(cd1+0))); |
| 694 |
|
// mstrip1max = cf->ConvertStrip(TMath::Min(dgf,(cd1+95))) + 1; |
| 695 |
|
// |
| 696 |
|
if ( nplane1 == 0 || nplane1 == 42 ) printf(" pl %i mstrip1min %i mstrip1max %i mindgf %i dgf %i cd1 %i\n",nplane1,mstrip1min,mstrip1max,mindgf,dgf,cd1); |
| 697 |
|
// |
| 698 |
|
for (Int_t mstrip1=mstrip1min; mstrip1<mstrip1max; mstrip1++){ |
| 699 |
|
// printf(".\n"); |
| 700 |
|
// |
| 701 |
mj = -1; |
mj = -1; |
| 702 |
// |
// |
| 703 |
if ( nplane1 >= 37 ) nn1 = nplane1 + 1; |
mip1 = mipv[nplane1][mstrip1] - cf->GetFullAverageAt(nplane1,mstrip1,erig,rbi); |
| 704 |
vi1 = 1; |
// |
| 705 |
if ( nn1%2 ) vi1 = 0; |
// mi = (nplane1 * 191) + mstrip1; |
| 706 |
pl1 = (nn1 - 1 + vi1)/2; |
// mi = (nplane1 * 43) + mstrip1; |
| 707 |
// |
mi = (nplane1 * 31) + mstrip1; |
| 708 |
cs1 = ct->tibar[pl1][vi1] - 1; // convertire nplane in pl1 e vi1 |
// |
| 709 |
// |
// if ( mstrip1 > mstrip1min ) break; |
| 710 |
cd1 = 95 - cs1; |
// if ( mstrip1 > dgf ) break; |
| 711 |
// |
// if ( mstrip1 >= mindgf && mstrip1 <= dgf && mstrip1 >= mstrip1min && mstrip1 <= mstrip1max ){ |
| 712 |
mstrip1min = cd1 + 0; |
// |
| 713 |
mstrip1max = cd1 + 95; |
// finmat[nplane1][mstrip1]++; |
| 714 |
mip1 = mipv[nplane1][mstrip1]; |
(*fnmat[rbi])[nplane1][mstrip1] += 1.; |
| 715 |
// |
// |
| 716 |
if ( mstrip1 >= mindgf && mstrip1 <= dgf ){ |
if ( mip1 != 0. ){ |
| 717 |
mi++; |
// |
|
// |
|
| 718 |
for (Int_t nplane2=0; nplane2<43; nplane2++){ |
for (Int_t nplane2=0; nplane2<43; nplane2++){ |
| 719 |
for (Int_t mstrip2=0; mstrip2<191; mstrip2++){ |
// |
| 720 |
// |
if ( nplane2 >= 37 ) nn2 = nplane2 + 1; |
| 721 |
if ( nplane2 >= 37 ) nn2 = nplane2 + 1; |
vi2 = 1; |
| 722 |
vi2 = 1; |
if ( nn2%2 ) vi2 = 0; |
| 723 |
if ( nn2%2 ) vi2 = 0; |
pl1 = (nn2 - 1 + vi2)/2; |
| 724 |
pl1 = (nn2 - 1 + vi2)/2; |
// |
| 725 |
// |
cs2 = ct->tibar[pl2][vi2] - 1; |
| 726 |
cs2 = ct->tibar[pl2][vi2] - 1; |
// |
| 727 |
// |
cd2 = 95 - cs2; |
| 728 |
cd2 = 95 - cs2; |
// |
| 729 |
|
// mstrip2min = cd2 + 0; |
| 730 |
|
// mstrip2max = cd2 + 95; |
| 731 |
|
Int_t t1 = TMath::Max(0,(cd2+0)); |
| 732 |
|
Int_t t2 = TMath::Min(190,(cd2+95)); |
| 733 |
|
mstrip2min = cf->ConvertStrip(t1); |
| 734 |
|
mstrip2max = cf->ConvertStrip(t2) + 1; |
| 735 |
|
// |
| 736 |
|
if ( nplane1 == 0 && nplane2 == 0 && mstrip1==mstrip1min ) printf(" mstrip2min %i mstrip2max %i \n",mstrip2min,mstrip2max); |
| 737 |
|
// |
| 738 |
|
for (Int_t mstrip2=mstrip2min; mstrip2<mstrip2max; mstrip2++){ |
| 739 |
|
// |
| 740 |
|
mip2 = mipv[nplane2][mstrip2] - cf->GetFullAverageAt(nplane2,mstrip2,erig,rbi); |
| 741 |
// |
// |
| 742 |
mstrip2min = cd2 + 0; |
if ( mip2 != 0. ){ |
| 743 |
mstrip2max = cd2 + 95; |
// |
| 744 |
// |
// mj = (nplane2 * 191) + mstrip2; |
| 745 |
mip2 = mipv[nplane2][mstrip2]; |
// mj = (nplane2 * 43) + mstrip2; |
| 746 |
// |
// mj = (nplane2 * 31) + mstrip2; |
| 747 |
if ( mstrip2 >= mindgf && mstrip2 <= dgf ){ |
Int_t sh = -15 + nplane1; |
| 748 |
mj++; |
if ( sh > 15 ) sh -= 31*nplane1; |
| 749 |
(*fmatrix[rbi])[mi][mj] += (mipv[nplane1][mstrip1] - cf->GetFullAverageAt(nplane1,mstrip1,erig)) * (mipv[nplane2][mstrip2] - cf->GetFullAverageAt(nplane2,mstrip2,erig)); |
// |
| 750 |
if ( mstrip1 >= mstrip1min && mstrip1 <= mstrip1max && mstrip2 >= mstrip2min && mstrip2 <= mstrip2max){ |
mj = (nplane2 * 31) + mstrip2 + sh; |
| 751 |
(*fnmat[rbi])[mi][mj] += 1.; |
// |
| 752 |
}; |
if ( mj < 0 ) mj += 1333; |
| 753 |
|
if ( mj >= 1333 ) mj -= 1333; |
| 754 |
|
// printf(" mi %i mj %i sh %i \n",mi,mj,sh); |
| 755 |
|
// |
| 756 |
|
// mj++; |
| 757 |
|
// |
| 758 |
|
// if ( mstrip2 > mstrip2min ) break; |
| 759 |
|
// if ( mstrip2 > dgf ) break; |
| 760 |
|
// if ( mstrip2 >= mindgf && mstrip2 <= dgf && mstrip2 >= mstrip2min && mstrip2 <= mstrip2max ){ |
| 761 |
|
// if ( mstrip1 >= mstrip1min && mstrip1 <= mstrip1max && mstrip2 >= mstrip2min && mstrip2 <= mstrip2max){ |
| 762 |
|
// (*fmatrix[rbi])[mi][mj] += (mipv[nplane1][mstrip1] - cf->GetFullAverageAt(nplane1,mstrip1,erig)) * (mipv[nplane2][mstrip2] - cf->GetFullAverageAt(nplane2,mstrip2,erig)); |
| 763 |
|
// (*fnmat[rbi])[mi][mj] += 1.; |
| 764 |
|
(*fmatrix[rbi])[mi][mj] += (mip1 * mip2); // giusto |
| 765 |
|
// (*fmatrix)[mi][mj] += (mip1 * mip2) * 1000000.; |
| 766 |
|
toto++; |
| 767 |
|
// (*fmatrix)[mi][mj] += 1.; |
| 768 |
|
// cf->GetFullAverageAt(nplane1,mstrip1,erig,rbi); |
| 769 |
|
// cf->GetFullAverageAt(nplane2,mstrip2,erig,rbi); |
| 770 |
|
// (*fnmat)[mi][mj] += 1.; |
| 771 |
|
// }; |
| 772 |
}; |
}; |
| 773 |
}; |
}; |
| 774 |
}; |
}; |
| 776 |
}; |
}; |
| 777 |
}; |
}; |
| 778 |
// |
// |
| 779 |
|
printf(" toto = %i \n",toto); |
| 780 |
|
printf("\n done \n"); |
| 781 |
|
// printf(" write matrix \n"); |
| 782 |
|
// cf->WriteFullMatrix(fmatrix, rbi); |
| 783 |
|
// cf->WriteFullNMatrix(fnmat, rbi); |
| 784 |
|
// printf(" done \n"); |
| 785 |
|
// printf(" unload matrix \n"); |
| 786 |
|
// cf->UnLoadFullMatrix(rbi); |
| 787 |
|
// cf->UnLoadFullNMatrix(rbi); |
| 788 |
|
// printf(" done \n"); |
| 789 |
|
// printf(" delete matrix \n"); |
| 790 |
|
// delete fmatrix; |
| 791 |
|
// delete fnmat; |
| 792 |
|
// printf(" done \n"); |
| 793 |
}; |
}; |
| 794 |
} |
} |
| 795 |
|
|
| 846 |
// FULL |
// FULL |
| 847 |
// |
// |
| 848 |
for (Int_t i=0; i<nbin-1; i++){ |
for (Int_t i=0; i<nbin-1; i++){ |
| 849 |
|
// for (Int_t i=3; i<5; i++){ |
| 850 |
|
// for (Int_t i=3; i<4; i++){ |
| 851 |
// |
// |
| 852 |
// determine the average matrix |
// determine the average matrix |
| 853 |
// |
// |
| 854 |
for (Int_t ii=0; ii<4171; ii++){ |
// fmatrix = cf->LoadFullMatrix(i); |
| 855 |
for (Int_t j=0; j<4171; j++){ |
// fnmat = cf->LoadFullNMatrix(i); |
| 856 |
if ( (*fnmat[i])[ii][j] > 0. ){ |
// |
| 857 |
(*fmatrix[i])[ii][j] /= (*fnmat[i])[ii][j]; |
// for (Int_t ii=0; ii<MDIM; ii++){ |
| 858 |
} else { |
// for (Int_t j=0; j<MDIM; j++){ |
| 859 |
(*fmatrix[i])[ii][j] = 0.; |
// // if ( (*fnmat[i])[ii][j] > 0. ){ |
| 860 |
|
// // (*fmatrix[i])[ii][j] /= (*fnmat[i])[ii][j]; |
| 861 |
|
// // } else { |
| 862 |
|
// // (*fmatrix[i])[ii][j] = 0.; |
| 863 |
|
// // }; |
| 864 |
|
// if ( (*fnmat)[ii][j] > 0. ){ |
| 865 |
|
// (*fmatrix)[ii][j] /= (*fnmat)[ii][j]; |
| 866 |
|
// } else { |
| 867 |
|
// (*fmatrix)[ii][j] = 0.; |
| 868 |
|
// }; |
| 869 |
|
// }; |
| 870 |
|
// }; |
| 871 |
|
// |
| 872 |
|
// TMatrixD *mymat3 = new TMatrixD(129,129); |
| 873 |
|
// TMatrixD *mymat5 = new TMatrixD(215,215); |
| 874 |
|
// TMatrixD *mymat7 = new TMatrixD(301,301); |
| 875 |
|
// TMatrixD *mymat9 = new TMatrixD(387,387); |
| 876 |
|
// TMatrixD *mymat11 = new TMatrixD(473,473); |
| 877 |
|
// TMatrixD *mymat17 = new TMatrixD(731,731); |
| 878 |
|
// TMatrixF *mymat = new TMatrixF(129,129); |
| 879 |
|
// TMatrixF *mymat = new TMatrixF(989,989); |
| 880 |
|
Int_t i1 = -1; |
| 881 |
|
Int_t j1 = -1; |
| 882 |
|
// int mi,mj; |
| 883 |
|
Int_t nonzero = 0; |
| 884 |
|
Int_t nonzero1 = 0; |
| 885 |
|
for (Int_t ii=0; ii<43; ii++){ |
| 886 |
|
// for (Int_t j=0; j<191; j++){ |
| 887 |
|
// for (Int_t j=0; j<43; j++){ |
| 888 |
|
for (Int_t j=0; j<31; j++){ |
| 889 |
|
// if ( (*fnmat[i])[ii][j] > 0. ){ |
| 890 |
|
// (*fmatrix[i])[ii][j] /= (*fnmat[i])[ii][j]; |
| 891 |
|
// } else { |
| 892 |
|
// (*fmatrix[i])[ii][j] = 0.; |
| 893 |
|
// }; |
| 894 |
|
// i1 = (ii * 191) + j; |
| 895 |
|
// i1 = (ii * 43) + j; |
| 896 |
|
i1 = (ii * 31) + j; |
| 897 |
|
// j1 = -1; |
| 898 |
|
for (Int_t iij=0; iij<43; iij++){ |
| 899 |
|
// for (Int_t jj=0; jj<191; jj++){ |
| 900 |
|
// for (Int_t jj=0; jj<43; jj++){ |
| 901 |
|
for (Int_t jj=0; jj<31; jj++){ |
| 902 |
|
// |
| 903 |
|
// j1 = (iij * 191) + jj; |
| 904 |
|
// j1 = (iij * 43) + jj; |
| 905 |
|
Int_t sh = -15 + ii; |
| 906 |
|
if ( sh > 15 ) sh -= 31*ii; |
| 907 |
|
// |
| 908 |
|
j1 = (iij * 31) + jj + sh; |
| 909 |
|
// |
| 910 |
|
if ( j1 < 0 ) j1 += 1333; |
| 911 |
|
if ( j1 >= 1333 ) j1 -= 1333; |
| 912 |
|
|
| 913 |
|
// j1 = (iij * 31) + jj; |
| 914 |
|
// j1++; |
| 915 |
|
// if ( finmat[ii][j] > 0 ){ |
| 916 |
|
// (*fmatrix)[i1][j1] /= finmat[ii][j]; |
| 917 |
|
if ( (*fnmat[i])[ii][j] == 0. || (*fmatrix[i])[i1][j1] == 0. || !((*fmatrix[i])[i1][j1] == (*fmatrix[i])[i1][j1]) ){ |
| 918 |
|
(*fmatrix[i])[i1][j1] = 1.; |
| 919 |
|
} else { |
| 920 |
|
(*fmatrix[i])[i1][j1] /= (*fnmat[i])[ii][j]; |
| 921 |
|
nonzero++; |
| 922 |
|
if ( i1 == 0 ) nonzero1++; |
| 923 |
|
}; |
| 924 |
|
// |
| 925 |
|
// if ( j>=7 && j <=23 && jj >=7 && jj<=23 ){ |
| 926 |
|
// Int_t mi17 = (ii*3) + j -7; |
| 927 |
|
// Int_t mj17 = (iij*3) + jj -7; |
| 928 |
|
// (*mymat17)[mi17][mj17] = (*fmatrix[i])[i1][j1]; |
| 929 |
|
// }; |
| 930 |
|
// if ( j>=10 && j <=20 && jj >=10 && jj<=20 ){ |
| 931 |
|
// Int_t mi11 = (ii*3) + j -10; |
| 932 |
|
// Int_t mj11 = (iij*3) + jj -10; |
| 933 |
|
// (*mymat11)[mi11][mj11] = (*fmatrix[i])[i1][j1]; |
| 934 |
|
// }; |
| 935 |
|
// if ( j>=11 && j <=19 && jj >=11 && jj<=19 ){ |
| 936 |
|
// Int_t mi9 = (ii*3) + j -11; |
| 937 |
|
// Int_t mj9 = (iij*3) + jj -11; |
| 938 |
|
// (*mymat9)[mi9][mj9] = (*fmatrix[i])[i1][j1]; |
| 939 |
|
// }; |
| 940 |
|
// if ( j>=12 && j <=18 && jj >=12 && jj<=18 ){ |
| 941 |
|
// Int_t mi7 = (ii*3) + j -12; |
| 942 |
|
// Int_t mj7 = (iij*3) + jj -12; |
| 943 |
|
// (*mymat7)[mi7][mj7] = (*fmatrix[i])[i1][j1]; |
| 944 |
|
// }; |
| 945 |
|
// if ( j>=13 && j <=17 && jj >=13 && jj<=17 ){ |
| 946 |
|
// Int_t mi5 = (ii*3) + j -13; |
| 947 |
|
// Int_t mj5 = (iij*3) + jj -13; |
| 948 |
|
// (*mymat5)[mi5][mj5] = (*fmatrix[i])[i1][j1]; |
| 949 |
|
// }; |
| 950 |
|
// if ( j>=14 && j <=16 && jj >=14 && jj<=16 ){ |
| 951 |
|
// Int_t mi3 = (ii*3) + j -14; |
| 952 |
|
// Int_t mj3 = (iij*3) + jj -14; |
| 953 |
|
// (*mymat3)[mi3][mj3] = (*fmatrix[i])[i1][j1]; |
| 954 |
|
// }; |
| 955 |
|
|
| 956 |
|
|
| 957 |
|
// if ( j>=94 && j <=96 && jj >=94 && jj<=96 ){ |
| 958 |
|
// mi = (ii*3) + j -94; |
| 959 |
|
// mj = (iij*3) + jj -94; |
| 960 |
|
// (*mymat)[mi][mj] = (*fmatrix)[i1][j1]; |
| 961 |
|
// }; |
| 962 |
|
|
| 963 |
|
|
| 964 |
|
// if ( j>=84 && j <=106 && jj >=84 && jj<=106 ){ |
| 965 |
|
// mi = (ii*3) + j -84; |
| 966 |
|
// mj = (iij*3) + jj -84; |
| 967 |
|
// (*mymat)[mi][mj] = (*fmatrix)[i1][j1]; |
| 968 |
|
// }; |
| 969 |
|
|
| 970 |
|
}; |
| 971 |
}; |
}; |
| 972 |
}; |
}; |
| 973 |
}; |
}; |
| 974 |
// |
// |
| 975 |
|
printf(" Matrix has %i non-zero elements \n",nonzero); |
| 976 |
|
// printf(" Matrix has %i non-zero elements on the first row\n",nonzero1); |
| 977 |
|
// |
| 978 |
|
// Bool_t BAD = false; |
| 979 |
|
// for (Int_t ii=0; ii<43; ii++){ |
| 980 |
|
// for (Int_t j=0; j<191; j++){ |
| 981 |
|
// // |
| 982 |
|
// i1 = (ii * 191) + j; |
| 983 |
|
// // |
| 984 |
|
// for (Int_t iij=0; iij<43; iij++){ |
| 985 |
|
// for (Int_t jj=0; jj<191; jj++){ |
| 986 |
|
// // |
| 987 |
|
// j1 = (iij * 191) + jj; |
| 988 |
|
// // |
| 989 |
|
// // printf(" ROW %i COLUMN %i VALUE %f \n",i1,j1,(*fmatrix)[i1][j1]); |
| 990 |
|
// if ( (*fmatrix)[i1][j1] == 0. || !((*fmatrix)[i1][j1]==(*fmatrix)[i1][j1]) ){ |
| 991 |
|
// printf(" ROW %i COLUMN %i VALUE %f \n",i1,j1,(*fmatrix)[i1][j1]); |
| 992 |
|
// printf(" che schifo! \n"); |
| 993 |
|
// BAD = true; |
| 994 |
|
// }; |
| 995 |
|
// // |
| 996 |
|
// }; |
| 997 |
|
// }; |
| 998 |
|
// }; |
| 999 |
|
// }; |
| 1000 |
|
// // |
| 1001 |
|
// if ( BAD ) printf(" questa matrice fa cagare \n"); |
| 1002 |
|
// |
| 1003 |
|
// |
| 1004 |
cf->WriteFullMatrix(fmatrix[i],i); |
cf->WriteFullMatrix(fmatrix[i],i); |
| 1005 |
|
// cf->WriteFullMatrix(fmatrix, i); |
| 1006 |
|
// cf->WriteFullNMatrix(fnmat, i); |
| 1007 |
|
cf->WriteFullNMatrix(fnmat[i], i); |
| 1008 |
// |
// |
| 1009 |
if ( fmatrix[i]->Determinant() == 0. ){ |
// TDecompSVD svd(*fmatrix[i]); |
| 1010 |
|
// Bool_t ok = svd.Decompose(); |
| 1011 |
|
// |
| 1012 |
|
Double_t zero = (Double_t)0.0; |
| 1013 |
|
// |
| 1014 |
|
if ( fmatrix[i]->Determinant() == zero ){ |
| 1015 |
|
//if ( fmatrix->Determinant() == 0. ){ |
| 1016 |
printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1017 |
} else { |
} else { |
| 1018 |
Double_t det = 0.; |
// }; |
| 1019 |
TMatrixF invmatrix = (TMatrixF)(fmatrix[i]->Invert(&det)); |
// if ( i == 3 ){ |
| 1020 |
printf(" Bin %i determinant is %f \n",i,det); |
// if ( ok ){ |
| 1021 |
cf->WriteInvertedFullMatrix((TMatrixF)invmatrix,i); |
// Double_t tol = 1E-20; |
| 1022 |
|
// TDecompSVD svd((*fmatrix)[i],tol); |
| 1023 |
|
// svd.Decompose(); |
| 1024 |
|
// TMatrixD svdInv = svd.Invert(); |
| 1025 |
|
// svdInv.Print("svdInv"); |
| 1026 |
|
// cout << "condition: " << svd.Condition() << endl; |
| 1027 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)svdInv,999); |
| 1028 |
|
|
| 1029 |
|
Double_t det = 0.; |
| 1030 |
|
TMatrixD invmatrix = (TMatrixD)(fmatrix[i]->Invert(&det)); |
| 1031 |
|
printf(" Bin %i determinant is %f \n",i,det); |
| 1032 |
|
cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,i); |
| 1033 |
}; |
}; |
| 1034 |
|
|
| 1035 |
|
// if ( mymat3->Determinant() == 0. ){ |
| 1036 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1037 |
|
// } else { |
| 1038 |
|
// Double_t det = 0.; |
| 1039 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat3->Invert(&det)); |
| 1040 |
|
// printf(" Mymat3 determinant is %f \n",det); |
| 1041 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1103); |
| 1042 |
|
// }; |
| 1043 |
|
// cf->WriteFullMatrix(mymat3, 103); |
| 1044 |
|
// if ( mymat5->Determinant() == 0. ){ |
| 1045 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1046 |
|
// } else { |
| 1047 |
|
// Double_t det = 0.; |
| 1048 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat5->Invert(&det)); |
| 1049 |
|
// printf(" Mymat5 determinant is %f \n",det); |
| 1050 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1105); |
| 1051 |
|
// }; |
| 1052 |
|
// cf->WriteFullMatrix(mymat5, 105); |
| 1053 |
|
// if ( mymat7->Determinant() == 0. ){ |
| 1054 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1055 |
|
// } else { |
| 1056 |
|
// Double_t det = 0.; |
| 1057 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat7->Invert(&det)); |
| 1058 |
|
// printf(" Mymat7 determinant is %f \n",det); |
| 1059 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1107); |
| 1060 |
|
// }; |
| 1061 |
|
// cf->WriteFullMatrix(mymat7, 107); |
| 1062 |
|
// if ( mymat9->Determinant() == 0. ){ |
| 1063 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1064 |
|
// } else { |
| 1065 |
|
// Double_t det = 0.; |
| 1066 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat9->Invert(&det)); |
| 1067 |
|
// printf(" Mymat3 determinant is %f \n",det); |
| 1068 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1109); |
| 1069 |
|
// }; |
| 1070 |
|
// cf->WriteFullMatrix(mymat9, 109); |
| 1071 |
|
// if ( mymat11->Determinant() == 0. ){ |
| 1072 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1073 |
|
// } else { |
| 1074 |
|
// Double_t det = 0.; |
| 1075 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat11->Invert(&det)); |
| 1076 |
|
// printf(" Mymat11 determinant is %f \n",det); |
| 1077 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1111); |
| 1078 |
|
// }; |
| 1079 |
|
// cf->WriteFullMatrix(mymat11, 111); |
| 1080 |
|
// if ( mymat17->Determinant() == 0. ){ |
| 1081 |
|
// printf(" ERROR: the matrix at bin %i is singular, determinant = 0., it cannot be inverted! \n",i); |
| 1082 |
|
// } else { |
| 1083 |
|
// Double_t det = 0.; |
| 1084 |
|
// TMatrixD invmatrix = (TMatrixD)(mymat17->Invert(&det)); |
| 1085 |
|
// printf(" Mymat3 determinant is %f \n",det); |
| 1086 |
|
// cf->WriteInvertedFullMatrix((TMatrixD)invmatrix,1117); |
| 1087 |
|
// }; |
| 1088 |
|
// cf->WriteFullMatrix(mymat17, 117); |
| 1089 |
|
|
| 1090 |
|
|
| 1091 |
|
// |
| 1092 |
|
// cf->UnLoadFullMatrix(i); |
| 1093 |
|
// cf->UnLoadFullNMatrix(i); |
| 1094 |
|
// delete fmatrix; |
| 1095 |
|
// delete fnmat; |
| 1096 |
|
// |
| 1097 |
}; |
}; |
| 1098 |
}; |
}; |
| 1099 |
// |
// |