C ============================================== SUBROUTINE BGDFIL(RUN, EVENT, YEAR, REAL_DATA) C ============================================== IMPLICIT NONE #include "zescommon.inc" #include "zestmpcommon.inc" #include "lmeb.inc" #include "partap.inc" REAL UnmEn_pi, UnmEn_k REAL Fetatr, Betatr INTEGER Iflag, BCN, RUN, YEAR, Iok, EVENT, IFL, Ierr INTEGER cleanrho, err_count LOGICAL REAL_DATA DATA err_count / 0 / C --------------- C --- IsItaMu --- C --------------- CALL IsItaMu(Iflag) ZESTMP_muonbit1 = Iflag+1 !!! range 0 - 3 C 17.12.98 AFM: Bug fix. Created muon flag 1 to replace C `bit' which used to be truncated. ZES_MuonF1=ZESTMP_muonbit1 C -------------- C --- MuTrig --- C -------------- IF (REAL_DATA) THEN IFL = 10 ELSE IFL = 20 ENDIF CALL MuTrig(50.,25.,6.,40.,30.,IFL,Iflag) IF (Iflag.eq.50) THEN !!! cosmic event ZESTMP_muonbit2 = 1 ELSEIF (Iflag.eq.55) THEN !!! muon through vertex ZESTMP_muonbit2 = 2 ELSEIF (Iflag.eq.60) THEN !!! beam halo muon ZESTMP_muonbit2 = 3 ELSE ZESTMP_muonbit2 = 0 !!! range 0 - 3 ENDIF C 17.12.98 AFM: Bug fix. Created muon flag 2 to replace C `bit' which used to be truncated. ZES_MuonF2=ZESTMP_muonbit2 C --------------- C --- RmSpark --- C --------------- CALL RmSpark(Iflag) IF (Iflag.eq.-1) THEN !!! energy sum (w/o spark) too small ZESTMP_sparkbit = 1 ELSEIF (Iflag.eq. 1) THEN !!! only one cell w bad channel ZESTMP_sparkbit = 2 ELSE !!! take the event ZESTMP_sparkbit = 0 ENDIF C 17.12.98 AFM: Bug fix. Created spark flag to replace C `bit' which used to be truncated. ZES_SparkF=ZESTMP_sparkbit C -------------------------------------- C --- Get Bunch-type from LMEB bank. --- C -------------------------------------- IF (COUTAB(LMEB).GT.0) THEN CALL FETTAB (LMEB,ID,1) IF (BTEST(LMEB_Enfla,12).AND. & BTEST(LMEB_Enfla,13)) BCN = 3 !!! ep bunches IF (.NOT.BTEST(LMEB_Enfla,12).AND. & BTEST(LMEB_Enfla,13)) BCN = 1 !!! p-pilot bunches IF (BTEST(LMEB_Enfla,12).AND. & .NOT.BTEST(LMEB_Enfla,13)) BCN = 2 !!! e-pilot bunches IF (.NOT.BTEST(LMEB_Enfla,12).AND. & .NOT.BTEST(LMEB_Enfla,13)) BCN = 0 !!! empty bunches ELSE WRITE(*,*) 'WARNING: Error Bunch crossing number !' BCN = 0 ENDIF ZESTMP_BunchNr = BCN !!! range 0 - 3 C ----------------------- C --- Good Track bits --- C ----------------------- CALL NUM_GTRK(Iflag) IF (Iflag.ne.0) THEN ZESTMP_gtrk1 = min(15,ABS(Iflag)) ELSE ZESTMP_gtrk1 = 0 ENDIF C -------------------------------------- C --- check clean QED Compton events --- C -------------------------------------- CALL QEDC(Iflag) ZESTMP_qedcbit = Iflag C -------------------------- C --- EVTAKE and friends --- C -------------------------- CALL EVTAKE(Iflag) IF (Iflag.eq.1) THEN ZESTMP_EVTAKE = 1 !!! accept event ELSE ZESTMP_EVTAKE = 0 !!! reject event ENDIF CALL EXOTAKE(RUN,Iflag,iok) IF (Iok.eq.1) THEN ZESTMP_EXOTAKE = 1 !!! accept event ELSE ZESTMP_EXOTAKE = 0 !!! reject event ENDIF IF (YEAR.eq.1996) THEN CALL XSECTAKE96(RUN,EVENT,Iflag) IF (Iflag.eq.0) THEN ZESTMP_XSECTAKE = 1 !!! accept event ELSE ZESTMP_XSECTAKE = 0 !!! reject event ENDIF ELSE ZESTMP_XSECTAKE = 0 !!! reject event ENDIF C ----------------------------------- C --- lowangle electron selection --- C ----------------------------------- CALL low_angle_electron(ZES_lowangle) !!! lowest angle C (highest Q^2) TLT ele C--------- C VM code C--------- CALL VMsel(ZES_ecorr_si,ZES_Trkmatch_si,ZES_Ecal, > ZES_Mtrknoe_pi,ZES_Mtrknoe_k, > ZES_UnmEn_pi,ZES_UnmEn_k, > ZES_Fetatr,ZES_Betatr,ZES_pt_tr, > ZES_Empz_tr_pi,ZES_Et_tr,ZES_E_tr_pi, > ZES_phi_tr,ierr) C ----------------------------------- C --- clean DIS rho selection bit --- C ----------------------------------- ZESTMP_rhobit = cleanrho(Ierr) RETURN END