Computational Lab in Physics: Final Project Monte Carlo Nuclear Collisions: Glauber Model Nuclear Charge Densities Charge densities: similar to a hard sphere. Edge is “fuzzy”. 2 For the Pb nucleus (used at LHC) Woods-Saxon density: r (r) = R = 1.07 fm * A 1/3 a =0.54 fm A = 208 nucleons Probability : r0 1+ e r-R a µ r 2 r (r) 3 Nuclei: A bunch of nucleons Each nucleon is distributed with: P(r,q , f ) = r(r)dV = r(r)r 2 drd(cosq )df Angular probabilities: Flat in f, flat in cos(q). 4 Impact parameter distribution Like hitting a target: Rings have more area Area: Area proportional to probability 2p bdb 5 Collision: 2 Nuclei colliding Red: nucleons from nucleus A Blue: nucleons from nucleus B 6 Interaction Probability vs. Impact Parameter, b After 100,000 events Beyond b~2R Nuclei miss each other Largest probability: Note fuzzy edge Collision at b~12-14 fm Head on collisions: b~0: Small probability 7 Binary Collisions, Number of participants If two nucleons get closer than d<s/p they collide. Each colliding nucleon is a “participant” (Dark colors) Count number of binary collisions. Count number of participants 8 Find Npart, Ncoll, b distributions Nuclear Collisions 9 Final Project: Monte Carlo Model of Nuclear Collisions 1. Nuclear Density Function 2. Make plots of the nuclear density for the Pb nucleus (see slide 3), Distribution of nucleons in the nucleus Using the nuclear density function, write a function that will randomly distribute A nucleons in the nucleus (A=208 for Pb). Make a plots of the x-y, and x-z coordinates of the nucleons in sample nucleus. You will need to distribute them in 3D. You can use spherical polar coordinates (slide 3,4), then convert to cartesian. 10 Final Project: Monte Carlo Model of Nuclear Collisions 3. Impact Parameter, b 4. Make a plot of the impact parameter probability distribution (slide 5) For b = 6 fm, make an example collision between two nuclei. Plot the x-y coordinates of the nucleons in each nucleus (color coded, see slide 6, left plot). Number of collisions, Number of participants For each pair of nucleons (one from nucleus A, one from nucleus B), check if there is a collision. Nucleon-Nucleon Collision: Find the distance d in the x-y plane between each nucleon-nucleon pair (the z axis is the beam axis, see slide 6) Collision: when d2<s/p. Use s = 60 mb (where 1 b = 10-28 m2). Any nucleon that collides is called a “participant”. Color each participant a darker color (as in slides 6, 8). Count the number of nucleon-nucleon collisions. 11 Final Project: Monte Carlo Model of Nuclear Collisions 5. Many collisions! Simulate 106 nucleus-nucleus collision events. Draw a random impact parameter from the distribution in slide 5. Calculate Npart, Ncoll for each collision. For those events where there was an interaction (Ncoll>1), fill histograms of the impact parameter, b. the number of participants the number of collisions (see slide 9) In part II of the project, we will model particle production, and compare it against CMS data. 12 For compiling with root: Using a makefile Enter the following in a file called e.g. make_mcglauber #ROOTCFLAGS =$(shell root-config --cflags) #ROOTLIBS =$(shell root-config --libs) #ROOTGLIBS =$(shell root-config --glibs) CXXFLAGS =$(shell root-config --cflags) LIBS =$(shell root-config --libs) mcglauber: g++ $(CXXFLAGS) -o mcglauber mcglauber.cc $(LIBS) Then, call the makefile using: make -f make_mcglauber 13 Useful code Snippets. 14 Text output into many files: ofstream #include <fstream> char filename[255]; sprintf(filename,"MandelbrotRunDataAdapIter%i.txt",i); cout << filename << endl; ofstream mandelOutput(filename); for (double c_real=RealPartMin[i]; c_real<RealPartMax[i];c_real+=stepSizeRe) { for (double c_imag=ImagPartMin[i]; c_imag<ImagPartMax[i]; c_imag+=stepSizeIm) { // iterate until iter>100 or |z|>4 mandelOutput << c_real << '\t' << c_imag << '\t' << iter << endl; 15 Using the complex class Operators defined for complex numbers Overloading of operators: +, -, *, /, -=, +=, /=, *=, =, ==, != complex_ob + scalar scalar + complex_ob complex_ob + complex_ob Functions: Returning a scalar: T abs(const complex<T> &ob) : absolute value T arg(const complex<t> &ob) : phase angle T conj(…) : complex conjugate cos, cosh, exp, imag, log, log10, pow, real, sin, sinh sqrt, tan, tanh, do the obvious T norm(const complex<T> &ob) : magnitude squared complex<T> polar(const T& v, const T& theta=0) : magnitude specified by v and phase angle specified by theta 16 Demonstrating complex class #include <iostream> #include <complex> using namespace std; int main() { complex<double> cmpx1(1,0); complex<double> cmpx2(1,1); cout << cmpx1 << “ “ << cmpx2 << endl; complex<double> cmpx3 = cmpx1*sqrt(cmpx2); cout << cmpx3 << endl; cmpx3+=10; cout << cmpx3 << endl; return 0; } 17 Reading data from text files //loop to read many files that have a similar name // and one number to index them. for (int i=0; i<nPlots; ++i) { char filename[255]; sprintf(filename,"MandelbrotRunData%i.txt",i); ifstream inputFile(filename); //read the data // example, read 1 line: char buffer[255]l; inputFile.getline(buffer,255); //example, read 3 numbers from a line double number1, number2, number3; inputFile >> number1 >> number2 >> number3; // note that one must take care of end-of-lines. // another useful loop: while(!inputFile.eof()) { // keep reading next line } // do something with data. } 18 Playing with Palettes gStyle: SetPalette(1,0); RGB colors in the range 51 to 99 SetPalette(51,0); Deep blue to light blue Look in TColor class: SetPalette CreateGradientColorTa ble 19 More control over colors: void colorPalette() { //example of new colors (greys) and definition of a new palette const Int_t NRGBs = 5; const Int_t NCont = 256; Double_t stops[NRGBs] = { 0.00, 0.30, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.57, 0.90, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.65, 0.95, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 0.55, 0.15, 0.00, 0.10 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); } TF2 *f2 = new TF2("f2","exp(-(x^2) - (y^2))",-1.5,1.5,-1.5,1.5); //f2->SetContour(colNum); f2->SetNpx(300); f2->SetNpy(300); f2->Draw("colz"); return; 20