Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding of a function to obtain MC indices array and a parents tuples … #112

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Tristan63170
Copy link

I built a function that create the indices array of all MC particles, it was needed to me to build the MC history of MC particles (in association with parentid) to study the efficiency of my analysis.
In addition I built a function that create a tuples of MC particle with a child.
I think it could be useful for who want to study some efficiency when the MC history is needed.
Emmanuel Perez told me to do a pull request if my function work this is what I done.

Copy link
Contributor

@clementhelsens clementhelsens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Tristan63170 , sorry for late reply here, there is some work needed.

@@ -426,6 +426,13 @@ ROOT::VecOps::RVec<int> MCParticle::get_parentid(ROOT::VecOps::RVec<int> mcind,
return result;
}

ROOT::VecOps::RVec<int> get_index(ROOT::VecOps::RVec<edm4hep::MCParticleData> mc){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the point of this function, it just return the list of indices of the collection. The result will always be a vector of int between 0 and size-1. Why is that needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed to be able to use the MCParticle::get_parentid() method directly on the MC sample (the list of indices is an input of this method).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I understand that but I think this is something that could go in the define directly, After checking with RDF experts, seems something like this should be the most efficient way:

df.Define("idxs", "RVecI v(sz); std::iota(...); return v;")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see, interesting , it is another way to do that directly in the analysis.py script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you check it does work the same and remove the corresponding C++ code ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check that later.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to use std::iota in the analysis.py, the following error occurred:

input_line_101:2:108: error: no matching function for call to 'iota'
auto lambda21 = [](ROOT::VecOps::RVecedm4hep::MCParticleData& var0){ROOT::RVecI list_index(var0.size()); std::iota(list_index,list_index+list_index.size(),0); return list_index;
^~~~~~~~~
/cvmfs/sw.hsf.org/contrib/gcc/11.2.0/x86_64-centos7-gcc8.3.0-opt/d3epy/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_numeric.h:88:5: note: candidate template ignored: deduced conflicting types for parameter '_ForwardIterator' ('RVec' vs. 'RVec')
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
^
python3: /tmp/gitlab-runner/spack-stage/spack-stage-root-6.26.02-oqvm2mao7vull7th2vj4tmyo3i4jqsdp/spack-src/interpreter/llvm/src/tools/clang/lib/AST/DeclCXX.cpp:1391: clang::CXXMethodDecl* clang::CXXRecordDecl::getLambdaCallOperator() const: Assertion !Calls.empty() && "Missing lambda call operator!"' failed. *** Break *** abort ^Cinput_line_102:2:108: error: no matching function for call to 'iota' auto lambda21 = [](ROOT::VecOps::RVec<edm4hep::MCParticleData>& var0){ROOT::RVecI list_index(var0.size()); std::iota(list_index,list_index+list_index.size(),0); return list_index; ^~~~~~~~~ /cvmfs/sw.hsf.org/contrib/gcc/11.2.0/x86_64-centos7-gcc8.3.0-opt/d3epy/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/bits/stl_numeric.h:88:5: note: candidate template ignored: deduced conflicting types for parameter '_ForwardIterator' ('RVec<int>' vs. 'RVec<unsigned long>') iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) ^ python3: /tmp/gitlab-runner/spack-stage/spack-stage-root-6.26.02-oqvm2mao7vull7th2vj4tmyo3i4jqsdp/spack-src/interpreter/llvm/src/tools/clang/lib/AST/DeclCXX.cpp:1391: clang::CXXMethodDecl* clang::CXXRecordDecl::getLambdaCallOperator() const: Assertion !Calls.empty() && "Missing lambda call operator!"' failed.
*** Break *** abort

I have certainly something wrong but I don't understand what, have you any idea ?

thanks


ROOT::VecOps::RVec<edm4hep::MCParticleData> MCParticle::get(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is to get a list of MCParticle from a list of indices. The name get is then very confusing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change it in a new commit, don't hesitate if you have any other suggestion for the name.

@@ -49,6 +49,8 @@ namespace MCParticle{
bool m_chargeconjugate = true;
ROOT::VecOps::RVec<edm4hep::MCParticleData> operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 2 spaces

@@ -201,6 +205,7 @@ namespace MCParticle{
ROOT::VecOps::RVec<int> ind) ;


ROOT::VecOps::RVec<edm4hep::MCParticleData> get(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a documentation line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in a new commit

Copy link
Contributor

@clementhelsens clementhelsens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more thoughts

@@ -200,7 +204,8 @@ namespace MCParticle{
ROOT::VecOps::RVec<edm4hep::MCParticleData> in,
ROOT::VecOps::RVec<int> ind) ;


/// get a list of MCParticle from a list of indices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should write somethig like: return a sub list of MCParticles

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


ROOT::VecOps::RVec<edm4hep::MCParticleData> MCParticle::get_MC_from_indices(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would go for somehting like get_subMC

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants