LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
spectrum.C
Go to the documentation of this file.
1
// *********************************************************************
2
// To execute this macro under ROOT after your simulation ended,
3
// 1 - launch ROOT (usually type 'root' at your machine's prompt)
4
// 2 - type '.X spectrum.C' at the ROOT session prompt
5
// 3 - OR type directly 'root spectrum.C'
6
// this will generate an output energy spectrum spectrum.txt,
7
// according to selected statistics and distribution
8
// (energy unit assumed by svalue example: eV)
9
// *********************************************************************
10
11
{
12
gROOT->Reset();
13
14
// 1) SELECT number of values to shoot
15
int
nbValues
= 100;
16
//
17
18
double
value
;
19
TNtuple *
ntuple
=
new
TNtuple (
""
,
""
,
"value"
);
20
21
FILE *
fp
= fopen(
"spectrum.txt"
,
"w"
);
22
23
TRandom
r
;
24
25
for
(
int
i=0;i<
nbValues
;i++)
26
{
27
// 2) SELECT distribution
28
// here Gaussian with mean, sigma
29
// see https://root.cern.ch/doc/master/classTRandom.html
30
value = r.Gaus(1.,0.1);
31
//
32
ntuple->Fill(value);
33
fprintf(fp,
"%f \n"
,value);
34
}
35
fclose
(fp);
36
37
ntuple->Draw(
"value"
);
38
}
r
TRandom r
Definition:
spectrum.C:23
ntuple
TNtuple * ntuple
Definition:
spectrum.C:19
nbValues
int nbValues
Definition:
spectrum.C:15
fclose
fclose(fp)
fp
FILE * fp
Definition:
spectrum.C:21
value
double value
Definition:
spectrum.C:18
geant4.10.06.p01
examples
extended
medical
dna
svalue
spectrum.C
Generated on Thu May 2 2024 20:59:32 for LArSoft by
1.8.11