132 |
|
|
133 |
end |
end |
134 |
|
|
|
c$$$ |
|
|
c$$$c$$$c------------------------------------------------------------------------ |
|
|
c$$$c$$$ |
|
|
c$$$c$$$c NB: le coordinate in mech_pos.dat sono calcolate a partire da alcuni dati |
|
|
c$$$c$$$c contenuti in commontracker.f. forse si puo' evitare mech_pos.dat e mettere |
|
|
c$$$c$$$c tutto in commontracker.f |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ subroutine mech_sensor !it reads sensors coordinates (in PAMELA reference |
|
|
c$$$c$$$ ! frame) from a text file and it uses them to fill |
|
|
c$$$c$$$ ! x/y/z_mech_sensor variables, taking into account |
|
|
c$$$c$$$ ! last plane inversion |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ include './commontracker.f' |
|
|
c$$$c$$$ include './common_tracks.f' |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ real xvec(nladders_view),yvec(2),zvec(nplanes) |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ integer id !file identifier |
|
|
c$$$c$$$ logical od !.true. if the specified unit is connected to a file |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ do id=20,100,1 !opens the file using a free file id |
|
|
c$$$c$$$ inquire (id, opened=od) |
|
|
c$$$c$$$ if(.not.od) goto 666 |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$ 666 continue |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ open(id,FILE='../common/mech_pos.dat') !sensors centres coordinates in mm in |
|
|
c$$$c$$$ ! PAMELA reference frame: |
|
|
c$$$c$$$ ! the first plane is the one with lowest Z (the one |
|
|
c$$$c$$$ ! nearest the calorimeter) |
|
|
c$$$c$$$ ! the first ladder is the one with lowest X (the |
|
|
c$$$c$$$ ! one on which the first X strip is) |
|
|
c$$$c$$$ ! the first sensor is the one with lowest Y (the |
|
|
c$$$c$$$ ! one on which the first Y strip is) for planes |
|
|
c$$$c$$$ ! 2..6. for plane 1 the first sensor has higher Y |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ read(20,*) xvec |
|
|
c$$$c$$$ read(20,*) yvec |
|
|
c$$$c$$$ read(20,*) zvec |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ do i=1,nplanes |
|
|
c$$$c$$$ do j=1,nladders_view |
|
|
c$$$c$$$ do k=1,2 |
|
|
c$$$c$$$ x_mech_sensor(i,j,k)=xvec(j) |
|
|
c$$$c$$$ y_mech_sensor(i,j,k)=yvec(k) |
|
|
c$$$c$$$ z_mech_sensor(i,j,k)=zvec(i) |
|
|
c$$$c$$$ if(i.eq.1) then !y coordinates of first plane (11th view) are |
|
|
c$$$c$$$ y_mech_sensor(i,j,k)=-yvec(k) ! exchanged due to last plane inversion |
|
|
c$$$c$$$ endif |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ close(id) |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ |
|
|
c$$$c$$$c$$$ ! *** INIZIO DEBUG *** |
|
|
c$$$c$$$c$$$ do i=1,6 |
|
|
c$$$c$$$c$$$ do j=1,3 |
|
|
c$$$c$$$c$$$ do k=1,2 |
|
|
c$$$c$$$c$$$ c print*,x_mech_sensor(1,j,k) |
|
|
c$$$c$$$c$$$ print*,y_mech_sensor(i,j,k) |
|
|
c$$$c$$$c$$$ c print*,z_mech_sensor(i,j,k) |
|
|
c$$$c$$$c$$$ enddo |
|
|
c$$$c$$$c$$$ enddo |
|
|
c$$$c$$$c$$$ print*,' ' |
|
|
c$$$c$$$c$$$ enddo |
|
|
c$$$c$$$c$$$ ! *** FINE DEBUG *** |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ |
|
|
c$$$c$$$ return |
|
|
c$$$c$$$ end |
|
|
|
|
|
|
|
|
c$$$c------------------------------------------------------------------------ |
|
|
c$$$ |
|
|
c$$$c NB: le coordinate in mech_pos.dat sono calcolate a partire da alcuni dati |
|
|
c$$$c contenuti in commontracker.f. forse si puo' evitare mech_pos.dat e mettere |
|
|
c$$$c tutto in commontracker.f |
|
|
c$$$ |
|
|
c$$$ |
|
|
c$$$ subroutine mech_sensor |
|
|
c$$$c !it reads sensors coordinates (in PAMELA reference |
|
|
c$$$c ! frame) from a text file and it uses them to fill |
|
|
c$$$c ! x/y/z_mech_sensor variables, taking into account |
|
|
c$$$c ! last plane inversion |
|
|
c$$$ |
|
|
c$$$ include './commontracker.f' |
|
|
c$$$ include './common_tracks.f' |
|
|
c$$$ |
|
|
c$$$ real xvec(nladders_view),yvec(2),zvec(nplanes) |
|
|
c$$$ |
|
|
c$$$ integer id !file identifier |
|
|
c$$$ logical od !.true. if the specified unit is connected to a file |
|
|
c$$$ |
|
|
c$$$ do id=20,100,1 !opens the file using a free file id |
|
|
c$$$ inquire (id, opened=od) |
|
|
c$$$ if(.not.od) goto 666 |
|
|
c$$$ enddo |
|
|
c$$$ 666 continue |
|
|
c$$$ |
|
|
c$$$c open(id,FILE='../common/mech_pos.dat') !sensors centres coordinates in mm in |
|
|
c$$$c open(id,FILE='source/common/mech_pos.dat') |
|
|
c$$$c call system('cp $TRK_GRND/source/common/mech_pos.dat .') |
|
|
c$$$ print *,'Opening file: mech_pos.dat' |
|
|
c$$$ open(id,FILE='./bin-aux/mech_pos.dat',IOSTAT=iostat) |
|
|
c$$$c !sensors centres coordinates in mm in |
|
|
c$$$c ! PAMELA reference frame: |
|
|
c$$$c ! the first plane is the one with lowest Z (the one |
|
|
c$$$c ! nearest the calorimeter) |
|
|
c$$$c ! the first ladder is the one with lowest X (the |
|
|
c$$$c ! one on which the first X strip is) |
|
|
c$$$c ! the first sensor is the one with lowest Y (the |
|
|
c$$$c ! one on which the first Y strip is) for planes |
|
|
c$$$c ! 2..6. for plane 1 the first sensor has higher Y |
|
|
c$$$ |
|
|
c$$$ if(iostat.ne.0)then |
|
|
c$$$ print*,'MECH_SENSOR: *** Error in opening file ***' |
|
|
c$$$ return |
|
|
c$$$ endif |
|
|
c$$$ |
|
|
c$$$ read(id,*) xvec |
|
|
c$$$ read(id,*) yvec |
|
|
c$$$ read(id,*) zvec |
|
|
c$$$ |
|
|
c$$$ do i=1,nplanes |
|
|
c$$$ do j=1,nladders_view |
|
|
c$$$ do k=1,2 |
|
|
c$$$ x_mech_sensor(i,j,k)=xvec(j) |
|
|
c$$$ y_mech_sensor(i,j,k)=yvec(k) |
|
|
c$$$ z_mech_sensor(i,j,k)=zvec(i) |
|
|
c$$$ if(i.eq.1) then !y coordinates of first plane (11th view) are |
|
|
c$$$ y_mech_sensor(i,j,k)=-yvec(k) ! exchanged due to last plane inversion |
|
|
c$$$ endif |
|
|
c$$$ enddo |
|
|
c$$$ enddo |
|
|
c$$$ enddo |
|
|
c$$$ |
|
|
c$$$ close(id) |
|
|
c$$$c call system('rm -f mech_pos.dat') |
|
|
c$$$ |
|
|
c$$$c$$$ ! *** INIZIO DEBUG *** |
|
|
c$$$c$$$ do i=1,6 |
|
|
c$$$c$$$c do j=1,3 |
|
|
c$$$c$$$ do k=1,2 |
|
|
c$$$c$$$ j=1 |
|
|
c$$$c$$$c print*,x_mech_sensor(1,j,k) |
|
|
c$$$c$$$ print*,y_mech_sensor(i,j,k) |
|
|
c$$$c$$$c print*,z_mech_sensor(i,j,k) |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$c enddo |
|
|
c$$$c$$$ print*,' ' |
|
|
c$$$c$$$ enddo |
|
|
c$$$c$$$ ! *** FINE DEBUG *** |
|
|
c$$$ |
|
|
c$$$ |
|
|
c$$$ return |
|
|
c$$$ end |
|
|
c$$$ |
|
|
c$$$ |
|
|
c$$$c------------------------------------------------------------------------ |
|
135 |
|
|
136 |
|
|
137 |
function coordsi(istrip,view) |
function coordsi(istrip,view) |
382 |
|
|
383 |
|
|
384 |
c------------------------------------------------------------------------ |
c------------------------------------------------------------------------ |
385 |
|
integer function nsatstrips(ic) |
386 |
|
*-------------------------------------------------------------- |
387 |
|
* this function returns the number of saturated strips |
388 |
|
* inside a cluster |
389 |
|
*-------------------------------------------------------------- |
390 |
|
include 'commontracker.f' |
391 |
|
include 'level1.f' |
392 |
|
include 'calib.f' |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
integer nsat |
397 |
|
nsat = 0 |
398 |
|
iv=VIEW(ic) |
399 |
|
if(mod(iv,2).eq.1)incut=incuty |
400 |
|
if(mod(iv,2).eq.0)incut=incutx |
401 |
|
istart = INDSTART(IC) |
402 |
|
istop = TOTCLLENGTH |
403 |
|
if(ic.lt.NCLSTR1)istop=INDSTART(IC+1)-1 |
404 |
|
do i = INDMAX(IC),istart,-1 |
405 |
|
c cut = incut*CLSIGMA(i) |
406 |
|
c if(CLSIGNAL(i).ge.cut)then |
407 |
|
if( (mod(iv,2).eq.1.and.CLADC(i).lt.ADCsatx) |
408 |
|
$ .or. |
409 |
|
$ (mod(iv,2).eq.0.and.CLADC(i).gt.ADCsaty) )then |
410 |
|
nsat = nsat +1 |
411 |
|
else |
412 |
|
goto 10 |
413 |
|
endif |
414 |
|
enddo |
415 |
|
10 continue |
416 |
|
do i = INDMAX(IC)+1,istop |
417 |
|
c cut = incut*CLSIGMA(i) |
418 |
|
c if(CLSIGNAL(i).ge.cut)then |
419 |
|
if( (mod(iv,2).eq.1.and.CLADC(i).lt.ADCsatx) |
420 |
|
$ .or. |
421 |
|
$ (mod(iv,2).eq.0.and.CLADC(i).gt.ADCsaty) )then |
422 |
|
nsat = nsat +1 |
423 |
|
else |
424 |
|
goto 20 |
425 |
|
endif |
426 |
|
enddo |
427 |
|
20 continue |
428 |
|
|
429 |
|
nsatstrips = nsat |
430 |
|
return |
431 |
|
end |
432 |
|
|
433 |
|
c------------------------------------------------------------------------ |
434 |
|
integer function nbadstrips(ncog,ic) |
435 |
|
*-------------------------------------------------------------- |
436 |
|
* this function returns the number of BAD strips |
437 |
|
* inside a cluster: |
438 |
|
* - if NCOG=0, the number BAD strips inside the whole cluster |
439 |
|
* are given, according to the cluster multiplicity |
440 |
|
* |
441 |
|
* - if NCOG>0, the number BAD strips is evaluated using NCOG |
442 |
|
* strips, even if they have a negative signal (according to Landi) |
443 |
|
*-------------------------------------------------------------- |
444 |
|
include 'commontracker.f' |
445 |
|
include 'level1.f' |
446 |
|
include 'calib.f' |
447 |
|
|
448 |
|
integer nbad |
449 |
|
nbad = 0 |
450 |
|
|
451 |
|
if (ncog.gt.0) then |
452 |
|
|
453 |
|
* --> signal of the central strip |
454 |
|
sc = CLSIGNAL(INDMAX(ic)) !center |
455 |
|
* signal of adjacent strips |
456 |
|
sl1 = -100000 !left 1 |
457 |
|
if( |
458 |
|
$ (INDMAX(ic)-1).ge.INDSTART(ic) |
459 |
|
$ ) |
460 |
|
$ sl1 = CLSIGNAL(INDMAX(ic)-1) |
461 |
|
|
462 |
|
sl2 = -100000 !left 2 |
463 |
|
if( |
464 |
|
$ (INDMAX(ic)-2).ge.INDSTART(ic) |
465 |
|
$ ) |
466 |
|
$ sl2 = CLSIGNAL(INDMAX(ic)-2) |
467 |
|
|
468 |
|
sr1 = -100000 !right 1 |
469 |
|
if( |
470 |
|
$ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1)) |
471 |
|
$ .or. |
472 |
|
$ (ic.eq.NCLSTR1.and.(INDMAX(ic)+1).le.TOTCLLENGTH) |
473 |
|
$ ) |
474 |
|
$ sr1 = CLSIGNAL(INDMAX(ic)+1) |
475 |
|
|
476 |
|
sr2 = -100000 !right 2 |
477 |
|
if( |
478 |
|
$ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1)) |
479 |
|
$ .or. |
480 |
|
$ (ic.eq.NCLSTR1.and.(INDMAX(ic)+2).le.TOTCLLENGTH) |
481 |
|
$ ) |
482 |
|
$ sr2 = CLSIGNAL(INDMAX(ic)+2) |
483 |
|
|
484 |
|
if(ncog.ge.1)nbad = nbad+1-CLBAD(INDMAX(ic)) |
485 |
|
|
486 |
|
if(ncog.ge.2)then |
487 |
|
if(sl1.gt.sr1.and.(INDMAX(ic)-1).ge.1)then |
488 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)-1) |
489 |
|
elseif(sl1.le.sr1.and.(INDMAX(ic)+1).le.NCLSTR1)then |
490 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)+1) |
491 |
|
endif |
492 |
|
endif |
493 |
|
|
494 |
|
if(ncog.ge.3)then |
495 |
|
if(sl1.gt.sr1.and.(INDMAX(ic)+1).le.NCLSTR1)then |
496 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)+1) |
497 |
|
elseif(sl1.le.sr1.and.(INDMAX(ic)-1).ge.1)then |
498 |
|
c if(INDMAX(ic)-1.eq.0) |
499 |
|
c $ print*,' ======= ',sl2,sl1,sc,sr1,sr2 |
500 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)-1) |
501 |
|
endif |
502 |
|
endif |
503 |
|
|
504 |
|
if(ncog.ge.4)then |
505 |
|
if(sl2.gt.sr2.and.(INDMAX(ic)-2).ge.1)then |
506 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)-2) |
507 |
|
elseif(sl2.le.sr2.and.(INDMAX(ic)+2).le.NCLSTR1)then |
508 |
|
nbad=nbad+1-CLBAD(INDMAX(ic)+2) |
509 |
|
endif |
510 |
|
endif |
511 |
|
|
512 |
|
if(ncog.ge.5)then |
513 |
|
print*,'function CLBAD(NCOG,IC) ==> WARNING!! NCOG=',NCOG |
514 |
|
$ ,' not implemented' |
515 |
|
endif |
516 |
|
|
517 |
|
elseif(ncog.eq.0)then |
518 |
|
* ========================= |
519 |
|
* COG computation |
520 |
|
* ========================= |
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
iv=VIEW(ic) |
525 |
|
if(mod(iv,2).eq.1)incut=incuty |
526 |
|
if(mod(iv,2).eq.0)incut=incutx |
527 |
|
|
528 |
|
istart = INDSTART(IC) |
529 |
|
istop = TOTCLLENGTH |
530 |
|
if(ic.lt.NCLSTR1)istop=INDSTART(IC+1)-1 |
531 |
|
nbad = 0 |
532 |
|
c$$$ do i=istart,istop |
533 |
|
c$$$ cut = incut*CLSIGMA(i) |
534 |
|
c$$$ if(CLSIGNAL(i).ge.cut)nbad = nbad +1 -CLBAD(i) |
535 |
|
c$$$ enddo |
536 |
|
do i = INDMAX(IC),istart,-1 |
537 |
|
cut = incut*CLSIGMA(i) |
538 |
|
if(CLSIGNAL(i).ge.cut)then |
539 |
|
nbad = nbad +1 -CLBAD(i) |
540 |
|
else |
541 |
|
goto 10 |
542 |
|
endif |
543 |
|
enddo |
544 |
|
10 continue |
545 |
|
do i = INDMAX(IC)+1,istop |
546 |
|
cut = incut*CLSIGMA(i) |
547 |
|
if(CLSIGNAL(i).ge.cut)then |
548 |
|
nbad = nbad +1 -CLBAD(i) |
549 |
|
else |
550 |
|
goto 20 |
551 |
|
endif |
552 |
|
enddo |
553 |
|
20 continue |
554 |
|
|
555 |
|
else |
556 |
|
|
557 |
|
print*,'function CLBAD(NCOG,IC) ==> WARNING!! NCOG=',NCOG |
558 |
|
$ ,' not implemented' |
559 |
|
|
560 |
|
|
561 |
|
endif |
562 |
|
|
563 |
|
nbadstrips = nbad |
564 |
|
|
565 |
|
return |
566 |
|
end |