Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:34

0001 ************************************************************************
0002 *                                                                      *
0003       SUBROUTINE KI_BHG_INIT(seed)      !      by droll (30/05/05)           *
0004 *                                                                      *
0005 *                initialize beam halo generator                        *
0006 *                                                                      *
0007 ************************************************************************
0008 
0009       IMPLICIT NONE
0010 cc #include "kine/kicdes/pythia.inc"
0011 cc #include "kine/kicdes/bhgrhists.inc"
0012 cc #include "kine/kicdes/bhgcons.inc"
0013 cc #include "kine/kicdes/bhgctrl.inc"
0014 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgcons.inc"
0015 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgctrl.inc"
0016 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgrhists.inc"
0017 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgp_info.inc"
0018       INTEGER SEED,K1,K2
0019 
0020       INTEGER NI,M15_ID,IORIG,KORIG,COUNT,ID_PDG
0021       REAL    EF,W,X,Y,DCX,DCY,TOFF,PRIMEHITZ,
0022      &        ZORIG,XORIG,YORIG,EORIG,WORIG
0023 
0024       INTEGER IDCONVERT(40)
0025       DATA IDCONVERT/2212,2112,211,-211,321,-321,-13,13,22,11,-11,
0026      &              -2212,111,1,6,-104,-102,14,-14,12,-12,130,310,
0027      &               311,-311,3122,-3122,3222,3212,3112,-2112,3322,
0028      &               3312,3334,5112,5212,5222,-3322,-5132,-5332/
0029 
0030 
0031       PRINT*,' '
0032       PRINT*,'*********************************************************'
0033       PRINT*,'*********************************************************'
0034       PRINT*,'***                                                   ***'
0035       PRINT*,'***  B E A M   H A L O   G E N E R A T O R  (vers.2)  ***'
0036       PRINT*,'***                                                   ***'
0037       PRINT*,'*********************************************************'
0038       PRINT*,'*********************************************************'
0039       PRINT*,' '
0040 
0041       ! check some input parameters
0042       IF (GENMOD.LT.0.OR.GENMOD.GT.3) THEN
0043         PRINT*,'bad choice of parameter GENMOD'
0044         STOP
0045       ENDIF
0046       IF (LHC_B1.NE.0.AND.LHC_B1.NE.1) THEN
0047         PRINT*,'bad choice of parameter LHC_B1'
0048         STOP
0049       ENDIF
0050       IF (LHC_B2.NE.0.AND.LHC_B2.NE.1) THEN
0051         PRINT*,'bad choice of parameter LHC_B2'
0052         STOP
0053       ENDIF
0054       IF (IW_MUO.NE.1.AND.IW_HAD.NE.1) THEN
0055         PRINT*,'bad choice of parameters IW_MUO and IW_HAD'
0056         STOP
0057       ENDIF
0058 
0059       ! initialize random packages
0060 c      SEED = MRPY(1)
0061       k1 = 0
0062       k2 = 0
0063       CALL RLUXGO(4,SEED,K1,K2)
0064       CALL RM48IN(SEED,0,0)
0065 
0066       IF (GENMOD.EQ.1) THEN
0067         CALL F66MUP  ! mu+ histos
0068         CALL RNHPRE(H01MUP,N_BINS)
0069         CALL RNHPRE(H11MUP,N_BINS)
0070         CALL RNHPRE(H12MUP,N_BINS)
0071         CALL RNHPRE(H13MUP,N_BINS)
0072         CALL RNHPRE(H14MUP,N_BINS)
0073         CALL RNHPRE(H15MUP,N_BINS)
0074         CALL RNHPRE(H16MUP,N_BINS)
0075         CALL RNHPRE(H17MUP,N_BINS)
0076         CALL RNHPRE(H18MUP,N_BINS)
0077         CALL RNHPRE(H21MUP,N_BINS)
0078         CALL RNHPRE(H22MUP,N_BINS)
0079         CALL RNHPRE(H23MUP,N_BINS)
0080         CALL RNHPRE(H24MUP,N_BINS)
0081         CALL RNHPRE(H25MUP,N_BINS)
0082         CALL RNHPRE(H26MUP,N_BINS)
0083         CALL RNHPRE(H27MUP,N_BINS)
0084         CALL RNHPRE(H28MUP,N_BINS)
0085         CALL RNHPRE(H31MUP,N_BINS)
0086         CALL RNHPRE(H32MUP,N_BINS)
0087         CALL RNHPRE(H33MUP,N_BINS)
0088         CALL RNHPRE(H34MUP,N_BINS)
0089         CALL RNHPRE(H35MUP,N_BINS)
0090         CALL RNHPRE(H36MUP,N_BINS)
0091         CALL RNHPRE(H37MUP,N_BINS)
0092         CALL RNHPRE(H38MUP,N_BINS)
0093         CALL RNHPRE(H41MUP,N_BINS)
0094         CALL RNHPRE(H42MUP,N_BINS)
0095         CALL RNHPRE(H43MUP,N_BINS)
0096         CALL RNHPRE(H44MUP,N_BINS)
0097         CALL RNHPRE(H45MUP,N_BINS)
0098         CALL RNHPRE(H46MUP,N_BINS)
0099         CALL RNHPRE(H47MUP,N_BINS)
0100         CALL RNHPRE(H48MUP,N_BINS)
0101         CALL F66MUM  ! mu- histos
0102         CALL RNHPRE(H01MUM,N_BINS)
0103         CALL RNHPRE(H11MUM,N_BINS)
0104         CALL RNHPRE(H12MUM,N_BINS)
0105         CALL RNHPRE(H13MUM,N_BINS)
0106         CALL RNHPRE(H14MUM,N_BINS)
0107         CALL RNHPRE(H15MUM,N_BINS)
0108         CALL RNHPRE(H16MUM,N_BINS)
0109         CALL RNHPRE(H17MUM,N_BINS)
0110         CALL RNHPRE(H18MUM,N_BINS)
0111         CALL RNHPRE(H21MUM,N_BINS)
0112         CALL RNHPRE(H22MUM,N_BINS)
0113         CALL RNHPRE(H23MUM,N_BINS)
0114         CALL RNHPRE(H24MUM,N_BINS)
0115         CALL RNHPRE(H25MUM,N_BINS)
0116         CALL RNHPRE(H26MUM,N_BINS)
0117         CALL RNHPRE(H27MUM,N_BINS)
0118         CALL RNHPRE(H28MUM,N_BINS)
0119         CALL RNHPRE(H31MUM,N_BINS)
0120         CALL RNHPRE(H32MUM,N_BINS)
0121         CALL RNHPRE(H33MUM,N_BINS)
0122         CALL RNHPRE(H34MUM,N_BINS)
0123         CALL RNHPRE(H35MUM,N_BINS)
0124         CALL RNHPRE(H36MUM,N_BINS)
0125         CALL RNHPRE(H37MUM,N_BINS)
0126         CALL RNHPRE(H38MUM,N_BINS)
0127         CALL RNHPRE(H41MUM,N_BINS)
0128         CALL RNHPRE(H42MUM,N_BINS)
0129         CALL RNHPRE(H43MUM,N_BINS)
0130         CALL RNHPRE(H44MUM,N_BINS)
0131         CALL RNHPRE(H45MUM,N_BINS)
0132         CALL RNHPRE(H46MUM,N_BINS)
0133         CALL RNHPRE(H47MUM,N_BINS)
0134         CALL RNHPRE(H48MUM,N_BINS)
0135         CALL F66PIP  ! pi+ histos
0136         CALL RNHPRE(H01PIP,N_BINS)
0137         CALL RNHPRE(H11PIP,N_BINS)
0138         CALL RNHPRE(H12PIP,N_BINS)
0139         CALL RNHPRE(H13PIP,N_BINS)
0140         CALL RNHPRE(H14PIP,N_BINS)
0141         CALL RNHPRE(H15PIP,N_BINS)
0142         CALL RNHPRE(H16PIP,N_BINS)
0143         CALL RNHPRE(H17PIP,N_BINS)
0144         CALL RNHPRE(H18PIP,N_BINS)
0145         CALL RNHPRE(H21PIP,N_BINS)
0146         CALL RNHPRE(H22PIP,N_BINS)
0147         CALL RNHPRE(H23PIP,N_BINS)
0148         CALL RNHPRE(H24PIP,N_BINS)
0149         CALL RNHPRE(H25PIP,N_BINS)
0150         CALL RNHPRE(H26PIP,N_BINS)
0151         CALL RNHPRE(H27PIP,N_BINS)
0152         CALL RNHPRE(H28PIP,N_BINS)
0153         CALL RNHPRE(H31PIP,N_BINS)
0154         CALL RNHPRE(H32PIP,N_BINS)
0155         CALL RNHPRE(H33PIP,N_BINS)
0156         CALL RNHPRE(H34PIP,N_BINS)
0157         CALL RNHPRE(H35PIP,N_BINS)
0158         CALL RNHPRE(H36PIP,N_BINS)
0159         CALL RNHPRE(H37PIP,N_BINS)
0160         CALL RNHPRE(H38PIP,N_BINS)
0161         CALL RNHPRE(H41PIP,N_BINS)
0162         CALL RNHPRE(H42PIP,N_BINS)
0163         CALL RNHPRE(H43PIP,N_BINS)
0164         CALL RNHPRE(H44PIP,N_BINS)
0165         CALL RNHPRE(H45PIP,N_BINS)
0166         CALL RNHPRE(H46PIP,N_BINS)
0167         CALL RNHPRE(H47PIP,N_BINS)
0168         CALL RNHPRE(H48PIP,N_BINS)
0169         CALL F66PIM  ! pi- histos
0170         CALL RNHPRE(H01PIM,N_BINS)
0171         CALL RNHPRE(H11PIM,N_BINS)
0172         CALL RNHPRE(H12PIM,N_BINS)
0173         CALL RNHPRE(H13PIM,N_BINS)
0174         CALL RNHPRE(H14PIM,N_BINS)
0175         CALL RNHPRE(H15PIM,N_BINS)
0176         CALL RNHPRE(H16PIM,N_BINS)
0177         CALL RNHPRE(H17PIM,N_BINS)
0178         CALL RNHPRE(H18PIM,N_BINS)
0179         CALL RNHPRE(H21PIM,N_BINS)
0180         CALL RNHPRE(H22PIM,N_BINS)
0181         CALL RNHPRE(H23PIM,N_BINS)
0182         CALL RNHPRE(H24PIM,N_BINS)
0183         CALL RNHPRE(H25PIM,N_BINS)
0184         CALL RNHPRE(H26PIM,N_BINS)
0185         CALL RNHPRE(H27PIM,N_BINS)
0186         CALL RNHPRE(H28PIM,N_BINS)
0187         CALL RNHPRE(H31PIM,N_BINS)
0188         CALL RNHPRE(H32PIM,N_BINS)
0189         CALL RNHPRE(H33PIM,N_BINS)
0190         CALL RNHPRE(H34PIM,N_BINS)
0191         CALL RNHPRE(H35PIM,N_BINS)
0192         CALL RNHPRE(H36PIM,N_BINS)
0193         CALL RNHPRE(H37PIM,N_BINS)
0194         CALL RNHPRE(H38PIM,N_BINS)
0195         CALL RNHPRE(H41PIM,N_BINS)
0196         CALL RNHPRE(H42PIM,N_BINS)
0197         CALL RNHPRE(H43PIM,N_BINS)
0198         CALL RNHPRE(H44PIM,N_BINS)
0199         CALL RNHPRE(H45PIM,N_BINS)
0200         CALL RNHPRE(H46PIM,N_BINS)
0201         CALL RNHPRE(H47PIM,N_BINS)
0202         CALL RNHPRE(H48PIM,N_BINS)
0203         CALL F66KAP  ! K+ histos
0204         CALL RNHPRE(H01KAP,N_BINS)
0205         CALL RNHPRE(H11KAP,N_BINS)
0206         CALL RNHPRE(H12KAP,N_BINS)
0207         CALL RNHPRE(H13KAP,N_BINS)
0208         CALL RNHPRE(H14KAP,N_BINS)
0209         CALL RNHPRE(H15KAP,N_BINS)
0210         CALL RNHPRE(H16KAP,N_BINS)
0211         CALL RNHPRE(H17KAP,N_BINS)
0212         CALL RNHPRE(H18KAP,N_BINS)
0213         CALL RNHPRE(H21KAP,N_BINS)
0214         CALL RNHPRE(H22KAP,N_BINS)
0215         CALL RNHPRE(H23KAP,N_BINS)
0216         CALL RNHPRE(H24KAP,N_BINS)
0217         CALL RNHPRE(H25KAP,N_BINS)
0218         CALL RNHPRE(H26KAP,N_BINS)
0219         CALL RNHPRE(H27KAP,N_BINS)
0220         CALL RNHPRE(H28KAP,N_BINS)
0221         CALL RNHPRE(H31KAP,N_BINS)
0222         CALL RNHPRE(H32KAP,N_BINS)
0223         CALL RNHPRE(H33KAP,N_BINS)
0224         CALL RNHPRE(H34KAP,N_BINS)
0225         CALL RNHPRE(H35KAP,N_BINS)
0226         CALL RNHPRE(H36KAP,N_BINS)
0227         CALL RNHPRE(H37KAP,N_BINS)
0228         CALL RNHPRE(H38KAP,N_BINS)
0229         CALL RNHPRE(H41KAP,N_BINS)
0230         CALL RNHPRE(H42KAP,N_BINS)
0231         CALL RNHPRE(H43KAP,N_BINS)
0232         CALL RNHPRE(H44KAP,N_BINS)
0233         CALL RNHPRE(H45KAP,N_BINS)
0234         CALL RNHPRE(H46KAP,N_BINS)
0235         CALL RNHPRE(H47KAP,N_BINS)
0236         CALL RNHPRE(H48KAP,N_BINS)
0237         CALL F66KAM  ! K- histos
0238         CALL RNHPRE(H01KAM,N_BINS)
0239         CALL RNHPRE(H11KAM,N_BINS)
0240         CALL RNHPRE(H12KAM,N_BINS)
0241         CALL RNHPRE(H13KAM,N_BINS)
0242         CALL RNHPRE(H14KAM,N_BINS)
0243         CALL RNHPRE(H15KAM,N_BINS)
0244         CALL RNHPRE(H16KAM,N_BINS)
0245         CALL RNHPRE(H17KAM,N_BINS)
0246         CALL RNHPRE(H18KAM,N_BINS)
0247         CALL RNHPRE(H21KAM,N_BINS)
0248         CALL RNHPRE(H22KAM,N_BINS)
0249         CALL RNHPRE(H23KAM,N_BINS)
0250         CALL RNHPRE(H24KAM,N_BINS)
0251         CALL RNHPRE(H25KAM,N_BINS)
0252         CALL RNHPRE(H26KAM,N_BINS)
0253         CALL RNHPRE(H27KAM,N_BINS)
0254         CALL RNHPRE(H28KAM,N_BINS)
0255         CALL RNHPRE(H31KAM,N_BINS)
0256         CALL RNHPRE(H32KAM,N_BINS)
0257         CALL RNHPRE(H33KAM,N_BINS)
0258         CALL RNHPRE(H34KAM,N_BINS)
0259         CALL RNHPRE(H35KAM,N_BINS)
0260         CALL RNHPRE(H36KAM,N_BINS)
0261         CALL RNHPRE(H37KAM,N_BINS)
0262         CALL RNHPRE(H38KAM,N_BINS)
0263         CALL RNHPRE(H41KAM,N_BINS)
0264         CALL RNHPRE(H42KAM,N_BINS)
0265         CALL RNHPRE(H43KAM,N_BINS)
0266         CALL RNHPRE(H44KAM,N_BINS)
0267         CALL RNHPRE(H45KAM,N_BINS)
0268         CALL RNHPRE(H46KAM,N_BINS)
0269         CALL RNHPRE(H47KAM,N_BINS)
0270         CALL RNHPRE(H48KAM,N_BINS)
0271         CALL F66PRO  ! p+ histos
0272         CALL RNHPRE(H01PRO,N_BINS)
0273         CALL RNHPRE(H11PRO,N_BINS)
0274         CALL RNHPRE(H12PRO,N_BINS)
0275         CALL RNHPRE(H13PRO,N_BINS)
0276         CALL RNHPRE(H14PRO,N_BINS)
0277         CALL RNHPRE(H15PRO,N_BINS)
0278         CALL RNHPRE(H16PRO,N_BINS)
0279         CALL RNHPRE(H17PRO,N_BINS)
0280         CALL RNHPRE(H18PRO,N_BINS)
0281         CALL RNHPRE(H21PRO,N_BINS)
0282         CALL RNHPRE(H22PRO,N_BINS)
0283         CALL RNHPRE(H23PRO,N_BINS)
0284         CALL RNHPRE(H24PRO,N_BINS)
0285         CALL RNHPRE(H25PRO,N_BINS)
0286         CALL RNHPRE(H26PRO,N_BINS)
0287         CALL RNHPRE(H27PRO,N_BINS)
0288         CALL RNHPRE(H28PRO,N_BINS)
0289         CALL RNHPRE(H31PRO,N_BINS)
0290         CALL RNHPRE(H32PRO,N_BINS)
0291         CALL RNHPRE(H33PRO,N_BINS)
0292         CALL RNHPRE(H34PRO,N_BINS)
0293         CALL RNHPRE(H35PRO,N_BINS)
0294         CALL RNHPRE(H36PRO,N_BINS)
0295         CALL RNHPRE(H37PRO,N_BINS)
0296         CALL RNHPRE(H38PRO,N_BINS)
0297         CALL RNHPRE(H41PRO,N_BINS)
0298         CALL RNHPRE(H42PRO,N_BINS)
0299         CALL RNHPRE(H43PRO,N_BINS)
0300         CALL RNHPRE(H44PRO,N_BINS)
0301         CALL RNHPRE(H45PRO,N_BINS)
0302         CALL RNHPRE(H46PRO,N_BINS)
0303         CALL RNHPRE(H47PRO,N_BINS)
0304         CALL RNHPRE(H48PRO,N_BINS)
0305         CALL F66NEU  ! n0 histos
0306         CALL RNHPRE(H01NEU,N_BINS)
0307         CALL RNHPRE(H11NEU,N_BINS)
0308         CALL RNHPRE(H12NEU,N_BINS)
0309         CALL RNHPRE(H13NEU,N_BINS)
0310         CALL RNHPRE(H14NEU,N_BINS)
0311         CALL RNHPRE(H15NEU,N_BINS)
0312         CALL RNHPRE(H16NEU,N_BINS)
0313         CALL RNHPRE(H17NEU,N_BINS)
0314         CALL RNHPRE(H18NEU,N_BINS)
0315         CALL RNHPRE(H21NEU,N_BINS)
0316         CALL RNHPRE(H22NEU,N_BINS)
0317         CALL RNHPRE(H23NEU,N_BINS)
0318         CALL RNHPRE(H24NEU,N_BINS)
0319         CALL RNHPRE(H25NEU,N_BINS)
0320         CALL RNHPRE(H26NEU,N_BINS)
0321         CALL RNHPRE(H27NEU,N_BINS)
0322         CALL RNHPRE(H28NEU,N_BINS)
0323         CALL RNHPRE(H31NEU,N_BINS)
0324         CALL RNHPRE(H32NEU,N_BINS)
0325         CALL RNHPRE(H33NEU,N_BINS)
0326         CALL RNHPRE(H34NEU,N_BINS)
0327         CALL RNHPRE(H35NEU,N_BINS)
0328         CALL RNHPRE(H36NEU,N_BINS)
0329         CALL RNHPRE(H37NEU,N_BINS)
0330         CALL RNHPRE(H38NEU,N_BINS)
0331         CALL RNHPRE(H41NEU,N_BINS)
0332         CALL RNHPRE(H42NEU,N_BINS)
0333         CALL RNHPRE(H43NEU,N_BINS)
0334         CALL RNHPRE(H44NEU,N_BINS)
0335         CALL RNHPRE(H45NEU,N_BINS)
0336         CALL RNHPRE(H46NEU,N_BINS)
0337         CALL RNHPRE(H47NEU,N_BINS)
0338         CALL RNHPRE(H48NEU,N_BINS)
0339       ENDIF
0340 
0341       ! initialize counters, limits, rates, ratios
0342       NP_GEN = 0.
0343       N_READ = 0.
0344       CALL INILIM
0345       CALL INIRES
0346       CALL INIROS
0347 
0348       ! open input file
0349       IF (GENMOD.EQ.2) OPEN(22,FILE=F1NAME,STATUS='UNKNOWN')
0350 
0351       IF (GENMOD.EQ.3) THEN
0352          MAXLINE=0
0353          OPEN(22,FILE=G3FNAME,STATUS='UNKNOWN')
0354          READ(22,*) MAXLINE
0355          NPRIME = 0.0
0356          NSTACK = 0.0
0357          COUNT = 0
0358          DO WHILE( COUNT .LT. OFFSET )
0359             READ(22,*) NI,M15_ID,EF,W,X,Y,DCX,DCY,TOFF,PRIMEHITZ,
0360      &                 ZORIG,XORIG,YORIG,EORIG,WORIG,IORIG,KORIG
0361 
0362             ID_PDG = IDCONVERT(M15_ID)
0363             IF (IW_MUO.EQ.1) THEN
0364                IF (EF.GT.EMUMIN.AND.EF.LT.EMUMAX) THEN
0365                   IF (ID_PDG.EQ. -13) COUNT = COUNT + 1 ! accept mu+
0366                   IF (ID_PDG.EQ.  13) COUNT = COUNT + 1 ! accept mu-
0367                ENDIF
0368             ENDIF
0369             IF (IW_HAD.EQ.1) THEN
0370                IF (EF.GT.EPIMIN.AND.EF.LT.EPIMAX) THEN
0371                   IF (ID_PDG.EQ. 211) COUNT = COUNT + 1 ! accept pi+
0372                   IF (ID_PDG.EQ.-211) COUNT = COUNT + 1 ! accept pi-
0373                ENDIF
0374                IF (EF.GT.EKAMIN.AND.EF.LT.EKAMAX) THEN
0375                   IF (ID_PDG.EQ. 321) COUNT = COUNT + 1 ! accept K+
0376                   IF (ID_PDG.EQ.-321) COUNT = COUNT + 1 ! accept K-
0377                ENDIF
0378                IF (EF.GT.EPRMIN.AND.EF.LT.EPRMAX) THEN
0379                   IF (ID_PDG.EQ.2212) COUNT = COUNT + 1 ! accept p+
0380                ENDIF
0381                IF (EF.GT.ENEMIN.AND.EF.LT.ENEMAX) THEN
0382                   IF (ID_PDG.EQ.2112) COUNT = COUNT + 1 ! accept n0
0383                ENDIF
0384             ENDIF
0385          ENDDO
0386          
0387       ENDIF
0388 
0389 
0390       RETURN
0391 
0392       END                                                                     
0393 
0394 ************************************************************************
0395       SUBROUTINE INILIM      !      by droll (01/06/05)                *
0396 *                calculate limits for kinetic E for each particle type *
0397 ************************************************************************
0398 
0399       IMPLICIT NONE
0400 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgcons.inc"
0401 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgp_info.inc"
0402 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgctrl.inc"
0403 
0404       ! ranges of kinetic energies
0405       EMUMIN = MAX(EG_MIN-M_MUON,1.)
0406       EMUMAX = MIN(EG_MAX-M_MUON,E_BEAM-M_MUON)
0407       EPIMIN = MAX(EG_MIN-M_PION,1.)
0408       EPIMAX = MIN(EG_MAX-M_PION,E_BEAM-M_PION)
0409       EKAMIN = MAX(EG_MIN-M_KAON,1.)
0410       EKAMAX = MIN(EG_MAX-M_KAON,E_BEAM-M_KAON)
0411       EPRMIN = MAX(EG_MIN-M_PROT,1.)
0412       EPRMAX = MIN(EG_MAX-M_PROT,E_BEAM-M_PROT)
0413       ENEMIN = MAX(EG_MIN-M_NEUT,1.)
0414       ENEMAX = MIN(EG_MAX-M_NEUT,E_BEAM-M_NEUT)
0415 
0416       ! for max.E >= E_BEAM allow slighly higher energies (e.g. off-beam protons)
0417       IF ((E_BEAM/EG_MAX).LT.1.0002) THEN
0418         EMUMAX = 1.0002*E_BEAM - M_MUON
0419         EPIMAX = 1.0002*E_BEAM - M_PION
0420         EKAMAX = 1.0002*E_BEAM - M_KAON
0421         EPRMAX = 1.0002*E_BEAM - M_PROT
0422         ENEMAX = 1.0002*E_BEAM - M_NEUT
0423       ENDIF
0424 
0425       RETURN
0426       END
0427 
0428 ************************************************************************
0429       SUBROUTINE INIRES      !      by droll (01/06/05)                *
0430 *                initialize/calculate rates for each particle type     *
0431 ************************************************************************
0432 
0433       IMPLICIT NONE
0434 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgp_info.inc"
0435 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgctrl.inc"
0436       REAL GR_MUP,GR_MUM,GR_PIP,GR_PIM,GR_KAP,GR_KAM,GR_PRO,GR_NEU
0437 
0438       ! initialize rates for each particle type
0439       R_MU_P = 0.
0440       R_MU_M = 0.
0441       R_PI_P = 0.
0442       R_PI_M = 0.
0443       R_KA_P = 0.
0444       R_KA_M = 0.
0445       R_PROT = 0.
0446       R_NEUT = 0.
0447       IF (GENMOD.LE.1.AND.IW_MUO.EQ.1) THEN
0448         R_MU_P = GR_MUP()
0449         R_MU_M = GR_MUM()
0450       ENDIF
0451       IF (GENMOD.LE.1.AND.IW_HAD.EQ.1) THEN
0452         R_PI_P = GR_PIP()
0453         R_PI_M = GR_PIM()
0454         R_KA_P = GR_KAP()
0455         R_KA_M = GR_KAM()
0456         R_PROT = GR_PRO()
0457         R_NEUT = GR_NEU()
0458       ENDIF
0459 
0460       RETURN
0461       END
0462 
0463 ************************************************************************
0464       SUBROUTINE INIROS      !      by droll (01/06/05)                *
0465 *                calculate ratios of rates for each particle type      *
0466 ************************************************************************
0467 
0468       IMPLICIT NONE
0469 #include "GeneratorInterface/BeamHaloGenerator/interface/bhgp_info.inc"
0470       DOUBLE PRECISION SRATES
0471 
0472       ! calculate rate fractions for each particle type
0473       SRATES = R_MU_P+R_PI_P+R_KA_P+R_PROT+R_NEUT
0474      &       + R_MU_M+R_PI_M+R_KA_M
0475       FR_MUP = R_MU_P/SRATES
0476       FR_MUM = R_MU_M/SRATES
0477       FR_PIP = R_PI_P/SRATES
0478       FR_PIM = R_PI_M/SRATES
0479       FR_KAP = R_KA_P/SRATES
0480       FR_KAM = R_KA_M/SRATES
0481       FR_PRO = R_PROT/SRATES
0482       FR_NEU = R_NEUT/SRATES
0483 
0484       RETURN
0485       END