Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW_OTE_development
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
yudian2002@sjtu.edu.cn
CEPCSW_OTE_development
Commits
f2f0f1b2
Commit
f2f0f1b2
authored
1 year ago
by
FU Chengdong
Browse files
Options
Downloads
Patches
Plain Diff
edm4hep version control for ObjectID
parent
1938074c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Utilities/DataHelper/include/DataHelper/Navigation.h
+15
-0
15 additions, 0 deletions
Utilities/DataHelper/include/DataHelper/Navigation.h
Utilities/DataHelper/src/Navigation.cpp
+20
-3
20 additions, 3 deletions
Utilities/DataHelper/src/Navigation.cpp
with
35 additions
and
3 deletions
Utilities/DataHelper/include/DataHelper/Navigation.h
+
15
−
0
View file @
f2f0f1b2
...
@@ -5,6 +5,15 @@
...
@@ -5,6 +5,15 @@
#include
"edm4hep/TrackerHitCollection.h"
#include
"edm4hep/TrackerHitCollection.h"
#include
<map>
#include
<map>
#if __has_include("edm4hep/EDM4hepVersion.h")
#include
"edm4hep/EDM4hepVersion.h"
#else
// Copy the necessary parts from the header above to make whatever we need to work here
#define EDM4HEP_VERSION(major, minor, patch) ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | (UINT64_C(patch)))
// v00-09 is the last version without the capitalization change of the track vector members
#define EDM4HEP_BUILD_VERSION EDM4HEP_VERSION(0, 9, 0)
#endif
class
Navigation
{
class
Navigation
{
public:
public:
static
Navigation
*
Instance
();
static
Navigation
*
Instance
();
...
@@ -17,9 +26,15 @@ class Navigation{
...
@@ -17,9 +26,15 @@ class Navigation{
void
AddTrackerHitCollection
(
const
edm4hep
::
TrackerHitCollection
*
col
){
m_hitColVec
.
push_back
(
col
);};
void
AddTrackerHitCollection
(
const
edm4hep
::
TrackerHitCollection
*
col
){
m_hitColVec
.
push_back
(
col
);};
void
AddTrackerAssociationCollection
(
const
edm4hep
::
MCRecoTrackerAssociationCollection
*
col
){
m_assColVec
.
push_back
(
col
);};
void
AddTrackerAssociationCollection
(
const
edm4hep
::
MCRecoTrackerAssociationCollection
*
col
){
m_assColVec
.
push_back
(
col
);};
#if EDM4HEP_BUILD_VERSION <= EDM4HEP_VERSION(0, 10, 2)
edm4hep
::
TrackerHit
GetTrackerHit
(
const
edm4hep
::
ObjectID
&
id
,
bool
delete_by_caller
=
true
);
edm4hep
::
TrackerHit
GetTrackerHit
(
const
edm4hep
::
ObjectID
&
id
,
bool
delete_by_caller
=
true
);
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
edm4hep
::
ObjectID
&
id
);
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
edm4hep
::
ObjectID
&
id
);
#else
edm4hep
::
TrackerHit
GetTrackerHit
(
const
podio
::
ObjectID
&
id
,
bool
delete_by_caller
=
true
);
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
podio
::
ObjectID
&
id
);
#endif
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
edm4hep
::
TrackerHit
&
hit
);
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
edm4hep
::
TrackerHit
&
hit
);
std
::
vector
<
edm4hep
::
SimTrackerHit
>
GetRelatedTrackerHit
(
const
edm4hep
::
TrackerHit
&
hit
,
const
edm4hep
::
MCRecoTrackerAssociationCollection
*
col
);
//static Navigation* m_fNavigation;
//static Navigation* m_fNavigation;
private
:
private
:
...
...
This diff is collapsed.
Click to expand it.
Utilities/DataHelper/src/Navigation.cpp
+
20
−
3
View file @
f2f0f1b2
...
@@ -25,7 +25,11 @@ void Navigation::Initialize(){
...
@@ -25,7 +25,11 @@ void Navigation::Initialize(){
m_trkHits
.
clear
();
m_trkHits
.
clear
();
}
}
#if EDM4HEP_BUILD_VERSION <= EDM4HEP_VERSION(0, 10, 2)
edm4hep
::
TrackerHit
Navigation
::
GetTrackerHit
(
const
edm4hep
::
ObjectID
&
obj_id
,
bool
delete_by_caller
){
edm4hep
::
TrackerHit
Navigation
::
GetTrackerHit
(
const
edm4hep
::
ObjectID
&
obj_id
,
bool
delete_by_caller
){
#else
edm4hep
::
TrackerHit
Navigation
::
GetTrackerHit
(
const
podio
::
ObjectID
&
obj_id
,
bool
delete_by_caller
){
#endif
int
id
=
obj_id
.
collectionID
*
10000000
+
obj_id
.
index
;
int
id
=
obj_id
.
collectionID
*
10000000
+
obj_id
.
index
;
if
(
!
delete_by_caller
){
if
(
!
delete_by_caller
){
if
(
m_trkHits
.
find
(
id
)
!=
m_trkHits
.
end
())
return
m_trkHits
[
id
];
if
(
m_trkHits
.
find
(
id
)
!=
m_trkHits
.
end
())
return
m_trkHits
[
id
];
...
@@ -33,7 +37,7 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
...
@@ -33,7 +37,7 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
/*
/*
for(int i=0;i<m_assColVec.size();i++){
for(int i=0;i<m_assColVec.size();i++){
for(auto ass : *m_assColVec[i]){
for(auto ass : *m_assColVec[i]){
edm4hep::ObjectID
rec_id = ass.getRec().getObjectID();
auto
rec_id = ass.getRec().getObjectID();
if(rec_id.collectionID!=id.collectionID)break;
if(rec_id.collectionID!=id.collectionID)break;
else if(rec_id.index==id.index){
else if(rec_id.index==id.index){
m_trkHits.push_back(ass.getRec());
m_trkHits.push_back(ass.getRec());
...
@@ -44,7 +48,7 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
...
@@ -44,7 +48,7 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
*/
*/
for
(
int
i
=
0
;
i
<
m_hitColVec
.
size
();
i
++
){
for
(
int
i
=
0
;
i
<
m_hitColVec
.
size
();
i
++
){
for
(
auto
hit
:
*
m_hitColVec
[
i
]){
for
(
auto
hit
:
*
m_hitColVec
[
i
]){
edm4hep
::
ObjectID
this_id
=
hit
.
getObjectID
();
auto
this_id
=
hit
.
getObjectID
();
if
(
this_id
.
collectionID
!=
obj_id
.
collectionID
)
break
;
if
(
this_id
.
collectionID
!=
obj_id
.
collectionID
)
break
;
else
if
(
this_id
.
index
==
obj_id
.
index
){
else
if
(
this_id
.
index
==
obj_id
.
index
){
edm4hep
::
TrackerHit
hit_copy
=
edm4hep
::
TrackerHit
(
hit
);
edm4hep
::
TrackerHit
hit_copy
=
edm4hep
::
TrackerHit
(
hit
);
...
@@ -57,11 +61,15 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
...
@@ -57,11 +61,15 @@ edm4hep::TrackerHit Navigation::GetTrackerHit(const edm4hep::ObjectID& obj_id, b
throw
std
::
runtime_error
(
"Not found TrackerHit"
);
throw
std
::
runtime_error
(
"Not found TrackerHit"
);
}
}
#if EDM4HEP_BUILD_VERSION <= EDM4HEP_VERSION(0, 10, 2)
std
::
vector
<
edm4hep
::
SimTrackerHit
>
Navigation
::
GetRelatedTrackerHit
(
const
edm4hep
::
ObjectID
&
id
){
std
::
vector
<
edm4hep
::
SimTrackerHit
>
Navigation
::
GetRelatedTrackerHit
(
const
edm4hep
::
ObjectID
&
id
){
#else
std
::
vector
<
edm4hep
::
SimTrackerHit
>
Navigation
::
GetRelatedTrackerHit
(
const
podio
::
ObjectID
&
id
){
#endif
std
::
vector
<
edm4hep
::
SimTrackerHit
>
hits
;
std
::
vector
<
edm4hep
::
SimTrackerHit
>
hits
;
for
(
int
i
=
0
;
i
<
m_assColVec
.
size
();
i
++
){
for
(
int
i
=
0
;
i
<
m_assColVec
.
size
();
i
++
){
for
(
auto
ass
:
*
m_assColVec
[
i
]){
for
(
auto
ass
:
*
m_assColVec
[
i
]){
edm4hep
::
ObjectID
this_id
=
ass
.
getRec
().
getObjectID
();
auto
this_id
=
ass
.
getRec
().
getObjectID
();
if
(
this_id
.
collectionID
!=
id
.
collectionID
)
break
;
if
(
this_id
.
collectionID
!=
id
.
collectionID
)
break
;
else
if
(
this_id
.
index
==
id
.
index
)
hits
.
push_back
(
ass
.
getSim
());
else
if
(
this_id
.
index
==
id
.
index
)
hits
.
push_back
(
ass
.
getSim
());
}
}
...
@@ -79,3 +87,12 @@ std::vector<edm4hep::SimTrackerHit> Navigation::GetRelatedTrackerHit(const edm4h
...
@@ -79,3 +87,12 @@ std::vector<edm4hep::SimTrackerHit> Navigation::GetRelatedTrackerHit(const edm4h
}
}
return
hits
;
return
hits
;
}
}
std
::
vector
<
edm4hep
::
SimTrackerHit
>
Navigation
::
GetRelatedTrackerHit
(
const
edm4hep
::
TrackerHit
&
hit
,
const
edm4hep
::
MCRecoTrackerAssociationCollection
*
col
){
std
::
vector
<
edm4hep
::
SimTrackerHit
>
hits
;
for
(
auto
ass
:
*
col
){
if
(
ass
.
getRec
().
getObjectID
().
collectionID
!=
hit
.
getObjectID
().
collectionID
)
break
;
else
if
(
ass
.
getRec
()
==
hit
)
hits
.
push_back
(
ass
.
getSim
());
}
return
hits
;
}
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