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
9
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
86112aed
Commit
86112aed
authored
5 years ago
by
zoujh@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
add reading test for plcio
parent
fcd6ddd1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Event/CMakeLists.txt
+7
-4
7 additions, 4 deletions
Event/CMakeLists.txt
Event/tests/read.cpp
+54
-0
54 additions, 0 deletions
Event/tests/read.cpp
Event/tests/write.cpp
+28
-3
28 additions, 3 deletions
Event/tests/write.cpp
with
89 additions
and
7 deletions
Event/CMakeLists.txt
+
7
−
4
View file @
86112aed
...
...
@@ -37,7 +37,7 @@ install(TARGETS Event DESTINATION lib)
REFLEX_GENERATE_DICTIONARY
(
Event
${
headers
}
SELECTION src/selection.xml
)
add_library
(
EventDict SHARED Event.cxx
)
add_dependencies
(
EventDict Event-dictgen
)
target_link_libraries
(
EventDict Event
)
target_link_libraries
(
EventDict Event
ROOT::Core
)
install
(
TARGETS EventDict DESTINATION lib
)
# Headers and Libraries
...
...
@@ -53,6 +53,9 @@ install(TARGETS write DESTINATION tests)
add_test
(
NAME write COMMAND write
)
set_property
(
TEST write PROPERTY ENVIRONMENT LD_LIBRARY_PATH=
${
CMAKE_INSTALL_PREFIX
}
/lib:$ENV{LD_LIBRARY_PATH}
)
#add_test(NAME read COMMAND read)
#set_property(TEST read PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:$ENV{LD_LIBRARY_PATH})
#set_property(TEST read PROPERTY DEPENDS write)
add_executable
(
read tests/read.cpp
)
target_link_libraries
(
read EventDict
)
install
(
TARGETS read DESTINATION tests
)
add_test
(
NAME read COMMAND read
)
set_property
(
TEST read PROPERTY ENVIRONMENT LD_LIBRARY_PATH=
${
CMAKE_INSTALL_PREFIX
}
/lib:$ENV{LD_LIBRARY_PATH}
)
set_property
(
TEST read PROPERTY DEPENDS write
)
This diff is collapsed.
Click to expand it.
Event/tests/read.cpp
0 → 100644
+
54
−
0
View file @
86112aed
#include
"EventHeaderCollection.h"
#include
"MCParticleCollection.h"
#include
"podio/EventStore.h"
#include
"podio/ROOTReader.h"
int
main
(
int
argc
,
char
*
argv
[])
{
auto
reader
=
podio
::
ROOTReader
();
auto
store
=
podio
::
EventStore
();
reader
.
openFile
(
"test.root"
);
store
.
setReader
(
&
reader
);
unsigned
int
nEvt
=
reader
.
getEntries
();
for
(
unsigned
int
i
=
0
;
i
<
nEvt
;
++
i
)
{
//if ( i%10 == 0 ) {
// std::cout << "processing event " << i << std::endl;
//}
auto
&
hds
=
store
.
get
<
plcio
::
EventHeaderCollection
>
(
"EvtHeaders"
);
if
(
hds
.
isValid
()
)
{
auto
header
=
hds
[
0
];
std
::
cout
<<
"processing event "
<<
header
.
getEventNumber
()
<<
std
::
endl
;
}
else
{
return
-
1
;
}
auto
&
mcc
=
store
.
get
<
plcio
::
MCParticleCollection
>
(
"MCParticles"
);
if
(
!
mcc
.
isValid
()
)
{
return
-
1
;
}
for
(
auto
p
:
mcc
)
{
std
::
cout
<<
" particle "
<<
p
.
getObjectID
().
index
<<
" has daughters: "
;
for
(
auto
it
=
p
.
daughters_begin
(),
end
=
p
.
daughters_end
();
it
!=
end
;
++
it
)
{
std
::
cout
<<
" "
<<
it
->
getObjectID
().
index
;
}
std
::
cout
<<
" and parents: "
;
for
(
auto
it
=
p
.
parents_begin
(),
end
=
p
.
parents_end
();
it
!=
end
;
++
it
){
std
::
cout
<<
" "
<<
it
->
getObjectID
().
index
;
}
std
::
cout
<<
std
::
endl
;
}
store
.
clear
();
reader
.
endOfEvent
();
}
reader
.
closeFile
();
return
0
;
}
This diff is collapsed.
Click to expand it.
Event/tests/write.cpp
+
28
−
3
View file @
86112aed
...
...
@@ -9,7 +9,7 @@
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
cout
<<
"start writing test"
<<
std
::
endl
;
//
std::cout << "start writing test" << std::endl;
auto
store
=
podio
::
EventStore
();
auto
writer
=
podio
::
ROOTWriter
(
"test.root"
,
&
store
);
...
...
@@ -23,13 +23,38 @@ int main(int argc, char* argv[])
const
unsigned
int
nEvt
=
100
;
for
(
unsigned
int
i
=
0
;
i
<
nEvt
;
++
i
)
{
if
(
i
%
10
==
0
)
{
//
if ( i%10 == 0 ) {
std
::
cout
<<
"processing event "
<<
i
<<
std
::
endl
;
}
//
}
auto
header
=
plcio
::
EventHeader
(
i
,
-
99
,
9999
,
"SimDet"
);
ehc
.
push_back
(
header
);
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
mcc
.
create
();
}
for
(
unsigned
int
i
=
0
;
i
<
4
;
++
i
)
{
auto
p
=
mcc
[
i
];
for
(
unsigned
int
j
=
0
;
j
<
4
;
++
j
)
{
unsigned
int
idx
=
(
2
+
j
)
+
(
i
/
2
)
*
4
;
p
.
addDaughter
(
mcc
[
idx
]
);
mcc
[
idx
].
addParent
(
p
);
}
}
for
(
auto
p
:
mcc
)
{
std
::
cout
<<
" particle "
<<
p
.
getObjectID
().
index
<<
" has daughters: "
;
for
(
auto
it
=
p
.
daughters_begin
(),
end
=
p
.
daughters_end
();
it
!=
end
;
++
it
)
{
std
::
cout
<<
" "
<<
it
->
getObjectID
().
index
;
}
std
::
cout
<<
" and parents: "
;
for
(
auto
it
=
p
.
parents_begin
(),
end
=
p
.
parents_end
();
it
!=
end
;
++
it
){
std
::
cout
<<
" "
<<
it
->
getObjectID
().
index
;
}
std
::
cout
<<
std
::
endl
;
}
//////////
writer
.
writeEvent
();
store
.
clearCollections
();
...
...
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