<<

What is inside MC generators...... and why it is wrong

Tomasz Golan University of Rochester / Fermilab

NuSTEC, Okayama 2015 method Buffon’s needle problem

Suppose we have a floor made of parallel strips of wood, each the same width, and we drop a needle onto the floor. What is the probability that the needle will lie across a line between two strips?

Georges-Louis Leclerc, blue are good Comte de Buffon 18th century red are bad

Monte Carlo without computers

If needle length (l) < lines width (t): MC experiment was performed by Mario Lazzarini in 1901 by throwing 3408 2l P = needles: tπ which can be used to estimate π: 2l 3408 355 π = · = = 3.14159292 2l t #red 113 π = · tP

Tomasz Golan MC generators @ NuSTEC 3 / 96 From to Monte Carlo method

■ Stanislaw Ulam was a Polish mathematician

■ He invented the Monte Carlo method while playing solitaire

■ The method was used in Los Alamos, performed by ENIAC computer

■ What is a probability of success in solitaire? ◆ Too complex for an analytical calculations

◆ Lets try N = 100 times and count wins

◆ With N we are getting closer to→ correct ∞ result

Tomasz Golan MC generators @ NuSTEC 4 / 96 Newton-Pepys problem

Monte Carlo method Which of the three Buffon’s needle problem From Solitaire to MC propositions has the greatest Newton-Pepys problem PRNG chance of success? Hit-or-miss method MC integration results Optimization of MC Crude method A Six fair dice are tossed Methods comparison Random from PDF independently and at least CDF CDF discrete one “6” appears. CDF continuous Acceptance-rejection B Twelve fair dice are tossed Quasi-elastic scattering

Tutorial MC independently and at least

MC generators two “6”s appear.

νN interactions νA interactions C Eighteen fair dice are Final state interactions tossed independently and at Formation time least three “6”s appear. Summary

Tutorial generators

Tomasz Golan MC generators @ NuSTEC 5 / 96 Newton-Pepys problem: analytical attempt

■ First, lets go back to high school and calculate this analytically Monte Carlo method Buffon’s needle problem From Solitaire to MC ■ 1 Newton-Pepys problem Let p = 6 be the probability of rolling 6 PRNG Hit-or-miss method MC integration results ■ The probability of not rolling 6 is (1 p) Optimization of MC Crude method − Methods comparison Random from PDF A six attempts, at least one six CDF CDF discrete CDF continuous 6 Acceptance-rejection PA = 1 (1 p) 0.6651 Quasi-elastic scattering − − ≈ Tutorial MC B twelve attempts, at least two sixes MC generators

νN interactions 12 12 11 νA P = 1 (1 p) p(1 p) 0.6187 interactions B − − −  1  − ≈ Final state interactions Formation time C eighteen attempts, at least three sixes Summary

Tutorial generators 18 18 P = 1 (1 p)18 p(1 p)17 p2(1 p)16 0.5973 C − − − 1  − − 2  − ≈

Tomasz Golan MC generators @ NuSTEC 6 / 96 Newton-Pepys problem: MC attempt

def throw (nSixes): ■ MC attempt is just “performing the n = 0 experiment”, so we will be rolling for _ in range (6 * nSixes): dices if random.randint (1, 6) == 6: n += 1 return n >= nSixes ■ Roll 6n times and check if number of def MC (nSixes, nAttempts): sixes is greater or equal n n = 0 for _ in range (nAttempts): ■ Repeat N times and your probability n += throw (nSixes) is given by: return float (n) / nAttempts number of successes P = if __name__ == "__main__": N for i in range (1, 4): print MC (i, 1000)

Tomasz Golan MC generators @ NuSTEC 7 / 96 Newton-Pepys problem: summary

■ Your MC result depends on N Monte Carlo method Buffon’s needle problem From Solitaire to MC ■ Newton-Pepys problem Results for N = 100: PRNG Hit-or-miss method MC integration results Optimization of MC true Crude method PA = 0.71, 0.68, 0.76, 0.65, 0.68 PA = 0.6651 Methods comparison true Random from PDF P = 0.70, 0.56, 0.60, 0.63, 0.69 P = 0.6187 CDF B B CDF discrete true CDF continuous PC = 0.62, 0.62, 0.53, 0.57, 0.62 PC = 0.5973 Acceptance-rejection

Quasi-elastic scattering 6 Tutorial MC ■ Results for N = 10 : MC generators

νN interactions νA interactions PA = 0.6655, 0.6648, 0.6653, 0.6662, 0.6653 Final state interactions PB = 0.6188, 0.6191, 0.6191, 0.6190, 0.6182 Formation time Summary PC = 0.5975, 0.5979, 0.5972, 0.5978, 0.5973 Tutorial generators ■ Your MC results also depends on the way how random numbers were generated

Tomasz Golan MC generators @ NuSTEC 8 / 96 Pseudorandom number generator

■ PRNG is an algorithm for generating a sequence of “random” Monte Carlo method Buffon’s needle problem numbers From Solitaire to MC Newton-Pepys problem PRNG ■ Hit-or-miss method Example: middle-square method (used in ENIAC) MC integration results Optimization of MC ◆ Crude method take n-digit number as your seed Methods comparison Random from PDF CDF ◆ square it to get 2n-digit number (add leading zeroes if CDF discrete CDF continuous necessary) Acceptance-rejection Quasi-elastic scattering ◆ n middle digits are the result and the seed for next number Tutorial MC

MC generators νN interactions ■ Middle-square method for n = 4 and base seed = 1111: νA interactions 2 Final state interactions 1111 = 01234321 2343 → Formation time 23432 = 05489649 4896 Summary . → Tutorial generators . 11112 = 01234321 2343 →

Tomasz Golan MC generators @ NuSTEC 9 / 96 Pseudorandom number generator

■ Nowadays, more sophisticated PRNGs exist, but they also Monte Carlo method Buffon’s needle problem suffer on some common problems: From Solitaire to MC Newton-Pepys problem ◆ PRNG periodicity / different periodicity for different base seed Hit-or-miss method MC integration results Optimization of MC ◆ Crude method nonuniformity of number distributions Methods comparison Random from PDF CDF ◆ correlation of successive numbers CDF discrete CDF continuous Acceptance-rejection

Quasi-elastic scattering

Tutorial MC

MC generators

νN interactions

νA interactions

Final state interactions

Formation time

Summary

Tutorial generators

Mathematics and Computers in Simulations 46 (1998) 485-505

Tomasz Golan MC generators @ NuSTEC 10 / 96 MC integration (hit-or-miss method)

Lets do the following integration using MC method: Monte Carlo method Buffon’s needle problem From Solitaire to MC 1 1 2 1 Newton-Pepys problem 1 1 x 1 PRNG f(x)dx = x dx = = Hit-or-miss method Z0 Z0 2  2 2 0 4 MC integration results Optimization of MC Crude method y Methods comparison Random from PDF ■ take a random point from CDF CDF discrete the [0, 1] [0, 1] square CDF continuous × 1 Acceptance-rejection ■ 1 Quasi-elastic scattering compare it to your f(x) f(x) = 2 x Tutorial MC MC generators ■ repeat N times νN interactions νA interactions ■ count n points below the Final state interactions function Formation time Summary ■ you results is given by 1 x Tutorial generators 1 n n f(x)dx = P = Z0 · N N

Tomasz Golan MC generators @ NuSTEC 11 / 96 N = 100 (hit-or-miss) N = 10000 (hit-or-miss) 0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2 MC result MC result MC

0.1 0.1

0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 Run number Run number

N = 1000 (hit-or-miss) N = 100000 (hit-or-miss) 0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2 MC result MC MC result

0.1 0.1

0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 Run number Run number Optimization of MC

y y Monte Carlo method Buffon’s needle problem From Solitaire to MC Newton-Pepys problem 1 PRNG f(x) = 1 x f(x) = 1 x Hit-or-miss method 2 2 MC integration results Optimization of MC Crude method 0.5 Methods comparison Random from PDF CDF CDF discrete CDF continuous Acceptance-rejection 1 x x Quasi-elastic scattering 1 Tutorial MC

MC generators ■ νN interactions You want to avoid generating “red” points as they do not

νA interactions contribute to your integral

Final state interactions Formation time ■ You can choose any rectangle as far as it contains maximum of Summary f(x) in given range Tutorial generators

Tomasz Golan MC generators @ NuSTEC 13 / 96 Optimization of MC

■ Lets consider the following Monte Carlo method function: Buffon’s needle problem 0.2

From Solitaire to MC )

Newton-Pepys problem 2 PRNG Q Hit-or-miss method 1 ( MC integration results 2 F (Q ) = F 0.1 Optimization of MC 2 2 Crude method (1 + Q ) Methods comparison Random from PDF CDF more or less dipole form 0 CDF discrete CDF continuous factor 2 4 6 8 10 Acceptance-rejection Q2 Quasi-elastic scattering ■ Integrating this function Tutorial MC over Q2 is highly inefficient MC generators 1 νN interactions

■ ) νA interactions However, one can integrate x ( Final state interactions by substitution to get F 0.5 Formation time better performance, e.g. Summary

Tutorial generators 2 x = log10(Q ) 0 2 1 0 1 − − 2 don’t forget about Jacobian x = log10(Q )

Tomasz Golan MC generators @ NuSTEC 14 / 96 MC integration (crude method)

Lets do the following integration using MC method once again: Monte Carlo method Buffon’s needle problem From Solitaire to MC 1 1 2 1 Newton-Pepys problem 1 1 x 1 PRNG f(x)dx = x dx = = Hit-or-miss method Z0 Z0 2  2 2 0 4 MC integration results Optimization of MC Crude method ■ One can approximate y Methods comparison Random from PDF integral CDF CDF discrete b N CDF continuous b a Acceptance-rejection f(x)dx − f(xi) 1 Quasi-elastic scattering Z ≈ N f(x) = x a Xi=1 2 Tutorial MC MC generators where xi is a random νN interactions number from [a, b] νA interactions Final state interactions ■ It can be shown that crude Formation time method is more accurate Summary x Tutorial generators than hit-or-miss ■ We will skip the math and look at some comparisons

Tomasz Golan MC generators @ NuSTEC 15 / 96 N = 100 (hit-or-miss) N = 100 (crude) 0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2 MC result MC result MC

0.1 0.1

0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 Run number Run number

N = 1000 (hit-or-miss) N = 1000 (crude) 0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2 MC result MC MC result

0.1 0.1

0 0 0 200 400 600 800 1000 0 200 400 600 800 1000 Run number Run number Random numbers from probability density function

Monte Carlo method Buffon’s needle problem From Solitaire to MC Newton-Pepys problem PRNG Hit-or-miss method ■ MC integration results How to generate a random 3 Optimization of MC Crude method number from probability Methods comparison Random from PDF density function? 2 CDF

CDF discrete y CDF continuous ■ Lets consider f(x) = 3x2 Acceptance-rejection 1 Quasi-elastic scattering ■ Tutorial MC Which means that x = 1

MC generators should be thrown 2 times 0 √2 0 0.5 1 νN interactions more often than x = 2 x νA interactions

Final state interactions

Formation time

Summary

Tutorial generators

Tomasz Golan MC generators @ NuSTEC 17 / 96 Cumulative distribution function

■ Cumulative distribution function of a random variable X: Monte Carlo method Buffon’s needle problem From Solitaire to MC Newton-Pepys problem F (x) = P (X x) PRNG ≤ Hit-or-miss method MC integration results Optimization of MC Crude method Note: 0 F (x) 1 for all x Methods comparison ≤ ≤ Random from PDF CDF ■ CDF discrete Discrete random variable X: CDF continuous Acceptance-rejection Quasi-elastic scattering F (x) = f(xi) Tutorial MC xXi x ≤ MC generators

νN interactions where f is probability mass function (PMF)

νA interactions ■ Final state interactions Continuous random variable X:

Formation time x Summary

Tutorial generators F (x) = f(t)dt Z −∞ where f is probability density function (PDF)

Tomasz Golan MC generators @ NuSTEC 18 / 96 Cumulative distribution function - discrete example

■ Probability mass function f(x) = 3x2 Monte Carlo method Buffon’s needle problem From Solitaire to MC 1 2 3 4 Newton-Pepys problem with discrete random variables X is , , , , PRNG 30 30 30 30 Hit-or-miss method {q q q q } MC integration results Optimization of MC ■ CDF is given by: Crude method Methods comparison Random from PDF CDF 1 CDF discrete 1 1 CDF continuous 10 if x 30 Acceptance-rejection ≤  q ) 3 2 Quasi-elastic scattering x

 if x (  10 ≤ 30 0.5 Tutorial MC F (x) =  q F  6 if x 3 MC generators 10 ≤ 30 νN q interactions  10 if x 4 νA interactions  10 30 0  ≤ q Final state interactions  0 0.2 0.4 Formation time x Summary Tutorial generators ■ 4 With P = 1 the random number is less or equal to 30 , with q 3 P = 0.6 the random number is less or equal 30 ... q

Tomasz Golan MC generators @ NuSTEC 19 / 96 Cumulative distribution function - discrete example

■ To generate a random number from X according to 3x2: Monte Carlo method Buffon’s needle problem ◆ From Solitaire to MC generate a random number u from [0, 1] Newton-Pepys problem PRNG Hit-or-miss method ◆ 1 MC integration results if u 0.1: x = 30 Optimization of MC ≤ Crude method q Methods comparison Random from PDF ◆ 2 CDF else if u 0.3: x = 30 ... CDF discrete ≤ CDF continuous q Acceptance-rejection Quasi-elastic scattering ■ Results for N = 10000: Tutorial MC MC generators x n n/N f(x) νN interactions

νA interactions 1 30 989 0.0989 0.1 Final state interactions q 2 Formation time 30 1959 0.1959 0.2 Summary q 3 2949 0.2949 0.3 Tutorial generators 30 q 4 30 4103 0.4103 0.4 q

Tomasz Golan MC generators @ NuSTEC 20 / 96 Cumulative distribution function - continuous example

■ Probability density function f(x) = 3x2 Monte Carlo method Buffon’s needle problem From Solitaire to MC Newton-Pepys problem with continuous random variables X range [0, 1] PRNG Hit-or-miss method MC integration results ■ CDF is given by: Optimization of MC Crude method Methods comparison Random from PDF x 1 CDF CDF discrete CDF continuous F (x) = f(t)dt Acceptance-rejection )

Z x Quasi-elastic scattering 0 ( 0.5 F Tutorial MC x MC generators = 3t2dt νN interactions Z 0 0 νA interactions 3 x 3 0 0.5 1 Final state interactions = t = x 0 x Formation time Summary

Tutorial generators ■ Blue area gives the probability that x 0.75 ≤

Tomasz Golan MC generators @ NuSTEC 21 / 96 Cumulative distribution function - continuous example

■ To generate a random number from X according to 3x2: Monte Carlo method Buffon’s needle problem ◆ From Solitaire to MC generate a random number u from [0, 1] Newton-Pepys problem PRNG Hit-or-miss method ◆ 1 MC integration results find x for which F (x) = u, i.e. x = F − (u) Optimization of MC Crude method Methods comparison ◆ x is your guy Random from PDF CDF CDF discrete CDF continuous ■ Acceptance-rejection Results for N = 10000:

Quasi-elastic scattering

Tutorial MC 3 MC generators

νN interactions 1 νA interactions 2 Unfortunately, usually F − is width Final state interactions unknown, which makes this Formation time 1 method pretty useless (at least n/N/ Summary directly). Tutorial generators 0 0 0.5 1 x

Tomasz Golan MC generators @ NuSTEC 22 / 96 Acceptance-rejection method

■ Lets consider Monte Carlo method 0.4 2 3 −x Buffon’s needle problem 2 f(x) = x · e From Solitaire to MC 3 x Newton-Pepys problem f(x) = A x e− PRNG · · Hit-or-miss method 2e y MC integration results with x [0, 1], A = 0.2 Optimization of MC e 2 Crude method ∈ − Methods comparison Random from PDF ■ CDF is given by CDF CDF discrete 0 CDF continuous N 2 0 0.5 1 Acceptance-rejection 2 x F (x) = (x 1)e− x Quasi-elastic scattering 2 −

Tutorial MC

MC generators ■ 1 νN interactions Since, we do not know F − we have to find another way to νA interactions generate x from f(x) distribution Final state interactions Formation time ■ We will use acceptance-rejection method (do you remember Summary MC integration via hit-or-miss?) Tutorial generators

Tomasz Golan MC generators @ NuSTEC 23 / 96 Acceptance-rejection method

■ Evaluate f max(f) max ≥ fmax Monte Carlo method 0.6 Buffon’s needle problem From Solitaire to MC Note: fmax > max(f) will Newton-Pepys problem PRNG affect performance, but the y 0.4 Hit-or-miss method MC integration results result will be still correct Optimization of MC Crude method 0.2 Methods comparison ■ Random from PDF Generate random x CDF 0 CDF discrete f(x) 0 0.5 1 CDF continuous ■ Accept x with P = Acceptance-rejection fmax x Quasi-elastic scattering ◆ generate a random u Tutorial MC from [0, fmax] MC generators 0.4 νN interactions ◆

accept if u < f(x) width νA interactions / Final state interactions 0.2 Formation time ■ on the right shows sum Summary the results for N = 105

Tutorial generators n/A/ 0 0 0.5 1 x

Tomasz Golan MC generators @ NuSTEC 24 / 96 Acceptance-rejection method - optimization

■ The area under the plot of 0.4 Monte Carlo method f(x) is 0.13 Buffon’s needle problem From Solitaire to MC ∼ Newton-Pepys problem PRNG ■

The total area is 0.4 y Hit-or-miss method 0.2 MC integration results Optimization of MC ■ Crude method Thus, only about 30% of Methods comparison Random from PDF points gives contribution to CDF 0 CDF discrete the final distribution CDF continuous 0 0.5 1 Acceptance-rejection ■ x Quasi-elastic scattering One can find g(x) for

Tutorial MC which CDF method is MC generators possible and which 0.4 νN interactions encapsulates f(x) in given νA interactions range and generate x Final state interactions according to g(x) y 0.2 Formation time Summary ■ For g(x) = 0.4x the total Tutorial generators area is 0.2, so we speed up 0 twice 0 0.5 1 x

Tomasz Golan MC generators @ NuSTEC 25 / 96 Acceptance-rejection method - optimization

Monte Carlo method Buffon’s needle problem From Solitaire to MC ■ Newton-Pepys problem Cumulative distribution function for g(x) = 2x PRNG Hit-or-miss method x MC integration results 2 1 Optimization of MC G(x) = g(t)dt = x G− (x) = √x Crude method Z ⇒ Methods comparison 0 Random from PDF CDF Note: PDF must be normalized to 1 for CDF CDF discrete CDF continuous Acceptance-rejection ■ Generate random number u [0, 1] Quasi-elastic scattering ∈ Tutorial MC 1 ■ Calculate your x = G− (u) MC generators νN interactions ■ Accept x with probability P = f(x)/g(x) νA interactions

Final state interactions instead of using constant fmax we are using fmax(x) g(x) Formation time ≡ Summary

Tutorial generators

Tomasz Golan MC generators @ NuSTEC 26 / 96 Quasi-elastic scattering Building a generator step by step Quasi-elastic scattering on a free nucleon

Llewellyn-Smith formula

2 2 2 dσ ν + n l− + p M G cos θ (s u) (s u) l → = F C A(q2) B(q2) − + C(q2) − d q2 ν¯ + p l+ + n 8πE2  ∓ M 2 M 4  | | l → ν

Notation

■ Constants: M - nucleon mass, GF - Fermi constant, θC - Cabibbo angle,

2 2 2 ■ q =(k k′) =(p′ p) - four-momentum squared, where k, k′, p, p′ are four-momenta− of initial− and final lepton, initial and final nucleon

■ Eν - neutrino energy

2 2 ■ s =(k + k′) and u =(k p′) - Mandelstam variables −

Tomasz Golan MC generators @ NuSTEC 28 / 96 Quasi-elastic scattering on a free nucleon

Llewellyn-Smith formula

2 2 2 dσ ν + n l− + p M G cos θ (s u) (s u) l → = F C A(q2) B(q2) − + C(q2) − d q2 ν¯ + p l+ + n 8πE2  ∓ M 2 M 4  | | l → ν

General idea

■ Having k and p, generate k′ and p′

■ Calculate q2 and (s u) = 4ME + q2 m2 based on generated kinematics − ν − ■ Calculate cross section

■ Repeat N times and the result is given by:

1 N σ σ(q2) total ∼ N i Xi=1

Tomasz Golan MC generators @ NuSTEC 29 / 96 Generating kinematics

Monte Carlo method LAB CMS Quasi-elastic scattering ~pN QEL on free N Generating kinematics ~pν ~p ~p LAB ⇆ CMS ∗ ∗ Cross section Generating events A few more steps Tutorial MC ■ Lets consider kinematics in center-of-mass system MC generators νN interactions ■ Mandelstam s is invariant under Lorentz transformation νA interactions Final state interactions 2 2 2 2 s =(k + p) =(E + Ep) (~k + ~p) =(E∗ + E∗) Formation time − p Summary Tutorial generators ■ √s is the total energy in CMS

2 2 2 2 √s = E∗ + Ep∗ = p∗ + m + p∗ + M p p ■ We will use it to calculate p ∗

Tomasz Golan MC generators @ NuSTEC 30 / 96 Generating kinematics

■ Lets do some simple algebra: Monte Carlo method Quasi-elastic scattering 2 2 2 2 QEL on free N √s = E∗ + Ep∗ = p∗ + m + p∗ + M Generating kinematics LAB ⇆ CMS 2p 2 2 p Cross section √s = E∗ + E∗ m + M Generating events − 2 p 2 2 2 A few more steps s = E∗ + E∗ m + M + 2E∗E∗ − p Tutorial MC 2 2 s = 2E∗(E∗ + E∗) m + M MC generators p − νN interactions 2 2 s = 2E∗√s m + M νA interactions − s + m2 M 2 Final state interactions E∗ = − Formation time 2√s Summary s + M 2 m2 Tutorial generators E∗ = − (analogously) p 2√s

■ After more algebra we get:

2 2 2 2 [s (m M) ] [s (m + M) ] p∗ = E∗ m = − − · − p − 2√s

Tomasz Golan MC generators @ NuSTEC 31 / 96 Generating kinematics

z Monte Carlo method ■ We use spherical coordinate Quasi-elastic scattering QEL on free N system to determine Generating kinematics θ p∗ LAB ⇆ CMS momentum direction in Cross section Generating events CMS: A few more steps Tutorial MC ~p∗ = p∗ (sin θ cos φ, sin θ sin φ, cos θ) φ y MC generators · νN interactions x νA interactions Final state interactions ■ Generate random angles: Formation time

Summary Tutorial generators φ = 2π random[0, 1] sin φ, cos φ · ⇒ cos θ = 2 random[0, 1] 1 sin θ, cos θ · − ⇒

■ All we need to do is to go back to LAB frame

Tomasz Golan MC generators @ NuSTEC 32 / 96 LAB ⇆ CMS

■ Lorentz boost in direction nˆ = ~v of (t, ~r): Monte Carlo method v

Quasi-elastic scattering QEL on free N Generating kinematics t′ = γ (t vnˆ ~r) LAB ⇆ CMS Cross section − · Generating events ~r′ = ~r +(γ 1)(ˆn ~r)ˆn γtvnˆ A few more steps − · − Tutorial MC

MC generators ■ In our case LAB νN interactions νA interactions ~pν + ~pN ~p ~v = N ~pν Final state interactions Eν + EN Formation time Summary ■ Boost from LAB to CMS in Tutorial generators ~v direction CMS ■ Boost from CMS to LAB in ~v direction ~p ~p − ∗ ∗

Tomasz Golan MC generators @ NuSTEC 33 / 96 Calculating cross section

Llewellyn-Smith formula

2 2 2 dσ ν + n l− + p M G cos θ (s u) (s u) l → = F C A(q2) B(q2) − + C(q2) − d q2 ν¯ + p l+ + n 8πE2  ∓ M 2 M 4  | | l → ν

Calculation

2 ■ Once we have p′ and k′ in LAB frame we can calculate q and (s u) − ■ Once we have q2 we can calculate A(q2), B(q2), C(q2)

■ We have everything to calculate cross section

■ Do we? Or maybe we are still missing something?

Tomasz Golan MC generators @ NuSTEC 34 / 96 Calculating cross section

Llewellyn-Smith formula

2 2 2 dσ ν + n l− + p M G cos θ (s u) (s u) l → = F C A(q2) B(q2) − + C(q2) − d q2 ν¯ + p l+ + n 8πE2  ∓ M 2 M 4  | | l → ν

Calculation

2 ■ Once we have p′ and k′ in LAB frame we can calculate q and (s u) − ■ Once we have q2 we can calculate A(q2), B(q2), C(q2)

■ We have everything to calculate cross section

■ Do we? Or maybe we are still missing something?

We change the variable we integrate over! We need Jacobian!

Tomasz Golan MC generators @ NuSTEC 35 / 96 Calculating cross section

■ Express q2 in terms of angle:

2 2 2 2 q =(k k′) = m 2kk′ = m 2EE′ + 2 ~k ~k′ cos θ − − − | || |

■ Thus, the Jacobian is given by:

2 dq = 2 ~k ~k′ d(cos θ) | || | Note: must be calculated in CMS

■ Total cross section is given by:

1 2 2 2 M GF cos θC 2 2 (s − u) 2 (s − u) ~ ~ ′ σ = 2 A(q ) ∓ B(q ) 2 + C(q ) 4 2|k||k |d cos θ Z 8πEν  M M  −1

N 2 2 2 2 M GF cos θC 2 2 (si − ui) 2 (si − ui) ′ σMC = A(q ) ∓ B(q ) + C(q ) 2|~ki||~k | N 8πE2  i i M 2 i M 4  i Xi=1 ν

Tomasz Golan MC generators @ NuSTEC 36 / 96 Calculating cross section

Monte Carlo method ■ We want to avoid any Quasi-elastic scattering 1 QEL on free N sharp peaks Generating kinematics LAB ⇆ CMS Cross section ■ They affect our efficiency Generating events 0.5 A few more steps and accuracy [arbitrary units] Tutorial MC θ MC generators ■ dσ Lets change variable once cos

νN interactions d 0 again: 1 0.5 0 0.5 1 νA interactions − − Final state interactions cos θ cos θ = 1 2x2 Formation time − Summary where x [0, 1] 1 Tutorial generators ∈ ■ Note extra Jacobian and new integration limits 0.5

1 0 1 [arbitrary units] dx 2 d(cos θ) dx( 4x) 4xdx dσ 0 Z → Z − → Z 1 1 0 0 0.5 1 − x

Tomasz Golan MC generators @ NuSTEC 37 / 96 Calculating cross section

■ Finally, the cross section is given by:

1 2 2 2 M GF cos θC 2 2 (s − u) 2 (s − u) ~ ~ ′ σ = 2 A(q ) ∓ B(q ) 2 + C(q ) 4 2|k||k |4xdx Z 8πEν  M M  0 N 2 2 2 1 M GF cos θC 2 2 (si − ui) 2 (si − ui) ′ σMC = A(q ) ∓ B(q ) + C(q ) 2|~ki||~k |4x N 8πE2  i i M 2 i M 4  i Xi=1 ν

■ In conclusion: do some kinematics and some boosts between CMS and LAB, change integration variable several times... and you are ready to calculate total cross section

■ Now we need to generate some events. We want them to be distributed according to our cross section formula.

Tomasz Golan MC generators @ NuSTEC 38 / 96 Generating events

■ Generate x [0 : 1] Monte Carlo method ∈ Quasi-elastic scattering ■ Do kinematics QEL on free N Generating kinematics LAB ⇆ CMS σmax Cross section Generating events x cos θ A few more steps → Tutorial MC cos θ k′∗,p′∗ → MC generators k′∗,p′∗ k′,p′ νN interactions → [arbitrary units] νA . dx interactions . dσ . 0 Final state interactions 0 0.5 1 Formation time x Summary ■ Calculate cross section σ Tutorial generators ■ Accept an event with the probability given by σ P = σmax ■ And you almost have you MC neutrino-event generator, just a few more steps...

Tomasz Golan MC generators @ NuSTEC 39 / 96 A few more steps

■ add other dynamics: resonance pion production, deep inelastic Monte Carlo method scattering... Quasi-elastic scattering QEL on free N Generating kinematics LAB ⇆ CMS ■ add support for nucleus as a target Cross section Generating events A few more steps ■ if you have nucleus add some two-body current interactions Tutorial MC MC generators ■ if you have nucleus add some nuclear effects: Pauli blocking, νN interactions final state interactions, formation zone... νA interactions Final state interactions ■ add support for neutrino Formation time beam Summary Tutorial generators ■ add support for detector geometry

■ add some interface to set up simulations parameters and saving the output

■ and your MC is done!

Tomasz Golan MC generators @ NuSTEC 40 / 96 Tutorial: Monte Carlo methods PRNG

Monte Carlo method ■ Quasi-elastic scattering You can use whatever random number generator you want

Tutorial MC PRNG ■ Task 1 If you are using C++ you may consider using PRNG class, Task 2 Task 3 which wraps up mersenne twister engine [link to PRNG.h] Task 4* MC generators ■ Usage: νN interactions

νA interactions Final state interactions const PRNG random (min, max); Formation time random.generate00(); // returns RN from (min, max) Summary

Tutorial generators random.generate01(); // returns RN from (min, max] random.generate10(); // returns RN from [min, max) random.generate11(); // returns RN from [min, max]

Tomasz Golan MC generators @ NuSTEC 42 / 96 Task 1: evaluate π

Monte Carlo method Quasi-elastic scattering y Tutorial MC PRNG Task 1 Evaluate π using MC method Task 2 Task 3 ■ a Task 4* get N random points from

MC generators a square

νN interactions νA interactions ■ count how many points are Final state interactions inside a circle Formation time Summary ■ calculate π Tutorial generators ■ check how the results a x depends on N

Tomasz Golan MC generators @ NuSTEC 43 / 96 Task 2: integration

Lets consider the following Monte Carlo method function: Quasi-elastic scattering 0.2 ) 2 Tutorial MC 2 1 PRNG Q

F (Q ) = ( Task 1 (1 + Q2)2 Task 2 F 0.1 Task 3 Task 4*

MC generators a) Integrate this function over 2 0 νN interactions Q using hit-or-miss 2 4 6 8 10 νA interactions method 2 Final state interactions Q Formation time b) Integrate this function over Summary 2 x = log10(Q ) using the 1 Tutorial generators same method ) x (

c) Compare efficiency F 0.5

d) Integrate this function using crude method 0 2 1 0 1 − − 2 x = log10(Q )

Tomasz Golan MC generators @ NuSTEC 44 / 96 Task 3: generating number from distribution

Monte Carlo method Quasi-elastic scattering Write a program to generate 1 Tutorial MC PRNG random numbers from [0, 1] Task 1 Task 2 according to the following y Task 3 0.5 Task 4* distribution: MC generators νN interactions f(x) = x3 0 νA interactions 0 0.5 1 Final state interactions x Formation time

Summary

Tutorial generators a) using cumulative distribution function

b) using acceptance-rejection method (consider substitution to get better performance)

Tomasz Golan MC generators @ NuSTEC 45 / 96 Task 4*: neutrino-electron scattering

■ For Eν >> me, the cross section for νµ e scattering can be Monte Carlo method approximated by: − Quasi-elastic scattering Tutorial MC 2 PRNG dσ GF s 2 2 2 Task 1 = A + B (1 y) Task 2 dy π · − Task 3   Task 4* where GF - Fermi weak coupling constant, s - Mandelstam MC generators Te variable, y with Te - electron kinetic energy, νN interactions ≡ Eν νA 1 2 2 interactions A = 2 sin θW , B = sin θW , θW - Weinberg angle Final state interactions − Formation time a) Write a program to calculate total cross section for given Summary neutrino energy Tutorial generators dσ b) Using results from a), generate dTe distribution

dσ c) Using results from a), generate d cos θ distribution, hint:

2m E2 cos2 θ cos2 θ T = e ν 2m e (m + E )2 E2 cos2 θ ≈ e 1 cos2 θ e ν − ν −

Tomasz Golan MC generators @ NuSTEC 46 / 96 Monte Carlo neutrino event generators Monte Carlo event generators

Monte Carlo method Quasi-elastic scattering ■ Monte Carlo generators Tutorial MC simulate interactions MC generators Common generators Why do we need them? ■ The main problem Physicists have been using Cooking generator them since ENIAC νN interactions νA interactions ■ Some common generators used Final state interactions in neutrino community: Formation time

Summary Tutorial generators ◆ transport of particles through matter: Geant4, FLUKA

◆ high-energy collisions of elementary particles: PYTHIA

◆ neutrino interactions: GENIE, GIBUU, NEUT, NUANCE, NuWro

Tomasz Golan MC generators @ NuSTEC 48 / 96 Why do we need them?

Monte Carlo method

Quasi-elastic scattering

Tutorial MC MC generators Theory MC generators Experiment Common generators Why do we need them? The main problem Cooking generator

νN interactions

νA interactions Final state interactions ■ Monte Carlo event generators connect experiment (what we Formation time see) and theory (what we think we should see) Summary Tutorial generators ■ Any neutrino analysis relies on MC generators

■ From neutrino beam simulations, through neutrino interactions, to detector simulations

■ Used to evaluate systematic uncertainties, backgrounds, acceptances...

Tomasz Golan MC generators @ NuSTEC 49 / 96 Why do we need them?

Monte Carlo method EXPERIMENT Quasi-elastic scattering

Tutorial MC

MC generators Common generators Why do we need them? The main problem Neutrino Final state Cooking generator Neutrino

νN interactions production interaction propagation

νA interactions

Final state interactions

Formation time

Summary

Tutorial generators

e.g. GEANT4 e.g. GENIE e.g. GEANT4

MONTE CARLO

Tomasz Golan MC generators @ NuSTEC 50 / 96 What is the main problem?

“You use Monte Carlo until you understand the problem” Monte Carlo method Mark Kac Quasi-elastic scattering

Tutorial MC

MC generators Common generators Why do we need them? The main problem Cooking generator ■ In perfect world MC νN interactions MC νA interactions generators would contain

Final state interactions “pure” theoretical models

Formation time Summary ■ In real world theory does Tutorial generators not cover everything input input

■ Neutrino and non-neutrino data are used to tune generators Data

Tomasz Golan MC generators @ NuSTEC 51 / 96 How to build generator

INGREDIENTS: RECIPE:

Phase space

theory ν data other data

educated guesses

Tomasz Golan MC generators @ NuSTEC 52 / 96 Neutrino interactions: free nucleon (Quasi-)elastic scattering

■ Llewellyn-Smith model is ν/l N’ Monte Carlo method usually used for charged Quasi-elastic scattering 0 current quasi-elastic Z /W ± Tutorial MC scattering MC generators

νN interactions (Q)EL scattering ■ Not much difference here ν Rein-Sehgal model N Deep Inelastic Scattering between generators (but AGKY model π in NuWro default parameters) Transition region

νA interactions

Final state interactions Formation time ■ Nucleon structure is Summary parametrized by form Tutorial generators factors

■ Vector Conserved Vector Current (CVC) → ■ Pseudo-scalar Partially Conserved Axial Current (PCAC) → ■ Axial dipole form with one free parameter (axial mass, M ) → A Tomasz Golan MC generators @ NuSTEC 54 / 96 Rein-Sehgal model

π ν/l ∆ N’ 0 Z /W ±

ν N

■ Rein-Sehgal model describes single pion production through baryon resonances below W = 2 GeV

■ It is used by GENIE and NEUT

■ However, GENIE includes only 16 resonances and interference between them is neglected

Tomasz Golan MC generators @ NuSTEC 55 / 96 Deep inelastic scattering [DIS]

Monte Carlo method ■ Quark-parton model is used Quasi-elastic scattering for deep inelastic scattering ν/l Tutorial MC 0 MC generators ■ Bodek-Young modification Z /W ± νN interactions (Q)EL scattering to the parton distributions Rein-Sehgal model 2 Deep Inelastic Scattering at low Q is included by AGKY model ν π in NuWro most generators Transition region

νA interactions

Final state interactions

Formation time Hadronization Summary

Tutorial generators ■ Hadronization is the process of formation hadrons from quarks Hadrons ■ Pythia is widely used at high invariant masses

Tomasz Golan MC generators @ NuSTEC 56 / 96 Andreopoulos-Gallagher-Kehayias-Yang model

Monte Carlo method ■ AGKY hadronization model Quasi-elastic scattering is used in GENIE Hadrons Tutorial MC

MC generators ■ νN interactions It includes phenomenological description of the low invariant (Q)EL scattering Rein-Sehgal model mass based on Koba-Nielsen-Olesen (KNO) scaling Deep Inelastic Scattering AGKY model π in NuWro ■ Transition region Pythia is used for the high invariant mass

νA interactions ■ Final state interactions The smooth transition between two models is made in a

Formation time window W [2.3, 3.0] GeV ∈ Summary

Tutorial generators

Linear KNO PYTHIA transition

tr tr Wmin Wmax

Tomasz Golan MC generators @ NuSTEC 57 / 96 Pion production in NuWro

Monte Carlo method π production Quasi-elastic scattering

Tutorial MC

MC generators

νN interactions (Q)EL scattering Rein-Sehgal model ∆ resonance Quark-parton Deep Inelastic Scattering AGKY model Adler-Rarita-Schwinger model π in NuWro Transition region νA GeV interactions .6 1 W > 1.6 GeV Final state interactions W < Formation time

Summary Tutorial generators RES DIS

RES/DIS distinguish is arbitrary for each MC generator!

Tomasz Golan MC generators @ NuSTEC 58 / 96 Transition region

■ We factorized the reality to RES and DIS

■ We must be careful to avoid double counting

■ The smooth transition between RES and DIS is performed by each generator (but in slightly different way)

■ E.g. in GENIE:

d2σRES d2σR S = − Θ(W W ) dQ2dW  dQ2dW  · cut − Xk k d2σDIS d2σDIS,BY d2σDIS,BY = Θ(W W ) + Θ(W W ) f dQ2dW dQ2dW · − cut dQ2dW · cut − · m Xm where k - sum over resonances in Rein-Sehgal model, m - sum over multiplicity, f = R P with P - probability of given multiplicity (taken form hadronization m m · m m model), Rm - tunable parameter

Tomasz Golan MC generators @ NuSTEC 59 / 96 Neutrino interactions: nucleus Impulse approximation

■ In impulse approximation p Monte Carlo method neutrino interacts with a p Quasi-elastic scattering n ν n single nucleon p Tutorial MC n p MC generators n ■ If ~q is low the impact area p νN interactions | | n usually includes many n νA interactions p ν Impulse approximation nucleons Fermi gas Spectral function Two-body current COH pion production ■ For high ~q IA is justified Summary | | Final state interactions Formation time ■ Squares of transition matrices are summed up and interference Summary terms are neglected Tutorial generators Z A Z A − σ = σp + σn Xi=1 Xi=1

■ High ~q means more than 400 MeV. However, IA is always assumed| |

Tomasz Golan MC generators @ NuSTEC 61 / 96 Fermi gas

protons potential

Monte Carlo method Nucleons move freely neutrons protons EB Quasi-elastic scattering within the nuclear vol- neutrons Tutorial MC potential p ume in constant bind- EF MC generators En ing potential. F νN interactions

νA interactions Impulse approximation Fermi gas Spectral function Two-body current Global Fermi Gas Local Fermi Gas COH pion production Summary 1/3 1/3 Final state interactions ~ 9πN ~ 2 N Formation time pF = pF (r) = 3π ρ(r) r0  4A   A  Summary 300 Tutorial generators Global FG 250 Local FG 200

150

100

Fermi momentum [MeV/c] 50

0 0 1 2 3 4 5 6 7 Distance from the center of nucleus [fm]

Tomasz Golan MC generators @ NuSTEC 62 / 96 Spectral function

12

10 Total Mean Field Part 8 The probability of removing SRC Part 6 of a nucleon with momentum 4

~p and leaving residual nucleus Arbitrary units with excitation energy E. 2 0 0 100 200 300 400 500 600 700 800 P (~p, E) = PMF (~p, E) + Pcorr(~p, E) Momentum [MeV/c]

0.14 0.12 FG 0.1 LFG l′ 0.08 SF

SRC 0.06

Arbitrary units 0.04 spectator l 0.02 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Nucleon momentum [GeV/c]

Tomasz Golan MC generators @ NuSTEC 63 / 96 Two-body current interactions

Monte Carlo method Quasi-elastic scattering Two Body Current Tutorial MC

MC generators l′ νN interactions

νA interactions Impulse approximation 2 particles - 2 holes (2p-2h) VM Fermi gas Spectral function Two-body current COH pion production l Summary

Final state interactions Meson Exchange Current (MEC)

Formation time

Summary Tutorial generators Models in generators

■ Nieves model (GENIE - coming soon, NEUT, NuWro)

■ Transverse Enhancement (TE) model by Bodek (NuWro)

■ Dytman model (GENIE)

Tomasz Golan MC generators @ NuSTEC 64 / 96 Two-body current interactions

■ Nieves model is microscopic calculation

■ TE model introduce 2p 2h contribution by modification of the vector magnetic form factors −

Total MEC cross section MEC / (QEL + MEC)

10 0.5

x = Nieves 0.4 x = TE ) 1 QEL

σ 0.3 + x σ / GeV / nucleon] 0.1 0.2

Nieves / ( -40 x

TE σ 0.1

[10 QEL σ 0.01 0 0.2 0.5 0.8 1.1 1.4 0.2 0.5 0.8 1.1 1.4 Neutrino energy [GeV] Neutrino energy [GeV]

Tomasz Golan MC generators @ NuSTEC 65 / 96 Two-body current interactions

■ Both models provide only the inclusive double differential cross section for the final state lepton

■ Final nucleons momenta are set isotropically in CMS

Nieves Transverse Enhancement

1 1 30 0.8 0.8 6 0.6 0.6 20 4 [GeV] [GeV]

k 0.4 k 0.4 T T 10 0.2 2 0.2 0 0 0 0 -1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1 cosθ cosθ

Tomasz Golan MC generators @ NuSTEC 66 / 96 Coherent pion production

■ Rein-Sehgal model is Monte Carlo method commonly used for ν/l π Quasi-elastic scattering coherent pion production Tutorial MC 0 Z /W ± MC generators ■ Note: it is different model νN interactions than for RES νA interactions Impulse approximation Fermi gas ν A,Z A,Z Spectral function ■ Berger-Sehgal model Two-body current COH pion production replaces RS (NuWro, Summary GENIE - coming soon) Final state interactions

Formation time

Summary

Tutorial generators Comments

■ In COH the residual nucleus is left in the same state (not excited)

■ The interaction occurs on a whole nucleus - no final state interactions

Tomasz Golan MC generators @ NuSTEC 67 / 96 Neutrino interactions - summary

Monte Carlo method Neutrino Quasi-elastic scattering

Tutorial MC

MC generators

νN interactions

νA interactions Impulse approximation Nucleon (IA*) np-nh (semi-IA) Nucleus Fermi gas Spectral function Two-body current COH pion production Summary Final state interactions (Q)EL MEC (2p2h) Coherent π Formation time

Summary

Tutorial generators RES

Final state interactions

DIS

*IA = Impulse Approximation

Tomasz Golan MC generators @ NuSTEC 68 / 96 Final state interactions Final state interactions

FSI describe the propagation of particles created in a primary Monte Carlo method neutrino interaction through nucleus Quasi-elastic scattering

Tutorial MC

MC generators

νN interactions

νA interactions

Final state interactions FSI Intranuclear cascade Cascade algorithm INC input FSI in GENIE

Formation time

Summary

Tutorial generators

All MC generators (but GIBUU) use intranuclear cascade model

Tomasz Golan MC generators @ NuSTEC 70 / 96 Intranuclear cascade

Monte Carlo method Quasi-elastic scattering ■ In INC model particles Tutorial MC are assumed to be classical MC generators and move along νN interactions

νA interactions the straight line.

Final state interactions FSI ■ The probability of passing Intranuclear cascade Cascade algorithm a distance λ (small enough to assume constant nuclear density) INC input FSI in GENIE without any interaction is given by: Formation time Summary λ/λ˜ P (λ) = e− Tutorial generators

1 λ˜ = (σρ)− - mean free path

σ - cross section Can be easily handled with MC methods. ρ - nuclear density

Tomasz Golan MC generators @ NuSTEC 71 / 96 The algorithm for intranuclear cascade

Calculate: −1 λ˜(r) = [σρ(r)]

r

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

move particle by

min(λ, λmax)

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Check r′ > R move particle by

R - nucleus radius min(λ, λmax)

r′

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Check r′ > R move particle by

R - nucleus radius min(λ, λmax)

Yes

The particle leaves nucleus.

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Check r′ > R move particle by

R - nucleus radius min(λ, λmax)

Yes No

xmax The particle Check

leaves nucleus. λ < λmax. No

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Check r′ > R move particle by

R - nucleus radius min(λ, λmax)

Yes No

max x The particle Check

leaves nucleus. λ < λmax. No

Yes

Generate the interaction.

Tomasz Golan MC generators @ NuSTEC 72 / 96 The algorithm for intranuclear cascade

Calculate: λ = λ˜ · ln(P ) −1 λ˜(r) = [σρ(r)] P = rand[0, 1]

Check r′ > R move particle by

R - nucleus radius min(λ, λmax)

Yes No

The particle Check

leaves nucleus. λ < λmax. No

Yes

Check Generate Pauli blocking. the interaction.

Tomasz Golan MC generators @ NuSTEC 72 / 96 INC input

■ The main input to the INC model is the particle-nucleon cross Monte Carlo method

Quasi-elastic scattering section

Tutorial MC ■ MC generators Total cross section affects the mean free path

νN interactions ■ νA interactions Ratios of cross sections

Final state interactions FSI Intranuclear cascade Cascade algorithm σqel σcex σabs INC input , , , ... FSI in GENIE σtotal σtotal σtotal Formation time Summary are used to determine what kind of scattering happened Tutorial generators ■ NuWro and Neut use Oset model for low-energy pions and data-driven cross sections for all other cases

■ GENIE has two models of FSI

Tomasz Golan MC generators @ NuSTEC 73 / 96 FSI in GENIE

Monte Carlo method FSI Quasi-elastic scattering

Tutorial MC

MC generators

νN interactions

νA interactions Intranuke

Final state interactions FSI Intranuclear cascade Cascade algorithm INC input hN Intranuke hA Intranuke FSI in GENIE

Formation time

Summary Tutorial generators ■ intranuclear cascade ■ INC-like with one “effective” interaction ■ data-driven cross sections ■ tuned do hadron-nucleus ■ Oset model for pions data (coming soon) ■ easy to reweight

Tomasz Golan MC generators @ NuSTEC 74 / 96 Formation time Landau Pomeranchuk effect

γ γ Monte Carlo method ■ The concept of Quasi-elastic scattering formation time e e Tutorial MC was introduced by MC generators Landau and Pomeranchuk νN interactions γ γ νA interactions in the context of electrons

Final state interactions passing through a layer of material.

Formation time LP effect ■ Formation time For high energy electrons they observed less radiated energy NOMAD then expected. Summary Tutorial generators ■ The energy radiated in such process is given by:

2 dI ∞ i(ωt ~k ~x(t)) 3 ~j(~x, t)e − · d xdt 3 ∼ Z d k −∞

~x(t) describes the trajectory of the electron.

ω, ~k are energy and momentum of the emitted photon.

Tomasz Golan MC generators @ NuSTEC 76 / 96 Landau Pomeranchuk effect

■ Assuming the trajectory to be a series of γFormation zone γ straight lines (the current density j δ3(~x ~vt)) the radiation integral is: e e ∼ − i(~k~v ω)t e − dt γ γ ∼ Zpath

■ Formation time is defined as: ■ If time between collisions t>>tf , there is no interference and total 1 E E 1 tf = = = γTr.f. radiated energy is just the average ≡ ω ~k~v kp me ωr.f. − emitted in one collision multiplied by k, p - photon, electron four-momenta the number of collisions. ω - photon frequency in the rest r.f. ■ If t<

Tomasz Golan MC generators @ NuSTEC 77 / 96 Formation time in INC

■ One may expect a similar effect in hadron-nucleus scattering.

■ In terms of INC it means that particles produced in primary vertex travel some distance, before they can interact.

■ There are several parametrization used in MC generators

■ Ranft parametrization: E M tf = τ0 ·2 µT

2 2 2 where E, M - nucleon energy and mass, µT = M + pT - transverse mass

■ SKAT parametrization (similar but with pT = 0)

■ NEUT and GENIE use SKAT parametrization

■ NuWro uses Ranft parametrization for DIS and a model based on ∆ lifetime for RES

Tomasz Golan MC generators @ NuSTEC 78 / 96 Comparison with NOMAD data

π

Monte Carlo method ■ Nomad data from π Quasi-elastic scattering Nucl. Phys. B609 (2001) 255. Tutorial MC hEν i ∼ 24 GeV MC generators ■ The average number νN interactions of backward going negative pions π νA interactions with the momentum π Final state interactions

Formation time from 350 to 800 MeV/c. LP effect Formation time NOMAD ■ 0.05 In this neutrino Nomad data Summary energy range NuWro w/o formation time Tutorial generators 0.04 Bπ− are an NuWro with formation time > -

effect of FSI. π 0.03

■ The observable is 0.02 very sensitive

effect. 0 1 10 100 Q2 [(GeV/c)2]

Tomasz Golan MC generators @ NuSTEC 79 / 96 Summary Neutrino-nucleus interactions

For all channels (but coherent) neutrino interactions are factorized in the following way

p p

n

π− n p π− π+ n π0 π0 n n n

p p

+ π− π

IA νN hadronization formation time FSI

■ Is the physics really factorized this way?

■ This factorization is common for all generators

■ However, some pieces are done in different way

Tomasz Golan MC generators @ NuSTEC 81 / 96 MiniBooNE data for CC π production

Monte Carlo method ■ The cross section hEν i 0 Quasi-elastic scattering for π0 (π+) production ∼ 1 GeV 0π± (0π−) Tutorial MC through charge current 1π0 (1π+) MC generators measured by MiniBooNE νN interactions

νA interactions ■ The signal is defined as: charged leptons, no charged pions and Final state interactions

Formation time one neutral pion (one positive pion and no other pions) in the

Summary final state. Neutrino interactions MiniBooNE CC π Summary ■ The result depends on primary vertex and FSI, as pion can be: Tutorial generators ◆ produced in primary vertex

◆ produced in FSI

◆ affected by charge exchange

◆ absorbed

Tomasz Golan MC generators @ NuSTEC 82 / 96 MiniBooNE data for CC π production

Tomasz Golan MC generators @ NuSTEC 83 / 96 MiniBooNE data for CC π production

Tomasz Golan MC generators @ NuSTEC 84 / 96 Summary

Monte Carlo method

Quasi-elastic scattering ■ Tutorial MC MC generators are irreplaceable MC generators tools in high-energy physics νN interactions νA interactions ■ People use them before Final state interactions experiment exists Formation time (feasibility studies, requirements ...) Summary Neutrino interactions MiniBooNE CC π ■ Summary And during data analysis Tutorial generators (systematics uncertainties, backgrounds ...)

■ There are several neutrino event generators and they all differ slightly

■ And, unfortunately, there is no one right generator

Tomasz Golan MC generators @ NuSTEC 85 / 96 Tutorial: analyzing MC output Introduction

Monte Carlo method Quasi-elastic scattering ■ Each neutrino MC event generator performs simulations in two Tutorial MC steps: MC generators νN interactions ◆ cross section calculation νA interactions Final state interactions ◆ event generation Formation time

Summary Tutorial generators ■ Usually, two output files are produced: Introduction gst files Interactive ROOT ◆ cross section per channel (sometimes as a function of Script example Task 1 energy - GENIE, sometimes integrated over flux - NuWro) Task 2 Task 3 Task 4 ◆ ROOT file with TTree of events

Tomasz Golan MC generators @ NuSTEC 87 / 96 Introduction

Monte Carlo method

Quasi-elastic scattering

Tutorial MC

MC generators ■ During tutorial we are going to work with GENIE’s gst file (as νN interactions

νA interactions it requires only ROOT)

Final state interactions

Formation time ■ You can find it here: [gst file]

Summary Tutorial generators ■ If you are interested in more technical details on running Introduction gst files generators visit the web page of NuSTEC school in Liverpool: Interactive ROOT Script example Task 1 Task 2 Task 3 NuSTEC Neutrino Generator School Task 4

Tomasz Golan MC generators @ NuSTEC 88 / 96 gst files

■ The ’gst’ is a GENIE summary ntuple format Monte Carlo method Quasi-elastic scattering ■ Selected branches: Tutorial MC MC generators iev number of events νN interactions νA interactions Q2 momentum transfer squared Final state interactions Formation time W invariant mass Summary

Tutorial generators Introduction nf number of final state particles in hadronic system gst files Interactive ROOT Script example + Task 1 nfpip number of final state π Task 2 Task 3 Task 4 Ef(i) energy of i-th particle in hadronic system

■ You can find all of them in GENIE manual (p. 112): [GENIE manual]

Tomasz Golan MC generators @ NuSTEC 89 / 96 Interactive ROOT

Monte Carlo method # load ROOT file Quasi-elastic scattering root [0] TFile *myFile = new TFile ("file.gst.root") Tutorial MC

MC generators

νN interactions # load TTree νA interactions root [1] TTree *myTree = myFile->Get("gst") Final state interactions Formation time # lepton energy distribution Summary root [2] myTree->Draw("El") Tutorial generators Introduction gst files Interactive ROOT # lepton energy distribution for events with 1 hadron in the final state Script example Task 1 root [3] myTree->Draw("El", "nf == 1") Task 2 Task 3 Task 4 # use TBrowser if you prefer mouse over keyboard root [4] TBrowser t

Tomasz Golan MC generators @ NuSTEC 90 / 96 Script example void analyzeGST (const char *inputFile)

{ TFile *file = new TFile (inputFile); // load root file TTree *tree = (TTree*)file->Get ("gst"); // get proper tree

TH1D *leadingPip = new TH1D ("pip energy", "pip energy", 50, 0, 1);

double leptonEnergy; // lepton energy int nParticlesFS; // number of particle in final state int nPip; // number of positive pion int hadronPDG[100]; // final state hadron pdg double hadronEnergy[100]; // final state hadron energy

// set up branches tree->SetBranchAddress ("El", &leptonEnergy); tree->SetBranchAddress ("nf", &nParticlesFS); tree->SetBranchAddress ("nfpip", &nPip); tree->SetBranchAddress ("pdgf", hadronPDG); tree->SetBranchAddress ("Ef", hadronEnergy); ...

Tomasz Golan MC generators @ NuSTEC 91 / 96 Script example

... const int nEvents = tree->GetEntries(); // get number of events

for (int i = 0; i < nEvents; i++) // events loop

{ tree->GetEntry (i); // get i-th event

if (nPip == 0) continue;

double maxEnergy = 0.0;

for (int j = 0; j < nParticlesFS; j++) // particle loop if (hadronPDG[j] == 211 && hadronEnergy[j] > maxEnergy) maxEnergy = hadronEnergy[j];

leadingPip->Fill (maxEnergy); // events loop } leadingPip->Draw(); } Tomasz Golan MC generators @ NuSTEC 92 / 96 Task 1: basic informations

Monte Carlo method

Quasi-elastic scattering Tutorial MC ■ Using interactive ROOT find the following information on the MC generators simulation: νN interactions

νA interactions

Final state interactions ◆ number of events Formation time Summary ◆ Tutorial generators neutrino beam (flavor, energy) Introduction gst files Interactive ROOT ◆ target Script example Task 1 Task 2 Task 3 ◆ dynamics Task 4

Tomasz Golan MC generators @ NuSTEC 93 / 96 Task 2: basic distributions

Monte Carlo method

Quasi-elastic scattering Tutorial MC ■ Using interactive ROOT plot the following distributions: MC generators

νN interactions νA interactions ◆ proton energy (before FSI) Final state interactions Formation time ◆ proton energy (after FSI) Summary Tutorial generators ◆ lepton energy Introduction gst files Interactive ROOT Script example ◆ lepton energy for QEL Task 1 Task 2 Task 3 ◆ Task 4 lepton energy for all events with no meson in the final state

Tomasz Golan MC generators @ NuSTEC 94 / 96 Task 3: QEL

Monte Carlo method Quasi-elastic scattering ■ Lets define QEL-like events as those without mesons in the Tutorial MC final state MC generators νN interactions dσ ■ 2 νA interactions On the same plot draw dQ [in arbitrary units]: Final state interactions Formation time ◆ Summary total QEL-like

Tutorial generators Introduction ◆ contribution from true QEL gst files Interactive ROOT Script example Task 1 ◆ background for QEL Task 2 Task 3 Task 4 ■ What cut could you apply to reduce background?

Tomasz Golan MC generators @ NuSTEC 95 / 96 Task 4: reconstructed energy

Monte Carlo method

Quasi-elastic scattering

Tutorial MC ■ MC generators For QEL neutrino scattering on a nucleon at rest the incoming

νN interactions neutrino energy can be expressed by lepton kinematics:

νA interactions 2 2 Final state interactions 2(M E )E (E 2M E + m ) rec N − B µ − B − N B µ Formation time Eν = 2[MN EB Eµ + ~kµ cos θµ] Summary − − | | Tutorial generators Introduction gst files ■ Compare true and reconstructed neutrino energy for QEL events Interactive ROOT Script example Task 1 ■ Task 2 Compare true and reconstructed neutrino energy for QEL-like Task 3 Task 4 events

Tomasz Golan MC generators @ NuSTEC 96 / 96