*
*	quicky KUMAC to get decay spectra from GEANT simulations
*	(GEANT_LEMSR.KUMAC)
*
*	TP,	03-Feb-1999,	PSI
*
*	[1]	Geant Runnumber; for histogram titles
*
*----------------------------------------------------------------------
*
	if ( [1] .eq. ' ' .or. [1] .eq. '?' .or. [1] .eq. '!') then
		mess
		mess Missing GEANT RunNumber as parameter.
		mess Needed for Histogram titles.
		mess
		mess Syntax:
		mess
		mess GEANT_DOHIST RunNo
		mess
		exitm
	endif
	runno = [1]
*
*	cuts for e+ and e- and gammas
*
	cut $20 btest(int(partcode),0).and.btest(int(partcode),4) |require gamma in both detec.
	cut $21 btest(int(partcode),1).and.btest(int(partcode),5) |require e+ in both detec.
	cut $22 btest(int(partcode),2).and.btest(int(partcode),6) |require e- in both detec.
*
	cut $11 p0>30.
	cut $10 desci>0.and.desco>0
	cut $1 de_left_i>0.and.de_left_o>0
	cut $2 de_top_i>0.and.de_top_o>0
	cut $3 de_rite_i>0.and.de_rite_o>0
	cut $4 de_bot_i>0.and.de_bot_o>0
*
cut $5 btest(int(volno),0).and.btest(int(volno),4) | bits for left in and out
cut $6 btest(int(volno),1).and.btest(int(volno),5) | bits for top in and out
cut $7 btest(int(volno),2).and.btest(int(volno),6) | bits for right in and out
cut $8 btest(int(volno),3).and.btest(int(volno),7) | bits for bottom in and out
*
	1d   1 'GEANT '//[runno]//' volno, dE gt 0' 256 -.5 255.5
	1d   2 'GEANT '//[runno]//' volno, dE gt 0, e+ bit or e- bit required' 256 -.5 255.5
	1d   3 'GEANT '//[runno]//' volno, dE ge 0, only gammas' 256 -.5 255.5
	1d   4 'GEANT '//[runno]//' volno, dE gt 0, only gammas' 256 -.5 255.5
	1d   5 'GEANT '//[runno]//' volno, volno gt 0' 256 -.5 255.5
*goto fine
	1d 404 'GEANT '//[runno]//' only left,   de gt 0, 50ns bins' 220 0. 11000.
	1d 406 'GEANT '//[runno]//' only top,    de gt 0, 50ns bins' 220 0. 11000.
	1d 407 'GEANT '//[runno]//' only right,  de gt 0, 50ns bins' 220 0. 11000.
	1d 408 'GEANT '//[runno]//' only bottom, de gt 0, 50ns bins' 220 0. 11000.
	1d 504 'GEANT '//[runno]//' left ,       de gt 0, 50ns bins' 220 0. 11000.
	1d 506 'GEANT '//[runno]//' top  ,       de gt 0, 50ns bins' 220 0. 11000.
	1d 507 'GEANT '//[runno]//' right,       de gt 0, 50ns bins' 220 0. 11000.
	1d 508 'GEANT '//[runno]//' bottom,      de gt 0, 50ns bins' 220 0. 11000.
	1d 604 'GEANT '//[runno]//' left  , e+ or e- bit, de gt 0, 50ns bins' 220 0. 11000.
	1d 606 'GEANT '//[runno]//' top   , e+ or e- bit, de gt 0, 50ns bins' 220 0. 11000.
	1d 607 'GEANT '//[runno]//' right , e+ or e- bit, de gt 0, 50ns bins' 220 0. 11000.
	1d 608 'GEANT '//[runno]//' bottom, e+ or e- bit, de gt 0, 50ns bins' 220 0. 11000.
	1d 704 'GEANT '//[runno]//' left  , only gamma, de ge 0, 50ns bins' 220 0. 11000.
	1d 706 'GEANT '//[runno]//' top   , only gamma, de ge 0, 50ns bins' 220 0. 11000.
	1d 707 'GEANT '//[runno]//' right , only gamma, de ge 0, 50ns bins' 220 0. 11000.
	1d 708 'GEANT '//[runno]//' bottom, only gamma, de ge 0, 50ns bins' 220 0. 11000.
*	goto cont
*
fine:
	1d 1404 'GEANT '//[runno]//' only left,   de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1406 'GEANT '//[runno]//' only top,    de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1407 'GEANT '//[runno]//' only right,  de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1408 'GEANT '//[runno]//' only bottom, de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1504 'GEANT '//[runno]//' left ,       de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1506 'GEANT '//[runno]//' top  ,       de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1507 'GEANT '//[runno]//' right,       de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1508 'GEANT '//[runno]//' bottom,      de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1604 'GEANT '//[runno]//' left  , e+ or e- bit, de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1606 'GEANT '//[runno]//' top   , e+ or e- bit, de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1607 'GEANT '//[runno]//' right , e+ or e- bit, de gt 0, 2ns bins' 5500 0.5 11000.5
	1d 1608 'GEANT '//[runno]//' bottom, e+ or e- bit, de gt 0, 2ns bins' 5500 0.5 11000.5
*

mess Plot 1=Volno dE>0
nt/pl 111.volno volno>0.and.$10 -1

mess Plot 2=Volno dE>0 and e+ or e- bit reuqired
nt/pl 111.volno volno>0.and.$10.and.($21.or.$22) -2

mess Plot 3=Volno dE>=0, only gammas
nt/pl 111.volno volno>0.and.partcode=17 -3

mess Plot 4=Volno dE>0, only gammas
nt/pl 111.volno volno>0.and.partcode=17.and.$10 -4

mess Plot 5=Volno volno>0
nt/pl 111.volno volno>0 -5

mess NTPlot left=404
nt/pl 111.tsci volno=17.and.$10 -404
mess NTPlot top =406
nt/pl 111.tsci volno=34.and.$10 -406
mess NTPlot right=407
nt/pl 111.tsci volno=68.and.$10 -407
mess NTPlot bottom=408
nt/pl 111.tsci volno=136.and.$10 -408

mess NTPlot left=1404
nt/pl 111.tsci volno=17.and.$10 -1404
mess NTPlot top =1406
nt/pl 111.tsci volno=34.and.$10 -1406
mess NTPlot right=1407
nt/pl 111.tsci volno=68.and.$10 -1407
mess NTPlot bottom=1408
nt/pl 111.tsci volno=136.and.$10 -1408

mess NTPlot left id=504
nt/pl 111.tsci $1.and.$5 -504
mess NTPlot top id=506
nt/pl 111.tsci $2.and.$6 -506
mess NTPlot rite id=507
nt/pl 111.tsci $3.and.$7 -507
mess NTPlot bot id=508
nt/pl 111.tsci $4.and.$8 -508

mess NTPlot left id=604
nt/pl 111.tsci $1.and.$5.and.($21.or.$22) -604
mess NTPlot top id=606
nt/pl 111.tsci $2.and.$6.and.($21.or.$22) -606
mess NTPlot rite id=607
nt/pl 111.tsci $3.and.$7.and.($21.or.$22) -607
mess NTPlot bot id=608
nt/pl 111.tsci $4.and.$8.and.($21.or.$22) -608

mess NTPlot left id=704
nt/pl 111.tsci partcode=17.and.$5 -704
mess NTPlot top id=706
nt/pl 111.tsci partcode=17.and.$6 -706
mess NTPlot rite id=707
nt/pl 111.tsci partcode=17.and.$7 -707
mess NTPlot bot id=708
nt/pl 111.tsci partcode=17.and.$8 -708

mess NTPlot left id=1504
nt/pl 111.tsci $1.and.$5 -1504
mess NTPlot top id=1506
nt/pl 111.tsci $2.and.$6 -1506
mess NTPlot rite id=1507
nt/pl 111.tsci $3.and.$7 -1507
mess NTPlot bot id=1508
nt/pl 111.tsci $4.and.$8 -1508

mess NTPlot left id=1604
nt/pl 111.tsci $1.and.$5.and.($21.or.$22) -1604
mess NTPlot top id=1606
nt/pl 111.tsci $2.and.$6.and.($21.or.$22) -1606
mess NTPlot rite id=1607
nt/pl 111.tsci $3.and.$7.and.($21.or.$22) -1607
mess NTPlot bot id=1608
nt/pl 111.tsci $4.and.$8.and.($21.or.$22) -1608

