import conf
def CSSTF1(NEV,NVAC,L1,DIST1):           
	# IMPLICIT #real*8 (A-H,O-Z)
	# IMPLICIT #integer*8 (I-N)
	def get_globals():
		IONSUM0=conf.IONSUM0
		IFLSUM0=conf.IFLSUM0
		ESTORE0=conf.ESTORE0
		EPHOTON0=conf.EPHOTON0
		DRXE0=conf.DRXE0
		DRYE0=conf.DRYE0
		DRZE0=conf.DRZE0
		DRX0=conf.DRX0
		DRY0=conf.DRY0
		DRZ0=conf.DRZ0
		IONSUM=conf.IONSUM
		IFLSUM=conf.IFLSUM
		ESTORE=conf.ESTORE
		EPHOTON=conf.EPHOTON
		DRXE=conf.DRXE
		DRYE=conf.DRYE
		DRZE=conf.DRZE
		DRX=conf.DRX
		DRY=conf.DRY
		DRZ=conf.DRZ
		IONF1=conf.IONF1
		ESTF1=conf.ESTF1
		X1=conf.X1
		Y1=conf.Y1
		Z1=conf.Z1
		DRXS=conf.DRXS
		DRYS=conf.DRYS
		DRZS=conf.DRZS
		X11=conf.X11
		Y11=conf.Y11
		Z11=conf.Z11
		X01=conf.X01
		Y01=conf.Y01
		Z01=conf.Z01
	get_globals()
	def update_globals():
		conf.IONSUM0=IONSUM0
		conf.IFLSUM0=IFLSUM0
		conf.ESTORE0=ESTORE0
		conf.EPHOTON0=EPHOTON0
		conf.DRXE0=DRXE0
		conf.DRYE0=DRYE0
		conf.DRZE0=DRZE0
		conf.DRX0=DRX0
		conf.DRY0=DRY0
		conf.DRZ0=DRZ0
		conf.IONSUM=IONSUM
		conf.IFLSUM=IFLSUM
		conf.ESTORE=ESTORE
		conf.EPHOTON=EPHOTON
		conf.DRXE=DRXE
		conf.DRYE=DRYE
		conf.DRZE=DRZE
		conf.DRX=DRX
		conf.DRY=DRY
		conf.DRZ=DRZ
		conf.IONF1=IONF1
		conf.ESTF1=ESTF1
		conf.X1=X1
		conf.Y1=Y1
		conf.Z1=Z1
		conf.DRXS=DRXS
		conf.DRYS=DRYS
		conf.DRZS=DRZS
		conf.X11=X11
		conf.Y11=Y11
		conf.Z11=Z11
		conf.X01=X01
		conf.Y01=Y01
		conf.Z01=Z01
	# STORE EVENT DATA FOR FIRST GENERATION FLUORESCENCE
	if(IONSUM[NVAC]> 28) :
		print(' WARNING FIRST GENERATION CONVERTED FLUORESCENCE HAS AN EVENT WITH',I3IONSUM[NVAC],' IONS.','\n COMPTON BRANCH NO=',I3NVAC,'\n PRIMARY INTERACTION NUMBER =',I3NEV)
		sys.exit()
	# endif
	IONF1[NVAC][NEV]=IONSUM[NVAC]
	for J in range(1,IONSUM[NVAC]+1):
		ESTF1[NVAC][J][NEV]=ESTORE[NVAC][J]
		X1[NVAC][J][NEV]=X01[NVAC]+DIST1*DRX0[NVAC][L1]
		Y1[NVAC][J][NEV]=Y01[NVAC]+DIST1*DRY0[NVAC][L1]
		Z1[NVAC][J][NEV]=Z01[NVAC]+DIST1*DRZ0[NVAC][L1]
		X11[NVAC][L1]=X1[NVAC][J][NEV]
		Y11[NVAC][L1]=Y1[NVAC][J][NEV]
		Z11[NVAC][L1]=Z1[NVAC][J][NEV]
		DRXS[NVAC][J][NEV]=DRXE[NVAC][J]
		DRYS[NVAC][J][NEV]=DRYE[NVAC][J]
		DRZS[NVAC][J][NEV]=DRZE[NVAC][J]
	update_globals()
	return
	# end
def CSSTF2(NEV,NVAC,L1,DIST1):               
	# IMPLICIT #real*8 (A-H,O-Z)
	# IMPLICIT #integer*8 (I-N)
	
	# STORE EVENT DATA FOR SECOND GENERATION FLUORESCENCE
	def get_globals():
		IONSUM0=conf.IONSUM0
		IFLSUM0=conf.IFLSUM0
		ESTORE0=conf.ESTORE0
		EPHOTON0=conf.EPHOTON0
		DRXE0=conf.DRXE0
		DRYE0=conf.DRYE0
		DRZE0=conf.DRZE0
		DRX0=conf.DRX0
		DRY0=conf.DRY0
		DRZ0=conf.DRZ0
		IONSUM=conf.IONSUM
		IFLSUM=conf.IFLSUM
		ESTORE=conf.ESTORE
		EPHOTON=conf.EPHOTON
		DRXE=conf.DRXE
		DRYE=conf.DRYE
		DRZE=conf.DRZE
		DRX=conf.DRX
		DRY=conf.DRY
		DRZ=conf.DRZ
		IONF2=conf.IONF2
		ESTF2=conf.ESTF2
		X2=conf.X2
		Y2=conf.Y2
		Z2=conf.Z2
		DRXS=conf.DRXS
		DRYS=conf.DRYS
		DRZS=conf.DRZS
		X21=conf.X21
		Y21=conf.Y21
		Z21=conf.Z21
		X11=conf.X11
		Y11=conf.Y11
		Z11=conf.Z11
	get_globals()
	def update_globals():
		conf.IONSUM0=IONSUM0
		conf.IFLSUM0=IFLSUM0
		conf.ESTORE0=ESTORE0
		conf.EPHOTON0=EPHOTON0
		conf.DRXE0=DRXE0
		conf.DRYE0=DRYE0
		conf.DRZE0=DRZE0
		conf.DRX0=DRX0
		conf.DRY0=DRY0
		conf.DRZ0=DRZ0
		conf.IONSUM=IONSUM
		conf.IFLSUM=IFLSUM
		conf.ESTORE=ESTORE
		conf.EPHOTON=EPHOTON
		conf.DRXE=DRXE
		conf.DRYE=DRYE
		conf.DRZE=DRZE
		conf.DRX=DRX
		conf.DRY=DRY
		conf.DRZ=DRZ
		conf.IONF2=IONF2
		conf.ESTF2=ESTF2
		conf.X2=X2
		conf.Y2=Y2
		conf.Z2=Z2
		conf.DRXS=DRXS
		conf.DRYS=DRYS
		conf.DRZS=DRZS
		conf.X21=X21
		conf.Y21=Y21
		conf.Z21=Z21
		conf.X11=X11
		conf.Y11=Y11
		conf.Z11=Z11

	if(IONSUM[NVAC]> 28) :
		print(' WARNING SECOND GENERATION CONVERTED FLUORESCENCE HAS AN  EVENT WITH',IONSUM[NVAC],' IONS.','\n COMPTON BRANCH NO=',NVAC,'\n PRIMARY INTERACTION NUMBER =',NEV)
		sys.exit()
	# endif
	IONF2[NVAC][NEV]=IONSUM[NVAC]
	for J in range(1,IONSUM[NVAC]+1):
		ESTF2[NVAC][J][NEV]=ESTORE[NVAC][J]
		X2[NVAC][J][NEV]=X11[NVAC][L1]+DIST1*DRX0[NVAC][L1]
		Y2[NVAC][J][NEV]=Y11[NVAC][L1]+DIST1*DRY0[NVAC][L1]
		Z2[NVAC][J][NEV]=Z11[NVAC][L1]+DIST1*DRZ0[NVAC][L1]
		X21[NVAC][L1]=X2[NVAC][J][NEV]
		Y21[NVAC][L1]=Y2[NVAC][J][NEV]
		Z21[NVAC][L1]=Z2[NVAC][J][NEV]
		DRXS[NVAC][J][NEV]=DRXE[NVAC][J]
		DRYS[NVAC][J][NEV]=DRYE[NVAC][J]
		DRZS[NVAC][J][NEV]=DRZE[NVAC][J]
	update_globals()
	return
	# end
def CSSTF3(NEV,NVAC,L1,DIST1):
	# IMPLICIT #real*8 (A-H,O-Z)
	# IMPLICIT #integer*8 (I-N)
	def get_globals():
		IONSUM0=conf.IONSUM0
		IFLSUM0=conf.IFLSUM0
		ESTORE0=conf.ESTORE0
		EPHOTON0=conf.EPHOTON0
		DRXE0=conf.DRXE0
		DRYE0=conf.DRYE0
		DRZE0=conf.DRZE0
		DRX0=conf.DRX0
		DRY0=conf.DRY0
		DRZ0=conf.DRZ0
		IONSUM=conf.IONSUM
		IFLSUM=conf.IFLSUM
		ESTORE=conf.ESTORE
		EPHOTON=conf.EPHOTON
		DRXE=conf.DRXE
		DRYE=conf.DRYE
		DRZE=conf.DRZE
		DRX=conf.DRX
		DRY=conf.DRY
		DRZ=conf.DRZ
		IONF3=conf.IONF3
		ESTF3=conf.ESTF3
		X3=conf.X3
		Y3=conf.Y3
		Z3=conf.Z3
		DRXS=conf.DRXS
		DRYS=conf.DRYS
		DRZS=conf.DRZS
		X31=conf.X31
		Y31=conf.Y31
		Z31=conf.Z31
		X21=conf.X21
		Y21=conf.Y21
		Z21=conf.Z21
	get_globals()
	def update_globals():
		conf.IONSUM0=IONSUM0
		conf.IFLSUM0=IFLSUM0
		conf.ESTORE0=ESTORE0
		conf.EPHOTON0=EPHOTON0
		conf.DRXE0=DRXE0
		conf.DRYE0=DRYE0
		conf.DRZE0=DRZE0
		conf.DRX0=DRX0
		conf.DRY0=DRY0
		conf.DRZ0=DRZ0
		conf.IONSUM=IONSUM
		conf.IFLSUM=IFLSUM
		conf.ESTORE=ESTORE
		conf.EPHOTON=EPHOTON
		conf.DRXE=DRXE
		conf.DRYE=DRYE
		conf.DRZE=DRZE
		conf.DRX=DRX
		conf.DRY=DRY
		conf.DRZ=DRZ
		conf.IONF3=IONF3
		conf.ESTF3=ESTF3
		conf.X3=X3
		conf.Y3=Y3
		conf.Z3=Z3
		conf.DRXS=DRXS
		conf.DRYS=DRYS
		conf.DRZS=DRZS
		conf.X31=X31
		conf.Y31=Y31
		conf.Z31=Z31
		conf.X21=X21
		conf.Y21=Y21
		conf.Z21=Z21

	# STORE EVENT DATA FOR THIRD GENERATION FLUORESCENCE
	if(IONSUM[NVAC]> 15) :
		print(' WARNING THIRD GENERATION CONVERTED FLUORESCENCE HAS AN  EVENT WITH',IONSUM[NVAC],' IONS.','\n COMPTON BRANCH NO=',INVAC3,'\n PRIMARY INTERACTION NUMBER =',NEV)
		sys.exit()
	# endif
	IONF3[NVAC][NEV]=IONSUM[NVAC]
	for J in range(1,IONSUM[NVAC]+1):
		ESTF3[NVAC][J][NEV]=ESTORE[NVAC][J]
		X3[NVAC][J][NEV]=X21[NVAC][L1]+DIST1*DRX0[NVAC][L1]
		Y3[NVAC][J][NEV]=Y21[NVAC][L1]+DIST1*DRY0[NVAC][L1]
		Z3[NVAC][J][NEV]=Z21[NVAC][L1]+DIST1*DRZ0[NVAC][L1]
		X31[NVAC][L1]=X3[NVAC][J][NEV]
		Y31[NVAC][L1]=Y3[NVAC][J][NEV]
		Z31[NVAC][L1]=Z3[NVAC][J][NEV]
		DRXS[NVAC][J][NEV]=DRXE[NVAC][J]
		DRYS[NVAC][J][NEV]=DRYE[NVAC][J]
		DRZS[NVAC][J][NEV]=DRZE[NVAC][J]
	update_globals()
	return
	# end
def CSSTF4(NEV,NVAC,L1,DIST1):
	# IMPLICIT #real*8 (A-H,O-Z)
	# IMPLICIT #integer*8 (I-N)
	def get_globals():
		IONSUM0=conf.IONSUM0
		IFLSUM0=conf.IFLSUM0
		ESTORE0=conf.ESTORE0
		EPHOTON0=conf.EPHOTON0
		DRXE0=conf.DRXE0
		DRYE0=conf.DRYE0
		DRZE0=conf.DRZE0
		DRX0=conf.DRX0
		DRY0=conf.DRY0
		DRZ0=conf.DRZ0
		IONSUM=conf.IONSUM
		IFLSUM=conf.IFLSUM
		ESTORE=conf.ESTORE
		EPHOTON=conf.EPHOTON
		DRXE=conf.DRXE
		DRYE=conf.DRYE
		DRZE=conf.DRZE
		DRX=conf.DRX
		DRY=conf.DRY
		DRZ=conf.DRZ
		IONF4=conf.IONF4
		ESTF4=conf.ESTF4
		X4=conf.X4
		Y4=conf.Y4
		Z4=conf.Z4
		DRXS=conf.DRXS
		DRYS=conf.DRYS
		DRZS=conf.DRZS
		X31=conf.X31
		Y31=conf.Y31
		Z31=conf.Z31
		X41=conf.X41
		Y41=conf.Y41
		Z41=conf.Z41
	get_globals()
	def update_globals():
		conf.IONSUM0=IONSUM0
		conf.IFLSUM0=IFLSUM0
		conf.ESTORE0=ESTORE0
		conf.EPHOTON0=EPHOTON0
		conf.DRXE0=DRXE0
		conf.DRYE0=DRYE0
		conf.DRZE0=DRZE0
		conf.DRX0=DRX0
		conf.DRY0=DRY0
		conf.DRZ0=DRZ0
		conf.IONSUM=IONSUM
		conf.IFLSUM=IFLSUM
		conf.ESTORE=ESTORE
		conf.EPHOTON=EPHOTON
		conf.DRXE=DRXE
		conf.DRYE=DRYE
		conf.DRZE=DRZE
		conf.DRX=DRX
		conf.DRY=DRY
		conf.DRZ=DRZ
		conf.IONF4=IONF4
		conf.ESTF4=ESTF4
		conf.X4=X4
		conf.Y4=Y4
		conf.Z4=Z4
		conf.DRXS=DRXS
		conf.DRYS=DRYS
		conf.DRZS=DRZS
		conf.X31=X31
		conf.Y31=Y31
		conf.Z31=Z31
		conf.X41=X41
		conf.Y41=Y41
		conf.Z41=Z41
	# STORE EVENT DATA FOR FOURTH GENERATION FLUORESCENCE
	if(IONSUM[NVAC]> 12) :
		print(' WARNING FOURTH GENERATION CONVERTED FLUORESCENCE HAS AN  EVENT WITH',IONSUM[NVAC],' IONS.','\n COMPTON BRANCH NO=',NVAC,'\n PRIMARY INTERACTION NUMBER =',NEV)
		sys.exit()
	# endif
	IONF4[NVAC][NEV]=IONSUM[NVAC]
	for J in range(1,IONSUM[NVAC]+1):
		ESTF4[NVAC][J][NEV]=ESTORE[NVAC][J]
		X4[NVAC][J][NEV]=X31[NVAC][L1]+DIST1*DRX0[NVAC][L1]
		Y4[NVAC][J][NEV]=Y31[NVAC][L1]+DIST1*DRY0[NVAC][L1]
		Z4[NVAC][J][NEV]=Z31[NVAC][L1]+DIST1*DRZ0[NVAC][L1]
		X41[NVAC][L1]=X4[NVAC][J][NEV]
		Y41[NVAC][L1]=Y4[NVAC][J][NEV]
		Z41[NVAC][L1]=Z4[NVAC][J][NEV]
		DRXS[NVAC][J][NEV]=DRXE[NVAC][J]
		DRYS[NVAC][J][NEV]=DRYE[NVAC][J]
		DRZS[NVAC][J][NEV]=DRZE[NVAC][J]
	# 1 CONTINUE
	update_globals()
	return
	# end
def CSSTF5(NEV,NVAC,L1,DIST1): 
	# IMPLICIT #real*8 (A-H,O-Z)
	# IMPLICIT #integer*8 (I-N)
	def get_globals():
		IONSUM0=conf.IONSUM0
		IFLSUM0=conf.IFLSUM0
		ESTORE0=conf.ESTORE0
		EPHOTON0=conf.EPHOTON0
		DRXE0=conf.DRXE0
		DRYE0=conf.DRYE0
		DRZE0=conf.DRZE0
		DRX0=conf.DRX0
		DRY0=conf.DRY0
		DRZ0=conf.DRZ0
		IONSUM=conf.IONSUM
		IFLSUM=conf.IFLSUM
		ESTORE=conf.ESTORE
		EPHOTON=conf.EPHOTON
		DRXE=conf.DRXE
		DRYE=conf.DRYE
		DRZE=conf.DRZE
		DRX=conf.DRX
		DRY=conf.DRY
		DRZ=conf.DRZ
		IONF5=conf.IONF5
		ESTF5=conf.ESTF5
		X5=conf.X5
		Y5=conf.Y5
		Z5=conf.Z5
		DRXS=conf.DRXS
		DRYS=conf.DRYS
		DRZS=conf.DRZS
		X41=conf.X41
		Y41=conf.Y41
		Z41=conf.Z41
		X51=conf.X51
		Y51=conf.Y51
		Z51=conf.Z51
	get_globals()
	def update_globals():
		conf.IONSUM0=IONSUM0
		conf.IFLSUM0=IFLSUM0
		conf.ESTORE0=ESTORE0
		conf.EPHOTON0=EPHOTON0
		conf.DRXE0=DRXE0
		conf.DRYE0=DRYE0
		conf.DRZE0=DRZE0
		conf.DRX0=DRX0
		conf.DRY0=DRY0
		conf.DRZ0=DRZ0
		conf.IONSUM=IONSUM
		conf.IFLSUM=IFLSUM
		conf.ESTORE=ESTORE
		conf.EPHOTON=EPHOTON
		conf.DRXE=DRXE
		conf.DRYE=DRYE
		conf.DRZE=DRZE
		conf.DRX=DRX
		conf.DRY=DRY
		conf.DRZ=DRZ
		conf.IONF5=IONF5
		conf.ESTF5=ESTF5
		conf.X5=X5
		conf.Y5=Y5
		conf.Z5=Z5
		conf.DRXS=DRXS
		conf.DRYS=DRYS
		conf.DRZS=DRZS
		conf.X41=X41
		conf.Y41=Y41
		conf.Z41=Z41
		conf.X51=X51
		conf.Y51=Y51
		conf.Z51=Z51
	# STORE EVENT DATA FOR FIFTH GENERATION FLUORESCENCE
	if(IONSUM[NVAC]> 5) :
		print(' WARNING FIFTH GENERATION CONVERTED FLUORESCENCE HAS AN  EVENT WITH',IONSUM[NVAC],' IONS.\n',' COMPTON BRANCH NO=',NVAC,'\n PRIMARY INTERACTION NUMBER=',NEV)
		sys.exit()
	# endif
	IONF5[NVAC][NEV]=IONSUM[NVAC]
	for J in range(1,IONSUM[NVAC]+1):
		ESTF5[NVAC][J][NEV]=ESTORE[NVAC][J]
		X5[NVAC][J][NEV]=X41[NVAC][L1]+DIST1*DRX0[NVAC][L1]
		Y5[NVAC][J][NEV]=Y41[NVAC][L1]+DIST1*DRY0[NVAC][L1]
		Z5[NVAC][J][NEV]=Z41[NVAC][L1]+DIST1*DRZ0[NVAC][L1]
		X51[NVAC][L1]=X5[NVAC][J][NEV]
		Y51[NVAC][L1]=Y5[NVAC][J][NEV]
		Z51[NVAC][L1]=Z5[NVAC][J][NEV]
		DRXS[NVAC][J][NEV]=DRXE[NVAC][J]
		DRYS[NVAC][J][NEV]=DRYE[NVAC][J]
		DRZS[NVAC][J][NEV]=DRZE[NVAC][J]
	update_globals()
	return
	# end