• No results found

COINCIDENCES BETWEEN NEUTRONS AND GAMMAS

N/A
N/A
Protected

Academic year: 2021

Share "COINCIDENCES BETWEEN NEUTRONS AND GAMMAS"

Copied!
45
0
0

Loading.... (view fulltext now)

Full text

(1)

GAMMAS

July 21, 2019

Josefine Sjöberg

Uppsala University

(2)

The neutron is a valuable tool in many fields of science due to its properties regarding electric charge and magnetic moment. However, these properties also makes it difficult to detect.

Through simulation one can optimize the detector environment to best correspond with the needs for a specific experiment. In this project, a detector environment is simulated, consisting of a neutron and gamma point source and one detector for each type of particle.

The simulated results were in good agreement with the underlying theory and the simulation can, therefore, be used in future work.

(3)

1 Introduction . . . 3

2 Theory . . . 4

2.1 Interaction of gamma rays . . . 4

2.1.1 Photoelectric absorption . . . 4

2.1.2 Compton scattering . . . 4

2.1.3 Pair production . . . 5

2.2 Interaction of fast neutrons . . . 6

2.2.1 Cross-section . . . 6

2.3 Time of flight . . . 8

3 Method . . . 8

3.1 Technical specifications . . . 8

3.2 Simulation build . . . 8

3.3 Code . . . 10

4 Result and analysis . . . 11

4.1 Mono-energetic . . . 11

4.2 Uniform spectrum . . . 15

5 Conclusion . . . 17

Appendix 18

A PrimaryGeneratorAction.h 19

B PrimaryGeneratorAction.ccp 20

C DetectorConstruction.h 22

D DetectorConstruction.cpp 23

E EventAction.h 28

1

(4)

F EventAction.cpp 30

G RunAction.h 34

H RunAction.cpp 35

I G4PSTime.h 37

J G4PSTime.cpp 38

K Analysis.h 40

L Main.cpp 41

(5)

1 I NTRODUCTION

The goal of this project was to simulate a detector environment where the detectors reg- ister both the deposited energy and the time of interaction for neutrons and gammas in coincidence. A neutron source and two scintillator detectors are simulated, one made of vinyl-toluene for neutrons and a barium-fluoride detector for gammas. The source is a point source which emits neutrons and gammas in opposite directions simultaneously and if both the particles deposit energy into the detector, they are in coincidence. The neutron-gamma coincidence requirement was implemented to verify the simulated result with theory. The simulation was done for two special cases regarding the neutron energy, mono-energetic 2.4 MeV neutrons and neutrons with a uniform distribution between 2 and 4 MeV. The energy of the gamma quanta is 4.4 MeV in both cases. In the first case, the source is set to energies corresponding to an americium-beryllium source, which is the source to be used in a contin- uation of this project. The simulation can later be used to optimize the detector environment by testing different geometries, materials and neutron energy distributions and also to test different shielding materials and geometries. The simulation was done with the open source simulation tool kit GEANT4.

The properties of the neutron make it an important probe of matter and is consequently a valuable tool in many fields of science [2]. The neutron carries no electric charge and can therefore probe deeply into matter, since it will not be influenced by Coulomb interactions.

Instead, it interacts with the nuclei through mostly elastic scattering for 2.4 MeV neutrons, where the scattering cross sections have a high isotope and element dependency. This means that the neutron is ideal for probing the isotope or element composition of samples. Further, the neutron has a small magnetic moment which makes it possible to investigate the mag- netic properties of materials. The downside with these properties is that they also make the neutron difficult to detect. Since the neutron does not have a charge it can not be detected by direct ionization of the detector material, as charged particles. Only by studying the inter- actions of the neutron with its surroundings can conclusions be drawn about its properties, for example its energy. These interactions are primarily absorption, elastic scattering and activation.

Scintillator detectors are widely used for detecting fast neutrons and they rely to a large extent on the elastic scattering interaction. The recoiling nuclei will ionize and excite further atoms through collisions and scintillation light is sent out in the de-excitation process. The

(6)

challenge when using this type of detector is to distinguish the scintillation light signals produced by neutrons from signals produced by gamma radiation in the same detector.

2 T HEORY

2.1 Interaction of gamma rays

The information in this section is extracted from Radiation Detection and Measurement [1].

The three major gamma-ray interactions are photoelectric absorption, Compton scattering and pair production. The photoelectric absorption is dominant for lower energy photons, Compton scattering for mid-energy photons and pair production for high energy photons.

2.1.1 Photoelectric absorption

The photoelectric absorption is when a photon is absorbed by an atom which then ejects an electron, called a photoelectron, if the photon energy is high enough. Electrons are bound to the nucleus with a specific energy, the binding energy, and this energy needs to be overcome for the electron to leave the atom. Therefore the incoming photon must have an energy above the electrons binding energy for the interaction to take place. The resulting photoelectron energy is:

Ee= Ep− Eb. (1)

where Ep is the energy of the incoming photon and Ebis the binding energy of the photoelec- tron in its original shell.

When the photoelectron is emitted from the atom it leaves a vacancy in one of the shells, making the atom excited. This vacancy is filled by the atom capturing a free electron or by rearranging the remaining electrons. In this process, characteristic x-ray photons, Auger electrons or scintillation light may be emitted, carrying away the atomic excitation energy.

2.1.2 Compton scattering

Compton scattering is when a photon is scattered by an electron, transferring some of its energy. If the electron is bound to an atom, the atom will be ionized. The energy transferred in the scattering event depends on the angle which the photon is scattered through, where 0°

is zero energy and 180° maximum energy. In Figure 1, a photon of wavelengthλ comes in

(7)

from the left, collides with a target at rest, and a new photon of wavelengthλ0emerges at an angleθ. The target recoils, carrying away an angle-dependent amount of the incident energy.

The relationship between wavelength and energy for photons is given by E = hcλ, where h is Planck’s constant and c the speed of light in vacuum.

Figure 1: Schematic over a Compton scattering event [3].

The amount of energy exchanged in a Compton scattering event is given by the formula:

1 E0−1

E = 1

mec2(1 − cosθ), (2)

or

E0= E

1 +mEec2(1 − cosθ) (3)

where E0and E is the outgoing and incoming photon energy, mec2is the electron rest mass andθ is the scattering angle defined in Figure 1. The energy transferred to the electron is the outgoing photon energy subtracted from the incoming photon energy:

Ee= E − E0= E − E

1 +mEec2(1 − cosθ), (4) The maximum energy that can be transferred in a Compton scattering event is called the Compton edge and it is found by usingθ = 180, giving:

EC ompt on_ed g e= E − E 1 +m2Eec2

. (5)

2.1.3 Pair production

When an incoming high energy photon is in the proximity of a nucleus, i.e. in the Coulomb field of a nucleus, pair production can take place. In this process, the photon is transformed to a electron-positron pair:γ → e+ e+. For the production to occur, the photon needs to have an energy higher than 1.022 MeV, which is the rest mass of the electron and the positron

(8)

together. Any energy above this threshold becomes kinetic energy of both the electron- positron pair and the nucleus, which recoil. When the positron slows down, it will bind itself with an available electron in the material and subsequently annihilate, creating two annihilation photons in the process. There are three possible outcomes after the annihilation:

both photons deposit their energy in the detector, one deposit its energy and one escape the detector or both escapes the detector. The two last outcomes result in two peaks in the gamma spectrum, one at -511 keV and one at -1022 keV from the photopeak, which is caused by the lost photons. The photopeak is the peak formed due to the complete absorption of the photon energy in the detector

2.2 Interaction of fast neutrons

2.2.1 Cross-section

The cross-section is a probability measure for an interaction or reaction to occur between two particles. The neutron scintillator detector in this project consists of the plastic vinyl-toluene which is composed of hydrogen and carbon. Between fast neutrons and these two elements the most occurring interaction is elastic scattering, which has an energy dependent cross- section. In Figure 2 and Figure 3 these cross-sections for neutrons on carbon and hydrogen are shown respectively, i.e the probability for an elastic scattering event to occur with these elements for different neutron energies.

(9)

Figure 2: Elastic scattering cross section for neutrons on carbon [4].

Figure 3: Elastic scattering cross section for neutrons on hydrogen [4].

(10)

2.3 Time of flight

There are two set quantities in the simulation, the energy of the emitted source particles and the source distance to the detectors. These can be used to verify the results from the simulations, by theoretically calculate the expected times of interaction. For this, two funda- mental equations are needed. The first equation describes the relationship between distance, velocity and time:

s = v · t → t = s

v, (6)

where s is the source distance to the detector, v the velocity of the emitted particles and t the time it takes for a particle to travel the distance s. The velocity can be found using the second equation needed, which describes the relationship between velocity and kinetic energy:

E = 1

2· m · v2→ v = s

2 · E

m , (7)

where E is the kinetic energy, m the mass of the particle and v the velocity of the particle.

Substituting equation 7 in to equation 6 gives the equation for the time of flight:

t = s q2·E

m

. (8)

3 M ETHOD

3.1 Technical specifications

Operating system used in this project was OS X Yosemite. All simulations were done with GEANT4 version 10.3 and the data was processed in MATLAB version 2014b. GEANT4 was built with cmake version 3.12.2 and the simulations were run with XQuartz terminal version 2.7.11.

3.2 Simulation build

GEANT4 uses a Monte-Carlo algorithm to simulate particle transport through matter. The environment is object-oriented and using the programming language C++.

The source used in the simulation was a point source in origin, emitting one neutron and one gamma quanta in the directions (0, 0, 1) and (0, 0, -1) respectively, in the Cartesian coordinate

(11)

system (x,y,z). The gamma quanta energy was held at 4.4 MeV during all simulations while the neutrons were set to 2.4 MeV mono-energetic or with a uniform distribution between 2 and 4 MeV.

Two detectors were simulated, one for neutrons and one for gammas. The neutron detector consisted of the organic plastic scintillator material vinyl-toluene and the gamma detector of the crystalline barium-fluoride. Both detectors were shaped like cylinders where the neutron detector had a diameter of 94 mm and a length of 62 mm and the gamma detector had 51 mm for both diameter and length. The neutron detectors center was placed at (0, 0, -1.05) m and the gamma detector at (0, 0, 0.1) m. Both the detector sizes and placements are arbitrary.

The detector environment is illustrated in Figure 4.

The detectors register the energy that is deposited into the detectors and at what time this energy transfer is occurring, i.e. the time of interaction, being the average of the time of the first interaction and the last. In a real experiment, the time it takes for the neutron to reach the detector, the time of flight, is determined by using the interaction in the gamma detector as a start signal and the interaction in the neutron detector as a stop signal. This process is not necessary in a simulation, but to see how the result would look in a real experiment the gamma time of interaction was subtracted from the neutron time of interaction, giving the time of flight. The neutron detector has a proton filter added and the gamma detector an electron, positron and gamma filter. These filters result in the output energy being the sum of the energy transferred between only the source particle and the particles in the filter. The reason for the proton filter is to simplify the simulation by disregarding the elastic scattering events on carbon. Since carbon is much heavier than hydrogen, the scintillation light output is less for the same amount of energy transferred from the neutron. To include carbon scattering events, a response function would have to be added in the code. The filter on the gamma detector was added for future use in the continuation of this project.

(12)

Figure 4: Visual of the simulation build.

3.3 Code

When building this simulation there were three challenges, how to send out two different particles from one source, how to register both energy deposition and time of interaction in a detector and lastly how to ensure that the neutron and gamma quantum were in coincidence.

The source in this project should send out two different particles at the same time. Preferably this should be done within the same event, but how to achieve that was not found during this project. The solution instead was to send out one particle in one event and the other particle in the next event. By using a private boolean variable particle, see Appendix A and B, it was possible to keep track of which particle was last emitted. This could be done since the time of interaction is the time it takes for the particle to reach the detector, and is therefore not dependent on when the particle leaves the source.

The time of flight of the neutrons can be retrieved by taking the difference in time of inter- action of the energy deposition for the neutrons and gammas. However, GEANT4 does not have a built-in scorer for time registration and therefore one was needed to be written, see Appendix J. A function GetTime was added to handle the scorer, see Appendix F.

To get a realistic time of flights of the neutrons, it was important that the registered neutrons and gammas were in coincidence. To ensure this the gamma energies and times were saved higher up in the code hierarchy, see Appendix H, and then retrieved and added to the same line as the neutron energy and time in the data file. When the data then was processed in MATLAB, only the data with positive energies for both gammas and neutrons was used for the result.

(13)

4 R ESULT AND ANALYSIS

4.1 Mono-energetic

The energy deposition from gammas and neutrons in coincidence for the mono-energetic case is seen in Figure 5 and Figure 6 respectively. In the gamma energy spectrum, Figure 5, there is a large peak at 4.4 MeV. This peak, the photopeak, is formed in the case of full absorption of the gamma quanta’s energy in the detector due to photoelectric absorption, see section 2.1.1. At approximately 4.2 MeV one can see the Compton edge described in section 2.1.2. Using equation 5, the theoretical value of the Compton edge should be at 4.16 MeV, which is in good agreement with the simulated result shown in the figure. The region between 0 MeV and the Compton edge is the Compton continuum. This region contains the Compton scattering events with scattering angles between 0° and 180°, where 180° gives the Compton edge. The peaks at 3.4 MeV and 3.9 MeV are the double and single escape peaks caused by pair production, see section 2.1.3. Theoretically, these two peaks should be at -511 keV and -1022 keV from the photopeak which is 3.889 MeV and 3.378 MeV. This is also in good agreement with the simulated result.

Figure 5: Energy deposition in gamma detector.

In the mono-energetic neutron energy spectrum, Figure 6, there is a large peak at 2.4 MeV which is the incident energy of the neutrons. This means that the neutrons deposited all their energy into the detector, due to elastic scattering with hydrogen. The tail of energies that follows is fractions of the initial energy, meaning the neutrons only deposited some of their energy in the detector before they escaped.

(14)

In a real detector, the neutron energy spectrum is more the shape of a rectangle, due to the non-linear response function of the scintillator material [5]. In most organic scintillators the scintillation light output does not increase linearly with deposited energy. Instead, the translation between the proton energy and the scintillation light output is dependent on a response function which is vital to know it if one is to inquire information about an unknown incident neutron energy. This function is unique for most detectors as it depends on many variables like material, size and external factors such as scratches and dirt. No response function was added to the detector in this project, instead the neutron energy registered by the detector is the sum of the recoiling proton energies:

Et ot=

N

X

i =1

EPi, (9)

where Et ot is the total neutron energy deposited for one neutron and EPi is the proton energy from different elastic scattering events in the detector. If there was a response function, the registered neutron energy would instead be:

Lt ot = XN i =1

L(EPi), (10)

where Lt ot is the total scintillation light output caused by a neutron interacting with hydrogen producing recoil protons and L(EPi) is the response function translating the proton energy to scintillation light output.

Figure 6: Energy deposition in neutron detector.

(15)

The time of interaction for gammas and mono-energetic neutrons in coincidence are seen in Figure 7 and Figure 8 respectively. Due to the size of the detectors, there is a distribution in time in the time of interactions. The particle interaction might be at the beginning or the end of the detector and everything in between, and this causes the time distribution.

In the gamma time of interaction, there is a time distribution from approximately 0.25 ns to 0.42 ns. The theoretical values gained from equation 6 was found to be 0.249 ns and 0.419 ns, which is in good agreement with the simulation. It is unclear what origin the large peak at roughly 0.42 ns has, but a possibility is that it is a result of the code that handles the interaction times. This needs to be looked into more.

Figure 7: Time of interaction in gamma detector.

In Figure 8, the neutron time of interaction is displayed. The distribution in time is between approximately 47.6 ns and 50.5 ns in the figure. These values are in good agreement with the theoretical values which was found to be 47.5 ns and 50.4 ns according to equation 8.

The rounded slope between 47.6 ns and 50.5 ns and the tail of counts after 50.5 ns in Figure 8 is caused by the slowing down of the neutrons in the detector. Since the neutron loses energy in its interactions with the detector material, it will slow down after each interaction.

There are also fewer counts at the end of the detector since some neutrons deposit all of their energy into the detector before they reach the end of the detector.

(16)

Figure 8: Time of interaction in neutron detector.

To get the time of flight of the neutrons, the time of interaction for the gamma is subtracted from the neutron time of interaction, and the result is seen in Figure 9. In the figure, the spectrum is slightly shifted to the left and the edges are slightly more curved. This slight difference between the time of interaction of the neutrons, Figure 8, and the time of flight is because the gamma time of interaction, Figure 7, is small in comparison. This is due to the placement of the gamma detector, which is close to the source and that the gamma quanta is much faster than the neutrons. This also makes the distribution in the gamma time of interaction relatively small, which is preferable since this distribution gives an uncertainty in the time of flight of the neutrons.

Figure 9: Time of flight of the neutrons.

(17)

4.2 Uniform spectrum

In the uniform distribution neutron energy spectrum, Figure 10, the energy with the most counts is 2 MeV and then it falls off to 0 and 4 MeV. This shape is explained by the uniform distribution since the same amount of 2 MeV and 4 MeV neutrons are sent out from the source and since 4 MeV neutrons can deposit a larger variation of energies, the counts will be more spread out. In other words, the integral of the contribution from the 2 MeV neutrons is close to the same as the integral from the 4 MeV neutrons. The difference between the integrals is caused by the cross-section for the different neutron energies. Looking at the cross-section for incoming neutrons on hydrogen, Figure 3, it decreases with higher energies.

For 2 MeV neutrons the cross-section is approximately 3 barns and for 4 MeV neutrons it is 2 barns. As the probability for the neutrons to scatter from the hydrogen decreases with the energy it will result in fewer counts for higher energies.

Also, in the uniform distribution neutron energy spectrum, Figure 10, there is a dip in counts at approximately 2.1 MeV and 2.9 MeV. These dips might be explained by the elastic scattering cross-section for carbon, Figure 2. Looking at 2.1, 2.8 and 2.9 MeV in Figure 2 there are large spikes in the carbon cross-section, meaning the probability for the neutrons to react with the carbon in the detector is a lot higher at those energies. If the neutrons scatter from carbon instead of hydrogen, the energy transferred will not be registered by the detector since it has a proton filter and it will therefore be fewer counts for these energies. This is a valid assumption due to the large difference in scintillation response between protons and carbon.

Figure 10: Energy deposition in neutron detector.

(18)

In Figure 11 the time of interaction for the neutrons is seen. In the figure, the time distribution is roughly between 37 ns and 55 ns. Using equation 7, the theoretical values were found to be 36.8 ns and 55.2 ns which again is in good agreement with the simulation.

Figure 11: Time of interaction in neutron detector.

The reason for the shape of the spectrum is not as clear as for the mono-energetic neutrons.

One could expect more counts at the end of the spectrum since the probability for elastic scattering on protons to take place is higher for lower energies, see Figure 3. However, the distribution is smaller for higher energies since the higher energy neutrons travel faster, see Table 1. The values were calculated, using equation 8. The counts for the higher energy neutrons will therefore be more gathered, resulting in more counts at the beginning of the spectrum.

Energy (MeV) Distribution Length 2 52.1 to 55.2 ns 3.2 ns 3 42.5 to 45.1 ns 2.6 ns 4 36.8 to 39.1 ns 2.2 ns

Table 1: Distribution in time for different neutron incident energies.

The time of flight for the neutrons with the uniform energy distribution is seen in Figure 12. Again, this figure is obtained by subtracting the gamma time of interactions from the neutron time of interactions. Notice the slight shift to lower times as in the time of flight for the mono-energetic neutrons.

(19)

Figure 12: Time of flight of the neutrons.

5 C ONCLUSION

In this project, I have begun to implement a simulation code of a detector environment which later can be used to optimize geometries and materials of a detector set up for different neutron energies. The detector environment consisted of two detectors, one for neutrons and one for gammas, and a neutron and gamma source. The gamma detector was placed close to the source and acts as a start signal for when a neutron is sent out. When the neutron interacts with the neutron detector, placed much further from the source, an end signal is acquired. With this detector set up, the time of flight and ultimately the initial energy of the neutrons can be obtained. For this to work, the neutron and gamma quanta need to be in coincidence so that the start and stop signal correspond with each other.

The results from the simulation are in good agreement with the underlying theory and can therefore be used and further expanded in future work. In the continuation of this project, an isotropic AmBe neutron source is going to be simulated and scintillator response functions will be added to the detectors. The simulation will then be used to optimize the detector environment geometry and shielding, for optimal neutron detection.

(20)

[1] Glenn F. Knoll, Radiation Detection and Measurement, 3rd edition, ( Ann Arbor, Michigan, 2000), 48-53.

[2] Heinz Maier-Liebnitz Zentrum. (2019). Neutrons used as a probe https://www.mlz-garching.de/englisch/neutron-research/

neutrons-as-a-probe.html

[3] Wikipedia. (2019). Compton scattering

https://en.wikipedia.org/wiki/Compton_scattering

[4] https://www-nds.iaea.org/

[5] Glenn F. Knoll, Radiation Detection and Measurement, 559-561.

18

(21)

PrimaryGeneratorAction.h

# i f n d e f M a S P r i m a r y G e n e r a t o r A c t i o n _ h

# d e f i n e M a S P r i m a r y G e n e r a t o r A c t i o n _ h 1

# i n c l u d e " G 4 V U s e r P r i m a r y G e n e r a t o r A c t i o n . hh "

# i n c l u d e " g l o b a l s . hh "

# i n c l u d e " R a n d o m i z e . hh "

# i n c l u d e " G 4 P a r t i c l e G u n . hh "

# i n c l u d e " G 4 E v e n t . hh "

# i n c l u d e " G 4 P a r t i c l e D e f i n i t i o n . hh "

# i n c l u d e " G 4 G e n e r a l P a r t i c l e S o u r c e . hh "

cl ass M a S P r i m a r y G e n e r a t o r A c t i o n : p u b l i c G 4 V U s e r P r i m a r y G e n e r a t o r A c t i o n {

p u b l i c :

M a S P r i m a r y G e n e r a t o r A c t i o n () ;

v i r t u a l ~ M a S P r i m a r y G e n e r a t o r A c t i o n () ; v i r t u a l void G e n e r a t e P r i m a r i e s ( G 4 E v e n t * ) ;

p r i v a t e :

G 4 P a r t i c l e G u n * f P a r t i c l e G u n ; bool p a r t i c l e = true ;

G 4 P a r t i c l e D e f i n i t i o n * p a r t i c l e D e f i n i t i o n 1 ; G 4 P a r t i c l e D e f i n i t i o n * p a r t i c l e D e f i n i t i o n 2 ; };

# endif

19

(22)

PrimaryGeneratorAction.ccp

# i n c l u d e " M a S P r i m a r y G e n e r a t o r A c t i o n . h "

# i n c l u d e " G 4 E v e n t . hh "

# i n c l u d e " G 4 P a r t i c l e G u n . hh "

# i n c l u d e " G 4 P a r t i c l e T a b l e . hh "

# i n c l u d e " G 4 P a r t i c l e D e f i n i t i o n . hh "

# i n c l u d e " G 4 S y s t e m O f U n i t s . hh "

# i n c l u d e " R a n d o m i z e . hh "

M a S P r i m a r y G e n e r a t o r A c t i o n :: M a S P r i m a r y G e n e r a t o r A c t i o n () : G 4 V U s e r P r i m a r y G e n e r a t o r A c t i o n ()

{

G4 int n o f P a r t i c l e s = 1;

f P a r t i c l e G u n = new G 4 P a r t i c l e G u n ( n o f P a r t i c l e s ) ;

p a r t i c l e D e f i n i t i o n 1

= G 4 P a r t i c l e T a b l e :: G e t P a r t i c l e T a b l e () -> F i n d P a r t i c l e (" gam ma ") ;

p a r t i c l e D e f i n i t i o n 2

= G 4 P a r t i c l e T a b l e :: G e t P a r t i c l e T a b l e () -> F i n d P a r t i c l e (" n e u t r o n ") ; }

M a S P r i m a r y G e n e r a t o r A c t i o n ::~ M a S P r i m a r y G e n e r a t o r A c t i o n () {

d e l e t e f P a r t i c l e G u n ; }

20

(23)

void M a S P r i m a r y G e n e r a t o r A c t i o n :: G e n e r a t e P r i m a r i e s ( G 4 E v e n t * a n E v e n t ) {

if( p a r t i c l e ) {

f P a r t i c l e G u n - > S e t P a r t i c l e D e f i n i t i o n ( p a r t i c l e D e f i n i t i o n 1 ) ;

f P a r t i c l e G u n - > S e t P a r t i c l e M o m e n t u m D i r e c t i o n ( G 4 T h r e e V e c t o r (0. ,0. ,1.) )

;

f P a r t i c l e G u n - > S e t P a r t i c l e P o s i t i o n ( G 4 T h r e e V e c t o r (0. , 0. , 0.) ) ; f P a r t i c l e G u n - > S e t P a r t i c l e E n e r g y (4 .4* MeV ) ;

p a r t i c l e = fal se ; }else{

f P a r t i c l e G u n - > S e t P a r t i c l e D e f i n i t i o n ( p a r t i c l e D e f i n i t i o n 2 ) ;

f P a r t i c l e G u n - > S e t P a r t i c l e M o m e n t u m D i r e c t i o n ( G 4 T h r e e V e c t o r (0. ,0. , -1.) ) ;

f P a r t i c l e G u n - > S e t P a r t i c l e P o s i t i o n ( G 4 T h r e e V e c t o r (0. , 0. , 0.) ) ; f P a r t i c l e G u n - > S e t P a r t i c l e E n e r g y (2 .4* MeV ) ;

// f P a r t i c l e G u n - > S e t P a r t i c l e E n e r g y ( ( 2 + 2 * G 4 U n i f o r m R a n d () ) * MeV ) ; p a r t i c l e = true ;

}

f P a r t i c l e G u n - > G e n e r a t e P r i m a r y V e r t e x ( a n E v e n t ) ; }

(24)

DetectorConstruction.h

# i f n d e f M a S D e t e c t o r C o n s t r u c t i o n _ h

# d e f i n e M a S D e t e c t o r C o n s t r u c t i o n _ h 1

# i n c l u d e " g l o b a l s . hh "

# i n c l u d e " G 4 V U s e r D e t e c t o r C o n s t r u c t i o n . hh "

# i n c l u d e " G 4 V P h y s i c a l V o l u m e . hh "

# i n c l u d e " G 4 L o g i c a l V o l u m e . hh "

cl ass M a S D e t e c t o r C o n s t r u c t i o n : p u b l i c G 4 V U s e r D e t e c t o r C o n s t r u c t i o n {

p u b l i c :

M a S D e t e c t o r C o n s t r u c t i o n () ;

v i r t u a l ~ M a S D e t e c t o r C o n s t r u c t i o n () ; v i r t u a l G 4 V P h y s i c a l V o l u m e * C o n s t r u c t () ;

p r i v a t e :

G 4 V P h y s i c a l V o l u m e * f W o r l d P ; G 4 L o g i c a l V o l u m e * d e t e c t o r L 1 ; G 4 L o g i c a l V o l u m e * d e t e c t o r L 2 ; G 4 M a t e r i a l * f W o r l d M a t e r i a l ; G 4 M a t e r i a l * f D e t e c t o r M a t e r i a l 1 ; G 4 M a t e r i a l * f D e t e c t o r M a t e r i a l 2 ; };

# endif

22

(25)

DetectorConstruction.cpp

# i n c l u d e " M a S D e t e c t o r C o n s t r u c t i o n . h "

# i n c l u d e " G 4 P S T i m e . h "

# i n c l u d e " G 4 M a t e r i a l . hh "

# i n c l u d e " G 4 N i s t M a n a g e r . hh "

# i n c l u d e " G 4Bo x . hh "

# i n c l u d e " G 4 T u b s . hh "

# i n c l u d e " G 4 L o g i c a l V o l u m e . hh "

# i n c l u d e " G 4 P V P l a c e m e n t . hh "

# i n c l u d e " G 4 S y s t e m O f U n i t s . hh "

# i n c l u d e " G 4 S D M a n a g e r . hh "

# i n c l u d e " G 4 M u l t i F u n c t i o n a l D e t e c t o r . hh "

# i n c l u d e " G 4 V P r i m i t i v e S c o r e r . hh "

# i n c l u d e " G 4 P S E n e r g y D e p o s i t . hh "

# i n c l u d e < G 4 S D P a r t i c l e F i l t e r . hh >

# i n c l u d e " G 4 V i s A t t r i b u t e s . hh "

# i n c l u d e " G 4 C o l o u r . hh "

M a S D e t e c t o r C o n s t r u c t i o n :: M a S D e t e c t o r C o n s t r u c t i o n () : G 4 V U s e r D e t e c t o r C o n s t r u c t i o n ()

{}

M a S D e t e c t o r C o n s t r u c t i o n ::~ M a S D e t e c t o r C o n s t r u c t i o n () {}

23

(26)

G 4 V P h y s i c a l V o l u m e * M a S D e t e c t o r C o n s t r u c t i o n :: C o n s t r u c t () {

G 4 c o u t << " C o n s t r u c t " << G 4 e n d l ;

G 4 N i s t M a n a g e r * n i s t M a n a g e r = G 4 N i s t M a n a g e r :: I n s t a n c e () ; G 4 b o o l f r o m I s o t o p e s = fal se ;

// C r e a t i n g the wor ld sol id v o l u m e with G4 box . G 4 d o u b l e w o r l d _ h x = 1.5* m ;

G 4 d o u b l e w o r l d _ h y = 1.0* m ; G 4 d o u b l e w o r l d _ h z = 2.0* m ;

G4 Box * w o r l d S = new G4 Bo x (" W o r l d S ", world_hx , world_hy , w o r l d _ h z ) ;

// C r e a t e a wor ld l o g i c a l v o l u m e c o m p o s t e d of air

f W o r l d M a t e r i a l = n i s t M a n a g e r - > F i n d O r B u i l d M a t e r i a l (" G 4 _ A I R ", f r o m I s o t o p e s ) ;

G 4 L o g i c a l V o l u m e * w o r l d L = new G 4 L o g i c a l V o l u m e ( worldS , f W o r l d M a t e r i a l , "

w o r l d L ") ;

// Pla ce the wor ld l o g i c a l v o l u m e

f W o r l d P = new G 4 P V P l a c e m e n t (0 , G 4 T h r e e V e c t o r () , worldL , " W orl d ", 0 , false , 0 , fa lse ) ;

// C r e a t e the a c t i v e d e t e c t o r so lid v o l u m e s

// BaF2

G 4 d o u b l e i n n e r R a d i u s B a F 2 = 0.* cm ; G 4 d o u b l e o u t e r R a d i u s B a F 2 = 51.* mm ; G 4 d o u b l e h z B a F 2 = 51.* mm ;

G 4 d o u b l e s t a r t A n g l e B a F 2 = 0.* deg ; G 4 d o u b l e s p a n n i n g A n g l e B a F 2 = 360 .* deg ;

G 4 T u b s * d e t e c t o r S 1 = new G 4 T u b s (" d e t e c t o r S 1 ", i n n e r R a d i u s B a F 2 /2 ,

o u t e r R a d i u s B a F 2 /2 , h z B a F 2 /2 ,

s t a r t A n g l e B a F 2 , s p a n n i n g A n g l e B a F 2 ) ;

f D e t e c t o r M a t e r i a l 1 = n i s t M a n a g e r -> F i n d O r B u i l d M a t e r i a l ("

G 4 _ B A R I U M _ F L U O R I D E ", f r o m I s o t o p e s ) ;

(27)

// v i n y l t o l u e n e

G 4 d o u b l e i n n e r R a d i u s V i n y l = 0.* cm ; G 4 d o u b l e o u t e r R a d i u s V i n y l = 94.* mm ; G 4 d o u b l e h z V i n y l = 62.* mm ;

G 4 d o u b l e s t a r t A n g l e V i n y l = 0.* deg ; G 4 d o u b l e s p a n n i n g A n g l e V i n y l = 360 .* deg ;

G 4 T u b s * d e t e c t o r S 2 = new G 4 T u b s (" d e t e c t o r S 2 ", i n n e r R a d i u s V i n y l /2 ,

o u t e r R a d i u s V i n y l /2 , h z V i n y l /2 ,

s t a r t A n g l e V i n y l , s p a n n i n g A n g l e V i n y l ) ;

f D e t e c t o r M a t e r i a l 2 = n i s t M a n a g e r -> F i n d O r B u i l d M a t e r i a l ("

G 4 _ P L A S T I C _ S C _ V I N Y L T O L U E N E ", f r o m I s o t o p e s ) ;

// C r e a t e the a c t i v e d e t e c t o r l o g i c a l v o l u m e s

// BaF2

d e t e c t o r L 1 = new G 4 L o g i c a l V o l u m e ( det ect orS 1 , f D e t e c t o r M a t e r i a l 1 , "

d e t e c t o r L 1 ") ;

G 4 d o u b l e d e t e c t o r B a F 2 _ X = 0.0* cm ; G 4 d o u b l e d e t e c t o r B a F 2 _ Y = 0.0* cm ; G 4 d o u b l e d e t e c t o r B a F 2 _ Z = 10. 0* cm ;

new G 4 P V P l a c e m e n t (0 , G 4 T h r e e V e c t o r ( d e t e c t o r B a F 2 _ X , d e t e c t o r B a F 2 _ Y ,

d e t e c t o r B a F 2 _ Z ) , de tec tor L1 , "

d e t e c t o r B a F 2 ", worldL , false ,0 , fa lse ) ;

// V i n y l t o l u e n e

d e t e c t o r L 2 = new G 4 L o g i c a l V o l u m e ( det ect orS 2 , f D e t e c t o r M a t e r i a l 2 , "

d e t e c t o r L 2 ") ;

G 4 d o u b l e d e t e c t o r V i n y l _ X = 0.0* cm ; G 4 d o u b l e d e t e c t o r V i n y l _ Y = 0.0* cm ; G 4 d o u b l e d e t e c t o r V i n y l _ Z = -1.05* m ;

(28)

new G 4 P V P l a c e m e n t (0 , G 4 T h r e e V e c t o r ( d e t e c t o r V i n y l _ X , d e t e c t o r V i n y l _ Y ,

d e t e c t o r V i n y l _ Z ) , det ect orL 2 , "

d e t e c t o r P l a s t i c ", worldL , false ,0 , f als e ) ;

// C r e a t e s e n s i t v e d e t e c t o r s of the a c t i v e l o g i c a l v o l u m e s

G 4 M u l t i F u n c t i o n a l D e t e c t o r * g D e t e c t o r = new G 4 M u l t i F u n c t i o n a l D e t e c t o r ("

g D e t e c t o r ") ;

G 4 M u l t i F u n c t i o n a l D e t e c t o r * n D e t e c t o r = new G 4 M u l t i F u n c t i o n a l D e t e c t o r ("

n D e t e c t o r ") ;

G 4 V P r i m i t i v e S c o r e r * Ede p1 = new G 4 P S E n e r g y D e p o s i t (" Ed ep1 ") ; G 4 V P r i m i t i v e S c o r e r * Ede p2 = new G 4 P S E n e r g y D e p o s i t (" Ed ep2 ") ; G 4 V P r i m i t i v e S c o r e r * Tim e1 = new G 4 P S T i m e (" Ti me1 ") ;

G 4 V P r i m i t i v e S c o r e r * Tim e2 = new G 4 P S T i m e (" Ti me2 ") ;

G 4 S D P a r t i c l e F i l t e r * p r o t o n F i l t e r = new G 4 S D P a r t i c l e F i l t e r (" p r o t o n F i l t e r

") ;

p r o t o n F i l t e r -> add (" p r o t o n ") ;

G 4 S D P a r t i c l e F i l t e r * e l e c t r o n F i l t e r = new G 4 S D P a r t i c l e F i l t e r ("

e l e c t r o n F i l t e r ") ;

e l e c t r o n F i l t e r -> add ("e - ") ; e l e c t r o n F i l t e r -> add (" e + ") ; e l e c t r o n F i l t e r -> add (" g amm a ") ;

Ed ep1 -> S e t F i l t e r ( e l e c t r o n F i l t e r ) ; Ed ep2 -> S e t F i l t e r ( p r o t o n F i l t e r ) ; Ti me1 -> S e t F i l t e r ( e l e c t r o n F i l t e r ) ; Ti me2 -> S e t F i l t e r ( p r o t o n F i l t e r ) ;

gDetector - > R e g i s t e r P r i m i t i v e ( Ede p1 ) ; nDetector - > R e g i s t e r P r i m i t i v e ( Ede p2 ) ;

gDetector - > R e g i s t e r P r i m i t i v e ( Tim e1 ) ; nDetector - > R e g i s t e r P r i m i t i v e ( Tim e2 ) ;

G 4 S D M a n a g e r :: G e t S D M p o i n t e r () -> A d d N e w D e t e c t o r ( g D e t e c t o r ) ; G 4 S D M a n a g e r :: G e t S D M p o i n t e r () -> A d d N e w D e t e c t o r ( n D e t e c t o r ) ;

(29)

d e t e c t o r L 1 -> S e t S e n s i t i v e D e t e c t o r ( g D e t e c t o r ) ; d e t e c t o r L 2 -> S e t S e n s i t i v e D e t e c t o r ( n D e t e c t o r ) ;

// This part give d i f f e r e n t c o l o u r s to wo rld l o g i c a l v o l u m e and the l o g i c a l v o l u m e

G 4 V i s A t t r i b u t e s * w o r l d V i s A t t = new G 4 V i s A t t r i b u t e s ( G 4 C o l o u r (.5 ,.5 ,.5) ) ; w o r l d V i s A t t - > S e t V i s i b i l i t y ( true ) ;

w o r l d L -> S e t V i s A t t r i b u t e s ( w o r l d V i s A t t ) ;

G 4 V i s A t t r i b u t e s * d e t V i s A t t 1 = new G 4 V i s A t t r i b u t e s ( G 4 C o l o u r (1.0 ,0.0 ,0.0) )

;

de tVi sAt t1 - > S e t V i s i b i l i t y ( true ) ;

d e t e c t o r L 1 -> S e t V i s A t t r i b u t e s ( d e t V i s A t t 1 ) ;

G 4 V i s A t t r i b u t e s * d e t V i s A t t 2 = new G 4 V i s A t t r i b u t e s ( G 4 C o l o u r (0.0 ,1.0 ,0.0) )

;

de tVi sAt t2 - > S e t V i s i b i l i t y ( true ) ;

d e t e c t o r L 2 -> S e t V i s A t t r i b u t e s ( d e t V i s A t t 2 ) ;

// R e t u r n the g e o m e t r y r e t u r n f W o r l d P ;

}

(30)

EventAction.h

# i f n d e f M a S E v e n t A c t i o n _ h

# d e f i n e M a S E v e n t A c t i o n _ h 1

# i n c l u d e " G 4 U s e r E v e n t A c t i o n . hh "

# i n c l u d e " g l o b a l s . hh "

# i n c l u d e " G 4 T H i t s M a p . hh "

# i n c l u d e " M a S R u n A c t i o n . h "

cl ass M a S E v e n t A c t i o n : p u b l i c G 4 U s e r E v e n t A c t i o n {

p u b l i c :

M a S E v e n t A c t i o n ( M a S R u n A c t i o n * ) ; v i r t u a l ~ M a S E v e n t A c t i o n () ;

v i r t u a l void B e g i n O f E v e n t A c t i o n (const G 4 E v e n t * ) ; v i r t u a l void E n d O f E v e n t A c t i o n (const G 4 E v e n t * ) ; void S e t P r i n t M o d u l o ( G4 int v alu e ) ;

p r i v a t e :

G4 THi tsM ap < G4double >* G e t H i t s C o l l e c t i o n (const G 4 S t r i n g & hcName , const G 4 E v e n t * ev ent ) const;

G 4 d o u b l e G e t S u m ( G4T Hit sMa p < G4double >* h i t s M a p ) const; void P r i n t E v e n t S t a t i s t i c s ( G 4 d o u b l e Edep ) ;

G4 int f P r i n t M o d u l o ;

G 4 d o u b l e G e t T i m e ( G4T Hit sMa p < G4double >* h i t s M a p ) const; G 4 d o u b l e E d e p 1 s a v e ;

G 4 d o u b l e T i m e 1 s a v e ; G4 int c o u n t S a v e ; G4 int co unt ;

M a S R u n A c t i o n * arun ;

28

(31)

};

i n l i n e void M a S E v e n t A c t i o n :: S e t P r i n t M o d u l o ( G 4in t v alu e ) {

f P r i n t M o d u l o = v alu e ; }

# endif

(32)

EventAction.cpp

# i n c l u d e " M a S E v e n t A c t i o n . h "

# i n c l u d e " M a S A n a l y s i s . h "

# i n c l u d e " G 4 S D M a n a g e r . hh "

# i n c l u d e " G 4 E v e n t . hh "

# i n c l u d e " G 4 H C o f T h i s E v e n t . hh "

# i n c l u d e " G 4 U n i t s T a b l e . hh "

# i n c l u d e " R a n d o m i z e . hh "

M a S E v e n t A c t i o n :: M a S E v e n t A c t i o n ( M a S R u n A c t i o n * run ) : G 4 U s e r E v e n t A c t i o n () , f P r i n t M o d u l o ( 1 0 0 0 0 ) {

E d e p 1 s a v e = run -> G e t E d e p S a v e () ; T i m e 1 s a v e = run -> G e t T i m e S a v e () ; c o u n t S a v e = run -> G e t C o u n t S a v e () ; co unt = run -> G e t C o u n t () ;

arun = run ; }

M a S E v e n t A c t i o n ::~ M a S E v e n t A c t i o n () {;}

G4 THi tsM ap < G4double >*

M a S E v e n t A c t i o n :: G e t H i t s C o l l e c t i o n (const G 4 S t r i n g & hcName ,const G 4 E v e n t * ev ent ) const

{

G4 int hcID = G 4 S D M a n a g e r :: G e t S D M p o i n t e r () -> G e t C o l l e c t i o n I D ( h c N a m e ) ;

30

(33)

G4 THi tsM ap < G4double >* h i t s C o l l e c t i o n = s t a t i c _ c a s t < G 4TH its Map < G4double

>* >( eve nt -> G e t H C o f T h i s E v e n t () -> Ge tHC ( hcID ) ) ;

if (! h i t s C o l l e c t i o n ) {

G 4 c e r r << " C a n n o t a c c e s s h i t s C o l l e c t i o n " << h c N a m e << G 4 e n d l ; exit (1) ;

}

r e t u r n h i t s C o l l e c t i o n ; }

G 4 d o u b l e M a S E v e n t A c t i o n :: G e t S u m ( G4T Hit sMa p < G4double >* h i t s M a p ) const {

G 4 d o u b l e s u m V a l u e = 0;

std :: map < G4int , G 4 d o u b l e * >:: i t e r a t o r it ;

for ( it = h i t s M a p -> G e t M a p () -> beg in () ; it != h i t s M a p -> G e t M a p () ->

end () ; it ++) {

s u m V a l u e += *( it -> s e c o n d ) ; }

r e t u r n s u m V a l u e ; }

G 4 d o u b l e M a S E v e n t A c t i o n :: G e t T i m e ( G4T Hit sMa p < G4double >* h i t s M a p ) const {

G 4 d o u b l e s u m V a l u e = 0.;

std :: map < G4int , G 4 d o u b l e * >:: i t e r a t o r it ;

G4 int size = h i t s M a p -> G e t M a p () -> size () ; if( size > 0) {

it = h i t s M a p -> G e t M a p () -> be gin () ; s u m V a l u e = *( it -> s e c o n d ) ;

it = h i t s M a p -> G e t M a p () -> end () ; it - -;

s u m V a l u e += *( it -> s e c o n d ) ; }

r e t u r n s u m V a l u e /2.;

}

(34)

void M a S E v e n t A c t i o n :: P r i n t E v e n t S t a t i s t i c s ( G 4 d o u b l e Edep ) {

G 4 c o u t

<< " E d e t e c t o r : t ota l e n e r g y : "

<< std :: setw (7) << G 4 B e s t U n i t ( Edep , " E n e r g y ")

<< G 4 e n d l ; }

void M a S E v e n t A c t i o n :: B e g i n O f E v e n t A c t i o n (const G 4 E v e n t * ev ent ) {

G4 int e v e n t I D = event - > G e t E v e n t I D () ; if ( e v e n t I D % f P r i n t M o d u l o == 0) {

G 4 c o u t << " \ n - - - > Beg in of ev ent : " << e v e n t I D << G 4 e n d l ; }

}

void M a S E v e n t A c t i o n :: E n d O f E v e n t A c t i o n (const G 4 E v e n t * ev ent ) {

// Get the v a l u e s from the last ev ent E d e p 1 s a v e = arun -> G e t E d e p S a v e () ; T i m e 1 s a v e = arun -> G e t T i m e S a v e () ; c o u n t S a v e = arun -> G e t C o u n t S a v e () ; co unt = arun -> G e t C o u n t () ;

// Get the v a l u e s from the c u r r e n t ev ent

G 4 d o u b l e Ede p1 = G e t S u m ( G e t H i t s C o l l e c t i o n (" g D e t e c t o r / Ed ep1 ", ev ent ) ) ; G 4 d o u b l e Tim e1 = G e t T i m e ( G e t H i t s C o l l e c t i o n (" g D e t e c t o r / Ti me1 ", ev ent ) ) ; G 4 d o u b l e Ede p2 = G e t S u m ( G e t H i t s C o l l e c t i o n (" n D e t e c t o r / Ed ep2 ", ev ent ) ) ; G 4 d o u b l e Tim e2 = G e t T i m e ( G e t H i t s C o l l e c t i o n (" n D e t e c t o r / Ti me2 ", ev ent ) ) ;

co unt ++;

// Save the new v a l u e s to R u n A c t i o n arun -> S e t C o u n t ( c oun t ) ;

arun -> S e t A l l ( Edep1 , Time1 , cou nt ) ;

G4 int temp = ++ c o u n t S a v e ;

// Save data to o u t p u t file

if(( Ede p2 > 0.0 || Ede p1 > 0.0) && co unt == temp ) {

G 4 A n a l y s i s M a n a g e r * a n a l y s i s M a n a g e r = G 4 A n a l y s i s M a n a g e r :: I n s t a n c e () ; a n a l y s i s M a n a g e r - > F i l l N t u p l e D C o l u m n (0 , 0 , E d e p 1 s a v e ) ;

a n a l y s i s M a n a g e r - > F i l l N t u p l e D C o l u m n (0 , 1 , T i m e 1 s a v e ) ;

(35)

a n a l y s i s M a n a g e r - > F i l l N t u p l e D C o l u m n (0 , 2 , E dep 2 ) ; a n a l y s i s M a n a g e r - > F i l l N t u p l e D C o l u m n (0 , 3 , T ime 2 ) ; a n a l y s i s M a n a g e r - > A d d N t u p l e R o w () ;

arun -> S e t A l l (0 ,0 ,0) ; }

G4 int e v e n t I D = event - > G e t E v e n t I D () ; if ( e v e n t I D % f P r i n t M o d u l o == 0) {

G 4 c o u t << " - - - > End of eve nt : " << e v e n t I D << G 4 e n d l ; P r i n t E v e n t S t a t i s t i c s ( E dep 1 ) ;

} }

(36)

RunAction.h

# i f n d e f M a S R u n A c t i o n _ h

# d e f i n e M a S R u n A c t i o n _ h 1

# i n c l u d e " G 4 U s e r R u n A c t i o n . hh "

# i n c l u d e " g l o b a l s . hh "

# i n c l u d e " G 4Ru n . hh "

cl ass M a S R u n A c t i o n : p u b l i c G 4 U s e r R u n A c t i o n {

p u b l i c :

M a S R u n A c t i o n () ;

v i r t u a l ~ M a S R u n A c t i o n () ;

v i r t u a l void B e g i n O f R u n A c t i o n (const G4 Run * run ) ; v i r t u a l void E n d O f R u n A c t i o n (const G4 Run * run ) ;

void S e t A l l ( G 4 d o u b l e Edep , G 4 d o u b l e Time , G4 int co unt ) ; void S e t C o u n t ( G4i nt cou nt ) ;

G 4 d o u b l e G e t E d e p S a v e () ; G 4 d o u b l e G e t T i m e S a v e () ; G4 int G e t C o u n t S a v e () ; G4 int G e t C o u n t () ; p r i v a t e :

G 4 d o u b l e E d e p 1 s a v e = 0;

G 4 d o u b l e T i m e 1 s a v e = 0;

G4 int c o u n t S a v e = 0;

G4 int co unt = 0;

};

# endif

34

(37)

RunAction.cpp

# i n c l u d e " M a S R u n A c t i o n . h "

# i n c l u d e " M a S A n a l y s i s . h "

# i n c l u d e " G 4Ru n . hh "

# i n c l u d e " G 4 R u n M a n a g e r . hh "

# i n c l u d e " G 4 U n i t s T a b l e . hh "

M a S R u n A c t i o n :: M a S R u n A c t i o n () : G 4 U s e r R u n A c t i o n () {;}

M a S R u n A c t i o n ::~ M a S R u n A c t i o n () {;}

void M a S R u n A c t i o n :: B e g i n O f R u n A c t i o n (const G4 Run * aRun ) {

E d e p 1 s a v e = 0;

T i m e 1 s a v e = 0;

c o u n t S a v e = 0;

G 4 c o u t << " ### Run " << aRun -> G e t R u n I D () << " st art . " << G 4 e n d l ; G 4 A n a l y s i s M a n a g e r * a n a l y s i s M a n a g e r = G 4 A n a l y s i s M a n a g e r :: I n s t a n c e () ; char Ru nId [1 0];

s p r i n t f ( RunId , " % d ", aRun -> G e t R u n I D () ) ; G 4 S t r i n g f i l e N a m e = " Run ";

f i l e N a m e += Run Id ; f i l e N a m e += " depE ";

a n a l y s i s M a n a g e r - > O p e n F i l e ( f i l e N a m e ) ;

a n a l y s i s M a n a g e r - > C r e a t e N t u p l e (" Hit "," Hit ") ; a n a l y s i s M a n a g e r - > C r e a t e N t u p l e D C o l u m n (" g Ede p ") ;

35

(38)

a n a l y s i s M a n a g e r - > C r e a t e N t u p l e D C o l u m n (" g Tim e ") ; a n a l y s i s M a n a g e r - > C r e a t e N t u p l e D C o l u m n (" n Ede p ") ; a n a l y s i s M a n a g e r - > C r e a t e N t u p l e D C o l u m n (" n Tim e ") ; a n a l y s i s M a n a g e r - > F i n i s h N t u p l e () ;

}

void M a S R u n A c t i o n :: E n d O f R u n A c t i o n (const G4 Run * aRun ) {

G4 int n o f E v e n t s = aRun - > G e t N u m b e r O f E v e n t () ; if ( n o f E v e n t s == 0 ) r e t u r n;

G 4 A n a l y s i s M a n a g e r * a n a l y s i s M a n a g e r = G 4 A n a l y s i s M a n a g e r :: I n s t a n c e () ; a n a l y s i s M a n a g e r - > W rit e () ;

a n a l y s i s M a n a g e r - > C l o s e F i l e () ;

d e l e t e G 4 A n a l y s i s M a n a g e r :: I n s t a n c e () ; }

void M a S R u n A c t i o n :: S e t A l l ( G 4 d o u b l e Edep , G 4 d o u b l e Time , G 4in t c o u n t 1 ) { E d e p 1 s a v e = Edep ;

T i m e 1 s a v e = Time ; c o u n t S a v e = c o u n t 1 ; }

void M a S R u n A c t i o n :: S e t C o u n t ( G 4in t c o u n t 1 ) { co unt = c o u n t 1 ;

}

G 4 d o u b l e M a S R u n A c t i o n :: G e t E d e p S a v e () { r e t u r n E d e p 1 s a v e ;

}

G 4 d o u b l e M a S R u n A c t i o n :: G e t T i m e S a v e () { r e t u r n T i m e 1 s a v e ;

}

G4 int M a S R u n A c t i o n :: G e t C o u n t S a v e () { r e t u r n c o u n t S a v e ;

}

G4 int M a S R u n A c t i o n :: G e t C o u n t () { r e t u r n co unt ;

}

(39)

G4PSTime.h

# i f n d e f G 4 P S T i m e _ h

# d e f i n e G 4 P S T i m e _ h 1

# i n c l u d e " G 4 V P r i m i t i v e S c o r e r . hh "

# i n c l u d e " G 4 T H i t s M a p . hh "

cl ass G 4 P S T i m e : p u b l i c G 4 V P r i m i t i v e S c o r e r {

p u b l i c : // with d e s c r i p t i o n

G 4 P S T i m e ( G 4 S t r i n g name , G4i nt dep th =0) ; // d e f a u l t unit v i r t u a l ~ G 4 P S T i m e () ;

p r o t e c t e d : // with d e s c r i p t i o n

v i r t u a l G 4 b o o l P r o c e s s H i t s ( G 4 S t e p * , G 4 T o u c h a b l e H i s t o r y *) ;

p u b l i c :

v i r t u a l void I n i t i a l i z e ( G 4 H C o f T h i s E v e n t *) ; v i r t u a l void E n d O f E v e n t ( G 4 H C o f T h i s E v e n t *) ; v i r t u a l void cl ear () ;

p r i v a t e :

G4 int HCID ;

G4 THi tsM ap < G4double >* E v t M a p ; G4 int st eps ;

};

# endif

37

(40)

G4PSTime.cpp

# i n c l u d e " G 4 P S T i m e . h "

# i n c l u d e " G 4 U n i t s T a b l e . hh "

G 4 P S T i m e :: G 4 P S T i m e ( G 4 S t r i n g name , G4i nt dep th )

: G 4 V P r i m i t i v e S c o r e r ( name , dep th ) , HCID ( -1) , E v t M a p (0) {

S e t U n i t (" ns ") ; st eps = 0;

}

G 4 P S T i m e ::~ G 4 P S T i m e () {;}

G 4 b o o l G 4 P S T i m e :: P r o c e s s H i t s ( G 4 S t e p * aStep , G 4 T o u c h a b l e H i s t o r y *) {

G 4 d o u b l e time = aStep - > G e t P r e S t e p P o i n t () -> G e t G l o b a l T i m e () ; G 4 d o u b l e edep = aStep - > G e t T o t a l E n e r g y D e p o s i t () ;

if( edep = =0. ) r e t u r n FA LSE ; G4 int in dex = G e t I n d e x ( a Ste p ) ; E v t M a p -> set ( index , time ) ; r e t u r n TRUE ;

}

void G 4 P S T i m e :: I n i t i a l i z e ( G 4 H C o f T h i s E v e n t * HCE ) {

E v t M a p = new G4T Hit sMa p < G4double >( G e t M u l t i F u n c t i o n a l D e t e c t o r () -> G e t N a m e () , G e t N a m e () ) ;

if( HCID < 0) { HCID = G e t C o l l e c t i o n I D (0) ;}

HCE - > A d d H i t s C o l l e c t i o n ( HCID , ( G 4 V H i t s C o l l e c t i o n *) E v t M a p ) ;

38

(41)

st eps = 0;

}

void G 4 P S T i m e :: E n d O f E v e n t ( G 4 H C o f T h i s E v e n t *) {;}

void G 4 P S T i m e :: cle ar () {

EvtMap - > c lea r () ; }

(42)

Analysis.h

# i f n d e f A n a l y s i s _ h

# d e f i n e A n a l y s i s _ h 1

# i n c l u d e " g 4 a n a l y s i s _ d e f s . hh "

us ing n a m e s p a c e G4 Cs v ; // usi ng n a m e s p a c e G 4 R o o t ;

# endif

40

(43)

Main.cpp

# i n c l u d e " D e t e c t o r C o n s t r u c t i o n . h "

# i n c l u d e " P r i m a r y G e n e r a t o r A c t i o n . h "

# i n c l u d e " R u n A c t i o n . h "

# i n c l u d e " E v e n t A c t i o n . h "

# i n c l u d e " G 4 P h y s L i s t F a c t o r y . hh "

# i n c l u d e " G 4 V M o d u l a r P h y s i c s L i s t . hh "

# i n c l u d e " G 4 R u n M a n a g e r . hh "

# i n c l u d e " G 4 U I m a n a g e r . hh "

# i n c l u d e " Q G S P _ B E R T _ H P . hh "

# i n c l u d e " G 4 S y s t e m O f U n i t s . hh "

# ifdef G 4 V I S _ U S E

# i n c l u d e " G 4 V i s E x e c u t i v e . hh "

# endif

# ifdef G 4 U I _ U S E

# i n c l u d e " G 4 U I E x e c u t i v e . hh "

# endif

# i n c l u d e " R a n d o m i z e . hh "

int main (int argc , char** argv ) {

G 4 R u n M a n a g e r * r u n M a n a g e r = new G 4 R u n M a n a g e r ;

r u n M a n a g e r -> S e t U s e r I n i t i a l i z a t i o n ( new D e t e c t o r C o n s t r u c t i o n () ) ;

41

(44)

G 4 P h y s L i s t F a c t o r y f a c t o r y ;

G 4 V M o d u l a r P h y s i c s L i s t * p h y s i c s L i s t = f a c t o r y . G e t R e f e r e n c e P h y s L i s t ("

Q G S P _ B E R T _ H P ") ;

p h y s i c s L i s t -> S e t V e r b o s e L e v e l (1) ;

p h y s i c s L i s t -> S e t D e f a u l t C u t V a l u e (. 01* mm ) ;

r u n M a n a g e r -> S e t U s e r I n i t i a l i z a t i o n ( p h y s i c s L i s t ) ;

r u n M a n a g e r -> S e t U s e r A c t i o n ( new P r i m a r y G e n e r a t o r A c t i o n () ) ;

R u n A c t i o n * run = new R u n A c t i o n () ;

r u n M a n a g e r -> S e t U s e r A c t i o n ( run ) ;

r u n M a n a g e r -> S e t U s e r A c t i o n ( new E v e n t A c t i o n ( run ) ) ;

r u n M a n a g e r -> I n i t i a l i z e () ;

# ifdef G 4 V I S _ U S E

G 4 V i s M a n a g e r * v i s M a n a g e r = new G 4 V i s E x e c u t i v e ; vi sMa nag er - > I n i t i a l i z e () ;

# endif

G 4 U I m a n a g e r * U I m a n a g e r = G 4 U I m a n a g e r :: G e t U I p o i n t e r () ;

if ( argc != 1) {

G 4 S t r i n g c o m m a n d = " / c o n t r o l / e x e c u t e ";

G 4 S t r i n g f i l e N a m e = argv [1];

G4cout < < argv [1] < < G 4 e n d l ;

UImanager - > A p p l y C o m m a n d ( c o m m a n d + f i l e N a m e ) ; }

else {

# ifdef G 4 U I _ U S E

G 4 U I E x e c u t i v e * ui = new G 4 U I E x e c u t i v e ( argc , argv ) ;

# ifdef G 4 V I S _ U S E

UImanager - > A p p l y C o m m a n d (" / c o n t r o l / e x e c u t e i n i t _ v i s . mac ") ;

# else

UImanager - > A p p l y C o m m a n d (" / c o n t r o l / e x e c u t e init . mac ") ;

# endif

ui - > S e s s i o n S t a r t () ; d e l e t e ui ;

# endif }

References

Related documents

This survey is part of a research project on how German manufacturing firms make use of digital technologies, supply chain integration, supply chain agility and

medical doctor in our team explained theories of epidemiology to us, how all epidemics had some kind of natural inbuilt flow to them, and that this might be a part of

Practical hands on experience in addition to the gymnasium class usability findings, led to final stage development in the form of a digital mobile application, &#34;id'8.&#34; An

The take-home message of this article is that although bullshit-receptivity and profound- ness-receptivity were positively correlated with each other, they yet correlated in

Sammantaget har studien klargjort att personer som arbetar på arbetsplatser med få anställda i Sverige har mer negativa attityder till invandrare än de som arbetar på

A possible solution was found by combining a decentralized cloud (see Section 4.1) with information propagation found in the Bittorrent network (see Section 4.2.1) and using

Huvudfrågan om dessa tre metoder, test för somaliska i samarbete med modersmålslärare, deltagande observation för svenska och intervjuer för att ta reda på bakgrundsinformation, är

I verkligheten använder de allra flesta företagen någon form av metod för att allokera sina kostnader och ska företaget göra detta samt att även teoretiskt kunna