Changeset 2341 for trunk/MagicSoft/Simulation
- Timestamp:
- 09/15/03 12:30:28 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
r2292 r2341 11 11 #include "TObjArray.h" 12 12 #include "MGTriggerSignal.hxx" 13 14 15 MTrigger::MTrigger() { 13 #include "MGeomCam.h" 14 #include "MGeomPix.h" 15 16 MTrigger::MTrigger(int pix) { 16 17 // ============================================================ 17 18 // … … 35 36 36 37 Float_t threshold ; 38 39 // Number of pixels in the trigger region 40 pixnum=pix; 37 41 38 42 // … … 40 44 // 41 45 42 for( Int_t j=0; j<TRIGGER_PIXELS; j++ ) { 46 used = new Bool_t[pix]; 47 nphotshow = new Int_t[pix]; 48 nphotnsb = new Int_t[pix]; 49 nphotstar = new Int_t[pix]; 50 a_sig = new Float_t * [pix]; 51 d_sig = new Float_t * [pix]; 52 baseline = new Float_t[pix]; 53 dknt = new Bool_t[pix]; 54 noise = new Float_t[TRIGGER_TIME_SLICES*1001]; 55 chan_thres = new Float_t[pix]; 56 for(Int_t j=0;j<6;j++) 57 NN[j] = new Int_t[pix]; 58 for(Int_t j=0;j<TRIGGER_CELLS;j++) 59 TC[j] = new Int_t[pix]; 60 61 for( Int_t j=0; j<pix; j++ ) { 43 62 44 63 a_sig[j] = new Float_t[TRIGGER_TIME_SLICES] ; … … 46 65 d_sig[j] = new Float_t[TRIGGER_TIME_SLICES] ; 47 66 } 67 68 48 69 49 70 // … … 155 176 cout<<"WARNING: not able to read ..."<<input_thres<<endl; 156 177 cout<<"Threshold will be set to "<<threshold<<" for all pixels"<<endl; 157 for (Int_t k=0; k< TRIGGER_PIXELS; k++ ) {178 for (Int_t k=0; k<CAMERA_PIXELS; k++ ) { 158 179 chan_thres[k] = threshold ; 159 180 } 160 181 } 161 182 else { 162 for (i=0;i< TRIGGER_PIXELS;i++){183 for (i=0;i<CAMERA_PIXELS;i++){ 163 184 fscanf(unit_thres, "%f",&chan_thres[i]); 164 185 } … … 167 188 } 168 189 else { 169 for (Int_t k=0; k< TRIGGER_PIXELS; k++ ) {190 for (Int_t k=0; k<CAMERA_PIXELS; k++ ) { 170 191 chan_thres[k] = threshold ; 171 192 } … … 256 277 } 257 278 else { 258 while ( i < TRIGGER_PIXELS )279 while ( i < CAMERA_PIXELS ) 259 280 { 260 281 fscanf ( unit, " %d", &id ) ; 261 282 262 283 for ( Int_t k=0; k<6; k++ ) { 263 fscanf ( unit, "%d ", &NN[ i][k] ) ;284 fscanf ( unit, "%d ", &NN[k][i] ) ; 264 285 } 265 286 i++ ; … … 282 303 } 283 304 else { 284 while ( i < TRIGGER_PIXELS )305 while ( i < CAMERA_PIXELS ) 285 306 { 286 307 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { … … 292 313 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 293 314 fscanf ( unit, "%d ", &i ) ; 294 if ((i-1)< TRIGGER_PIXELS)315 if ((i-1)<CAMERA_PIXELS) 295 316 TC[k][i-1]=TRUE; 296 317 } … … 306 327 // 307 328 308 for ( i =0 ; i < TRIGGER_PIXELS ; i++ ) {329 for ( i =0 ; i <CAMERA_PIXELS ; i++ ) { 309 330 used [i] = FALSE ; 310 331 dknt [i] = FALSE ; … … 341 362 } 342 363 343 MTrigger::MTrigger(float gate, float overt, float ampl, float fwhm) { 364 MTrigger::MTrigger(Int_t pix, MGeomCam *camgeom, 365 float gate, float overt, float ampl, float fwhm) { 344 366 // ============================================================ 345 367 // … … 356 378 Float_t threshold ; 357 379 380 // Number of pixels in the trigger region 381 pixnum=pix; 382 358 383 // 359 384 // allocate the memory for the 2dim arrays (a_sig, d_sig ) 360 385 // 361 386 362 for( Int_t j=0; j<TRIGGER_PIXELS; j++ ) { 387 used = new Bool_t[pix]; 388 nphotshow = new Int_t[pix]; 389 nphotnsb = new Int_t[pix]; 390 nphotstar = new Int_t[pix]; 391 a_sig = new Float_t * [pix]; 392 d_sig = new Float_t * [pix]; 393 baseline = new Float_t[pix]; 394 dknt = new Bool_t[pix]; 395 noise = new Float_t[TRIGGER_TIME_SLICES*1001]; 396 chan_thres = new Float_t[pix]; 397 for(Int_t j=0;j<6;j++) 398 NN[j] = new Int_t[pix]; 399 for(Int_t j=0;j<TRIGGER_CELLS;j++) 400 TC[j] = new Int_t[pix]; 401 402 for( Int_t j=0; j<pix; j++ ) { 363 403 364 404 a_sig[j] = new Float_t[TRIGGER_TIME_SLICES] ; … … 396 436 cout << endl ; 397 437 398 399 for (Int_t k=0; k<TRIGGER_PIXELS; k++ ) { 438 for (Int_t k=0; k<pixnum; k++ ) { 400 439 chan_thres[k] = threshold ; 401 440 } 402 441 403 404 442 // 405 443 // set up the response shape … … 439 477 peak_time = ( (Float_t) imax ) / ( (Float_t) SLICES_PER_NSEC ) ; 440 478 441 442 479 // 443 480 // the amplitude of one single photo electron is not a constant. … … 474 511 // 475 512 476 FILE *unit ; 477 int id ; 478 479 i = 0 ; 480 481 if ( (unit = fopen("../include-MTrigger/TABLE_NEXT_NEIGHBOUR", "r" )) == 0 ) { 482 cout << "ERROR: not able to read ../include-MTrigger/TABLE_NEXT_NEIGHBOUR" 483 << endl ; 484 exit(123) ; 485 } 486 else { 487 while ( i < TRIGGER_PIXELS ) 488 { 489 fscanf ( unit, " %d", &id ) ; 490 491 for ( Int_t k=0; k<6; k++ ) { 492 fscanf ( unit, "%d ", &NN[i][k] ) ; 513 for(i=0; i < pixnum;i++ ) 514 { 515 MGeomPix &pixel = (*camgeom)[i]; 516 for ( Int_t k=0; k<6; k++ ) { 517 NN[k][i]=pixel.GetNeighbor(k); 493 518 } 494 i++ ; 495 } 496 497 fclose (unit) ; 498 } 499 519 } 500 520 501 521 // 502 522 // Read in the lookup table for trigger cells 503 523 // 524 525 FILE *unit; 504 526 505 527 i = 0 ; … … 511 533 } 512 534 else { 513 while ( i < TRIGGER_PIXELS)535 while ( i < pixnum ) 514 536 { 515 537 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { … … 521 543 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 522 544 fscanf ( unit, "%d ", &i ) ; 523 if((i-1)< TRIGGER_PIXELS)545 if((i-1)<pixnum) 524 546 TC[k][i-1]=TRUE; 525 547 } … … 528 550 } 529 551 530 531 552 // 532 553 // … … 535 556 // 536 557 537 for ( i =0 ; i < TRIGGER_PIXELS; i++ ) {558 for ( i =0 ; i <pixnum ; i++ ) { 538 559 used [i] = FALSE ; 539 560 dknt [i] = FALSE ; … … 577 598 delete histPmt ; 578 599 579 for(i=0;i< TRIGGER_PIXELS;i++){600 for(i=0;i<pixnum;i++){ 580 601 //delete [] a_sig[i]; 581 602 //delete [] d_sig[i]; … … 593 614 Int_t i, ii ; 594 615 595 for ( i =0 ; i < TRIGGER_PIXELS; i++ ) {616 for ( i =0 ; i <pixnum ; i++ ) { 596 617 used [i] = FALSE ; 597 618 dknt [i] = FALSE ; … … 715 736 exit (1) ; 716 737 } 717 else if ( iPix >= TRIGGER_PIXELS) {738 else if ( iPix >= pixnum ) { 718 739 // 719 740 // We have not to fill information in the trigger part, … … 816 837 exit (1) ; 817 838 } 818 else if ( iPix >= TRIGGER_PIXELS) {839 else if ( iPix >= pixnum ) { 819 840 // 820 841 // We have not to fill information in the trigger part. … … 860 881 rausch = RESPONSE_AMPLITUDE * factor ; 861 882 862 cout<<"MTrigger::SetElecNoise ... generating database for electroni noise."883 cout<<"MTrigger::SetElecNoise ... generating database for electronic noise." 863 884 <<endl; 864 885 865 for (i=0;i<TRIGGER_PIXELS*TRIGGER_TIME_SLICES*101;i++){866 noise[i]=GenElec->Gaus(0., rausch );867 } 868 886 for (i=0;i<(UInt_t)(TRIGGER_TIME_SLICES*1001);i++){ 887 noise[i]=GenElec->Gaus(0., rausch ); 888 } 889 869 890 cout<<"MTrigger::SetElecNoise ... done"<<endl; 870 891 … … 882 903 883 904 UInt_t startslice; 884 885 startslice=GenElec->Integer(TRIGGER_PIXELS*TRIGGER_TIME_SLICES*100);886 887 888 905 889 for ( Int_t i=0 ; i < TRIGGER_PIXELS; i++ ) {906 for ( Int_t i=0 ; i < pixnum; i++ ) { 890 907 // 891 908 // but at the beginning we must check if this pixel is 892 909 // hitted the first time 893 910 // 911 startslice=GenElec->Integer(TRIGGER_TIME_SLICES*1000); 894 912 895 913 if ( used[i] == FALSE ) { … … 897 915 898 916 memcpy( (Float_t*)a_sig[i], 899 (Float_t*)&noise[startslice +TRIGGER_TIME_SLICES*i],917 (Float_t*)&noise[startslice], 900 918 TRIGGER_TIME_SLICES*sizeof(Float_t)); 901 919 memset( (Float_t*)d_sig[i], … … 908 926 // 909 927 else 910 for ( Int_t ii= 1; ii<TRIGGER_TIME_SLICES; ii++ ) {928 for ( Int_t ii=0 ; ii<TRIGGER_TIME_SLICES; ii++ ) { 911 929 912 a_sig [i][ii] += noise[startslice+ TRIGGER_TIME_SLICES*i+ii] ;930 a_sig [i][ii] += noise[startslice+ii] ; 913 931 914 932 } 915 916 933 } 917 934 } … … 964 981 //============================================================= 965 982 // 966 // It sets the private member chan_thres[ TRIGGER_PIXELS]983 // It sets the private member chan_thres[pixnum] 967 984 968 985 Int_t i; 969 986 970 for(i=0;i< TRIGGER_PIXELS;i++){987 for(i=0;i<pixnum;i++){ 971 988 chan_thres[i]=thres[i]; 972 989 } … … 974 991 975 992 976 void MTrigger::CheckThreshold(float *thres ){993 void MTrigger::CheckThreshold(float *thres, int cells){ 977 994 //============================================================= 978 995 // … … 983 1000 float thres_aux[CAMERA_PIXELS]; 984 1001 int id; 985 986 for (int i=0;i<CAMERA_PIXELS;i++) 987 thres_aux[i]=999999.99; 988 989 if((unit =fopen("../include-MTrigger/TABLE_PIXELS_IN_CELLS", "r" )) == 0 ){ 990 cout << "ERROR: not able to read ../include-MTrigger/TABLE_PIXELS_IN_CELLS" 991 << endl ; 992 exit(123) ; 993 } 994 else { 995 while ( feof(unit) == 0 ) { 996 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 997 fscanf ( unit, "%d ", &id ) ; 998 if ((id-1)<TRIGGER_PIXELS) 999 thres_aux[id-1]=thres[id-1]; 1000 } 1001 } 1002 } 1003 fclose (unit) ; 1004 1005 for (int i=0;i<CAMERA_PIXELS;i++) 1006 thres[i]=thres_aux[i]; 1007 1002 1003 for (int i=0;i<CAMERA_PIXELS;i++){ 1004 if(i<pixnum){ 1005 thres_aux[i]=999999.99; 1006 thres[i]=thres[i]; 1007 } 1008 else{ 1009 thres_aux[i]=-10.0; 1010 thres[i]=-10.0; 1011 } 1012 } 1013 1014 if (cells==1){ 1015 if((unit =fopen("../include-MTrigger/TABLE_PIXELS_IN_CELLS", "r" )) == 0 ){ 1016 cout << "ERROR: not able to read ../include-MTrigger/TABLE_PIXELS_IN_CELLS" 1017 << endl ; 1018 exit(123) ; 1019 } 1020 else { 1021 while ( feof(unit) == 0 ) { 1022 for ( Int_t k=0; k<TRIGGER_CELLS; k++ ) { 1023 fscanf ( unit, "%d ", &id ) ; 1024 if ((id-1)<pixnum) 1025 thres_aux[id-1]=thres[id-1]; 1026 } 1027 } 1028 } 1029 fclose (unit) ; 1030 1031 for (int i=0;i<CAMERA_PIXELS;i++) 1032 thres[i]=thres_aux[i]; 1033 } 1008 1034 } 1009 1035 … … 1020 1046 } 1021 1047 else { 1022 while (i< TRIGGER_PIXELS){1048 while (i<pixnum){ 1023 1049 fscanf(unit, "%f",&chan_thres[i++]); 1024 1050 } … … 1043 1069 //============================================================= 1044 1070 // 1045 // Gives a map of the fired pixels (Bool_t dknt [ TRIGGER_PIXELS])1071 // Gives a map of the fired pixels (Bool_t dknt [pixnum]) 1046 1072 // in an array of Byte_t (each byte has the information for 8 pixels) 1047 1073 // … … 1049 1075 Int_t i,ii; 1050 1076 1051 for(i=0;i< TRIGGER_PIXELS/8+1;i++){1077 for(i=0;i<pixnum/8+1;i++){ 1052 1078 map[i]=0; 1053 1079 } 1054 1080 1055 for(i=0;i< TRIGGER_PIXELS;i++){1081 for(i=0;i<pixnum;i++){ 1056 1082 ii=(Int_t)i/8; 1057 1083 if (dknt[i]==TRUE){ … … 1084 1110 // 1085 1111 1086 for ( i=0 ; i < TRIGGER_PIXELS; i++ ) {1112 for ( i=0 ; i < pixnum ; i++ ) { 1087 1113 if ( used[i] == TRUE ) { 1088 1114 baseline[i] = 0. ; … … 1109 1135 // 1110 1136 1111 for ( i=0 ; i < TRIGGER_PIXELS; i++ ) {1137 for ( i=0 ; i < pixnum; i++ ) { 1112 1138 if ( used [i] == TRUE ) { 1113 1139 … … 1176 1202 1177 1203 Int_t ic = 0 ; 1178 for ( Int_t i=0 ; i < TRIGGER_PIXELS; i++ ) {1204 for ( Int_t i=0 ; i < pixnum; i++ ) { 1179 1205 if ( used [i] == TRUE ) { 1180 1206 … … 1255 1281 // 1256 1282 Int_t iMul = 0 ; 1257 for ( Int_t iP =0 ; iP < TRIGGER_PIXELS; iP++ ) {1283 for ( Int_t iP =0 ; iP < pixnum; iP++ ) { 1258 1284 // 1259 1285 // … … 1270 1296 // fill the sum signal of all diskriminator signals 1271 1297 // 1272 for ( Int_t iP =0 ; iP < TRIGGER_PIXELS; iP++ ) {1298 for ( Int_t iP =0 ; iP < pixnum; iP++ ) { 1273 1299 // 1274 1300 // … … 1318 1344 1319 1345 // Definition of needed variables 1320 Bool_t Muster[ TRIGGER_PIXELS] ;1321 Bool_t Neighb[ TRIGGER_PIXELS] ;1346 Bool_t Muster[pixnum] ; 1347 Bool_t Neighb[pixnum] ; 1322 1348 Int_t iMulti = 0 ; 1323 1349 … … 1370 1396 // diskriminated signal is 1 1371 1397 // 1372 for ( Int_t iPix = 0 ; iPix < TRIGGER_PIXELS; iPix++ ) {1398 for ( Int_t iPix = 0 ; iPix < pixnum; iPix++ ) { 1373 1399 Muster[iPix] = kFALSE ; 1374 1400 Neighb[iPix] = kFALSE ; … … 1401 1427 // trigger_multi-1 neighbour pixels above threshold 1402 1428 1403 Bool_t Dummy[ TRIGGER_PIXELS] ;1429 Bool_t Dummy[pixnum] ; 1404 1430 1405 1431 // Loop over all pixels 1406 for (int j=0;j< TRIGGER_PIXELS;j++){1432 for (int j=0;j<pixnum;j++){ 1407 1433 1408 for (int k=0; k< TRIGGER_PIXELS; k++){1434 for (int k=0; k<pixnum; k++){ 1409 1435 Neighb[k]=kFALSE; 1410 1436 … … 1419 1445 break; 1420 1446 } 1421 for (int k=0; k< TRIGGER_PIXELS; k++){1447 for (int k=0; k<pixnum; k++){ 1422 1448 if (Neighb[k]){ 1423 1449 Dummy[k]=kFALSE; … … 1447 1473 // threshold. 1448 1474 1449 for (int j=0;j< TRIGGER_PIXELS;j++){1475 for (int j=0;j<pixnum;j++){ 1450 1476 if(Muster[j]){ 1451 1477 // It checks if you can find … … 1469 1495 else { 1470 1496 // We put Neighb to kFALSE to check an other pixel 1471 for (int k=0; k< TRIGGER_PIXELS; k++){1497 for (int k=0; k<pixnum; k++){ 1472 1498 if (Neighb[k]){ 1473 1499 Neighb[k]=kFALSE; … … 1490 1516 Int_t closed_pack = 1; 1491 1517 1492 for (int j=0;j< TRIGGER_PIXELS;j++){1518 for (int j=0;j<pixnum;j++){ 1493 1519 if(Muster[j]){ 1494 1520 // It checks if there are trigger_multi … … 1511 1537 // Check if there is closed pack topology 1512 1538 1513 Bool_t Aux1[ TRIGGER_PIXELS];1514 Bool_t Aux2[ TRIGGER_PIXELS];1515 for (int jj=0;jj< TRIGGER_PIXELS;jj++)1539 Bool_t Aux1[pixnum]; 1540 Bool_t Aux2[pixnum]; 1541 for (int jj=0;jj<pixnum;jj++) 1516 1542 Aux2[jj]=kFALSE; 1517 1543 1518 for (int i=0;i< TRIGGER_PIXELS;i++){1544 for (int i=0;i<pixnum;i++){ 1519 1545 if (Neighb[i]) { 1520 1546 // Loop over pixels that achive neighbouring condition 1521 1547 1522 for (int jj=0;jj< TRIGGER_PIXELS;jj++) {1548 for (int jj=0;jj<pixnum;jj++) { 1523 1549 1524 1550 Aux1[jj] = Neighb[jj] ; // huschel … … 1531 1557 Aux1[i]=kFALSE; 1532 1558 closed_pack=0; 1533 for (int jj=0;jj< TRIGGER_PIXELS;jj++) {1559 for (int jj=0;jj<pixnum;jj++) { 1534 1560 if (Aux1[jj]==kTRUE){ 1535 1561 Aux2[jj]=kTRUE; … … 1561 1587 } 1562 1588 else { 1563 for (int k=0; k< TRIGGER_PIXELS; k++){1589 for (int k=0; k<pixnum; k++){ 1564 1590 if (Neighb[k]){ 1565 1591 Neighb[k]=kFALSE; … … 1569 1595 } // end if trigger multiplicity achived 1570 1596 else{ 1571 for (int k=0; k< TRIGGER_PIXELS; k++)1597 for (int k=0; k<pixnum; k++) 1572 1598 Neighb[k]=kFALSE; 1573 1599 } … … 1606 1632 Bool_t return_val = kFALSE; 1607 1633 1608 for ( Int_t i=0; i< TRIGGER_PIXELS; i++) {1634 for ( Int_t i=0; i<pixnum; i++) { 1609 1635 // 1610 1636 // check if this pixel has a diskrminator signal … … 1623 1649 // 1624 1650 if (!return_val){ 1625 if (NN[ i][kk] >= TRIGGER_PIXELS) {1651 if (NN[kk][i] >= pixnum ) { 1626 1652 1627 1653 } 1628 // the nextneighbour is not inside the TRIGGER_PIXELS1654 // the nextneighbour is not inside the pixnum 1629 1655 else { 1630 1656 // … … 1632 1658 // 1633 1659 1634 if ( m[ NN[ i][kk] ] && !n[NN[i][kk]] ) {1635 n[NN[ i][kk]]=kTRUE ;1660 if ( m[ NN[kk][i] ] && !n[NN[kk][i]] ) { 1661 n[NN[kk][i]]=kTRUE ; 1636 1662 return_val =kTRUE; 1637 1663 } … … 1677 1703 1678 1704 // Put pixels that fulfill the requirement in n 1679 for (i=0;i< TRIGGER_PIXELS;i++){1705 for (i=0;i<pixnum;i++){ 1680 1706 if (m[i]==kTRUE){ 1681 1707 for(j=ifSli;j<ifSli+iNumSli;j++){
Note:
See TracChangeset
for help on using the changeset viewer.