foam multi-purpose s. jadach
TRANSCRIPT
Presentation compact version F-1
FOAMMulti-Purpose
Celular Monte Carlo Generator
S. JadachInstitute of Nuclear Physics, Krakow, Poland
Outline:
• General introduction.
• Foam algorithm and new MCell (Mega-Cell MC).
• Numerical tests.
• Conclusions.
Slides, program sources: http://home.cern.ch/jadach
S. Jadach Krakow, September, 2001
Introduction F-2
Just to give an idea...
Modern PC desktop can create within 15minCPU
nC =5k-50k cells and subsequently generate N =10M
events for relatively strongly peaked n-dimesional
integrand, n < 12.
With σ<W>
= 0.3 that provides 3-digit value of the
integral, δII
= σ√N
' 10−3,
or alternatively 3M events with W = 1,
assuming Wmax
<W>= 0.3.
Not bad!! What are the key limitations?
Memory: ∼ 16 × n × nC Bytes. <50MB.
CPU time: ∼ nC /1k Minutes CPU. <1h.
Efficient algorithm of build-up of cells:
maximizing <W>Wmax
and/or minimizing σ<W>
.
Algorithms based on BINARY SPLIT of cells seems to fulfill
the constraints. Parent cells kept in record →→ hierarchical data organization (tree-like linked list).
S. Jadach Krakow, September, 2001
Picture Gallery F-3
Evolution of simplical foam
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! """"
""""
""""
""""
""""
$# # # # # # # # # # #
!!!!!!!!!!!!!!!!!!!!!%%%%%%%%%%%%%%%%%%%%%%%%%%
& & & & & & & & & & & & & & & & & & & & & & & & & & & & &
! ! ! ! ! ! !(''''''''''')))))))))))
% % % % % % % %% % % % % % %*****************
++++
+++
% % % % % % % % % % % % %% % % % % % % % % % % % %
,,,,,,,,,,
-----------, , , , , , , , , ,
. .. . '''''''''''''
. .. .
. .. .
//////////////////////
" " " " " " " " " " " " " " " " " " " " &&&
&&&&
&&&&
&&&&
&&&&
&&&&
&&&&
&&- - - - - - - - - -
" " " " " " ----------
00
0000
0000 - - - - - - - - - - -
% % % % % % % % %% % % % % % %
%%%%%%%%%%%%%%%%
""""' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
"""
* * ** * * *
* *$1 1 1 1 1 1 1%%%%%%%%%%%%%%%
1 1 1 1 1 1 1 1 1 1*********
22222222
2
0 0 0 0 0 0 0
####
####
###2 2 2 2 2 2 2 2 2 0 0 0 0
+ + + + + + +
! ! ! )
) )) )) )) )) )3333333333
! ! ! ! 3
3 33 33 33 33............
4 4 4 4 4 4 4
4 4 4 4 4 4 44 // // // // // // // // //
! ! ! ! ! ! ! ! ! ! ! ! // // /444444444444444
!!!!!!!!!!!!!!!!!!!!!
55555555
5 1111111
111111111 5 5 5 5 5 5 5 5 5
6 7 6 8
6 9 6 :
6 ;6 <
6 =
6 >
6 ?
67 @
67 7
67 867 9
67 :
67 ;
67 <
67 =
67 >
67 ?
68 @
687
68 8
68 9
68 :
68 ;
68 <
68 =
68 >A8 ?
A9 @
69 7
69 8
69 9 69 :
69 ;
A9 <
69 =
69 >
69 ?
6: @
A: 7
6: 8
6: 9
6: :
6: ;
6: <
6: =
6: >6: ?
6; @
6; 7
6; 8
6; 9A; :
6; ;
A; <6; =
6; >
6; ?
A< @
6< 7A< 8
6< 9
6< :
6< ;
6< <
A< =6< >
6< ?
A= @
A= 76= 8
6= 9
A= :
6= ;
A= <
6= =
A= >
6= ?
A> @
A> 7
A> 8
A> 9
A> :A> ;
6> <
A> =
A> >
A> ?
6? @
A? 7
A? 8
A? 9
A? :
A? ;
A? <
A? =
A? >
A? ?A7 @ @
A7 @ 7A7 @ 8
A7 @ 9A7 @ :
A7 @ ;
A7 @ <
A7 @ =
A7 @ > A7 @ ?
A7 7 @A7 7 7
A7 7 8
A7 7 9 A7 7 :
A7 7 ;A7 7 <
A7 7 =
A7 7 >
A7 7 ?
A7 8 @
A7 8 7
A7 8 8
A7 8 9
A7 8 :
A7 8 ; A7 8 <
A7 8 =
B B B B B B B B B B B B B B B B B B B B B B BCCCC
CCC
: @
D D D D D D D D DEEEEEEEFFF = 7
GGGG
GH H H HJI I I I I I
> 8
K K K K K K K IIIIIIIIII
FFF> :
BBBBC C C C C C CEEEEEE> <
L L L L L LFF ? <
M MM MM M D D
D D D D D D D DDNNNNNNNNNNNNNNNNN
? >
O OO OO OO OPPPQQQQQQQQQQQ
7 @ @
F FF F
F FQ QQ QQRRRRRRRRRR
7 @ 8
S S S QQ QQ QQFFFFFF 7 @ 9T T
T TT T
T T$UU UURRRRRRRRRRR
7 @ ;
VVVV
VVVN N$W W W W W W
7 7 7
X X X XFFF7 7 9
YYYYYY
YYYYYY
YYYYYY
YYYZ Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z ZHHHH
7 7 ;
GGGG
GGG[ [ [ [ [ [ [ [ [ [ [
7 7 =
\\\\\\\\\\\\\\\] ]] ]] ]] ]] ]] ]] ]] ]] ]FFF
7 7 >
IIIIIII^ ^ ^ ^ ^ ^ ^ ^ ^ ^CCC7 8 @
______S S S S S S S SHH7 8 9
``P P P P P P P P P P
7 8 =
\ \\ \\ \\ \\ \\ \\ \GG
GGG
7 8 >
S S S S S S S S S S S S S S S S S GGG
GGGG
GGGG
GGGG
G\\\\\\\\\\\\\\7 8 ?
GGGG^ ^ ^ ^ ^ ^ ^ ^ ^ ^
7 9 @
a aa aa ]]]]NNN
7 9 9
b bb bb bGG
G
7 9 : bbbbbb
7 9 ;
ccccE E E E E E7 9 <
YYYE E E E E E E7 9 >
dddddd 7 : @
7 : 9
S S S S S S S S S S S S S S S S S S S S S S S S7 : :
KKKK
KKG G G G Gee7 : <
KKKKe e I I I I I7 : =
F FF F
F FF F
F FF F
F FF F
F FFFFFFFFFFFFFFFFFFF
7 : ?
N N N NN N N N
N N N N$c c c c cDDDDDDDDDDDDDDDD7 ; @
Y Y Y Y Y Y Y Y Y Y Y YNNNNNNNNNNNN
7 ; 7
[[PPPK K K K7 ; 9
d d d deeee7 ; :e e
e e aaaaa7 ; ;
] ]]fffffffffffffff 7 ; <S S S S S S S S S S S S ]
]7 ; =
g gg gg g PPP\\\\\\\\
7 ; >
T TT ThP
PPgggggg
7 ; ?
VVVVH H HK K K K7 < @
WWWW
WWV V V V K K K7 < 7
f f f f fJY Y7 < 8i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i
FFFFFFFFFFFFFF
7 < :j j j j j j j j j j j j j j j j j j j j j j j j j j j j j ii
iiii
iiii
iiii
iiii
iiii
iiii
iiii
iiiiFFFF
7 < ;
e e ee e$d dNNNNNNN7 < <
GGGG
GGGH H H
H H HH H H
H H HH H H
H H HH H H
HFFFFFFFFFFFFFFFFF
7 < >
^^^^^^^^^^G G G G G G GFFF
7 < ?
]]]7 = @
H H HH H H
H d d d d d d dDDDDDDDDDDDD7 = 8
N N NN N N N
N NHHHHHHHDDD7 = 9
GGGGc c c cFF7 = :
GGGGZ Z Z
P P P7 = <[[
[[[[
[[[[Z Z Z Z Z Z G G G G
7 = =
] ] ^^^^^^^^^^B B B B B B B B B B B
7 = >
IIIIII]]B B B B B7 = ?
GG HHHH 7 > @SSSSSSSSG G7 > 7
SSSSSSSSSSSSSSSSSSSSSSS 7 > 8
e e ee e
F FF F
F FFTTTTTTTTTTTT
7 > :
SkS FF Feeeee 7 > ;
D D D D DHHHHH7 > <H H H
H H MMMMMM7 > =
G G G KKKK
KKKP P P P P 7 > >
l l l PPPPPFF 7 > ?
\ \\ \\ \\ \\ \\ \\ \\FFFFFFFFFFFFFFF
7 ? @
f f f f f f ff f f f f f f
fFFFF 7 ? 7
G G G G G G G G G G G G G G jjjj
jjjj
jjjj
jjjj
jjjj
jjjj
jjjj
ji i i i i i i i i i i i i i i i 7 ? 8
G G G G G G G iiiiii
iiii
iiiiiiI I I I I I I I I I 7 ? 9
BBBBBBBBBBBP P P P P P P P P P P P P P
7 ? :
` ` BBBB7 ? ;
D D D D D D D D D D7 ? <D D D D D D D
LLLLLLL 7 ? =SSSSSSSS
SSSSSS S S S S S S S S S S S7 ? >
F FF F
F FF
]]]]]]]]]]]]]]]]
8 @ @
R RR RR RR RR RRFFFFFFF]]]]
8 @ 7Y Y B B BXXXX 8 @ 8
B B B B B B BYY8 @ 9 II
IIIIIIIIIIIIIIIIS S S S S S S S S S S S S S S S S S SFFFFFFFFFFFFFFFFF
8 @ :
^^^^^^^^^^^^^^^^^^S S S S I I I I I I I I I I I I I I I I I I
8 @ ;
L L L L LS S S S S S8 @ <L L LSSSSSSY Y Y 8 @ =
ZZCCC
CCV V V V V V V8 @ ?
SSSSSSSSSSSSK K 8 7 @KKFF 8 7 7 S S R
R RR RR RR RRaaaaaaaaaaa
8 7 8a a
a aa a
a aa a
aFFFFFFFFFF8 7 9
87 : ffff8 7 ; Y Y87 <D D D D D D D D DD D D D D D D$Y Y Y8 7 =
___SSSSSSSSSSS S S S S S S S S S S S S8 7 >
SSSSSSSSSSS_ _ _ 87 ?
_ _ _ _8 8 @ddddddd
ddd _ _ _ _ _ _8 8 7D D D D DD D D8 8 8____ DDDDDDDD 8 8 9
8 8 :LLLLLL 8 8 ;SSSSSSSSSSS
SSSSSSSSSSaaa 8 8 <a aafffffffffffff 8 8 =mmmmmmf f f f f f f
f f f f f fDDDDDDDD 8 8 >m m m m mmDDDDDDDDDDDDDDDDDD 8 8 ?
ZZZZZZZZ
ZZZZHH H H
H G G G G G G G8 9 @
H H HH H H
H H HH H Z Z Z Z Z Z Z Z Z Z Z Z8 9 7
CCC FF8 9 8SSSSSSSSSSSSSSSSSSSSSSSS C C C8 9 9
S S S S 8 9 :SSSS8 9 ;
\ \ PPPPPPPP
8 9 <
\ \\ \\ \
8 9 =
iiiiC C CFF8 9 >IIIIIi i i i8 9 ?
S S S S S S PPPPPPPPPQQQQQQQQQ
8 : @S S Q
Q QQ QQ QQ QOOOOOOOO
8 : 7
SSSSSSSSSSSSSSSS
SSSSSSSSSSSSSSSS
SSS HHHHHHHHHHHHH
8 : 8
ZZZZZZZZ
ZZZZZZZZ
ZZZZZZZZ
ZS S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S SHHHHHHHHH
8 : 9
] ] d d d dmmmmm 8 : :] ] mm m m meeeee 8 : ; H H H C C8 : <
ZZZZZZ
Z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
n
n
n
n
n
n
n nnn
n n
nn
n
n
n n
nn
n
n
n
n
n
n
n
n
n
n
nn
n
n
n
n
n
n
nn
n
n
nn
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
nnn
n
nn
n
n
n
n n
n
n
n
n
n n
n nn
n
nn
n
n
n
n
nn
nnn n
n
n n
nn
n
n
n
n
n
n
n
nn
nn
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
nn
n
n
n
n
n
n
nn
n
nn
n
n
n
n
Number of cells= 10, 70, 250, 2500.
S. Jadach Krakow, September, 2001
Picture Gallery F-4
Evolution of hyper-cubic. foam
Number of cells= 10, 70, 250, 2500.
S. Jadach Krakow, September, 2001
Picture Gallery F-5
Void and Diagonal
!!
" "
# # # # #
$ $ $ $ $ $
! ! ! ! ! !
% % %
& & $$$
''
%%% (((
# # # #####
( ( ( ( (
)))))))
* * ! ! ! !** + + + + + + +
## ###
%%%
,,
, ,# # # # # ) ) )
- - - - - - - - --!!!!!!!!
.
/ / ----------
0 0%%%% 00
1 1 1 $$$ &&
22 11 22
% % % ((
++ +++++
)))
) ) #####) ) ) ) ) )
""
3 3 3 3 3333 4 4 4 444
+++ + + +//
% %
%%
5 6
7 87 9
7 6
9 :
9 5
9 6
; 7
< =
< 8
< 6
6 >6 8
6 5
6 ;6 <
> = 8
> = 9
> > =
> > 8
> > 7
> > ;
> 8 =
> 8 8
> 8 7
> 8 ;
> 8 6
> : >
> : :
> : 5 > : 7
> : ;
> : 6
> 5>
> 5 8 > 5 :
> 5 5
> 5 ;
> 5 6
> 7 >
> 7 8> 7 5
> 7 9
> 7 6
> 9 >> 9 8
> 9 7
> 9 9> 9 ;
> 9 <
> ; => ; >
> ; 8
> ; :
> ; 7
> ; 9> ; ;
> ; < > ; 6
> < = > < >
> < :> < 5
> < ;> < 6
> 6 => 6>
> 6 8> 6 :
> 6 5 > 6 7
> 6 9 > 6 ;
> 6 <> 6 6
8 = =8 = >
8 = 8 8 = :
8 = 58 = 7
8 = 9 8 = ;
8 = < 8 = 6
8 > =8 > >
8 > 88 > :
8 > 58 > 7
8 > 98 > ;
8 > < 8 > 6
8 8 = 8 8 >
8 8 88 8 :
8 8 5 8 8 7
8 8 9 8 8 ;
8 8 <8 8 68 : =8 : >
8 : 8 8 : :
8 : 5 8 : 7
8 : 9
8 : ;
8 : < 8 : 6
8 5 =
8 5>8 5 8 8 5 :
8 5 58 5 7
8 5 9 8 5 ;
8 5 < 8 5 6
? @ A B
A C ? D
A EA F
A G
A H
A IA@ J
A@ @
A@ B
A@ C
A@ D
A@ E
A@ F
A@ G
A@ H
A@ IAB J
AB @
AB B
AB C
AB D
AB E
?B F
AB G
AB H
AB I
AC JAC @ AC B
AC C
AC D
AC E?C F
AC G
AC HAC I
AD J
AD @
AD B
?D C
AD D
AD EAD F
AD G?D H
AD I
AE J
?E @AE B
AE C
?E D
?E E
?E F
AE G
AE H
?E I
?F JAF @
?F B?F C
AF D
AF E
?F F
?F G
AF H
AF I
?G J
AG @
?G B
AG C?G D?G E?G F?G G
?G H
?G I
?H J
?H@
?H B
?H C
?H D
?H E
?H F ?H G
?H H
?H I
AI J
?I @
?I B
?I C ?I D
?I E
?I F
?I G
?I H ?I I
?@ J J
?@ J @?@ J B
?@ J C
?@ J D?@ J E
?@ J F
?@ J G?@ J H
?@ J I
?@ @ J
?@ @ @
?@ @ B ?@ @ C
?@ @ D
?@ @ E?@ @ F
?@ @ G?@ @ H
?@ @ I
?@ B J
?@ B @
?@ B B
?@ B C?@ B D
?@ B E
?@ B F
?@ B G
KKKK
KKKK
KKKK
KKKK
KKKK
KKL L L L L L L L L L L L L L L L L L L L L L LMMM
G F NNNN
NNNN
NNNN
NNNN
NNNN
NNNN N N N N N N N N N N N N N N N N N N N N N N N
H J
L L L L L L LNNNN
NNNN
NNNN
NNNNN N N N N N N N NI J
OOOO
OON NQP P P PI G
N N N N PPP
PP@ J @
NNNN
NNNN
NR R R N N N N N N N@ J C
LLLLLL
LN N N N N N@ J E
S S SNNNNT T T @ J G
N N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NNNN
NN
@ J H
NNNN
NNNN
NNNN
NNNNR R R R N N N N N N N N N N N N N
@ @ @
U U U U U U U U U U U U U U U U U U
MMMMMMMMMMMMMMMMMM @ @ DP P P P P P P P P P P P P P P P P P P P P P P P
UUUUUU
UUUUUU
UUUUUU
@ @ E
K K K K K K K K K K K KNNNN
NNNN
NNN
@ @ F
K K K K K K K K K K K K K K K K K K K K K K K K KNNNN
NNNN
NNNN
NNNN
NNNN
NN
@ @ H
NNNN
NNNN N N N N N N N N N N NLL
LLL@ B J
NNNN
NNNN
NNNN
NNNN
NN N N N N N N N N N N N N N N N N
@ B C
L L L L L L L L L LNNNN
NNNN
NN@ B D
NNNN
NNNN
NNNN
NNNN
NNNN
NNNNN N N N N N N N N N N N N N N N N N N N N N N N
@ B G
NNNN
NNNN
NNNN
NNK K K K K K K K K K K K K@ B H
KKKK
KKKK
KKKK
KT T T T T T T T T T T T T@ B I
NNNN
NNNN
NNNN
NN N N N N N N N N N N N N
@ C @
N N N N N N N N N NNNNN
NNNN
NN@ C C
K K K K K K K K K K K K K K K K K K K K K KVVVVVVVV
VVVVVVVV
VVV@ C DV V V V V V V V V V V V V V V V V V VMMMMMMMMMMMMMMMMMM
@ C E
W W W W WYX X X XNNNN
NNN
@ C G
LLLLLL
LLLLLL
LLLLLN N N N N N N N N N N N N N N
@ C I
NNNN
NNNN
NNNN
NNNNN N N N N N N N N N N N N N N N
@ D J
W W W W W W W W W W W W W W W W W W W W W WWWWW
WWWW
WWWW
WWWW
WWWW
WW
@ D B
NNNN
NNNN
NNNN
NN N N N N N N N N N N N N@ D E
NNNN
NNNN
NNNL L L L L L L L L L L L L
@ D FNN
NNNN
NNNN
NN N N N N N N N N N N@ D G
U U TTT@ D HP P P P P TT
TUU @ D I
NNNN
NNNN
NNNNN N N N N N N N N N[Z Z
@ E J
NNNN
NNNN
NZZK K K K K K K K K K K
@ E @
NNNN
NNNN
NNNN
NNNNN N N N N N N N N N N N N N N N
@ E B
NNNN
NNNN
NNNN
NNNNN N N N N N N N N N N N N N N N
@ E C
RRRRRR
R\\ N N N N N N N@ E D
RRRRRR
RRRRRR
RRRNN
NNNN
NU U U U U U U U U U U U U U U U U U U U U
@ E E
V V V V V V V V V V V V V V V V V V V V V V V V VNNNN
NNNN
NNNN
NNNN
NNNMMMMMM
@ E F
VVVVVVVV
VVVVVVVV
VVVVVVVV
VMMMMMMMMMMMMM@ E G
PPPP \\\\@ E HNN
NNP P P P@ E I
N N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NNNN
NLL
@ F @
NNNL L L L L]]]@ F B
K K K K K K K K KNNNN
NNNN @ F D
N N N N N N N NNNNN
NNNN @ F E
N N N N NNNNN
NNNN
NNNN
NN N N N N N N N N@ F F
N N N N N N N N N N KKKK
KKKK
KKSS
@ F HN N N N N N N N N N N N NNNN
NNNN
NNNN
NNN
@ F I
NNNN
NNNN
NNNN N N N N N N N N N
@ G JKK
KKKK
KKKK
KN N N N N N N N N N N@ G @
U U KKKT T @ G C
NNNN
NNNU U N N N N N N
@ G E
N N N NNNNN
NNNN
NN N N N N N@ G F
L L L L L L L L LNNNN
NNSSS
@ G G
OOOO
OOOO
OOOO
OOOO
OOOO ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
@ G H
NNNN
NNNN
NNNN
NNNN
NNNN
N O O O O O O O O O O O O O O O O O O O O
@ G I
N N N N N N N N N N N O O O O O O O O O O O O OKKKK
KKKK
KKKK
KKKK
KKKK
KKKK
K
@ H J
N N N N N N N N K K K K KNNNN
NNNN
NNN
@ H @
LLLL
LLLL
LLLL
LLLL
MMMMMMMMMMMMMM
@ H B
^^^^
^^^^
^^^^
^^^^
^^^^
^^L L L L L L L L L L L L L L L LMMMMMMM
@ H C
N N N N N N N N NNNNN
NNNN
N
@ H D
N N N N N N N N NNNNN
NNNN
N
@ H E
N N N N N N N N N N N N N N N N NLLL
LLLLLL
LLLLLL
LLL
@ H F
N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NLLLL
@ H G
NNNN
NNNN
NNNLL
LLLLLLN N N N N N N N N N N N N N N N N N
@ H H
NNNN
NNLL
LLLLN N N N N N N N N N N
@ H I
N N N N N_T TNNN
N@ I J
O O O O O O O TTTNN
NNN
@ I @
N N N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NNNN
NNNN
@ I C
OOOO
OOON N N N N N N N N N N N N N N NNN
NNNN
NNN @ I D
OOOO
OOOO
OON N N N N N N N NMM@ I E
L L L L L KKKKK
KKKT T T @ I FN N N N N N N N N N KKKK
KKLLL
LL
@ I GU U U ULLLL
LLLLL
LN N N N N N@ I HU U UNNNN
NNK K K @ I I
K K K K K K K OOOO
OOOB J JN N N N N N N KK
KKKK
KB J @N N N N N_TT
TTXXXXB J B
W W W W W W W W W W W W W W W W W TTTT
TTTT
TTTT
TNNN
NN
B J C
U U U U U UNNNSSS
SB J D
N N N N N N N N N N N NNNNN
NNNUU
UUUU
B J E
NNN] ] ] ^^B J F
L L L L L L L L L L L L L LNNNN
NNNN
NNNN
NNNN
NNNN
NK K K K K K K K KB J H
L L L L L L L L L KKKK
KKKK
KMMB J I
` ` ` ` ` ` WWWW
WMMM B @ JN N N N N N N N N N N N N N N N N N N WWWW
WWWW
WWWW
WWWW
WW``````
B @ @
UU a aB @ BRRR
RaaN N N NB @ C
S S SUUUUUU
UUUL L L L L LB @ D] ]LLLLLLN N N NB @ E
NNNN
NNNN
NNNN
NNN N N N N N N N N N N N N N N N
B @ G
NNNN
NNNN
NNNN
NR R R R R R R R R R R R R R RMMB @ H
NNNN
NNNN
NNNN
NN N N N N N N N N N N N NB @ I
N N N N N N N N N N N N N N N N N N N N N PPP
PPPP
PPPP
PPPP
PPPP
PPPP
PMM
B B J
N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NNNN
NMM
B B @
NNNN
NNNN
NNNN N N N N N N N N N N N N N N N N N N N N NNN
NNNN
NNNN
NB B B
PPN N N N N N N N N N NNNNN
NNNN
NNB B C
N N N N N N N N N N N NNNNN
NNNN
NNN
B B D
N N N N N N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NNNN
NNN
B B EN N N N N N N N N N N N N N NNN
NNNN
NNNN
NNNN
NNNT T
B B FN N N N N N N N N N N N N NNN
NNNN
NNNN
NNNN
NT T T
B B G
UUUUUU
UU\ \\ K K K K K K K K K
B B H
UUUUUU
UUUUUU
UUKK
KKKK
KKKN N N N N N N N N N N N N N N N N N N N N
B B IKKN N N N N N N N N N N N N N N N N NNN
NNNN
NNNN
NNNN
NNN
B C J
KKN N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
B C @
NNNNN N N N N N N N N N NNN
NNNN
NN B C B
K K K K K K K K K K K K K K K N N N NNNNN
NNNN
NNNN
NNNN
N
B C C
NNNN
NNNN
NNNN
NNNN
N N N N N N N N N N N N N N N N
B C D
NNNN
NNNN
NNNN
NNNN N N N N N N N N N N N N N N N
B C E
N N N N N N N N N LLL
LLLL
L
B C F
N N N N N N N N N L L L L L L L LNNNN
NNNN
NNNN
NNNN
B C G
KKKK
KKNN
NNNN
NNNN
NNN N N N N N N N N N N N N N N N N
B C H
NNNN
NNK K K K K KB C I
N N N N O O O O OKKKK
KKKK
K
B D J
O O O O ONNNN B D @
LLLLLLR R R R RB D B
NNNN
NNL L L L L LB D CS S S S S S S S N N N N N N N N N N N N N N NLLLLLL
LLLLLL
LLLLL
LLLLLL
B D D
N N N N N N N NSSSSSSSS B D EN N N N N N N N N N N N N N N N N N N NNN
NNNN
NNNN
NNNN
NNNN
NN
B D F
PPN N N N N N N N N N N N N N N N N N N NNNNN
NNNN
NNNN
NNNN
NN
B D G NN^ ^P P PB D H
NNNN
NNNN
NNPPPN N N N N N N N N N N N N
B D I
Number of cells= 250.
S. Jadach Krakow, September, 2001
Foam Algorithm F-6
Terminology&Notation
Integration domain Ω = [0, 1]n is split into Cells ω1...ωk .
Two AUXILIARY distributions ρ′(x) and ρloss(x) related
to integrand ρ(x), which are CONSTANT over each cell
are constructed. How? See next slides.
TWO STEP SCENARIO:
(1) Foam of cells BUILD-UP:
ρloss(x) is evolving with the foam, it DRIVES the division of
cells, Iloss =∫
ρlossdnx is minimized in the process.
(2) MC generation:
Events are generated according to ρ′(x).
I ′ =∫
ρ′dnx is known exactly.
I = I ′ < W >′ where W = ρ/ρ′,
The average < .. >′ means over events generated according to ρ′
OUR AIMS:
Minimize rejection (loss) rate L = 1 − <W>Wmax
, OR
Minimize variance σ =√
< W 2 > − < W >2.
S. Jadach Krakow, September, 2001
Foam Algorithm F-7
binary split of a cell
How do we minimize L = 1 − <W>
Wmax
?
DEF: ρ′(x) ≡ maxy∈Celli ρ(y), for x ∈ Celli.
is a maximum of ρ(x) within each cell:
Maximum over cell found experimentally using ∼1000 MC events.
We MINIMIZE during the foam construction:
Iloss =∫
dnx [ρ′(x) − ρ(x)] ≡∫
dnx ρloss(x)
Each SPLIT of a Cell: ω → ω′ + ω
′′
should obey: Iω′
loss+ I
ω′′
loss<< I
ωloss
.
RULES to follow:• For next split we choose a CELL with the biggest Iloss.
• Position/direction of a plane dividing a parent CELL into
two daughter CELLs is chosen to minimize total Iloss.
S. Jadach Krakow, September, 2001
Foam Algorithm F-8
Binary split 1-dim. example
! "$# %'&)(+*,*
-/.02143658797
-:.0
;
ρ(x) is integrand
Old ρ′ for parent cell (majorizing ρ(x))
New ρ′ for two daughter cells
OLD Iloss all area above red line, for the parent cell
New Iloss between red line and New ρ′, for 2 daughters.
Obviously I ′New < I ′
Old, the division point ? is chosen to
MINIMIZE THE LOSS functional/integral Iloss!
S. Jadach Krakow, September, 2001
Foam Algorithm F-9
Binary split 1-dim. example
The two-maximum case is a little bit more complicated.
We follow simple prescription:
Determine the blue line MAXIMIZING Iloss, see picture,
and apply the division procedure twice (obtaining 3 cells).
Division points are ? and
S. Jadach Krakow, September, 2001
Foam Algorithm F-10
Binary split 2-dim. example
! " # ! # ! $ # % ! !
! " #
! #
! $ #
% !
&'(
)
Integrand covers narrow strip along edges. Intend to split upper triangle.
Generate 1000 w-ted events and project them on 3 sides of the parent triangle.
3 Projections are analyzed.
We choose the one with the smallest LOSS functional Iloss (middle plot).
Two resulting daughter triangles are shown.
The DIVISION line EXPELLED from the “empty” area in the middle!!!
S. Jadach Krakow, September, 2001
Foam Algorithm F-11
Minimizing variance
How to Minimize σ2
<W>2 = <W 2>
<W>2 − 1 ?
DEF: ρ′(x) ≡ Vi ×√
< ρ2 >i, for x ∈ Celli.
The < .. >i is for uniformly distributed points ∈ Celli.
Cells with bigger contribution to total variance, “promoted” in MC generation.
We MINIMIZE during the foam build-up:
Iloss =∫
dnx ρloss(x) where
ρloss(x) ≡ Vi ×√
< ρ2 >i − < ρ >2i , for x ∈ Celli.
The algorithm avoids dividing cells in the areas where the integrand is flat,
the dispersion of the function over the cell is small.
All the algorithm of cell division remain the same.
We did less effort to optimize this mode of the program.
S. Jadach Krakow, September, 2001
Foam Algorithm F-12
Weight distribution: minimization of variance
Number of cells: 200, 2k, 20k
Weight distribution: minimization of rejection rate
! " " ! # $" %
# $" %
& $" %
' $" %
( $" %
)* +) ,* )) ,* +) -* )))* )).,)/
)* +).,)/
,* )).,) /
,* +).,)/
01 20 31 00 31 20 41 0001 005306
01 205306
31 00530 6
31 205306
41 005306
41 20530 6
Number of cells: 200, 2k, 20k
S. Jadach Krakow, September, 2001
New development F-13
Why hypercubes as cells? Why not?
Consideration in favor of simplexes:MEMORY: In n-dimensions, simplical foam (binary division)
requires only one vertex vector ~v for each new cell!
That means: 8n Bytes/Cell.
Every new hypercubic at n=15 has 32k vertices :-(
However, it can be parameterized using only 2 vectors: ~v for
“lower left corner” vertex position, and ~d defining n lengths
along each direction :-) Hence only 16n Bytes/Cell.
(The interior of the hypercube is xi = vi + λidi, 0 < λi < 1.)
Consideration in favor of hypercubes:Simplexes limited to n < 6 and NCell <5k because:
(1) Already for n=10 initial h-cube → n! ∼ 106 simplexes,
(2) geometry become CPU consuming (determinants).
(2) memory limitation,
However, memory consumption for h-cubes can be limited to
below 50Bytes/Cell indep. of n, albeit with some tolerable CPU overhead,
and no determinants :-))
BOTTOM LINE:
With hypercubes we can reach 1Mega Cells at n ∼ 15.
S. Jadach Krakow, September, 2001
Picture Gallery F-14
Hyper-cubics = rectangles in 2-dimen.
The “Camel” Double-Gauss functionof Peter Lepage.
S. Jadach Krakow, September, 2001
New development F-15
Miracle of ∼50Bytes/Cell
Two essential ingredients:
• ~v and ~x are not stored but (re)calculated using the
division parameter λ and the index i of the edge along
which the division occurred, all over ∼ ln2 NCell
steps, up to first Cell.
• Furthermore parameter λ = j/nbin can be stored as
a short inter j (2Bytes sufficient).
Each cell has several other attributes like I ′, Iloss (16B),
pointers to parent and daughter cells (12B), status (8B)
etc., altogether ∼ 50B/Cell.
Can be easily reduced to 32B/Cell if necessary.
BOTTOM LINE:
The way to 1Mega Cells is open.
We hit CPU barrier instead. See next slide.
S. Jadach Krakow, September, 2001
Foam Algorithm F-16
CPU barrier: one quick fix is found
Playing with hypercubical code MCell for Nc ∼100k Cells
at n ∼ 10 dimensions shows that the obtained efficiency<W>Wmax
and variance σ is improved ESSENTIALLY by the
INCREASING of Nc.
However, another important factor is the number of MC
events used to explore each newly created Cell Nsamp.
A necessary value of Nsamp increases for higher n.
→ Dramatic increase of total CPU time for the foam
build-up, which is T ∼ n × Nc × Nsamp.
The trick limiting the above effect:
During MC exploration of a new cell continuously monitor
the no. of accumulated effective W = 1 events:
Neff = (∑
wi)2
∑
w2i
and stop when Neff/nbin > 25.
nbin is the number of bins in the histogram used to
estimate the best division direction/edge and parameter.
The increase of Nsamp is not wasted for cells in which integrand
is already not varying too much. We are now able to push input
Nsamp to high values, with little increase of CPU time.
S. Jadach Krakow, September, 2001
Foam F-17
Program usage very easy (f77)
*--------------------------------------------------------
DOUBLE PRECISION Density
EXTERNAL Density
CALL MCellA_SetkDim( 3) ! number of dimensions
CALL MCellA_SetnBuf( 2000) ! no. of cells
CALL MCellA_SetnSampl( 500) ! no. MC ev./cell (init.)
CALL MCellA_Initialize(Density) ! initialization
DO loop = 1, 200000
CALL MCellA_MakeEvent(Density) ! generate MC event
CALL MCellA_GetMCvector(MCvector) ! get MC event vector
CALL MCellA_GetMCwt(MCwt) ! get MC event weight
CALL GLK_Fil1(1000, MCwt,1d0) ! histogramming
ENDDO
CALL MCellA_Finalize(MCresult,MCerror) !get integr.+err.
*--------------------------------------------------------
User has to set only the number of dimensions kDim.
The other input variables are already preset for the user,
thus calling setters for them is optional.
User needs to provide his own integrand function,
which is here Density.
S. Jadach Krakow, September, 2001
Foam in C++ F-18
Program usage in C++ also easy
//-------------------------------------------------------
Foam FoamX; // Create Simulator
FunTest Density1(FunType); // Create integrand fun.
FoamX.SetnDim( nDim); // Dimension simplical
FoamX.SetkDim( kDim); // Dimension hyp-cubical
FoamX.SetnCells( nCells); // No. of cells
FoamX.Initialize( &Density1 ); // Initialize Foam cells
double *MCvect =new double[nDim+kDim];
for(long loop=0; loop<NevTot; loop++)
FoamX.MakeEvent(); // Generate MC event
FoamX.GetMCvect( MCvect); // Get MC event
MCwt=FoamX.GetMCwt(); // Get MC weight
double MCresult, MCerror;
FoamX.Finalize( &MCresult, &MCerror); // get integral
//------------------------------------------------------
User has to set only the number of dimensions kDim, nDim.
User needs to provide his own integrand function,
which is here Density. Its type FunTest has to inherit from
abstract class FIntegrand.
S. Jadach Krakow, September, 2001
MCell and Foam f77 codes F-19
Programs
MCell v2.02, f77:with up to 1Mega cells is specialized for higher dimensions,
n ≤ 20, hypercubical cells only.
Foam v2.02, f77 :with Nc ≤ 10000 cells, is aimed for up to six-dimensions.
It is upgraded and improved:
both simplices (n ≤ 5) and hypercubes (n ≤ 10) available.
Foam v2.02, c++ :unlimited number of cells Nc and dimension nDim+kDim.
Both simplices and hypercubes available.
Includes hypercubical algorithm MCell with low memory
consumtion as default option.
Foam v2.02, c++: bbased on ROOTpackage (R. Brun et.el.)
Other improvements:
• Cells can be simultaneously simplices in n-dimensions
and hypercubics in k-dimensions.
• It is possibile to start FOAM from SINGLE simplex instead
of unit hyper-cubic.
S. Jadach Krakow, September, 2001
Numerical tests F-20
Tests of MCell/Foam at low dimensions
Three 2-dimensional testing functions:
fa = 1 − Θ(0.5 − |x1 − 0.5| − γ) Θ(0.5 − |x1 − 0.5 − γ|), γ = 0.05,
fb =1
4πR2
γ
π[(R −√
(x1 − 0.25)2 + (x2 − 0.40)2)2 + γ2)],
γ = 0.02, R = 0.35
fc =γ
π[(x1 + x2)2 + γ2)], γ = 0.02.
Functions, 2-dimens. Foam MCell VEGAS
fa(x1, x2) (diagonal ridge) 0.94 0.74 0.03
fb(x1, x2) (circular ridge) 0.80 0.80 0.16
fc(x1, x2) (edge of square) 1.00 1.00 0.53
Results from Foam/MCell are for 5000 cells (2500 active cells)
and cell exploration based on 200 MC events/cell.
Efficiencies are < W > /W εmax with ε=0.0005.
Functions, 3-dimens. Foam MCell VEGAS
fa (thin diagonal) 0.56 0.62 0.002
fb (thin sphere) 0.27 0.50 0.11
fc (surface of cube) 0.66 1.00 0.30
The main point is that efficiency of MCell can be trivially
increased to 100% by increasing no of cells, while for VEGAS
we can NEVER do better.
S. Jadach Krakow, September, 2001
Numerical tests F-21
Tests of MCell at higher dimensions
Double-hump CAMEL test-function of P. Lepage. "! !$#&% # ('$'&% #$' $$ #$! ) +* %$, *$* $$$ % $$ # +* ! * # $$ % $$ ' !$! ! * , *- $$ .& $$ # /$ "! * ,$% . 0%$, ('$'$'$!$' $$ , ! /$ ) * &* 0%$% $$ ! $$ , . /$ ! * %$, 0% $$ $$ , ! /$ * # 0% # $$&*$* $$ ,$,' /$ ) !$! 0% . ('$' * #&, $+* !' /$ ! . !&, (# . ('$'&% , $ ! ' /$ .& % (#$' ('$'$#&% $ !$!+* /$ ) $ !&% ! ! (# .& ' $&*$*-+* /$ ! $ !$# !(!$! . #$'&, $&* !&,+* /$ $ ! . . # ('$'&, +* $ ! %+* /$ $ $ ! * ,- * $$$ ! $ ! #+* 1$ $ ,$, !(#$' ('$'&%$% ' $&* %$,
Efficiency depends mainly on number of cells MCell.
Number of MC trials per Cell cannot be too small.
S. Jadach Krakow, September, 2001
Conclusions F-22
Summary
• New f77 program MCell for 1 Mega cells and n<20 is now available, in
addition to upgraded f77 Foam.
• C++ version of the Foam with dynamic memory allocation now also
available! Also version with ROOT.
• MCell/Foam are are general purpose Monte Carlo simulators/integrators based
on a self-adapting FOAM OF CELLS.
• Cells are simplices and/or hyper-cubics in Foam (f77 and c++), only
hyper-cubics in MCell (f77).
• f77 MCell (and c++ Foam) is able to cope with CPU and MEMORY barriers at
higher dimensions, as numerical tests demonstrate.
• Looking forward for a KillerApp!
Postscript of these slides: http://home.cern.ch/jadach/public/MCell-talk.ps.gz
S. Jadach Krakow, September, 2001