monte carlo and analysis tool study shi-hong yao

30
Monte carlo and analysis tool study Shi-hong yao

Upload: amos-ross

Post on 05-Jan-2016

219 views

Category:

Documents


2 download

TRANSCRIPT

Monte carlo and analysis tool study

Shi-hong yao

motivation

Geant4

-- interest, because it’s seem to very useful for many science domain.

-- to understand how to design a big program?

-- work need…if I need to add/change something.

ROOT, Mysql-- for analysis, histogram, data store.

G4RunManager

In your Main

G4VUserDetectorConstruction

G4VUserPhysicsList

G4VUserPrimaryGeneratorAction

G4UserRunAction

G4RunManager is the only manager class in Geant4 kernel.

SetUserInitialization(…)SetUserAction(…)Initialize();beamOn(numberOfEvent);

Required

Optional

G4UserEventAction

G4UserStackingAction

G4UserTrackingAction

G4UserSteppingAction

User must be implement his own classes drivered from the three abstract classes respective and register them to the RunManager.

You can collect data from these classes or even change/interfere the process in order to reach some purpose.

In your Main

G4UIManager G4UIterminal

In interactive mode,

G4UIsession* session = new G4UIterminal;session->SessionStart();// Work… work… work…your work…delete session;

It’s hard-coded batch mode,G4UImanager* UI =G4UImanager::GetUIpointer();UI->ApplyCommand(“/run/verbose 1");UI->ApplyCommand(“/control/execute macrofile");

Idle> your command#macro file#set verbose level/run/verbose 2#start run/run/beamOn 100

Geant4 as a state machine

PreInit

Abort

Quit

Idle

EventProc

GeomClose

Initialized

beamOn

exit

Basic - Units

• Length(meter)km, m, cm, mm, um, nm, fm …• Surface(meter2)

km2, m2, cm2, mm2, barn, mbarn, …

• Angle(radian)

rad, mrad, sr, deg

…and a lot of extend unit…

• Energy(electron volt)eV, keV, MeV, …, PeV J(joule)• Mass(gram)mg, g, kg• Time(second)s, ms, mus, ns, ps

The units in blue are defined by one.

global

• When you read-in a value, it is recommend to set the units.

• If the units are not specified, it implicitly use the internal units.

• You can output your data with the units you wish.

• By divide the unit.

• You can get the list of units by static function G4UnitDefinition::PrintUnitsTable() or UI command /units/list .

density = 12.0*g/cm3;length = 1*cm;

G4cout << density/(g/cm3);G4cout << length/cm;

Construct Detector

G4VUserDetectorConstruction myDetectorConstructionPublic

Construct(); //pure virtual method which is invoked by G4RunManager when it's Initialize() method is invoked. This method must return the G4VPhysicalVolume pointer which represents the world volume.

Call from G4RunManager

your own concrete class

Material – molecule or mixture

G4ElementH

G4MaterialH2O

It include:Name,atomic number Z, number of nucleons N, atomic mass A,Or, Isotopes.

G4ElementO

x2

x1

G4MaterialOther

It include:Name,Density,State,Temperature,Pressure,Or Components

G4Element* elH = new G4Element(name="Hydrogen", symbol="H" , z= 1., a = 1.01*g/mole);G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a 16.00*g/mole);

G4Material* H2O = new G4Material(name="Water", density = 1.000*g/cm3, ncomponents=2);H2O->AddElement (elH, natoms=2);H2O->AddElement (elO, natoms=1);

Or get material from Geant4 databaseG4NistManager* man = G4NistManager::Instance();G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); See the list: Geant4 Material Database

Detector construct

G4LogicalVolumeLogiVolMother

G4BOX

G4Tube

SD

G4PVPlacement

PhysicsWorld

G4LogicalVolumeLogiVolDaughter

G4LogicalVolumeLogiVolOther

Air

World volume

SolidBox = new G4Box(name, xLangth, yLangth, zLangth);LogiVolMother = new G4LogicalVolume( SolidBox, Air, name2);LogiVolDaughter = new G4LogicalVolume( SolidTube, H2O, name3);PhysicsVolume = new G4PVPlacement( Rot, trans, LogiVolDaughter , name?, LogiVolMother, 0, copyNo);PhysicsWorld = new G4PVPlacement(0, G4ThreeVector(), LogicalVolume, “WORLD”, 0, false, 0);

Return to G4RunManager

G4PVPlacementPhysicsVolume

G4PVPlacementother

Physics list

G4VUserPhysicsList

Three pure virtual method must be implemented by the user.ConstructParticle(); // construction of particlesConstructProcess(); // construct processes and register them to particles SetCuts(); // setting a range cut value for all particles

myPhysicsListPublic

Other method for using:AddTransportation(); //register the G4Transportation class which describes the particle motion in space and time with all particles.SetCutsWithDefault();//

Call from G4RunManager

your own concrete class

ConstructParticle()

pure virtual method.User must define "All PARTICLE TYPES" include not only primary particles, but also all secondaries.

In constructParticle(),explicitly invoke static methods of all particle classes G4Proton::ProtonDefinition();G4Gamma::GammaDefinition();G4MuonMinus::MuonMinusDefinition();…

#include “G4LeptonConstructor.hh”G4LeptonConstructor pConstructor;pConstructor.ConstructParticle();

G4Proton

G4Gamma

G4Electron

G4MuonPlus

More than 100 types of particles are provided by default.

G4BosonConstructor

G4LeptonConstructor

G4MesonConstructor

G4BarionConstructor

G4IonConstructor

G4ShortlivedConstructor.

Define particles one by one or use this six utility classes, corresponding to each of the particle categories.

What is process

seven major categories of processes,electromagnetic, hadronic, transportation, decay, optical, photolepton_hadron, and parameterisation.

G4VProcess

Abstract base class for all physics processes.GPIL method:PostStepGetPhysicalInteractionLength(…);AlongStepGetPhysicalInteractionLength(…);AtRestGetPhysicalInteractionLength(…);

DoIt method:AlongStepDoIt(..);PostStepDoIt(…);AtRestDoIt(…);

Physics processes describe how particles interact with materials.

The GPIL method gives the step length from the current space-time point to the next space-time point. It does this by calculating the probability of interaction based on the process's cross section information.

The DoIt method implements the details of the interaction, changing the particle's energy, momentum, direction and position, and producing secondary tracks if required.

G4Transportation

G4Cerenkov

G4ComptonScattering

G4eplusAnnihilation

G4PhotoElectricEffect

ConstructProcess

AddTransportation();

particle = G4Gamma::GammaDefinition();G4ProcessManager* pmanager = particle->GetProcessManager(); G4PhotoElectricEffect * thePhotoElectricEffect = new G4PhotoElectricEffect();pmanager->AddDiscreteProcess(thePhotoElectricEffect); pmanager->AddDiscreteProcess(theComptonEffect); pmanager->AddDiscreteProcess(thePairProduction); … a lot ...

G4ComptonScattering

G4Gamma

G4ProcessManager

Register related physics process to each particle type. This maybe a big project.

Range Cut

SetCuts

pure virtual method. A "unique cut value in range“ should be defined as a distance which is internally converted to an energy for individual materials.Geant4 recommend cut value is 1.0 mm.

SetCutsWithDefault(); or defaultCutValue = 1.0*mm;

//set cut value for different particle types.SetCutValue(cutForGamma, "gamma");SetCutValue(cutForElectron, "e-"); …

Primary Generation

G4VUserPrimaryGeneratorAction myPrimaryGeneratorAction Public

your own concrete class GeneratePrimaries(G4Event* anEvent );Pure virtual method which is invoked at the beginning of each event.

G4int n_particle = 1;particleGun = new G4ParticleGun(n_particle);particleGun->SetParticleDefinition(G4Proton::ProtonDefinition());particleGun->SetParticleEnergy(120.0*GeV);particleGun->SetParticlePosition(G4ThreeVector(0.0*m, 0.0*m, -5.0*m));particleGun->GeneratePrimaryVertex(anEvent);

G4ParticleGunG4VPrimaryGenerator Public

This class generates primary particle(s) with a given momentum and position.

This is an abstract base class of all of primary generators.

GeneratePrimaryVertex() = 0;

G4GeneralParticleSource

G4HEPEvtInterface

For spatial distributionshttp://reat.space.qinetiq.com/gps/

Call from G4RunManager

PYTHIA8

PYTHIA is a program for the generation of high-energy physics events, i.e. for the description of collisions at high energies between elementary particles such as e+, e-, p and pbar in various combinations. ……Excerpt from PYTHIA’s site

Three step of PYTHIA

Pythia pythia;pythia.readString(“ProcessGroup:ProcessName = ON|OFF”);//List see appendix 1pythia.readFile(FileName);…pythia.init(idA, idB, eA, eB);//pythia.init(idA, idB, eCM);//Currently the program only works with pp, pbar p, e+e- and μ+μ- incoming beams.

while(!pythia.next());//event record found in pythia.eventpythia.event.list();

//do something….

pythia.statistics();

Only PYTHIA itself:1.Initialization2.Event loop3.Finish, statistics

PYTHIA play a generator role

myPrimaryGeneratorAction

G4ParticleGunPYTHIA

while(!pythia.next());for (int i = 1; i < pythia.event.size(); i++){Pythia8::Particle par = pythia.event[i];if (par.status() > 0) { ParticleGun -> SetParticlePosition(G4ThreeVector(par.xProd()*mm,par.yProd()*mm,par.zProd()*mm)); ParticleGun -> SetParticleDefinition(ParticleTable->FindParticle(par.id())); ParticleGun -> SetParticleMomentumDirection(G4ThreeVector(par.px(),par.py(),par.pz())*GeV); ParticleGun -> SetParticleEnergy(par.pAbs()*GeV); ParticleGun -> GeneratePrimaryVertex(anEvent); }}

Particle remnants sent to the particle gun.

visualization

OpenGL

What you can visualize-Detector components-A hierarchical structure of physical volumes-Particle trajectories and tracking steps-Hits of particles in detector components.

HepRep/WIRED

DAWN

???

OpenGL

#Create an empty scene ("world" is default):

/vis/scene/create

#Create a scene handler for a specific graphics system

/vis/open OGLIX

#/vis/open DAWNFILE

#/vis/open HepRepFile

# for drawing the tracks,hits

/vis/scene/add/trajectories

/vis/scene/add/hits

/tracking/storeTrajectory 1

#too many tracks may cause core dump

/vis/scene/endOfEventAction accumulate | refresh

/run/beamOn number

View directly from Geant4 when you are running, it can zoom, rotate, translate, but poor for graphics.

Addition on follow two line before session start.G4VisManager* visManager = new G4VisExecutive;visManager->Initialize();Then execute your program and stop at idle state.

WIRED

Replace OGLIX by HepRepFile

beamOn and produce G4DataX.heprep by Geant4, X is the event number.

View in the WIRED Event Display, you need to install java runtime environment.

And download WIRED from here.

>java -jar HepRApp.jar -file G4DataX.heprep

It can zoom, rotate, translate,…

click to show attributes,

control visibility from hierarchical (tree) view of data

Export to many vector graphic formats (PostScript, PDF, etc.)

Data store -- Mysql

• Benefits

It is a well-designed database manager system.

It is convenient for query specify data with some condition.

Some calculate capability, average, maximum, minimum, and so on.

Run two or more program parallelize without worry about the file conflict.

• Short

You need one computer to do the server.

You can’t run simulation without the server.

Efficiency depend on the network.

You still need other analysis tool for complex calculate.

Using Mysql API

#include “mysql.hh” if you can’t find this file, please contact your system manager….

MYSQL *conn = mysql_init(NULL);

mysql_real_connect(conn, host,user,pass,database, 0, NULL, 0)

mysql_query(conn, querystring);

//receive returned data…

result = mysql_store_result(conn);

for(num_rows=0;row = mysql_fetch_row(result);num_rows++){

eventlist[num_rows]=atoi(row[0]);

}

mysql_free_result(result);

mysql_close(conn);

Get the data you want to store from Geant4 or PYTHIA.According to the Mysql syntax, combine the data into string.Through function mysql_query() or mysql_

Data store – ROOT

• Benefits

ROOT is a very efficient and complete frameworks for analysing large amounts of data.

Root file can store many type of object include TTree.

Structure of TTree is similar to mysql but root provide many fancy function for drawing histogram.

The data directly store at local disk – fast.

• Short

If data has some problem or error, it’s inconvenient to find out and correct.

User Action

G4UserRunAction

G4UserEventAction

G4UserStackingAction

G4UserTrackingAction

G4UserSteppingAction

//at the beginning of the BeamOn() methodvirtual void BeginOfRunAction( const G4Run* aRun);//at the end of the BeamOn() methodvirtual void EndOfRunAction( const G4Run* aRun);

virtual void BeginOfEventAction( const G4Event* anEvent);virtual void EndOfEventAction( const G4Event* anEvent);

void PreUserTrackingAction( const G4Track*);void PostUserTrackingAction( const G4Track*)

void UserSteppingAction(const G4Step*)

void PrepareNewEvent ();G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*) void NewStage () NewStage

Feature work

• I have not yet understand all the detail/concept of Geant4.• Try to understand the physics process.

Thanks for Listening.

Appendix 1

ProcessGroup ProcessName

SoftQCD minBias,elastic, singleDiffractive,doubleDiffractive

HardQCD gg2gg, gg2qqbar, qg2qg, qq2qq, qqbar2gg,qqbar2qqbarNew, gg2ccbar, qqbar2ccbar,gg2bbbar, qqbar2bbbar

PromptPhoton qg2qgamma, qqbar2ggamma, gg2ggamma,ffbar2gammagamma, gg2gammagamma

WeakBosonExchange ff2ff(t:gmZ), ff2ff(t:W)

WeakSingleBoson ffbar2gmZ, ffbar2W, ffbar2ffbar(s:gm)

WeakDoubleBoson ffbar2gmZgmZ, ffbar2ZW, ffbar2WW

WeakBosonAndParton WeakBosonAndParton qqbar2gmZg, qg2gmZq, ffbar2gmZgm, fgm2gmZfqqbar2Wg, qg2Wq, ffbar2Wgm, fgm2Wf

Currently implemented processes, complete with respect to groups, but with some individual processes missing for lack of space (represented by “...”).In the names, a “2” separates initial and final state, an “(s:X)”, “(t:X)” or “(l:X)” occasionally appends info on an s- or t-channel- or loop-exchanged particle X.

ProcessGroup ProcessName

Charmonium gg2QQbar[3S1(1)]g, qg2QQbar[3PJ(8)]q, ...

Bottomonium gg2QQbar[3S1(1)]g, gg2QQbar[3P2(1)]g, ...

Top gg2ttbar, qqbar2ttbar, qq2tq(t:W),ffbar2ttbar(s:gmZ), ffbar2tqbar(s:W)

FourthBottom, FourthTop, FourthPair (fourth generation)

HiggsSM ffbar2H, gg2H, ffbar2HZ, ff2Hff(t:WW), ...

HiggsBSM h, H and A as above, charged Higgs, pairs

SUSY qqbar2chi0chi0 (not yet completed)

NewGaugeBoson ffbar2gmZZprime, ffbar2Wprime, ffbar2R0

LeftRightSymmmetry ffbar2ZR, ffbar2WR, ffbar2HLHL, ...

LeptoQuark ql2LQ, qg2LQl, gg2LQLQbar, qqbar2LQLQbar

ExcitedFermion dg2dStar, qq2uStarq, qqbar2muStarmu, ...

ExtraDimensionsG* gg2G*, qqbar2G*, ...

back