ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
spectrum.C
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file spectrum.C
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
}
geant4
tree
geant4-10.6-release
examples
extended
medical
dna
svalue
spectrum.C
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:08
using
1.8.2 with
ECCE GitHub integration