Outline
● Software in HEP
● Detector simulation with GEANT4
● Data analysis with ROOT
Special thanks to various Geant4 tutorials and Summer Student Lecturesby Jan Fiete Grosse-Oetringhaus
3
Why computing is so important?
4
Ages ago physics was evident ...
C.D.Anderson, Phys. Rev. 43, 491–494 (1933)
5
But nowadays long way from ...
6
… through ...
7
… to ...
8
… to ...
… without computers is impossible!
9
Trigger and Event Filter
DAQ
Slow control and monitoring
Reconstruction and Calibration
Monte-Carlo simulation
Analysis tools
Online software Offline software
10
Raw data
● Digitized detector response
– electronics channel id
– signal amplitude (charge, time)
– signal shape (if Flash ADC is used)
– scalers
– …
● Data stored as bytestream files
● Data format is determined by FE electronics and DAQ
● Event rate: up to 200 Hz at LHC
● Event size: up to 1.6 MB in ATLAS
About 100,000,000 channels
in A
TLAS !
11
0000000 aaaa 1234 0008 0000 0002 0000 0001 00000000010 f26b 01c9 7149 0003 0000 0000 0000 00000000020 aabb 1234 0005 0000 4653 2d4f 2032 20200000030 0009 0000 6152 646e 6d6f 7254 2067 20200000040 bbbb 1234 0009 0000 5543 0000 0000 00000000050 0000 0000 0000 0000 0000 0000 0000 00000000060 0000 0000 cccc 1234 0004 0000 0001 00000000070 31ac 0000 34aa aa12 0c6b 0000 0012 00000000080 0000 0300 5015 0079 0001 0000 0000 00000000090 000a 0000 7c0d 4d45 0014 0000 5543 000000000a0 0014 0000 0000 0000 0000 0000 0000 800000000b0 0000 0000 0000 0100 0000 0000 34bb bb1200000c0 0693 0000 0009 0000 0000 0300 5015 00a100000d0 0001 0000 0000 0000 0001 0000 0000 800000000e0 34cc cc12 043f 0000 000b 0000 0000 030000000f0 0030 00a1 0001 0000 0000 0000 0003 00000000100 5543 0000 0014 0000 0000 0000 34dd dd120000110 0035 0000 0008 0000 0000 0300 0010 00a10000120 0001 0000 0000 0000 0000 0000 34ee ee120000130 0009 0000 0000 0300 0010 00a1 0000 0000
12
Offline Data Processing
Event reconstruction
Calibration
Raw data
Data analysis
Nobel Prize !!!
Simulation
13
Calibration
Making correspondence between the detector response and physics quantities measured in the detector
● Detector alignment● Amplification gains● Drift velocity measurement in gas chambers● Timing and T0 calibration ● Energy scale in calorimeters● ….
Depends on signal magnitude, temperature, electric and magnetic fields and many more factors.
Calibration is carried in continuously during the experiment
14
Simulation
Imitating processes in the detector on base of known physics phenomena
Usually made by Monte-Carlo method and necessary for:
● Detector optimization (during R&D and construction phases)● Debugging and tuning the reconstruction software
● Data analysis
– event selection optimization
– background contributions
– study of systematic errors
– comparison with theory predictions
15
Reconstruction
Move from detector response to particle physics
● Pattern recognition
● Track and vertex fitting
● Jet reconstruction
● Reconstruction showers in calorimeters
● Measuring energy, momentum, time of flight
● Particle identification
16
Data analysis
● Event selection
● Background suppression
● Corrections for the energy losses, detector acceptance and efficiency, multiple scattering, secondary interactions etc.
● Getting physics results
● Systematic error study
● Interpretation and input to theorists
17
Software: standard tools vs. custom tools
● Calibration and reconstruction heavily use the knowledge of the detector hardware – software usually developed for each experiment from scratch.
● Simulation is based on known physics laws and models, coupled with knowledge of individual detector geometry and materials. At the moment the GEANT4 toolkit is commonly used to solve this problem.
● Data analysis techniques are more or less the same for all HEP experiments. ROOT software currently is the most popular tool for this work.
18
What about platforms?● The main platform in high energy physics is Linux● Scientific Linux based on RHEL
http://scientificlinux.org/
is the most popular flavor
(de facto standard for WLCG Grid sites)● Reasons:
– it is good for online (fast, robust and stable)– it is good for offline (convenient, safe and stable)– lots of HEP software origin from UNIX time– it is free!
● Current version SL6 (x86_64 or i386)
19
Detector simulation
20
The goal of simulation
Question 1: if we can simulate all physics processes in our detector, maybe we do not need to carry out an experiment at all?
21
The goal of simulation
Question 1: if we can simulate all physics processes in our detector, maybe we do not need to carry out an experiment at all?
Question 2: if we already measured all the quantities, why we need to imitate them on computers?
22
Where is a new boson on this plot?
23
24
The Monte-Carlo method
25
Idea of the method originates from the Manhattan Project: ● S.M. Ulam, J. von Neumann, “On combination of stochastic and deterministic processes”. Bull. Amer. Math. Soc. 53 1120 (1947)● S.M. Ulam, N. Metropolis, “The Monte-Carlo method”, J. Amer. Statist. Assoc. 1949 , 44 Vol 247, 335-341
26
The Monte-Carlo method is a numerical method of solving applied problems using repeated random sampling● Inputs of a stochastic process are generated randomly
according to known probability density function
● Histories of individual objects are simulated in a deterministic way
● Resulting probability density function describes the outcome of the process
27
Example: Rutherford scattering
probability ~ of scattering into an angle Θ
Simulation steps:1. Generate beam of N particles2. Determine random deflection angle Θ for each particle according to known p.d.f and the particle velocity3. Determine random angle φ for each particle flatly in the interval [0,2π)] 4. Simulate scattered particles
28
How to make random sampling?
● Many techniques exists● Uniformly distributed random numbers produced by
programs – pseudorandom generators (algorithms of l'Ecuyer, Marsaglia-Zaman, Mersenne Twister etc)
● “Hit-and-miss” - the simplest method of random sampling of any p.d.f
Y
X
f(X)
Ymax
1. Get random X at [0, Xmax]
2.Get random Y at [0, Ymax]
3.Accept X if Y< f(X)
29
The Monte-Carlo method in HEP
● Stochastic processes in high energy physics are a reflection of quantum mechanical nature of particle interactions
● Experiment in particle physics is typically a multiple measurement of a result of a long chain of stochastic processes – interaction of particles and their passage through matter in the detector
● Three categories of problems:
– simulation of observables (energy, momentum, vertex position etc) according to theory predictions – event generators
– simulation of change of observables after passing through matter
– simulation of detector response
30
The Monte-Carlo method in HEP
● Stochastic processes in high energy physics are a reflection of quantum mechanical nature of particle interactions
● Experiment in particle physics is typically a multiple measurement of a result of a long chain of stochastic processes – interaction of particles and their passage through matter in the detector
● Three categories of problems:
– simulation of observables (energy, momentum, vertex position etc) according to theory predictions – event generators
– simulation of change of observables after passing through matter
– simulation of detector responseUsually settled by GEANT4
31
History of simulation codes● 1950 - mid 60ies – first programs to calculate particle interactions in
matter
● mid 60ies – early 70ies – codes to simulate EM and hadron showers (EGS, GHEISHA, FLUKA …). Mainly used to design radiation protections.
● 1974 – GEANT (GEometry ANd Tracking) appears at CERN
● 1982 – GEANT3 becomes a universal tool for detector simulation on LEP. Remains a standard simulation program for >20 years.
● 1993 – GEANT4 project started
● 2004 – GEANT4 becomes a main tool to simulate LHC experiments
Currently several universal programs are widely used in HEP:
GEANT4, FLUKA, MCNP, MARS
Many more specialized programs: EGS, PENELOPE, SRIM, CALOR, AIRES, CORSIKA, ...
32
The GEANT4 toolkit
33
The GEANT4 code● GEANT4 is developed by the GEANT4 Collaboration● It is an open source and freely distributed under
GEANT4 license ● Source code, builds and documentation are available at
http://cern.ch/geant4● Written in C++● Runs on Linux, Windows and MacOS● References:
S. Agostinelli et al., Geant4: a simulation toolkit, NIM A 506 (2003) 250-303
J. Allison et al., Geant4 developments and applications, IEEE Trans. Nucl. Sci. 53 No. 1 (2006) 270-278
34
● GEANT4 is a toolkit. You have to write simulation program yourself, using tools provided by GEANT4 package
● GEANT4 contains powerful instruments to describe detector geometry and materials
● GEANT4 contains libraries to simulate almost all interactions of elementary particles and nuclei
● GEANT4 has an advanced user interface to control simulation loop and visualization tools
35
Simulation loop
Initialization
Termination
Event 1
Event 2
Event N
Run 1
...
...
It is necessary to describe:● Detector geometry, materials
and fields● Primary particle generator● List of physics processes to
be taken into account
Optional● Sensitive volumes and
detector response● Visualization● Advanced user interface● User extensions
36
#include "G4RunManager.hh"#include "G4UImanager.hh"#include "ExN01DetectorConstruction.hh"#include "ExN01PhysicsList.hh"#include "ExN01PrimaryGeneratorAction.hh"int main(){ // construct the default run manager G4RunManager* runManager = new G4RunManager; // set mandatory initialization classes runManager->SetUserInitialization(new ExN01DetectorConstruction); runManager->SetUserInitialization(new ExN01PhysicsList); // set mandatory user action class runManager->SetUserAction(new ExN01PrimaryGeneratorAction); // initialize G4 kernel runManager->initialize(); // get the pointer to the UI manager and set verbosities G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1"); UI->ApplyCommand("/event/verbose 1"); UI->ApplyCommand("/tracking/verbose 1"); // start a run int numberOfEvent = 10000; runManager->BeamOn(numberOfEvent); // job termination delete runManager; return 0;}
The simplest simulation program
37
Description of detector geometry● Unlike CAD systems, for physics simulation besides of shape one needs to
specify matter distribution
● Materials in GEANT4 are defined as a mixture of atoms using Z, A and density. Liquids, gases and vacuum can be defined as well as solids.
● It is possible to define any electric, magnetic and user-defined fields, which may change in time
● To describe geometry GEANT4 uses a 'Russian dolls' approach (complicated for developers, very flexible for users)
– complex volumes are decomposed to simple ones (box, tube, trapezoid etc)– inner (daughter) volumes are contained in outer (mother volumes) and
positioned in local coordinate system. Intersection of volumes is prohibited– the world volume contains all detector geometry
● Each part of the detector is described via chain 'Solid (shape) → Logical Volume (shape+material) → Placement (volume+position)'
38
ATLAS
39
User interface● Batch mode
● Interactive:jemtchou: ~/geant4/bin/Linux-g++$ ./prog01********************************************************** Geant4 version Name: geant4-08-00-patch-01 (10-February-2006) Copyright : Geant4 Collaboration Reference : NIM A 506 (2003), 250-303 WWW : http://cern.ch/geant4**********************************************************Idle>Idle> /tracking/verbose 1Idle> /control/execute run01.mac
● GUI (next slide)
40
41
Visualization● Many built-in and external viewers: OpenGL, gMocren,
JAS, HepRep, RayTracer, VRML, DAWN ...
42
Known particles all stable and long-lived particles, kaons, optical photons, nuclei and heavy ions Known physics processes
● Electromagnetic processes (0.1 keV – 10 TeV)ionization, Compton scattering, multiple Coulomb scattering, bremsstrahlung, pair production, photoeffect, annihilation, photonuclear and electronuclear processes, synchrotron radiation, transition radiation, Cherenkov radiation, scintillation, optical processes
● Hadronic interactions (0 eV – 100 TeV)elastic and inelastic scattering, capture, fission, nuclear deexcitation
● Transportation● Decays● Parametrization and fast simulation
Particles and physics processes
45
Tracking
PreStepPoint
PostStepPoint
Step Track
● Particles produced if their energy is above the production threshold
● New particles are put in stack● Particles are tracked down to zero kinetic
energy
46
Status and prospects of GEANT4
● GEANT4 has a number of advantages:– universal simulation of almost all interactions of elementary
particles– powerful geometry description– advantages of object-oriented approach: flexibility,
modularity, can extended by user– open source and minimum limitations by license
● It will remain the main simulation tool for HEP at least for another 10 years
● It is being actively adapted for nuclear physics and applied tasks in medicine, astronautics, material science etc.
47
Data analysis with ROOT
48
ROOT● ROOT is an object-oriented framework for
data analysis, written in C++● User interacts with ROOT via C++ interpreter
or by including ROOT functionality in her own program
● Extensive 2D+3D scientific data visualization capabilities
● Extensive set of multi-dimensional histograming, data fitting, modeling and analysis methods
● XROOTD and PROOF: parallel ROOT storage and analysis solutions for clusters
● Developed since 1995 and now it is the main analysis tool in high energy physics
● An open source and freely distributed under LGPL license● Runs on Linux, Windows and MacOS
49
Command line interpreter Cint/Cling
$ rootroot [0] 344+76.8(const double)4.20800000000000010e+002root [1] float x=89.7;root [2] float y=567.8;root [3] x+sqrt(y)(double)1.13528550991510710e+002root [4] float z = x+2*sqrt(y/6);root [5] z(float)1.09155929565429690e+002root [6] cout << “Hello world!” << endl;Hello world!root [7] .q$
50
Macros
Macro is a file interpreted by CINT
Save as mymacro.C
Execute with root [0] .x mymacro.C(10)Or root [0] .L mymacro.C root [1] mymacro(10)Can be compiled using built-in compiler ACLiC
int mymacro(int value){ int ret = 42; ret += value; return ret;}
51
Histograms and Graphs
Binned data. Most popular in HEP
Distinct points
Histogram Graph
52
Histograms
● Histograms are binned data containers● There are 1, 2 and 3-dimensional histograms TH1, TH2, TH3● The data can be stored with different precision and in
different types (byte, short, int, float, double) TH1C, TH1S, TH1I, TH1F, TH1D (same for TH2, TH3)
Histogram Examplehist = new TH1F("hist", "Vertex distribution;z (cm);Events", 20, -10, 10);hist->Fill(0.05);hist->Fill(-7.4);hist->Fill(0.2);hist->Draw();
53
Histogram fitting
root [4] hist->Fit("gaus") FCN=75.7525 FROM MIGRAD STATUS=CONVERGED 67 CALLS 68 TOTAL EDM=4.3218e-09 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 Constant 3.98366e+01 1.69178e+00 5.60562e-03 3.37534e-05 2 Mean -5.23123e-02 3.13950e-02 1.32816e-04 -2.62153e-03 3 Sigma 9.29006e-01 2.57773e-02 2.91662e-05 2.17761e-03
54
ROOT Trees
● Trees have been designed to support very large collections of objects. The overhead in memory is in general less than 4 bytes per entry.
● Trees allow direct and random access to any entry (sequential access is the most efficient)
● Trees are structured into branches and leaves. One can read a subset of all branches
● High level functions like TTree::Draw loop on all entries with selection expressions
● Trees can be browsed via TBrowser● Trees can be analyzed via TTreeViewer
55
Introduction to ROOT - Jan Fiete Grosse-Oetringhaus 55
Tree On Disk One instance in memory
57
Introduction to ROOT - Jan Fiete Grosse-Oetringhaus 57
TTree - Writing
● You want to store 1 million objects of type TMyEvent in a tree which is written into a file
● Initialization
● Fill the tree (1 million times)● TTree::Fill copies content of
member as new entry into the tree● Flush the tree to the file,
close the file
myEvent->SetMember(…); tree->Fill();
tree->Write();f->Close();
TFile* f = TFile::Open("events.root", "RECREATE");TTree* tree = new TTree("Events","Event Tree");TMyEvent* myEvent = new TMyEvent;TBranch* branch = tree->Branch("myevent",
"TMyEvent", &myEvent);
58
Introduction to ROOT - Jan Fiete Grosse-Oetringhaus 58
TTree - Reading
● Open the file, retrieve the tree and connect the branch with a pointer to TMyEvent
● Read entries from the tree and use the content of the class
TFile *f = TFile::Open("events.root");TTree *tree = (TTree*)f->Get("Events");TMyEvent* myEvent = 0;tree->SetBranchAddress("myevent", &myEvent);
Int_t nentries = tree->GetEntries();for (Int_t i=0;i<nentries;i++) { tree->GetEntry(i); cout << myEvent->GetMember() << endl;}
A quick way to browse through a tree is to use a TBrowser
59
TBrowser
60
TFile – a ROOT file
root [16] TFile * f = new TFile("f.root","RECREATE")root [17] f.cd(); root [18] t.Write();root [19] hist.Write();root [20] f.Close();
● ROOT has its own IO, which allows to store any ROOT objects into a file
● A TFile object may contain directories (TDirectory), like a Unix file system
● ROOT files contain dictionary for persistent classes written to the file● The file structure is optimized for sequential access, but random access
is also possible● Data is compressed on the fly to save space
● The ROOT file is portable, backward and forward compatible
61
ROOT contains many more
● FFT library● Oracle, MySQL, etc interfaces● XML drivers● TMVA (Multi Variate Analysis)● GRID, networking and thread classes● Interfaces to Castor, Dcache, GFAL, xrootd● Interfaces to Pythia, Geant3, Geant4, gdml● Matrix packages, Fitting packages, etc
62
More information
– Download– Documentation– Tutorials– Online Help– Mailing list– Forum
http://root.cern.ch
63
Questions?