ATLAS Offline Software
Loading...
Searching...
No Matches
Generators
CosmicGenerator
src
CosmicGun.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include <iostream>
7
#include <iomanip>
8
#include <math.h>
9
#include "
CosmicGenerator/CosmicGun.h
"
10
11
//--------------------------------------------------------
12
//
13
// These are the fortran subroutines
14
//
15
extern
"C"
{
16
void
cosmic2_
(
void
);
17
void
cosipr_
(
void
);
18
void
cosgin_
(
void
);
19
void
cosgen_
(
float
* emin,
float
* emax,
int
* iacc);
20
}
21
//--------------------------------------------------------
22
//
23
// and the common blocks
24
//
25
struct
genpar
{
26
float
LBINWID
,
LEMIN
,
LEMAX
;
27
int
NBIN
;
28
float
PROBE
[100];
29
};
30
alignas
(32)
genpar
genpar_
;
31
32
struct
coscut
{
33
float
ctcut
;
34
};
35
extern
coscut
coscut_
;
36
37
struct
cosevt
{
38
float
ENER
,
COSTH
,
PHI
,
CHRG
;
39
};
40
extern
cosevt
cosevt_
;
41
42
struct
flxout
{
43
float
FLUX
,
FLUX2
;
44
};
45
extern
flxout
flxout_
;
46
47
//--------------------------------------------------------
48
//
49
// singleton pattern
50
//
51
CosmicGun
*
CosmicGun::s_mpointer
= 0;
52
53
CosmicGun
*
CosmicGun::GetCosmicGun
(
void
){
54
if
(!
s_mpointer
)
s_mpointer
=
new
CosmicGun
();
55
return
s_mpointer
;
56
}
57
58
59
//--------------------------------------------------------
60
//
61
// constructor with some default settings
62
//
63
// 9 August 2005, RMcP: remove initialization from constructor.
64
CosmicGun::CosmicGun
(
void
){
65
m_event
= 0;
66
m_emin
= 50;
67
m_emax
= 500;
68
m_coscut
= 0.35;
69
m_printevt
= 20;
70
m_printmod
= 50;
71
72
coscut_
.ctcut =
m_coscut
;
73
genpar_
.LEMIN = std::log10(
m_emin
);
74
genpar_
.LEMAX = std::log10(
m_emax
);
75
genpar_
.NBIN = 100;
76
genpar_
.LBINWID = (
genpar_
.LEMAX-
genpar_
.LEMIN)/
genpar_
.NBIN;
77
78
// cosipr_();
79
// cosgin_();
80
81
}
82
83
// Add separate generator initialization routine
84
// to avoid forced default initialization, RMcP 9 Aug 05.
85
float
CosmicGun::InitializeGenerator
() {
86
std::cout <<
" CosmicGun::InitializeGenerator: E(min,max)=("
<<
m_emin
<<
","
<<
m_emax
87
<<
") GeV, and cos(ThetaCut)="
<<
m_coscut
<< std::endl;
88
cosipr_
();
89
cosgin_
();
90
cosmic2_
();
91
return
flxout_
.FLUX2;
92
}
93
94
void
CosmicGun::PrintLevel
(
int
printevt,
int
printmod){
95
if
(printevt >= 0)
96
{
97
m_printevt
= printevt;
98
}
99
else
100
{
101
std::cerr <<
"CosmicGun::PrintLevel - warning ignored input printevt = "
<< printevt << std::endl;
102
}
103
if
(printmod >= 1)
104
{
105
m_printmod
= printmod;
106
}
107
else
108
{
109
std::cerr <<
"CosmicGun::PrintLevel - warning ignored input printmod = "
<< printmod << std::endl;
110
}
111
}
112
113
CLHEP::HepLorentzVector
CosmicGun::GenerateEvent
(
void
){
114
int
iacc = 0;
115
116
while
(iacc == 0){
117
cosgen_
(&
m_emin
, &
m_emax
, &iacc);
118
}
119
m_event
++;
120
121
float
sinth = std::sqrt( 1-std::pow(
cosevt_
.COSTH,2) );
122
float
e =
cosevt_
.ENER;
123
float
px =
cosevt_
.ENER * sinth * std::sin(
cosevt_
.PHI);
124
float
py =
cosevt_
.ENER * sinth * std::cos(
cosevt_
.PHI);
125
float
pz =
cosevt_
.ENER *
cosevt_
.COSTH;
126
CLHEP::HepLorentzVector p(px,py,pz,e);
127
128
// if(m_event < m_printevt || m_event%m_printmod == 0)
129
// {
130
// std::cout << "CosmicGun::GenerateEvent: " << std::setw(4) << m_event
131
// << " muon charge " << std::setw(2) << cosevt_.CHRG << " with momentum : " << p << std::endl;
132
// }
133
134
return
p;
135
}
136
137
int
CosmicGun::GetMuonCharge
(
void
){
138
return
(
int
)
cosevt_
.CHRG;
139
}
140
141
void
CosmicGun::SetEnergyRange
(
float
emin,
float
emax){
142
if
(emin >= emax || emin < 0 )
143
{
144
std::cout <<
"Error input energy range : ("
<< emin <<
" - "
<< emax <<
") - ignored "
<< std::endl;
145
return
;
146
}
147
m_emin
= emin;
148
m_emax
= emax;
149
150
genpar_
.LEMIN = std::log10(
m_emin
);
151
genpar_
.LEMAX = std::log10(
m_emax
);
152
genpar_
.NBIN = 100;
153
genpar_
.LBINWID = (
genpar_
.LEMAX-
genpar_
.LEMIN)/
genpar_
.NBIN;
154
155
}
156
157
void
CosmicGun::SetCosCut
(
float
ctcut){
158
m_coscut
= ctcut;
159
160
coscut_
.ctcut =
m_coscut
;
161
}
162
cosgin_
void cosgin_(void)
genpar_
genpar genpar_
Definition
CosmicGun.cxx:30
cosmic2_
void cosmic2_(void)
flxout_
flxout flxout_
cosevt_
cosevt cosevt_
cosgen_
void cosgen_(float *emin, float *emax, int *iacc)
coscut_
coscut coscut_
cosipr_
void cosipr_(void)
CosmicGun.h
CosmicGun
Definition
CosmicGun.h:10
CosmicGun::PrintLevel
void PrintLevel(int printevt, int printmod)
Definition
CosmicGun.cxx:94
CosmicGun::s_mpointer
static CosmicGun * s_mpointer
Definition
CosmicGun.h:22
CosmicGun::SetEnergyRange
void SetEnergyRange(float emin, float emax)
Definition
CosmicGun.cxx:141
CosmicGun::GetMuonCharge
int GetMuonCharge(void)
Definition
CosmicGun.cxx:137
CosmicGun::m_emin
float m_emin
Definition
CosmicGun.h:26
CosmicGun::InitializeGenerator
float InitializeGenerator()
Definition
CosmicGun.cxx:85
CosmicGun::GenerateEvent
CLHEP::HepLorentzVector GenerateEvent(void)
Definition
CosmicGun.cxx:113
CosmicGun::SetCosCut
void SetCosCut(float ctcut)
Definition
CosmicGun.cxx:157
CosmicGun::m_emax
float m_emax
Definition
CosmicGun.h:26
CosmicGun::GetCosmicGun
static CosmicGun * GetCosmicGun(void)
Definition
CosmicGun.cxx:53
CosmicGun::m_event
int m_event
Definition
CosmicGun.h:24
CosmicGun::CosmicGun
CosmicGun(void)
Definition
CosmicGun.cxx:64
CosmicGun::m_printmod
int m_printmod
Definition
CosmicGun.h:25
CosmicGun::m_coscut
float m_coscut
Definition
CosmicGun.h:27
CosmicGun::m_printevt
int m_printevt
Definition
CosmicGun.h:25
coscut
Definition
CosmicGun.cxx:32
coscut::ctcut
float ctcut
Definition
CosmicGun.cxx:33
cosevt
Definition
CosmicGun.cxx:37
cosevt::CHRG
float CHRG
Definition
CosmicGun.cxx:38
cosevt::COSTH
float COSTH
Definition
CosmicGun.cxx:38
cosevt::PHI
float PHI
Definition
CosmicGun.cxx:38
cosevt::ENER
float ENER
Definition
CosmicGun.cxx:38
flxout
Definition
CosmicGun.cxx:42
flxout::FLUX
float FLUX
Definition
CosmicGun.cxx:43
flxout::FLUX2
float FLUX2
Definition
CosmicGun.cxx:43
genpar
Definition
CosmicGun.cxx:25
genpar::NBIN
int NBIN
Definition
CosmicGun.cxx:27
genpar::LEMAX
float LEMAX
Definition
CosmicGun.cxx:26
genpar::LEMIN
float LEMIN
Definition
CosmicGun.cxx:26
genpar::PROBE
float PROBE[100]
Definition
CosmicGun.cxx:28
genpar::LBINWID
float LBINWID
Definition
CosmicGun.cxx:26
Generated on
for ATLAS Offline Software by
1.14.0