Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Li Zhihao
CEPCSW
Commits
1c192e3a
Commit
1c192e3a
authored
3 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
parse the data.
parent
51ca041b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Generator/src/BeamBackgroundFileParserV0.cpp
+57
-2
57 additions, 2 deletions
Generator/src/BeamBackgroundFileParserV0.cpp
Generator/src/BeamBackgroundFileParserV0.h
+4
-1
4 additions, 1 deletion
Generator/src/BeamBackgroundFileParserV0.h
with
61 additions
and
3 deletions
Generator/src/BeamBackgroundFileParserV0.cpp
+
57
−
2
View file @
1c192e3a
#include
"BeamBackgroundFileParserV0.h"
#include
<sstream>
#include
<cmath>
BeamBackgroundFileParserV0
::
BeamBackgroundFileParserV0
(
const
std
::
string
&
filename
)
{
BeamBackgroundFileParserV0
::
BeamBackgroundFileParserV0
(
const
std
::
string
&
filename
,
int
pdgid
,
double
beam_energy
)
{
m_input
.
open
(
filename
.
c_str
());
m_pdgid
=
pdgid
;
m_beam_energy
=
beam_energy
;
}
bool
BeamBackgroundFileParserV0
::
load
(
IBeamBackgroundFileParser
::
BeamBackgroundData
&
result
)
{
return
true
;
if
(
not
m_input
.
good
())
{
return
false
;
}
// read one record
std
::
string
tmpline
;
// the format
double
generation_point
;
int
loss_turn
;
double
z
;
// unit: m
double
x
;
// unit: m
double
y
;
// unit: m
double
cosx
;
//
double
cosy
;
//
double
dz
;
// unit: m
double
dp
;
// unit: relative to the E
while
(
m_input
.
good
())
{
std
::
getline
(
m_input
,
tmpline
);
std
::
stringstream
ss
;
ss
<<
tmpline
;
ss
>>
generation_point
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
loss_turn
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
z
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
x
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
y
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
cosx
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
cosy
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
dz
;
if
(
ss
.
fail
())
{
continue
;
}
ss
>>
dp
;
if
(
ss
.
fail
())
{
continue
;
}
double
p
=
m_beam_energy
*
(
1
+
dp
);
// Now, we get a almost valid data
const
double
m2mm
=
1e3
;
// convert from m to mm
result
.
pdgid
=
m_pdgid
;
result
.
x
=
x
*
m2mm
;
result
.
y
=
y
*
m2mm
;
result
.
z
=
(
z
+
dz
)
*
m2mm
;
result
.
px
=
p
*
cosx
;
result
.
py
=
p
*
cosy
;
result
.
pz
=
p
*
std
::
sqrt
(
1
-
cosx
*
cosx
-
cosy
*
cosy
);
result
.
mass
=
0.000511
;
// assume e-/e+, mass is 0.511 MeV
return
true
;
}
return
false
;
}
This diff is collapsed.
Click to expand it.
Generator/src/BeamBackgroundFileParserV0.h
+
4
−
1
View file @
1c192e3a
...
...
@@ -7,11 +7,14 @@
class
BeamBackgroundFileParserV0
:
public
IBeamBackgroundFileParser
{
public:
BeamBackgroundFileParserV0
(
const
std
::
string
&
filename
);
BeamBackgroundFileParserV0
(
const
std
::
string
&
filename
,
int
pdgid
,
double
beam_energy
);
bool
load
(
IBeamBackgroundFileParser
::
BeamBackgroundData
&
);
private:
std
::
ifstream
m_input
;
int
m_pdgid
;
double
m_beam_energy
;
};
#endif
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