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
maxt@ihep.ac.cn
CEPCSW
Commits
2ca44d31
Commit
2ca44d31
authored
4 months ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Plain Diff
Merge branch 'lintao/gen/index' into 'master'
StdHepRdr: Add StartIndex. See merge request
!137
parents
a8517ccf
e7316103
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Generator/src/GenReader.h
+9
-3
9 additions, 3 deletions
Generator/src/GenReader.h
Generator/src/StdHepRdr.cpp
+25
-5
25 additions, 5 deletions
Generator/src/StdHepRdr.cpp
Generator/src/StdHepRdr.h
+4
-1
4 additions, 1 deletion
Generator/src/StdHepRdr.h
with
38 additions
and
9 deletions
Generator/src/GenReader.h
+
9
−
3
View file @
2ca44d31
#ifndef GenReader_h
#define GenReader_h 1
/*
* GenReader is a base class for the gentools which load events from file
*/
#include
"GenEvent.h"
#include
"IGenTool.h"
using
namespace
std
;
class
GenReader
:
virtual
public
IGenTool
{
public:
~
GenReader
();
virtual
~
GenReader
()
=
0
;
virtual
bool
configure_gentool
()
=
0
;
virtual
bool
mutate
(
MyHepMC
::
GenEvent
&
event
)
=
0
;
virtual
bool
finish
()
=
0
;
virtual
bool
isEnd
()
=
0
;
// The start index is used to skip the first n events.
// if start index is 0, then the first event is the first event in the file
virtual
int
startIndex
()
{
return
0
;
};
};
#endif
This diff is collapsed.
Click to expand it.
Generator/src/StdHepRdr.cpp
+
25
−
5
View file @
2ca44d31
...
...
@@ -31,9 +31,9 @@ StdHepRdr::~StdHepRdr(){
}
bool
StdHepRdr
::
mutate
(
MyHepMC
::
GenEvent
&
event
){
++
m_processed_event
;
if
(
isEnd
())
return
false
;
LCCollectionVec
*
mc_vec
=
m_stdhep_rdr
->
readEvent
();
m_processed_event
++
;
int
n_mc
=
mc_vec
->
getNumberOfElements
();
//std::cout<<"Debug: Read event :"<< m_processed_event <<", mc size :"<< n_mc <<std::endl;
std
::
map
<
int
,
int
>
pmcid_lmcid
;
// mapping between the obj idx in edm4hep and the idx in stdhep
...
...
@@ -85,8 +85,12 @@ bool StdHepRdr::mutate(MyHepMC::GenEvent& event){
}
bool
StdHepRdr
::
isEnd
(){
if
(
m_processed_event
==
m_total_event
)
{
std
::
cout
<<
"Have read all events, end now."
<<
std
::
endl
;
return
true
;}
else
return
false
;
if
(
m_processed_event
==
m_total_event
)
{
std
::
cout
<<
"Have read all events, end now."
<<
std
::
endl
;
return
true
;
}
else
{
return
false
;
}
}
bool
StdHepRdr
::
configure_gentool
(){
...
...
@@ -96,8 +100,8 @@ bool StdHepRdr::configure_gentool(){
return
false
;
}
m_total_event
=
m_stdhep_rdr
->
getNumberOfEvents
()
-
1
;
m_processed_event
=
0
;
m_total_event
=
m_stdhep_rdr
->
getNumberOfEvents
();
m_processed_event
=
-
1
;
return
true
;
}
...
...
@@ -114,6 +118,18 @@ StdHepRdr::initialize() {
return
StatusCode
::
FAILURE
;
}
// skip the first n events if startIndex is not 0.
if
(
startIndex
()
!=
0
)
{
for
(
int
i
=
0
;
i
<
startIndex
();
++
i
)
{
++
m_processed_event
;
if
(
isEnd
())
return
StatusCode
::
FAILURE
;
LCCollectionVec
*
mc_vec
=
m_stdhep_rdr
->
readEvent
();
delete
mc_vec
;
}
info
()
<<
"Skip the first "
<<
startIndex
()
<<
" events."
<<
endmsg
;
}
return
sc
;
}
...
...
@@ -126,3 +142,7 @@ StdHepRdr::finalize() {
}
return
sc
;
}
int
StdHepRdr
::
startIndex
(){
return
m_startIndex
.
value
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Generator/src/StdHepRdr.h
+
4
−
1
View file @
2ca44d31
...
...
@@ -27,6 +27,8 @@ public:
bool
mutate
(
MyHepMC
::
GenEvent
&
event
)
override
;
bool
finish
()
override
;
bool
isEnd
()
override
;
int
startIndex
()
override
;
private:
lcio
::
LCStdHepRdrNew
*
m_stdhep_rdr
{
nullptr
};
long
m_total_event
{
-
1
};
...
...
@@ -34,7 +36,8 @@ private:
// input file name
Gaudi
::
Property
<
std
::
string
>
m_filename
{
this
,
"Input"
};
Gaudi
::
Property
<
double
>
m_starttime
{
this
,
"StartTime"
,
0
,
"Default start time"
};
Gaudi
::
Property
<
double
>
m_starttime
{
this
,
"StartTime"
,
0
,
"Default start time"
};
Gaudi
::
Property
<
int
>
m_startIndex
{
this
,
"StartIndex"
,
0
,
"Default start index"
};
};
...
...
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