Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static...

98
Geant4 toolkits Based on talk prepared by Prof. S. Banerjee in March 2006

Transcript of Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static...

Page 1: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Geant4 toolkits

Based on talk prepared by Prof. S. Banerjee in March 2006

Page 2: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Geant4

Page 3: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Modeling of a Detector

• Detector is modeled by a Geometrical Shape and its material content →

Volume

• Several volume can describe different components of the detector system. Put

them together in a hierarchical structure

Composite Volume = Experimental Setup

Page 4: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Units in Geant4 • All unit needs to be specified, no c=ħ=1, but define those variables inside the

code, that you do not need to remember this

• By default, units are

• Length : mm (not cm)

• Time : ns

• Energy : MeV (not GeV)

• Angle : Radian

• Temperature : Kelvin

• All are defined inside

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

• Do not confused with SI units

$G4INSTALL/source/global/management/include/G4SIunits.hh, which will be

used in track reconstruction algorithm

Though internally, a convention of unit system is used, the recommendation s not

to remember them and use the units explicitly :

double length = 5.8*cm;

double angle = 30.0*degree;

cout <<length/cm; G4BestUnit(egap, “Energy”); G4BestUnit(elen, “Length”);

Page 5: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

• Whereas in G4SIunits.hh

// This file has been provided to CLHEP by Geant4 (simulation toolkit for

HEP).

// The basic units are :

// millimeter (millimeter)

// nanosecond (nanosecond)

// Mega electron Volt (MeV)

// positron charge (eplus)

// degree Kelvin (kelvin)

// the amount of substance (mole)

// luminous intensity (candela)

// radian (radian)

// steradian (steradian)

// meter

// second

// kilogram

// ampere

// degree kelvin

// the amount of substance (mole)

// luminous intensity (candela)

// radian

// steradian

Page 6: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Length [L]

//

static const double millimeter = 1.;

static const double millimeter2 = millimeter*millimeter;

static const double millimeter3 = millimeter*millimeter*millimeter;

static const double centimeter = 10.*millimeter;

static const double centimeter2 = centimeter*centimeter;

static const double centimeter3 = centimeter*centimeter*centimeter;

static const double meter = 1000.*millimeter;

static const double meter2 = meter*meter;

static const double meter3 = meter*meter*meter;

static const double kilometer = 1000.*meter;

static const double kilometer2 = kilometer*kilometer;

static const double kilometer3 = kilometer*kilometer*kilometer;

static const double parsec = 3.0856775807e+16*meter;

Page 7: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

static const double micrometer = 1.e-6 *meter;

static const double nanometer = 1.e-9 *meter;

static const double angstrom = 1.e-10*meter;

static const double fermi = 1.e-15*meter;

static const double barn = 1.e-28*meter2;

static const double millibarn = 1.e-3 *barn;

static const double microbarn = 1.e-6 *barn;

static const double nanobarn = 1.e-9 *barn;

static const double picobarn = 1.e-12*barn;

// symbols

static const double nm = nanometer;

static const double um = micrometer;

static const double mm = millimeter;

static const double mm2 = millimeter2;

static const double mm3 = millimeter3;

static const double cm = centimeter;

static const double cm2 = centimeter2;

static const double cm3 = centimeter3;

static const double m = meter;

static const double m2 = meter2;

static const double m3 = meter3;

static const double km = kilometer;

static const double km2 = kilometer2;

static const double km3 = kilometer3;

static const double pc = parsec;

Page 8: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Angle

//

static const double radian = 1.;

static const double milliradian = 1.e-3*radian;

static const double degree =

(3.14159265358979323846/180.0)*radian;

static const double steradian = 1.;

// symbols

static const double rad = radian;

static const double mrad = milliradian;

static const double sr = steradian;

static const double deg = degree;

//

// Time [T]

//

static const double nanosecond = 1.;

static const double second = 1.e+9 *nanosecond;

static const double millisecond = 1.e-3 *second;

static const double microsecond = 1.e-6 *second;

static const double picosecond = 1.e-12*second;

static const double hertz = 1./second;

static const double kilohertz = 1.e+3*hertz;

static const double megahertz = 1.e+6*hertz;

// symbols

static const double ns = nanosecond;

static const double s = second;

static const double ms = millisecond;

Page 9: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Electric charge [Q]

//

static const double eplus = 1. ;// positron charge

static const double e_SI = 1.602176487e-19;// positron charge in coulomb

static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus

//

// Energy [E]

//

static const double megaelectronvolt = 1. ;

static const double electronvolt = 1.e-6*megaelectronvolt;

static const double kiloelectronvolt = 1.e-3*megaelectronvolt;

static const double gigaelectronvolt = 1.e+3*megaelectronvolt;

static const double teraelectronvolt = 1.e+6*megaelectronvolt;

static const double petaelectronvolt = 1.e+9*megaelectronvolt;

static const double joule = electronvolt/e_SI;// joule = 6.24150 e+12 * MeV

// symbols

static const double MeV = megaelectronvolt;

static const double eV = electronvolt;

static const double keV = kiloelectronvolt;

static const double GeV = gigaelectronvolt;

static const double TeV = teraelectronvolt;

static const double PeV = petaelectronvolt;

Page 10: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Mass [E][T^2][L^-2]

//

static const double kilogram = joule*second*second/(meter*meter);

static const double gram = 1.e-3*kilogram;

static const double milligram = 1.e-3*gram;

// symbols

static const double kg = kilogram;

static const double g = gram;

static const double mg = milligram;

// Power [E][T^-1]

static const double watt = joule/second;// watt = 6.24150 e+3 * MeV/ns

// Force [E][L^-1]

static const double newton = joule/meter;// newton = 6.24150 e+9 * MeV/mm

// Pressure [E][L^-3]

#define pascal hep_pascal // a trick to avoid warnings

static const double hep_pascal = newton/m2; // pascal = 6.24150e+3 * MeV/mm3

static const double bar = 100000*pascal; // bar = 6.24150e+8 * MeV/mm3

static const double atmosphere = 101325*pascal; // atm = 6.32420e+8 * MeV/mm3

Page 11: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Electric current [Q][T^-1]

static const double ampere = coulomb/second; // ampere =6.24150 e+9 * eplus/ns

static const double milliampere = 1.e-3*ampere;

static const double microampere = 1.e-6*ampere;

static const double nanoampere = 1.e-9*ampere;

// Electric potential [E][Q^-1]

static const double megavolt = megaelectronvolt/eplus;

static const double kilovolt = 1.e-3*megavolt;

static const double volt = 1.e-6*megavolt;

// Electric resistance [E][T][Q^-2]

static const double ohm = volt/ampere;// ohm =1.60217e-16*(MeV/eplus)/(eplus/ns)

// Electric capacitance [Q^2][E^-1]

static const double farad = coulomb/volt;// farad = 6.24150e+24 *

eplus/Megavolt

static const double millifarad = 1.e-3*farad;

static const double microfarad = 1.e-6*farad;

static const double nanofarad = 1.e-9*farad;

static const double picofarad = 1.e-12*farad;

Page 12: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Magnetic Flux [T][E][Q^-1]

static const double weber = volt*second;// weber = 1000*megavolt*ns

// Magnetic Field [T][E][Q^-1][L^-2]

static const double tesla = volt*second/meter2;// tesla

=0.001*megavolt*ns/mm2

static const double gauss = 1.e-4*tesla;

static const double kilogauss = 1.e-1*tesla;

// Inductance [T^2][E][Q^-2]

static const double henry = weber/ampere;// henry =

1.60217e-7*MeV*(ns/eplus)**2

// Temperature

static const double kelvin = 1.;

// Amount of substance

static const double mole = 1.;

// Activity [T^-1]

static const double becquerel = 1./second ;

static const double curie = 3.7e+10 * becquerel;

// Absorbed dose [L^2][T^-2]

static const double gray = joule/kilogram ;

static const double kilogray = 1.e+3*gray;

static const double milligray = 1.e-3*gray;

static const double microgray = 1.e-6*gray;

Page 13: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

$CLHEP_BASE_DIR/Units/CLHEP/Units/SystemOfUnits.h

// Luminous intensity [I]

static const double candela = 1.;

// Luminous flux [I]

static const double lumen = candela*steradian;

// Illuminance [I][L^-2]

static const double lux = lumen/meter2;

// Miscellaneous

static const double perCent = 0.01 ;

static const double perThousand = 0.001;

static const double perMillion = 0.000001;

} // namespace CLHEP

Page 14: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Basic Structure

Old Paradigm : Geant3

Data Structures

PART, MATE, TMET, VOLU,

ROTM, SETS during

initialisation

VERT, KINE as event input

HiTS, DIGI, XYZ (also new

VERT, KINE) as event output

New Paradigm : Geant4

Objects

ParticleTable, Material, Solid,

LogicalVolume, PhysicalVolume,

SensitiveDetector during

initialisation

Track as event input

Hit, Digit, Trajectory (also new

Track) as event output

Page 15: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Initialisation

• Complete tables of particles with their static properties

• Initialise physics processes, prepare tables of cross sections, ranges etc in view of approximations and cuts

• Carry out the construction of detector geometry including all material

properties

• Take the input and output attributes and appropriate action

Page 16: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Event loop • Geometry has to be closed before event loop starts

– Done just before the first event in GEANT4 (during initialisation in Geant3)

• Get inputs from event

generators; particle with 4-

momenta and space-time

information at the start.

• Trace particles through

detector media and take care

of the particle-medium

interaction

• Store energy deposits in media

which can transform deposited

energy to detectable signal

• Store relavent parameters

which can be used for further

analysis.

• Keep track of all particles,

primary and secondary

Page 17: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

• Termination

– Produce plots/histogrammes etc

– Prepare run statistics

• What Simulation Tool Kit Provides ?

– Geometry Moduler

– Particle table with particle properties

– Physics processes with cross sections, final state products, kinematics of

particles produced in interactions,….

– Stepping through detector material and finding out what is to be done in which

step

– Provision of I/O capability

Page 18: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

• What User has to provide ?

– Define detector geometry with material definition

– Identify components of the detector which will generate signals and attributes

requires to compute these

– Interface event generators to the simulation tool kit

– Store information for further usage

– Convert energy deposits to detector signals

• What is special about GEANT ?

– Particle transport is automatically taken care of – good interface between

geometry and tracking

– Covers physics over a wide energy region – applicable to space science, high

energy and nuclear physics, medical imaging

Page 19: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Defining a Meterial • Material has a Name, effective Atomic Number and Weight, Density, Radiation (X0) and absorption (λ)

– Can be defined by specifying the attributes

– If X0, λ are not known but the chemical composition is known, one can furnish these information and GEANT can compute the required attributes

• Can in addition define the state, isotopic properties, ….

– Define pesudo-elements

• G4Material (name, Z, A, Density, State, Temperature, Pressure)

– Define a mixture of elements in atomic or weighted proportion

• G4Element (Name, Symbol, A,Z)

• G4Material (name, Z, A, Density, State, Temperature, Pressure)

– AddElement(Element, nAtom)

– AddElement(Element, fraction)

– Defining a mixture of materials by weighted proportion

• AddMaterial(Matrial, fraction)

Air in the Tracking (thin gaps) may be different in tracking properties from

Air between coil and yoke (large gap)

Page 20: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Detector construction G4double A, Z;

G4Element* eln = new G4Element(“Nitrogen”, “N”, Z=7., A=14.01*g/mole);

G4Element* elo = new G4Element(“Oxygen”, “O”, Z=8., A=16.00*g/mole);

G4Material* air = new G4Material(“Air”, 1.205E=03*g/cm3, 2);

air→AddElement(eln, 0.7);

air->AddElement(elo, 0.3);

Defines the material Air consisting of two constituent elements Nitrogen and

Oxygen in a given weight proportion. The elements Nitrogen and Oxygen are

defined with their appropriate A, Z values.

• G4NistManager* mat = G4NistManager :: Instance();

• G4Element* S = mat FindOrBuildElement (“S”);

• G4Material * Butane = mat FindOrBuildMaterial (“G4-Butane”);

Page 21: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Defining a volume

Page 22: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Defining a volume

• There are several ways to defining solids

– Constructed Solids Geometry (CSG) Solids : G4Box, G4Trd, G4Trap, G4Tubs,

G4Cones, G4Sphere, G4Polycon, ……

– Boundary Represented (BREPS) Solids : defined via the description of their

boundaries, much slower navigation,

G4BtrpSolidPcone, G4BREPSolidPolyhydra

– Boolean : Solids made out of adding, subtracting, intersecting several solids :

G4RotateSolid

– STEP : To import from the CAD system

Though internally, a convention of unit system is used, the recommendation s not

to remember them and use the units explicitly :

double length = 5.8*cm;

double angle = 30.0*degree;

cout <<length/cm; G4BestUnit(egap, “Energy”); G4BestUnit(elen, “Length”);

Page 23: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Constructed Solid Geometry (CSG) Solids

G4Box(const G4String& pName,

G4double pX, //half length in X, 30

G4double pY, // half length in Y, 40

G4double pZ) // half length in Z, 60

G4Tubs(const G4String& pName,

G4double pRMin, //Inner radius, 10

G4double pRMax, // Outer radius, 15

G4double pDz, // Half length in Z, 20

G4double pSPhi, // Starting Phi angle in radian, 1.75π

G4double pDPhi); // Angle of segment in radians, 0.25π

Cylindrical Section or Tube:

Page 24: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Constructed Solid Geometry (CSG) Solids G4CutTubs( const G4String& pName,

G4double pRMin, //12

G4double pRMax, //20

G4double pDz, //30

G4double pSPhi, //0

G4double pDPhi, //1.5π

G4ThreeVector pLowNorm, //Outside normal at −Z, (0,-0.7,-0.71),

G4ThreeVector pHighNorm ) // Outside normal at +Z, (0.7,0,0.71)

G4Cons(const G4String& pName,

G4double pRmin1,

G4double pRmax1,

G4double pRmin2,

G4double pRmax2,

G4double pDz,

G4double pSPhi,

G4double pDPhi)

Cone or Conical section:

Page 25: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Constructed Solid Geometry (CSG) Solids G4Para(const G4String& pName,

G4double dx,

G4double dy,

G4double dz,

G4double alpha, // Angle formed by the y axis and by the

plane joining the centre of the faces

parallel to the z-x plane at −dy and +dy

G4double theta, // Polar angle of the line joining the centres

of the faces at −dz and +dz in z

G4double phi); // Azimuthal angle of the line joining the

centres of the faces at −dz and +dz in z

Parallelepiped:

Trapezoid:

G4Trd(const G4String& pName,

G4double dx1, // Half-length along x at the surface positioned at –dz, 30

G4double dx2, // Half-length along x at the surface positioned at +dz, 10

G4double dy1, // Half-length along y at the surface positioned at –dz,

40

G4double dy2, // Half-length along y at the surface positioned at +dz, 15

G4double dz); // Half-length along z axis, 60

Page 26: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids: Generic Trapezoid

G4Trap(const G4String& pName,

G4double pZ, // Length along z

G4double pY, // Length along y

G4double pX, // Length along x at the wider side

G4double pLTX); // Length along x at the narrower side

(plTX<=pX)

G4Trap(const G4String& pName,

G4double pDz, // Half z length, 60

G4double pTheta, // Polar angle of the line joining the centres of the faces at -/+pDz,

20*Degree

G4double pPhi, // Azimuthal angle of the line joining the centre of the face at -pDz to the

centre of the face at +pDz, 5*Degree

G4double pDy1, // Half y length at –pDz, 40

G4double pDx1, // Half x length of the side at y=+pDy1 of the face at –pDz, 30

G4double pDx2, // Half x length of the side at y=+pDy1 of the face at –pDz, 40

G4double pAlp1, //Angle with respect to the y axis from the centre of the side (lower endcap),

10*Degree

G4double pDy2, // Half y length at +pDz, 16

G4double pDx3, // Half x length of the side at y=-pDy2 of the face at +pDz, 10

G4double pDx4, // Half x length of the side at y=+pDy2 of the face at +pDz, 14

G4double pAlp2); // Angle with respect to the y axis from the centre of the

side (upper endcap), 10*Degree

Page 27: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids: Sphere or Spherical Shell Section

G4Sphere(const G4String& pName,

G4double pRmin, // Inner radius, 100

G4double pRmax, // Outer radius, 120

G4double pSPhi, // Starting Phi angle of the

segment in radians, 0*Degree

G4double pDPhi, // Delta Phi angle of the segment

in radians, 180*degree,

G4double pSTheta, // Starting Theta angle of the

segment in radians , 0*Degree

G4double pDTheta); // Delta Theta angle of the

segment in radians, 180*Degree

G4Orb(const G4String& pName,

G4double pRmax); // Outer Radius,100

Same as G4Sphere with: pRmin = 0, pSPhi =

0, pDPhi = 2*Pi, pSTheta = 0, pDTheta= Pi

Page 28: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids: Torus

G4Torus(const G4String& pName,

G4double pRmin, //Inside Radius, 40

G4double pRmax, // Outside Radius, 60

G4double pRtor, // Swept radius of torus, 200

G4double pSPhi, // Starting Phi angle in

radians (fSPhi+fDPhi<=2PI, fSPhi>-2PI), 0

G4double pDPhi); // Delta angle of the segment

in radians, 90*Degree

Page 29: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids: Polycons (PCON)

Change in both inner and outer radius:

G4Polycone(const G4String& pName,

G4double phiStart, // Initial Phi starting angle. 0.25π

G4double phiTotal, // Total Phi angle, 1.5 π

G4int numZPlanes, // Number of z planes, 9

const G4double zPlane[], // Position of z planes, , { 5,

7, 9, 11, 25, 27, 29, 31, 35 }

const G4double rInner[], // Tangent distance to

inner surface, {0, 0, 0, 0, 0, 0, 0, 0,0}

const G4double rOuter[]), // Tangent distance to

outer surface, { 0, 10, 10, 5 ,5, 10 , 10 , 2, 2}

Only change in outer radius :

G4Polycone(const G4String& pName,

G4double phiStart,

G4double phiTotal,

G4int numRZ, // Number of corners in r,z space

const G4double r[], // r coordinate of corners

const G4double z[]), z coordinate of corners

Page 30: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids: Polyhedra (PGON)

Change in both inner and outer radius:

G4Polyhedra(const G4String& pName,

G4double phiStart, //Initial Phi starting angle. −π/4

G4double phiTotal, // Total Phi angle, (5/4)π

G4int numSide, // Number of sides, 3

G4int numZPlanes, //Number of z planes, 7

const G4double zPlane[], //Position of z planes, { 0, 5,

8, 13 , 30, 32, 35 }

const G4double rInner[], //Tangent distance to inner

surface, { 0, 0, 0, 0, 0, 0, 0 },

const G4double rOuter[] );//Tangent distance to outer

surface { 0, 15, 15, 4, 4, 10, 10 },

Only change in outer side :

G4Polyhedra(const G4String& pName,

G4double phiStart,

G4double phiTotal,

G4int numSide,

G4int numRZ, // Number of corners in r,z space

const G4double r[], // r coordinate of corners

const G4double z[] ); //z coordinate of corners

Page 31: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids:Tube with an elliptical cross section

G4EllipticalTube(const G4String& pName,

G4double Dx, // Half length X, 5

G4double Dy, // Half length Y, 10

G4double Dz); // Half length Z, 20

G4Ellipsoid(const G4String& pName,

G4double pxSemiAxis, // Semiaxis in X, 10

G4double pySemiAxis, // Semiaxis in Y, 20

G4double pzSemiAxis, // Semiaxis in Z, 50

G4double pzBottomCut=0, //lower cut plane level, z, −10

G4double pzTopCut=0); // Upper cut plane level, z, 40

Page 32: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids : Cone with Elliptical Cross Section

G4EllipticalCone(const G4String& pName,

G4double pxSemiAxis, // Semiaxis in X, 30/75

G4double pySemiAxis, // Semiaxis in Y, 60/75

G4double zMax, // Height of elliptical cone, 50

G4double pzTopCut); // upper cut plane level, 25

x = pxSemiAxis * ( zMax - u ) / u * Cos(v)

y = pySemiAxis * ( zMax - u ) / u * Sin(v)

z = u , Where v is between 0 and 2*Pi, and u

between 0 and h respectively.

Paraboloid, a solid with parabolic profile:

G4Paraboloid(const G4String& pName,

G4double Dz, // Half length Z, 20

G4double R1, // Radius at –Dz, 20

G4double R2); // Radius at +Dz (≥R1), 35

rho**2 <= k1 * z + k2;

-dz <= z <= dz

r1**2 = k1 * (-dz) + k2

r2**2 = k1 * ( dz) + k2

Page 33: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids : G4Hype G4Hype(const G4String& pName,

G4double innerRadius, // Inner radius, 20

G4double outerRadius, // Outer radius, 30 G4double

innerStereo, // Inner stereo angle in radians, 0.7

G4double outerStereo, // Outer stereo angle in radians, 0.7

G4double halfLenZ); // Half length in Z, 50

A stereo angle of 0 gives a cylindrical surface:

Tetrahedra:

G4Tet(const G4String& pName,

G4ThreeVector anchor, // Anchor point, {0, 0, sqrt(3)},

G4ThreeVector p2, // Point2, { 0, 2*sqrt(2/3), -1/sqrt(3) },

G4ThreeVector p3,// Point3, {-sqrt(2), -sqrt(2/3),-1/sqrt(3)},

G4ThreeVector p4, // Point4, { sqrt(2), -sqrt(2/3) , -1/sqrt(3) }

G4bool *degeneracyFlag=0); // Flag indicating

degeneracy of points

Page 34: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Xxxxx CSC Solids : Extruded Polygon

Fixed outline in the defined Z sections :

G4ExtrudedSolid(const G4String& pName,

std::vector<G4TwoVector> polygon, // the vertices of

the outlined polygon defined in clockwise

Order, {-30,-30},{-30,30},{30,30},{30,-30}, {15,-30},

{15,15},{-15,15},{-15,-30}

std::vector<ZSection> zsections); // the z-sections

defined by z position in increasing order,

[60,{0,30},0.8],[-15, {0,-30},1.], [10,{0,0},0.6],

[60,{0,30},1.2]

G4ExtrudedSolid(const G4String& pName,

std::vector<G4TwoVector> polygon, //

G4double hz, // Half length in Z

G4TwoVector off1, // Offset of the side in -hz

G4double scale1, // Scale of the side in +hz

G4TwoVector off2, // Offset of the side in +hz

G4double scale2); // Scale of the side in -hz

Page 35: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids : Box Twisted

G4TwistedBox(const G4String& pName,

G4double twistedangle, // Twist angle, 30*Degree (<90o )

G4double pDx, // Half X length, 30

G4double pDy, // Half Y length, 40

G4double pDz); // Half Z length, 60

Page 36: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids : Box Twisted

G4TwistedTrap(const G4String& pName,

G4double twistedangle, // Twisted angle,

G4double pDxx1, // Half x length at y=-pDy

G4double pDxx2, // Half x length at y=+pDy

G4double pDy, // Half y length

G4double pDz); // Half z length

G4TwistedTrap(const G4String& pName,

G4double twistedangle, // Twisted angle, 30*Degree

G4double pDz, // Half z length, 60

G4double pTheta, // Polar angle of the line joining the centres of the faces at -/+pDz,

20*Degree

G4double pPhi, // Azimuthal angle of the line joining the centre of the faceat -pDz to the

centre of the face at +pDz, 5*Degree

G4double pDy1, // Half y length at –pDz, 40

G4double pDx1, // Half x length at y=-pDy, 30

G4double pDx2, // Half x length at y=+pDy, 40

G4double pDy2, // Half y length at +pDz, 16

G4double pDx3, // Half x length at +pDz, y=-pDy2, 10

G4double pDx4, // Half x length at +pDz, y=+pDy2, 14

G4double pAlph); // Angle with respect to the y axis from the centre of the side,

10*Degree

Page 37: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSC Solids : Twisted Trapezoid with x and y

dimensions varying along z: G4TwistedTrd(const G4String& pName,

G4double pDx1, // Half x length at the surface

positioned at –dz, 30

G4double pDx2, // Half x length at the surface

positioned at +dz, 10

G4double pDy1, // Half y length at the surface

positioned at –dz, 40

G4double pDy2, // Half y length at the surface

positioned at +dz, 15

G4double pDz, // Half z length, 60

G4double twistedangle); // Twisted angle, 30*Degree

Page 38: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

CSG Solids : Tube Section Twisted along Its Axis

G4TwistedTubs(const G4String& pName,

G4double twistedangle, // Twisted angle, 60*Degree

G4double endinnerrad, // Inner radius at endcap, 10

G4double endouterrad, // Outer radius at endcap , 15

G4double halfzlen, // Half z length , 20

G4double dphi); // Phi angle of a segment , 90*Degree

• the number of segments in phi and the total angle

for all segments, or

• a combination of the above constructors providing

instead the inner and outer radii at z=0 with different

zlengths along negative and positive z-axis.

Page 39: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Example of specific BREP solids

G4BREPSolidPCone( const G4String& pName,

G4double start_angle,

G4double opening_angle,

G4int num_z_planes, // sections,

G4double z_start,

const G4double z_values[],

const G4double RMIN[],

const G4double RMAX[] );

The conical sections do not need to fill 360 degrees, but can have a common start

and opening angle.

start_angle starting angle

opening_angle opening angle

num_z_planes number of planes perpendicular to the z-axis used.

z_start starting value of z

z_values z coordinates of each plane

RMIN radius of inner cone at each plane

RMAX radius of outer cone at each plane

Page 40: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Definition of Detector Setup

To define a set up, one needs to

– Define a Master or World reference system

– Position the various components with respect to each other

Uses the concept of PhysicalVolume which is a LogicalVolume positioned in a Mother (PhysicalVolume or LogicalVolume) with a translation vector and rotation matrix (optional). For the top level volume (defining the World reference system) the reference Mother Volume is a Null

One useful way of defining daughter volume is by dividing an existing mother volume into n equal parts along a chosen axis (Cartesian, Cylindrical, Polar)

The creation and positioning is done in two separate steps

When a daughter is positioned inside a mother, the extent inside the mother occupied by the daughter gets filled up with the material/medium of the daughter

Can build up a tree like a Russian doll

Page 41: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

LogicalVolume

• A logical volume is made up with a Solid and a Material (pointer must be non null)

• Same Solid and Material can be used to defined different logical volume, to

represent different medium in different part of the detector

• Magnetic field can be associated with a logical volume, but in general global

magnetic field is used

• G4SensitiveDetector can be associated later on (a practice)

• G4UserLimit : Managing tracking steps, also associated separately

• Optimised : For parameterised volumes in the hierarchy, is -always- applied.

G4LogicalVolume( Solid* ,

Material* ,

Name,

G4MagneticFieldManager * = 0,

G4SensitiveDetector* = 0,

G4UserLimit* = 0 //for visualisation

G4bool optimised = true);

Page 42: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

PhysicalVolume G4PhysicalVolume* volume = new G4PVPlacement(rot, //rotation

G4ThreeVector(xpos*cm, ypos*cm, zpos*cm), //center of daughter

wrt to mother

G4LogicalVolume* daughter, // logical volume of daughter

NAME, // its name

G4LogicvalVolume* mother, //logical volume of its mother

false, // no boolean operation,Not used,

copyNumber) ; // copy/replica number

Creates a Physics volume by positioning copy copyNumber of LogicalVolume

daughter inside the mother volume mother with a translation vector (G4ThreeVector)

and a rotation matrix (G4RotationMatrix* rot)

Deleting a logical volume does not delete its daughter volumes

If one needs to define the rotation matrix by specifying θi, φi of the three axes of

daughter in mothers frame,

G4ThreeVector nAxis( sin(thetaN*deg)*cos(phiN*deg),

sin(thetaN*deg)*sin(phiN*deg), ( cos(thetaN*deg));

G4RotationMatrix* rot = new GeRotationMatrix();

rot->rotateAxes(xAxis, yAxis, Zaxis); // rot->rotateZ(45*degree)

rot->invert();

Page 43: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

solidWorld = new G4Box("Worlds", //its name

nINODet*(parino[0]+gapino/2.0), 1.01*parino[1], 1.01*parino[2]); //size for Three ical setup

logicWorld = new G4LogicalVolume(solidWorld, //its solid

Air, //its material

"World"); //its name

physiWorld = new G4PVPlacement(0, //no rotation

G4ThreeVector(0,0,0), //at (0,0,0)

logicWorld, //its logical volume

"World", //its name

0, //its mother volume

false, //no boolean operation

0); //copy number

solidINOM = new G4Box("INOM", parino[0], parino[1], parino[2]);

logicINOM = new G4LogicalVolume(solidINOM, //its solid

Air, //its material

"INOMlog"); //its name

physiINOM = new G4PVPlacement(0, //no rotation

G4ThreeVector((i-1)*(2*parino[0]+gapino), 0, 0), //position

logicINOM, //its logical volume

"INOMphy", //its name

logicWorld, //its mother volume

false, //no boolean operation

i); //copy number

WORLD

VOLUME

INO

DETECTOR

VOLUME

Page 44: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Replica, Parametrized volume and Division

• G4Box : kXAxis ; kYAxis ; kZAxis G4Trd, G4Para

• G4Tubs : kRho ; kPhi ; kZAxis G4Cone

• G4Polycone : kRho ; kPhi ; kZAxis G4Polyhedra

• Parameterized volumes:

• ExN02ChamberParameterisation: G4VPVParameterisation • Compute Transformation defines where one of the copies is placed • Compute Dimensions defines where the size of one copy is placed

Special case of parametrized volume is

G4PVDivision( const G4String& pName, G4LogicalVolume* pCurrentLogical,

G4LogicalVolume* pMotherLogical, const EAxis pAxis, const G4int nDivisions, const

G4double width, const G4double offset ); // Can use only nDividion or width individually

Daughter solid must be same as mother one, but dimensions of the solid associated with

pCurrentLogical will not be used, but recomputed through the

G4VParameterisation::ComputeDimension() method.

• For dividing a parent volume, one needs to create LogicalVolume by standard steps

(defining Solid and the LogicalVolume) and then position multiple replica through:

• G4PhysicalVolume* volume = new G4PCReplica(NAME, G4LogicalVolume*

current, G4LogivalVolume* mother, kAxis, nDivision, width, offset);

• The tree of physics volumes is instantiated at the time of tracking (G4Touchable)

and the TouchableHistory will provide the unique identification of a volume

Page 45: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

An example

Y

X

X

Z

X

Z

Y

X

Page 46: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Coding

Page 47: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Solids made by Boolean operations G4Box* box = new G4Box("Box",20*mm,30*mm,40*mm);

G4Tubs* cyl = new G4Tubs("Cylinder",0,50*mm,50*mm,0,twopi); // r: 0 mm ->

50 mm

// z: -50 mm -> 50 mm

// phi: 0 -> 2 pi

G4UnionSolid* union = new G4UnionSolid("Box+Cylinder", box, cyl);

G4IntersectionSolid* intersection = new G4IntersectionSolid("Box*Cylinder",

box, cyl);

G4SubtractionSolid* subtraction = new G4SubtractionSolid("Box-Cylinder",

box, cyl);

G4RotationMatrix* yRot = new G4RotationMatrix; // Rotates X and Z axes only

yRot->rotateY(M_PI/4.*rad); // Rotates 45 degrees

G4ThreeVector zTrans(0, 0, 50);

G4UnionSolid* unionMoved = new G4UnionSolid("Box+CylinderMoved", box,

cyl, yRot, zTrans);

// Now we build the same solid using the alternative method

G4RotationMatrix invRot = *(yRot->invert());

G4Transform3D transform(invRot, zTrans);

G4UnionSolid* unionMoved =

new G4UnionSolid("Box+CylinderMoved", box, cyl, transform);

Page 48: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Detecting Overlaps and visualisation Best option to visualise but for complicated and many layers; Use:

/geometry/test/grid-test true/false(only one depth)

/geometry/test/cylinder-test true/false

visx = G4VisAttributes(true, G4Color(1, 1, 1))

visxSetVisibility(G4bool)

visxSetColor(G4Color)

Logic Name SetVisAttributes(visx)

G4VisAttributes SetLineStyle(G4VisAttributes::unbroken, dashed, dotted)

SetLinewidth(G4Double )

SetForceWireframe(G4Bool) //only edges

SetForceSolid(G4Bool) //Force to visualised with surfaces

SetForceHuxEdgeVisible(G4Bool) //Force to look curved surface of polygon/sphere

SetForceLineSegmentsPerCircle(G4Int N) //Segment N*360

Page 49: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Particles • Particles are specified by Name and/or a code

• Uses PDG encoding and the list us rather large

• Particles are characterised by their statis properties : mass, spin, lifetime, decay

modes, lepton/baryon number ….

• In principle, only stable and long lived particles (τ >10−13 s) needed in the

simulation toolkit. Yhe remaining particles need not be created in particle-

medium interaction. This, however, sets some limitation on the hadron physics

model.

• Most commonly used particles are somewhat unique and each such particle is

described by a static object

– G4Gamma::GammaDefinition();

– G4Gamma:Gamma();

• Several particles are described through name, PDG code, e.g., Gluons, Quarks,

Di-Quarks, Leptons, Mesons, Baryons, … These are invoked through

– G4ParticleTable::FindParticle(code/name)

• Some ions and short lived particle are created by the process. They are activated

also through special methods in G4ParticleTable

Particles are to be initiated at the same time as the physics process initiation

Page 50: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Physics processes

• Transportation : Moving along a straight line (neutral or media with no em

field) or along a curve (charged in magnetic field) crossing volume boundaries

– It is treated as other processes. This process has to be registered during

initialisation and particles should know how to be transported

• Continuous Process : Particle kinematics get modified but the particle remains

its identity (continuous energy loss, multiple scattering, bremsstrahlung …)

• Discrete Process : Particle undergoes interaction or decays producing new

particles and may lose its own identity

– There are many discrete processes in em, weak and strong interactions.

Gradually updating these list

• Processes need to be registered at the initialisation time (by default all processes

are off) and activated during tracking particles

When a particle starts its journey through the detector, there will be several competing

processes the particle can go through. They are broadly divided into three categories:

Page 51: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Physics processes

Page 52: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Continuous process

Treatment of energy loss is a delicate problem – ionisation, δ-ray production,

bremsstrahlung process are strongly coupled to the continuous energy loss

estimation. Some of these processes have divergent cross section for soft emissions.

Need to use cuts, e.g., produce secondary particle if,

Range of secondary > Cutoff value (not on energy, it is on range, which provides a

more uniform treatment over different materials)

Page 53: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

:: ConstructParticle()

:: ConstructProcess()

:: ConstructEM()

while( (*theParticleIterator)() ){

G4ParticleDefinition* particle = theParticleIterator->value();

G4ProcessManager* pmanager = particle->GetProcessManager();

G4String particleName = particle->GetParticleName();

pmanager AddProcess (new G4eMultipleScattering); -1, 1, 1

pmanager AddProcess (new G4eIonization); -1, 2, 2

pmanager AddProcess (new G4Brehmstrahlung); -1, 3, 3

pmanager AddProcess (new G4eplusAnnihilation); 1, -1, 4 // ,,, …..

RemoveProcess(G4VProcess * aprocess) or (G4VInt index)

Order AtRestDoIt

Order AlongStepDoIt

Order PostStepDoIt

Setting up particle and physics list

//Swithch on or off processes

G4ProcessTable* process = G4ProcessTable::GetProcessTable();

G4ProcessManager* pmanager = particle->GetProcessManager(); //Need apropriate

particle ofr appropriate pmanager

process->Remove(process->FindProcess("muBrems",pmanager), pmanager);

process->Insert(new G4MultipleScattering(),pmanager);

G4VUserPhysicsList

Page 54: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Production and user cuts G4ProductionCutsTable :: GetProductionCutsTable () SetEnergyRange(10*eV, 100*TeV)

• SetCutswithDefault():

– SetCutValue(0.7*cm, “gamma”)

– SetCutValue(0.7*cm, “e+”)

– SetCutValue(0.7*cm, “e-”); // DumpCutValuesTable(); list of all

G4Region * region = G4RegionStore :: GetInstance() GetRegion(“Calor-EBlock”)

G4ProductionCuts * cuts = new G4ProductionCuts;

• cutsSetProductionCut(1*mm, index), index=0,1,2 for , e and e+. All others are used in 1

• Instead of index cut can pass through G4ParticleDefinition or “pName”

• cuts SetProductionCut(0.01*mm); //for all particles

• cuts SetProductionCut(0.1*mm, G4ProductionCuts :: GetIndex(“gamma”));

• region SetProductionCuts(cuts)

G4UserLimits *limits = new G4UserLimits ()

• region SetUserLimits(limits SetMaxAllowedStep(5e-2*mm))

MyLHEP.icc /IcaloPhysicsList.cc

::SetCuts()

Page 55: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Production and user cuts

• DetectorConstruction :: Construct()

logicGASR SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, 10*ms ));

ProductionCuts : through member function

inline const G4MaterialCutsCouple* GetMaterialCutsCouple() const;

inline void SetMaterialCutsCouple(G4MaterialCutsCouple* cuts);

G4ProductionCuts* cuts = new G4ProductionCuts();

G4MaterialCutsCouple * cutsAbsorber = new G4MaterialCutsCouple(

(G4Material*) pDet GetAbsorberMaterial, cuts)

cutsAbsorber PhysicsTableUpdated(); //no need

cutsAbsorber SetProductionCuts(cuts2);

MyLHEP.icc :: setcuts()

G4UserLimits(G4String * type, // particle type

ustepMax, /*maximum allowed step size*/ trackMax, /*maximum total track length*/

utimeMax, /*maximum total time of flight*/ uekinmin, /*minimum kinetic energy*/

urangmin); //minimum remaining range Neutron time of flight is 10ms in tracker region but all others are 1ns

Page 56: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Tracking • Heart of any detector simulation is tracking

• Tracks (particles with

kenematic information)

are put in a stack (at the

beginning of an event all

primary particles are

transferred) through

StackingManager on

request from

EventManager

• Stack is operated in a Last In Fast Out (LIFO) mod. Take out the last particle from

the stack (current track) having information on particle type, 4-momenta, position and

time

Page 57: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Tracking

• Looked at the list of processes available to it and estimate the limiting step

length from each of these processes, (Geant3)

– Boundary crossing assuming linear transport

– Limit from maimum turning angle

– Limit from multiple scattering

– Limit from continuous energy loss

– Limit from decay length

– Limit from each of the discrete interaction processes

• Choose the minimum of these steps sizes as the current step size and remember

the limiting process

• Take a step – first transportation – if the limiting process is not boundary

crossing, special treatment has to be applied (cutstep)

• Tracking is continued for a given track till it stops or get killed or it goes out of

the experimental setup

• Tracking is continued for a given event till the tracking stack is empty

Page 58: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Tracking

• Here a Step has two points and also ‘delta’ information of a particle (energy loss in that step, time spent in the step, ….)

• Each point knows the volume. In case a step is limited by a volume boundary,

the end point physically stands on the boundary, and it logically belongs to the

next volume.

• It does not make two steps at a boundary

• At each end of step a control is given to the method

• UserSteppingAction of an object G4UserSteppingAction (or a class derived

from it and registered to the ActionManager)

• If it is a sensitive detector, a control is given to the method ProcessHits of the

appropriate sensitive detector (for the logical volume)

• Any process (including processes supplied by user) will be asked to take

appropriate action AlognStep, PostStep, AtRest.

• User can also take action on a track either at the start of tracking or at the end

Page 59: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Tracking

• It provides a more careful and detailed approach in swimming particles in an

electromagnetic field

• The equation of motion is integrated over a path length using

a Runga-Kutta method or some variations of this.

• In a uniform field, analytical solution exists and are used. In a

nearly uniform field, perturbation is applied

• The path is calculated using a chosen integration method and then it is broken into

linear chord segments that closely approximate the curve path.

• The chords are used to interrogate the navigator to find out whether the track has

crossed a volume boundary.

Delta one step : the accuracy for the endpoint of 'ordinary' integration steps, those

which do not intersect a volume boundary

Page 60: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Electromagnetic field:

• called by G4VUserDetectorConstruction::Construct(), // a virtual member from

virtual G4VPhysicalVolume *

G4FieldManager * fieldMgr =

G4TransportationManager :: GetTransportationManager() GetFieldManager();

G4UniformField * magfield = new G4UniformField(G4ThreeVector(0, fieldvalue, 0));

//constant Magnetic field along Y axis

fieldMgr SetDetectorField(magfield); //set magnetic field map

• Ical0ElectroMagneticField * inoical0Field = new Ical0ElectroMagneticField();

fieldMgr SetDetectorField(inoical0Field);

Inclusion of ElectroMagnetic field in the Detector

Difficult to have mapping of EM field in all position.

In practice, read three components of electric and magnetic field in many grid

points (either is ascii format or in database) and using

interpolation/extrapolation routine calculate this in all point.

void Ical0ElectroMagneticField::ElectroMagneticField(const double x[3], double B[6])

const ; // returns EM field at any point, do interpolation/extrapolation here

Page 61: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Setup equation of motion in magnetic field:

• G4EqMagElectricField * fEquation = new G4EqMagElectricField(inoicalField) ;;

• G4MagIntegratorStepper * pStepper = new G4ClassicalRK4(fEquation)

• G4MagInt_Driver * pIntgrDriver = new G4MagInt_Driver(1e-5*mm, pStepper,

pStepper GetNumberOfVariables());

• G4ChordFinder * pChordFinder = new G4ChordFinder(pIntgrDriver);

pChordFinder SetDeltaChord(1e-3*mm);

fieldMgr SetChordFinder(pChordFinder);

fieldMgr SetDeltaOneStep(1e-3*mm);

fieldMgr SetDeltaIntersection(1e-4*mm);

Equation of motion in ElectroMagnetic

Different FieldManager can use different delta one step and delta intersection in

different regions.

Page 62: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

G4PropagationInField * fieldPropagator =

G4TransportationManager :: GetTransportationManager()GetPropagationInField();

fieldPropagator SetMinimumEpsilonStep(1e-5*mm); // impose a minimum relative

error - and take precedence over DeltaOneStep. of the position/momentum inaccuracy

fieldPropagator SetMaximuilomEpsilonStep(1e-2*mm); //maximum relative error

//Parameters must scale with problem size

fieldPropagator SetLargestAcceptableStep(10*m); // A particle

could then take large spiral steps,.

minimum step size : strong fields or integration problems → very small steps, protect that

Propagation in EM field

Page 63: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Interface of Event Generators

• At the start of the event used has to provide the complete kinematical

information of an Event :

– User has to declare a PrimaryGeneratorAction as an user action of the

RunManager. This has to provide the interface in one of its method

GeneratePrimaries

Method GeneratePrimaries creates primary vertices and primary particles

G4PrimaryVertex vertex = New G4PrimaryVertex(particlePosition, particleTime);

// Creates a vertex at a given position (3-vector) and at a time

G4PriamaryParticle* particle = new G4PrimaryParticle(particleDefinition, px, py, pz);

particle→setPolarisation(polrisation);

particle→setMass(mass);

particle→setCharge(charge);

vertex→setPrimary(particle)

//creates a primary particle, sets up its mass, charge, … and associate it to its origin

Page 64: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

G4UIcmdWithAnInteger * Run

G4UIcmdWithBool *

G4UIcmdWithString *

G4UIcmdWithDoubleAndUnit * IncEnergycmd

G4UIcmdWith3VectorAndUnit * IncDirectioncmd

Constructor:

IncEnergycmd = new G4UIcmdWithDoubleAndUnit(“ical0/gun/energy”, this)

SetGuidance(“Set incident energy of particle”);

SetParameterName(“Energy”, true, true);

must provide

SetDefaultUnit(“GeV”);

SetDefaultValue(12 );

SetUnitCandidates(“eV keV MeV GeV TeV PeV”);

The User Interface

Page 65: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Primary Generator Action

Ical0PrimaryGeneratorAction :: GeneratePrimaries(G4Event * anevent)

G4ParticleTable * particleTable = G4ParticleTable :: GetParticleTable();

G4ParticleDefinition* particle = particleTable FindParticle(particlenName =

“gamma”)

FindParticle(22)

G4ParticleGun * particleGun SetParticleDefinition(particle)

particleGun SetParticleMomentumDirection(G4ThreeVector(1, 1, 1))

particleGun SetParticleEnergy(100)

particleGun SetParticlePosition(G4ThreeVector(vx, vy, vz))

particleGun GeneratePrimaryVertex(anEvent)

Vertex must be within detector volume.

Page 66: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

• Class Ical0PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction

void SetIncEnergy(G4Double p) {incEnergy = p;}

void SetIncPosition(G4ThreeVector p) {incDirection = p;}

• Ical0PrimaryGeneratorMessenger * genMessenger;

Default constructor:

• genMessenger = new Ical0PrimaryGeneratorMessenger(this)

• Class Ical0PrimaryGeneratorMessenger : public G4UIMessenger

public : Ical0PrimaryGeneratorMessenger(Ical0PrimaryGeneratorAction * )

private : Ical0PrimaryGeneratorAction * Ical0Action

Primary Generator Action

Page 67: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

vis.mac (including visualisation)

• bin/Linux-g++/inoical0_field vis.mac 1

• # Avoid putting too many volumes in a Mother Volume

• # Use this open statement instead for OpenGL in immediate mode.

• /vis/open OGLIX

• /vis/viewer/set/viewpointThetaPhi 90 0

• /vis/viewer/zoom .4

• /vis/scene/add/trajectories 1000 //view particles

• /gun/number 1

• /Ical0/gun/rndm on

• /Ical0/gun/energy 12

– #/process/eLoss/minKinEnergy 1.0 MeV

– #/process/eLoss/maxKinEnergy 50 TeV

– #/gun/number 2

– /run/beamOn 10

– #Idle> help

Page 68: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

The “vis.mac” file:

/Ical0/gun/energy 15

/Ical0/gun/Incdir 0.87, 0, 0.5

void Ical0PrimaryGeneratorMessenger :: SetNewValue (G4UIcommand *

command, G4String newValue) { // …….

if(command == IncEnergyCmd) {

Ical0Action SetIncEnergy(IncEnergyCmdGetNewDoubleValue(newValue)); }

Page 69: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

User Action

• Apart from describing the detector in terms of passive and active elements, the

user has to take care of certain things duration simulation at the time of tracking

and post tracking.

• Take care of the secondaries produced in the discrete processes

• Store transient Hits at the time of tracking with information to be used for

producing detector response later

• Compte detector response in all sensitive detector starting from the Hist stored

in the event

– Group hits for individual readout channel

– Convert energy loss to pulse height; position and time to drift time, …

– Position signal into a number of readout channels; generate wire # /pad # / strip

#

– Take care of special effect; non-uniformity, attenuation, ….

– See effect due to merging; saturation, multi-hit capbility, ..

– Add background due to other physics process: electronic noise, radio activity,

beam induced, …

– Put in detector efficiency, intrinsic resolution

Page 70: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

User Action

• During tracking, user gets control at several places:

– For secondaries produced in discrete processes, appropriate action is to be

taken in G4UserStackingAction

– For steps inside a sensitive detector store hits using information from Step and

TouchableHistory in the method ProcessHit

– For deciding to store track information for future use, use the methods

PreUserTrackingAction and PostUserTrackingAction of

G4UserTrackingAction

– For steps inside any medium, sensitive or not, user can take action in

UserStepAction

– Finally storing informations of an Event, after the completion of tracking can

be interfaced in G4UserAction through the nethods BeginOfEventAction and

EndOfEventAction

Page 71: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Sensitive Detector

• A LogicalVolume is declared Sensitive by attaching a SensitiveDetector, to it through a

specific method. Since SensitiveDetector is user specific, this gives maximum flexibility

and these is no need to supplying additional information. Sensitive Detector can find the

unique volume location by examining the TouchableHistory

• There will be a corresponding Classes which will be invoked by the SensitiveDetector

whenever required. But parameters required for computing these – the Constants –

should be in the data base and SensitiveDetector would be using them from the data base

Certain part of the setup are sensitive to passage of particles through them. Energy

deposited due to energy loss of particles in these parts is converted to detectable signals

(scintillation light, ionisation is gas detector, ….) . These parts need to be declared as

sensitive so that special action can be taken in these parts at the time of tracking.

Let us consider the volume tree

Page 72: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

• G4SDManager* SDman = G4SDManager :: GetSDMPointer();

Ical0Cal0SD* Cal0SD = new ICal0Cal0SD(“XXXX”);

SDman AddNewDetector(cal0SD);

LogicGASR SetSensitiveDetector(Cal0SD) // Logical volume associated

with Cal0SD, a derived class of G4VSensitiveDetector

• G4Region * aregion0 = new G4Region(“Calor_EBlock”)

LogicGASRSetRegion(aRegion0)

aRegion0AddRootLogicalVolume(LogicGASR)

aRegion0SetProductionCuts(prdcuts)

Sensitive Detector

Page 73: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Sensitive Detector

• The Sensitive Detector has to provide 3 services :

– SD::initialize(G4HCofThisEvent*) at the start of the event (called with the

pointed to the Hit Container)

– SD:ProcessHits(G4Step*, G4TiuchableHistory*) called every time a track

makes a step in one of the touchables of the volume belonging to the sensitive

detector

– SD:EndOfEvent(G4HCofThisEvent*) at the end of the tracking. The user

should fill up the hit container with HITS with at least the minimal information

regarding the unique cell ID and quantities required to compute DIGITs

Page 74: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Helper classes and member functions

• G4HCofThisEvent //Class which stores hits collections generated at one event

• GetHC(); // pointer of hit collection.

• GetNumberOfCollection();

• AddHitsCollection(G4Int HCID, G4VHitsCollection* aHC);

• G4TouchableHistory : public G4VTouchable; // geomtrical hierarchy, including its

net resultant local->global transform. Pointers for geometry

• G4Int depth = G4HistoryDepth();

• G4Int GetReplicaNumber (depth);

• G4VPhysicaVolume* G4VVolume(depth);

• G4VSolid* GetSolid(depth);

• inline const G4NavigationHistory * GetHistory(); // for transformation of local to

global & vice versa

• G4SDManager :: GetSDMPointer(); //extract static pointer of all sensitive detector

Page 75: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Sensitive Detector and Hit information

G4HCofThisEvent //Class which

stores hits collections generated at one

event

G4SDManager ::

GetSDMPointer(); //extract

static pointer of all sensitive

detector

class Ical0cal0SD : public

G4VSensitiveDetector //extract signal in

sensitive detector

Ical0Cal0Hit : public G4VHit

//Collection of information (Hit)

for a particular sensitive detector

Ical0Cal0Hit 1: public G4VHit

Ical0Cal0Hit 2: public G4VHit

Ical0cal0SD1 : public G4VSensitiveDetector

Ical0cal0SD2 : public G4VSensitiveDetector

G4LogicalVolume logic

G4LogicalVolume logic1

G4LogicalVolume logic2 Helper class

Page 76: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

G4VHit:

Ical0Cal0Hit : public G4VHit

{G4Double edep; // Energy deposit

G4ThreeVector pos; // Position where energy deposit

G4ThreeVector mom; // Momentum of tracks

G4Double toff; // Global time of energy deposit

Unsigned long HitId;}// Detector ID

typedef G4THitsCollection<Ical0Cal0Hit>Ical0Cal0HitsCollection;

extern G4Allocator<Ical0Cal0Hit>Ical0Cal0HitAllocator;

Sensitive Detector:

Ical0Cal0SD : public G4VSensitiveDetector

:: Initialise(G4HCofThisEvent * HCE)

:: G4Bool ProcessHits(G4Step * astep, G4TouchableHistory * hist);

:: EndOfevent( G4HCofThisEvent * HCE);

SetEdep()

AddEdep()

GetEdep()

Page 77: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

class Ical0cal0SD : public G4VSensitiveDetector • private : Ical0cal0HitsCollection *cal0Collection;

• Default constructor : CollectionName.insert (HCname = “cal0Collect”); //Same string in

Ical0EventAction::BeginOfEventAction; colNam="cal0Collect"

• Initialise(G4HCofThisEvent * HCE) :

• Static int HCID = -1

• cal0Collection = new Ical0cal0HitsCollection (“SensitiveDetectorName”, CollectionName[0]);

• if ( HCID < 0 )

– HCID = G4SDManager :: GetSDMPointer GetCollectionID(CollectionName[0]);

– HCE AddHitsCollection(HCID, cal0Collection);

• ProcessHits(G4Step * astep, G4TouchableHistory *)

– edep = astep GetTotalEnergyDeposit()/keV

o G4TouchableHistory * theTouchable = (G4TouchableHistory *)(astep GetPrestepPoint

GetTouchable());

o Int level = theTouchable GetHistoryDepth(); //depth in geometry structure

Int ireplica = theTouchable GetReplicaNumber(0 level - 1); //replica number

For all steps calculate all these, irrespective of sensitve detector or not :

Ical0SteppingAction:public GeUserSteppingAction

:: UserSteppingAction (const G4Step* astep)

Page 78: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

class Ical0cal0SD : public G4VSensitiveDetector

– G4StepPoints apt = astep GetPreStepPoint(); //starting point of this step

– apt GetProcessDefinedStep() //G4VProcess * ;// 0 => step is defined by user limit step

– apt2 = astep GetPostStepPoint(); //end point of this step

– atime =apt GetGlobalTime()/ns; // Time since event is created

– GetLocalTime()/ns; // Time since track is created

– GetProperTime()/ns; // Time since track is created(rest frame of particle)

– atrk GetTrackID() , GetParentID(), GetKineticEnergy(), GetTotalEnergy(), GetMomentum();

– G4ThreeVector glbpos = 0.5*(apt GetPosition() + apt2 GetPosition());

– G4ThreeVector localpos = theTouchable GetHistory() GetTopTransform() (.invert()).

TransformPoint(glbpos);

– Int detid = INOM (2) + Layer(8) + module(3) + chamber(3) + X-strip(7) + Y-strip(7);

– Int oldcellid =−1; for (int ij=0; ij<Incell; ij++) { if (detId==cellDetId[ij]) { oldcellId=ij;}

– If (oldcellId==−1 && Incell <NumberofCell -1) {

• Ical0caloHit* newHit = new IcalocaloHit();

• newHit->SetEDep(edep); SetTime(atime); Setpos(glbpos), SetMom(amom);

• Incell = caloCollection insert(newHit); cellDetId[Incell-1] = detid; } else {

• (*calocollection)[oldCellId] AddEdep(edep); SetTime(atime); }

Page 79: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

G4Track & G4StackedTrack

– G4Track * atrk = astep G4Track(); //Pointer to the particle, which is interacting

– atrk GetDynamicParticle() //G4DynamicParticle *

– atrk GetDefinition() //G4ParticleDefinition *

– atrk GetCreatorProcess() //G4VProcess

– atrk GetVertexPosition();

– atrk GetVertexMomentumDirection();

– atrk GetLogicalVolumeAtVertex();

– atrk GetGlobalTime(); same as prestep time

Xxxxx G4StackedTrack : G4Track * GetTrack(); //a G4Track object in the form of bi-directional

linked list, using G4StackManager.cc

• G4StackedTrack * GetPrevious()

• G4StackedTrack * GetNext()

Page 80: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Ical0EventAction : Action at the end

• Ical0EventAction : public G4UserEventAction

• Private :G4int cal0CollID, cal1CollID, cal2CollID; //Different Hit collection ID, initialised

with -1;

• BeginOfEventAction(const G4Event* evt) {

• G4SDManager * SDman = G4SDManager::GetSDMpointer();

• cal0CollID = SDman->GetCollectionID(colNam="cal0Collect"); //Same string in

Ical0cal0SD, HCname = “cal0Collect”); // return the same HCID (in Ical0cal0SD ) of the

sensitive Detector , same ID can be obtained using GetCollectionID(G4VHitCollection* )

• EndOfEventAction (const G4Event* evt) {

• G4HCofThisEvent* HCE = evt->GetHCofThisEvent();

• evtNo = evt->GetEventId(); Ical0cal0HitsCollection* EHC0 = 0;

• If (HCE) { EHC0 = (Ical0cal0HitCollection*)(HCE->GetHC(cal0collID);

• If (EHC0) { n_hits = EHC0->entries();

• for (int i=0; i<n_hit; i++) { totE +=(*EHC0)[i]->GetEdep()/keV; (*EHC0)[i]->GetHitId();

Page 81: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Digitisation • Simulation on RPC : No strip in GEANT4. but digitisation is based on the position in a chamber.

• XX/YY = pargas [0][1] + localy.x()/y() ; // local position wrt to one edge of the chamber

• nInX/Y = int ((XX/YY)/strwd); // position divided by the strip width

• Strip multiplicity is 1.2 and # of strip is also 3 for 2% time

– gapy = YY – n/nY[0] * ystrwd/ystrwd - 0.5 ; // Look for local position in strip unit

– If (gRandom Rndm(0) > 0.95 ) nlnY[0] = −1; // Inefficiency

– If (abs(gapy) > 0.4 && gRandom Rndm(0) >0.5) { //multiplicity, provided hits are not at center region

– nlnY[1] = nlnY[0] + int (gapy/abs(gapy)); // Add the multiplicity, according to the position of incident particle

– If (TMath :: Gaus(gapy, 0, ystrwd, kTRUE) > gRandom Rndm(0)) nlnY[2] = nlnY[0] + int (gapy/max(1e-12,gapy)); // 3rd multiplicity

• Timing :

– Double atime = (*Cal0Collection)[i] GetTime(); // Already in ns

– atime +=G4RandGauss::shoot(0,1.0*ns); //Timing resolution is 1ns

– Or atime +=hist->GetRandom(); //If the resolution shape is very different than Gaussian

– Int nInT = int (atime/0.1); // least count in TDC=100ps = 0.1ns

– atime = 0.1*nInT; // return back to initial value

Page 82: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Noise simulation • Average # of free electron (p.e.), N = edep/< E >, npe = Poisson(N), Noise = Poisson

(100)

• for (int ij=0; ij < Npoise; ij++) {

• gRandom RndmArray(nrandom, randvar);

• Int nlnT = int (IMxT – IMnT + 200 ) * randvar[0] -100; // Time smearing within ±100ns

• Double atime = 0.1 * nInT; //Least count in TDC=100ps

• Int nInY = min (int (nstripy * randvar[1]), nstripy − 1); // Noisy Y-strip

• Int nInX = min (int (nstripx * randvar[2]), nstripx − 1); // Noisy X-strip

• Int nInCH = min (int (numbernCH * randvar[3]), numbernCH −1 ); //Chamber

• Int nInMo = min (int (numbernMO * randvar[4]), numbernMO −1 …); //Module

• Int nInLA = min (int (numbernLA * randvar[5]), numbernLA −1 …); // layer

• Int ihitxy = int (3* randvar[7]); //use noise in both strip

• Int nInDT = min(int (3* randvar[8], 2)); // Out of three detector

• float edep = gRandom Exp(eMx/Max( 1, nHits )); //observe signal in exponential

Page 83: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Position dependent multiplicities • Fit X-Z/Y-Z trajectory of a muon excluding the layer under study (Lxy)

• Extrapolate muon trajectory in the layer Lxy

• Calculate extrapolated point in strip co-ordinate (-0.5 to 0.5)

• Look for multiplicities as a function of this co-ordinate

0.5 0 0.5

x

x x

x

x

x

x x

x

x

x x

x

x

x x

x x x x x x

x x

• Expected single strip hit for trajectory passing through the center (all induced charge in one strip)

• Same region, double strip hit, which passed through the boundary; also inefficiency

Page 84: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

X-Strip multiplicity as function of muon position

Page 85: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Y-Strip multiplicity as function of muon position

• sd

Page 86: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

X-Strip efficiency

Page 87: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Y-Strip efficiency

Page 88: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Digitisation in scintillator

• Birk’s law of scintillator light output : dL/dx vs dE/dx

• Average number of photon Nave = ∑dL/dx

• Observed number of photon Nobs = gRandom Poission(Nave);

dx

dEwhere

cc

E

dx

dL

1,,

1 2

21

Page 89: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Optimisation

• Large fraction of detector simulation time is spent in tracking of particles in the

detector

• Big part of the traking time goes in geometry to find out minimum distance

along a direction to the volume boundary

• Use tracks to optimise this :

• From GEANT side XXXXXXXXXXXXXXXXXXXXXX

Introduce the concept of Safety : closest

distance to a boundary. It is often easier to

compute and on many occasions it is

sufficient to know Safety alone (when other

limiting distances are smaller). One has to

be conservative and need not be exact in

computing Safety

Page 90: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Optimisation

• In computing distance to boundary one needs to compute

– Distance to volume boundary where the point is (A)

– Distance to the boundaries of all daughter volumes (A1, A2, A3) from the point

– Minimum of all real positive roots gives the answer

• Avoid putting too many volumes in a Mother

• It is better to have many levels with small multiplicity in each level

• Position using the Division technique – it is very fast to find out which division

the point is associated with

• XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX It is done

automatically by creating voxels along a given axis to minimise number of

daughters per voxel in the search process. This is extended to second or third

dimension to improve upon the ratio of # of daughters per voxel. User has to

control on the voxelisation procedure (set smartness)

From User Side

Page 91: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Factors of Dependence:

1. Cosmic spectrum, which is our goal

2. Detector aperture, Geometry

3. Trigger criteria, efficiency for rate

4. Detector inefficiency, both for shape and

normalisation

5. Material in roof => threshold of muon

momentum

6. Shift in RPC chamber and its uncertainty

Angular Distribution

0th Layer

11th Layer

Θ = 45o

Page 92: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

1. Calculate shift in data using straight line fit

excluding that chamber Iterative method

2. Efficiency Fit and look for hit there

dx = xefx[ij] – xoff[ij] – int( xext – xoff ) – 0.5

(abs(dx) + exterror) < acceptrng(1) && Y…)

totalentry[ij] [iiterrs] Fill(xext[ij], yext[ij]);

Trigger efficiency:

if(xpts[ij]. Size() > 0)triggereffi = xevt[ij][iiterrs] Fill (xext[ij], yext[ij]);

Trigger efficiency for strip:

for (ix=0; ix < xhits[ij]; ix++)

if(abs(xefx[ij] – xpts[ij][ix]) – xoff[ij]) < acceptrng + effirng

=1 =0.25

Page 93: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Selection Efficiency:

If (|xpos - xext| < acceptrng)

efficiency – n[ij] [iiterrs] Fill (xext, yext)

Time resolution and efficiency for timing:

If (xpts[occulyr].size() == 1)

time – xt[occulyr][iiterrs] Fill[xpts[occulyr][0]);

If(xtdev[occulyr] < 3 * time – xrms[occulyr])

efficiency[occulyr] [iiterrs] Fill(xpts[occulyr] [0]));

Page 94: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Event Generation Loop:

thetax = acos(1 – gRandom Uniform() /2) //0 to 60 degree

phix = m – pi * (1 – 2 * gRandom Uniform() )

Top: xendpos = 1.002 * (xlower + (xupper – xlower)) * gRandom Uniform();

Slopx= dx/dz = tanθ cosφ ; Slopy = dy/dz = tanθ sinφ;

Bottom: xpos = xendspos – height * slopx; height = (nlayer - 1) * layergap;

If(xpos < xlower – 0.002 || xpos > xupper * 0.002) continue;

for(int ilayer = 0; ilayer < nlayer; ilayer++){

tmpxp = (ilayer)*layergap *slopx + xpos – shift[ilayer] + xposerr[ilayer]

Int ix = int(tmpxp/strwd); dx = tmpxp – (ix + 0.5)*strwd;

If(ix<0 || ix >= nstrip || iy < 0 || ij>=nstrip) continue;

If(gRandom Uniform() <effi _trig_x[ilayer][ix][ij]); //trigger criteria four layers 2,4,7,9

gRandom Uniform() <effi _table_x[ilayer][ix][ij] // Efficiency

… … multiplicity … …

Page 95: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Compare with Scintillators:

Radiation damage

Dependence factors for Scintillator detector:

1. Thickness of scintillators

Uniformity of scintillator properties

Collection, Position of shower

2. Collection of photon

shape of crystal

fraction of crystal surface covered by the PMT

Q.E. of photon as a function of λ

reflectivity at surface and incident angle

surface quality; Q.E. vs position; PMT vs SiPM

self-attenuation

Light guide

Cherenkov in glass window / neutron energy

Front PMT

Back PMT

Effect of non ionizing particle

Page 96: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

Width +shift

3. Propagation of photon:

• Attnuation

• Surface loss

• Bending of fibre

4. Loss in splice, connector

5. Cell-to-cell intercalibration

6. Non-containment

7. Dead area infront or inside the calorimeter (either simulate it or take care of it by fast sim) : dead area : Fast MC

8. TDC fluctuation

9. Gain

• HV stability

• dL/dT

10. Gas composition

• Electronegative substance

• Cell-to-cell variation

L

T

Page 97: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy

• C1: Electronic noise

• C2 : Particle other than one in inerest, e.g., pileup

• C3: Analog to digital : loss of information

• C4 : Shift in pedestal value

• b1 : Fluctuation in cascading, charge/neutral ratio

• b2 : photon/p.e. statistics

E

c

E

ba

E

E

G4VSolid* inomSolid = new G4Box(“INOM”, 1606.0*cm, 706.0*cm, 598.0*cm);

Defines a solid INOM, which is a Box of half length 1606cm, half width 706cm and

half thickness 598cm.

G4LogivalVolume* inomlog = new G4LogicalVolume(inomSolid, air, “INOML”);

Associates the solid inomSolid with material Air to define the logical volume.

Reference frame is a right handed Catersian co-ordinate system with origin at the

centre of the box.

Page 98: Based on talk prepared by Prof. S. Banerjee in March 2006gobinda/inosim/geant_ino2013.pdf · static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus // // Energy