Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW
Manage
Activity
Members
Labels
Plan
Issues
6
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
CEPCSW
Commits
2366aec6
Commit
2366aec6
authored
11 months ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
Allow to generate multiple particles for beam background
parent
4b8cc936
No related branches found
No related tags found
1 merge request
!12
Allow to generate multiple particles for beam background
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Generator/src/GtBeamBackgroundTool.cpp
+39
-27
39 additions, 27 deletions
Generator/src/GtBeamBackgroundTool.cpp
Generator/src/GtBeamBackgroundTool.h
+2
-1
2 additions, 1 deletion
Generator/src/GtBeamBackgroundTool.h
with
41 additions
and
28 deletions
Generator/src/GtBeamBackgroundTool.cpp
+
39
−
27
View file @
2366aec6
...
...
@@ -4,6 +4,8 @@
#include
"BeamBackgroundFileParserV0.h"
#include
"GuineaPigPairsFileParser.h"
#include
"CLHEP/Random/RandPoisson.h"
#include
"TVector3.h"
// for rotation
DECLARE_COMPONENT
(
GtBeamBackgroundTool
)
...
...
@@ -51,37 +53,47 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) {
// TODO: should sample according to the rates
// dummy: get one and stop to generate
for
(
auto
&
[
label
,
parser
]
:
m_beaminputs
)
{
IBeamBackgroundFileParser
::
BeamBackgroundData
beamdata
;
auto
isok
=
parser
->
load
(
beamdata
);
if
(
not
isok
)
{
error
()
<<
"Failed to load beam background data from the parser "
<<
label
<<
endmsg
;
return
false
;
}
// fill the value
float
charge
=
beamdata
.
pdgid
==
11
?
-
1
:
1
;
TVector3
pos
(
beamdata
.
x
,
beamdata
.
y
,
beamdata
.
z
);
TVector3
mom
(
beamdata
.
px
,
beamdata
.
py
,
beamdata
.
pz
);
int
nparticles
=
1
;
// by default, only one particle
auto
itrot
=
m_rotYmaps
.
find
(
label
);
if
(
itrot
!=
m_rotYmaps
.
end
()
)
{
info
()
<<
"Apply rotation along Y "
<<
itrot
->
second
<<
endmsg
;
if
(
auto
itRate
=
m_ratemaps
.
find
(
label
);
itRate
!=
m_ratemaps
.
end
())
{
nparticles
=
itRate
->
second
*
m_timewindow
;
pos
.
RotateY
(
itrot
->
second
);
mom
.
RotateY
(
itrot
->
second
);
// now sampling the number of particles
nparticles
=
CLHEP
::
RandPoisson
::
shoot
(
nparticles
);
}
// create the MC particle
auto
mcp
=
event
.
m_mc_vec
.
create
();
mcp
.
setPDG
(
beamdata
.
pdgid
);
mcp
.
setGeneratorStatus
(
1
);
mcp
.
setSimulatorStatus
(
1
);
mcp
.
setCharge
(
static_cast
<
float
>
(
charge
));
mcp
.
setTime
(
beamdata
.
t
);
mcp
.
setMass
(
beamdata
.
mass
);
mcp
.
setVertex
(
edm4hep
::
Vector3d
(
pos
.
X
(),
pos
.
Y
(),
pos
.
Z
()));
mcp
.
setMomentum
(
edm4hep
::
Vector3f
(
mom
.
X
(),
mom
.
Y
(),
mom
.
Z
()));
for
(
auto
iparticle
=
0
;
iparticle
<
nparticles
;
++
iparticle
)
{
IBeamBackgroundFileParser
::
BeamBackgroundData
beamdata
;
auto
isok
=
parser
->
load
(
beamdata
);
if
(
not
isok
)
{
error
()
<<
"Failed to load beam background data from the parser "
<<
label
<<
endmsg
;
return
false
;
}
// fill the value
float
charge
=
beamdata
.
pdgid
==
11
?
-
1
:
1
;
TVector3
pos
(
beamdata
.
x
,
beamdata
.
y
,
beamdata
.
z
);
TVector3
mom
(
beamdata
.
px
,
beamdata
.
py
,
beamdata
.
pz
);
auto
itrot
=
m_rotYmaps
.
find
(
label
);
if
(
itrot
!=
m_rotYmaps
.
end
()
)
{
info
()
<<
"Apply rotation along Y "
<<
itrot
->
second
<<
endmsg
;
pos
.
RotateY
(
itrot
->
second
);
mom
.
RotateY
(
itrot
->
second
);
}
// create the MC particle
auto
mcp
=
event
.
m_mc_vec
.
create
();
mcp
.
setPDG
(
beamdata
.
pdgid
);
mcp
.
setGeneratorStatus
(
1
);
mcp
.
setSimulatorStatus
(
1
);
mcp
.
setCharge
(
static_cast
<
float
>
(
charge
));
mcp
.
setTime
(
beamdata
.
t
);
mcp
.
setMass
(
beamdata
.
mass
);
mcp
.
setVertex
(
edm4hep
::
Vector3d
(
pos
.
X
(),
pos
.
Y
(),
pos
.
Z
()));
mcp
.
setMomentum
(
edm4hep
::
Vector3f
(
mom
.
X
(),
mom
.
Y
(),
mom
.
Z
()));
}
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
Generator/src/GtBeamBackgroundTool.h
+
2
−
1
View file @
2366aec6
...
...
@@ -54,7 +54,8 @@ private:
private:
Gaudi
::
Property
<
std
::
map
<
std
::
string
,
std
::
string
>>
m_inputmaps
{
this
,
"InputFileMap"
};
Gaudi
::
Property
<
std
::
map
<
std
::
string
,
std
::
string
>>
m_formatmaps
{
this
,
"InputFormatMap"
};
Gaudi
::
Property
<
std
::
map
<
std
::
string
,
double
>>
m_ratemaps
{
this
,
"InputRateMap"
};
Gaudi
::
Property
<
std
::
map
<
std
::
string
,
double
>>
m_ratemaps
{
this
,
"InputRateMap"
};
// unit: Hz
Gaudi
::
Property
<
double
>
m_timewindow
{
this
,
"TimeWindow"
,
1e-6
};
// unit: s
// unit of beam energy: GeV
Gaudi
::
Property
<
std
::
map
<
std
::
string
,
double
>>
m_Ebeammaps
{
this
,
"InputBeamEnergyMap"
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment