Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHG4PileupGenerator.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4PileupGenerator.cc
1
#include "
PHG4PileupGenerator.h
"
2
3
#include <
fun4all/Fun4AllReturnCodes.h
>
4
5
#include <gsl/gsl_randist.h>
6
7
#include <iostream>
// for operator<<, endl, basic_ostream
8
9
using namespace
std;
10
11
PHG4PileupGenerator::PHG4PileupGenerator
(
const
string
&
name
)
12
:
PHG4ParticleGeneratorBase
(name)
13
{
14
return
;
15
}
16
17
PHG4PileupGenerator::~PHG4PileupGenerator
()
18
{
19
delete
_generator
;
20
}
21
22
int
PHG4PileupGenerator::Init
(
PHCompositeNode
*topNode)
23
{
24
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
25
_generator
->
Init
(topNode);
26
return
Fun4AllReturnCodes::EVENT_OK
;
27
}
28
29
int
PHG4PileupGenerator::InitRun
(
PHCompositeNode
*topNode)
30
{
31
//cout << "generator ptr: " << _generator << endl;
32
33
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
34
35
_generator
->
InitRun
(topNode);
36
37
_ave_coll_per_crossing
=
_collision_rate
*
_time_between_crossings
* 1000.0 * 1
e
-9;
38
39
_min_crossing
=
_min_integration_time
/
_time_between_crossings
;
40
_max_crossing
=
_max_integration_time
/
_time_between_crossings
;
41
42
return
Fun4AllReturnCodes::EVENT_OK
;
43
}
44
45
int
PHG4PileupGenerator::process_event
(
PHCompositeNode
*topNode)
46
{
47
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
48
49
// toss multiple crossings all the way back
50
for
(
int
icrossing =
_min_crossing
; icrossing <=
_max_crossing
; ++icrossing)
51
{
52
double
crossing_time =
_time_between_crossings
* icrossing;
53
54
int
ncollisions = gsl_ran_poisson(
RandomGenerator
(),
_ave_coll_per_crossing
);
55
if
(icrossing == 0) --ncollisions;
56
57
for
(
int
icollision = 0; icollision < ncollisions; ++icollision)
58
{
59
_generator
->
set_t0
(crossing_time);
60
_generator
->
process_event
(topNode);
61
}
62
}
63
64
return
Fun4AllReturnCodes::EVENT_OK
;
65
}
66
67
int
PHG4PileupGenerator::Reset
(
PHCompositeNode
*topNode)
68
{
69
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
70
_generator
->
Reset
(topNode);
71
return
Fun4AllReturnCodes::EVENT_OK
;
72
}
73
74
int
PHG4PileupGenerator::ResetEvent
(
PHCompositeNode
*topNode)
75
{
76
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
77
_generator
->
ResetEvent
(topNode);
78
return
Fun4AllReturnCodes::EVENT_OK
;
79
}
80
81
int
PHG4PileupGenerator::EndRun
(
const
int
runnumber
)
82
{
83
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
84
_generator
->
EndRun
(runnumber);
85
return
Fun4AllReturnCodes::EVENT_OK
;
86
}
87
88
int
PHG4PileupGenerator::End
(
PHCompositeNode
*topNode)
89
{
90
if
(!
_generator
)
return
Fun4AllReturnCodes::EVENT_OK
;
91
_generator
->
End
(topNode);
92
return
Fun4AllReturnCodes::EVENT_OK
;
93
}
coresoftware
blob
master
simulation
g4simulation
g4main
PHG4PileupGenerator.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:15
using
1.8.2 with
sPHENIX GitHub integration