C Program: MC_CER_V1 C Authors: David Christian C Erik Gottschalk C Date: 19. November 1993 C C ------------------------------------------------------------------------- SUBROUTINE MC_CER_V1(IOT,DATFIL) save CHARACTER*(*) DATFIL C ------------------------------------------------------------------------- C C Description: C ============ C This subroutine predicts the number of photoelectrons for each C cell in a Cherenkov counter. The ADC and TDC values for cells C that have data are inserted in the MC_RAW common block. C C Arguments: C ========== C IOT - Initialization, Operation, Termination C DATFIL - Cherenkov data file for Initialization phase C C Implicit inputs, outputs, side effects: C ======================================= C Calls: MC_TRACK3 C CMC_PREDICT C C Revisions: C ========== C Date Who Description C -------- --- --------------------------------------------------- C 4/27/92 EEG Original version of MC_CER_V1. C C 11/19/93 EEG Included offset for NTS data block. C C 2/16/94 DCC Changed dimension of CON_FILES from 5 to 6 C to allow for CMC_PEBEQ1(96) to be read in. C C External Specifications: C ======================== INCLUDE 'CMC_COMMONS.FOR' INCLUDE 'MC_CONFIG.FOR' INCLUDE 'MC_EVTPAR2.FOR' INCLUDE 'MC_IO.FOR' INCLUDE 'MC_RAW.FOR' INCLUDE 'COM_INTAPE.FOR' C C LOCAL Specifications: C ===================== CHARACTER*3 C_FISH CHARACTER*70 CON_FILES(6) INTEGER*4 MCRAWM_MESS/10/ CHARACTER*8 DISENA(2)/'Disabled','Enabled '/ REAL*8 ZP8 REAL*8 ZERO/0.0/ C C COMMON Specifications: C ====================== COMMON/SCRATCH/I,J,K,ZP,ICMC_ADC C C ------------------------------------------------------------------------- C IF(IOT)100,200,900 C C ----- Initialization ----- 100 I0=MC_OFF(MC_SEG) ! Pointer to MC_MEM array OPEN(UNIT=LUNDAT,FILE=DATFIL,STATUS='OLD') C C Load MC_MEM array with values found in the Cherenkov data file. READ(LUNDAT,1098)ZP MC_MEM(I0)=ZP ! Z position of detector element READ(LUNDAT,1100)MC_MEM(I0+1) ! Detector ID for Cherenkov counter READ(LUNDAT,1100)MC_MEM(I0+2) ! Counter offset in NTS data block DO 105 I=1,6 READ(LUNDAT,1102)CON_FILES(I) ! Filenames for constants files 105 CONTINUE READ(LUNDAT,1104)C_FISH ! Enable Poisson smearing? MC_MEM(I0+3)=0 IF(C_FISH.EQ.'ON')MC_MEM(I0+3)=1 READ(LUNDAT,1106)ICMC_SEED ! Seed for random numbers in CMC_FISH 1098 FORMAT(///60X,F12.4) 1100 FORMAT(60X,F10.4) 1102 FORMAT(60X,A70) 1104 FORMAT(60X,A2) 1106 FORMAT(60X,I10) CLOSE(UNIT=LUNDAT) C WRITE(LUN6,1700)DATFIL WRITE(LUN6,1705)DISENA(MC_MEM(I0+3)+1) 1700 FORMAT(//5X,'For the Cherenkov file ',A/) 1705 FORMAT(5X,'Poisson smearing for Cherenkov ADCs: ',A8) I0=I0+4 C C Call initialization routine for constants files. CALL CMC_READ_DCC(CON_FILES) C MC_SEG=MC_SEG+1 ! Increment MC_SEG for next detector routine MC_OFF(MC_SEG)=I0 ! Save MC_MEM pointer for next routine RETURN C C ----- Operation ----- 200 I0=MC_OFF(MC_SEG) C If the current z position is less than the z position of the C detector element, then call the track stepping subroutine. ZP8=DBLE(MC_MEM(I0)) ! Z position of detector element IF(MC_ZIC(2).LT.ZP8)CALL MC_TRACK3(ZP8,ZERO) ! Use default step size. C C Predict the number of photoelectrons for each Cherenkov cell. CALL CMC_PREDICT C IF((MCRAWI+290).LE.MCRAWM)GOTO 305 C Exceeded MCRAW limit of (96 counters * 3 words = 288 + 2) MCRAWM_MESS=MCRAWM_MESS-1 IF(MCRAWM_MESS.LT.0)GOTO 800 WRITE(LUN6,3050)NEVUL 3050 FORMAT(//' MC_CER_V1: Event',Z9.8,' could exceed MCRAWM limit!'/) GOTO 800 C 305 MCRAW(MCRAWI)=MC_MEM(I0+1) ! MC_RAW detector ID MCRAW(MCRAWI+1)=0 ! Initialize number of data words C Loop over Cherenkov cells to find cells with data. DO 310 I=1,96 IF(CMC_ADC(I).LE.0.5)GOTO 310 ! Less than 0.5? IF(CMC_ADC(I).GE.350.)GOTO 310 ! skip if flagged ICMC_ADC=INT(CMC_ADC(I)+0.5) ! No: Integer ADC value ICMC_ADC=MIN0(127,MAX0(1,ICMC_ADC)) ! Range: 1-127 MCRAW(MCRAWI+MCRAW(MCRAWI+1)+2)=I+MC_MEM(I0+2)! Cherenkov cell number MCRAW(MCRAWI+MCRAW(MCRAWI+1)+3)=ICMC_ADC ! ADC value MCRAW(MCRAWI+MCRAW(MCRAWI+1)+4)=64 ! TDC value MCRAW(MCRAWI+1)=MCRAW(MCRAWI+1)+3 ! Add 3 words 310 CONTINUE MCRAWI=MCRAWI+MCRAW(MCRAWI+1)+2 C 800 MC_SEG=MC_SEG+1 ! Increment MC_SEG for next detector routine RETURN C C ----- Termination ----- 900 MC_SEG=MC_SEG+1 ! Increment MC_SEG for next detector routine RETURN END