Adding of a function to obtain MC indices array and a parents tuples …#112
Adding of a function to obtain MC indices array and a parents tuples …#112Tristan63170 wants to merge 7 commits intoHEP-FCC:masterfrom
Conversation
clementhelsens
left a comment
There was a problem hiding this comment.
Hello @Tristan63170 , sorry for late reply here, there is some work needed.
analyzers/dataframe/MCParticle.cc
Outdated
| return result; | ||
| } | ||
|
|
||
| ROOT::VecOps::RVec<int> get_index(ROOT::VecOps::RVec<edm4hep::MCParticleData> mc){ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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;")
There was a problem hiding this comment.
Ok I see, interesting , it is another way to do that directly in the analysis.py script.
There was a problem hiding this comment.
could you check it does work the same and remove the corresponding C++ code ?
There was a problem hiding this comment.
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
analyzers/dataframe/MCParticle.cc
Outdated
| return result; | ||
| } | ||
|
|
||
| ROOT::VecOps::RVec<edm4hep::MCParticleData> MCParticle::get(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in){ |
There was a problem hiding this comment.
I guess this is to get a list of MCParticle from a list of indices. The name get is then very confusing.
There was a problem hiding this comment.
I change it in a new commit, don't hesitate if you have any other suggestion for the name.
| bool m_chargeconjugate = true; | ||
| ROOT::VecOps::RVec<edm4hep::MCParticleData> operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in); | ||
| }; | ||
|
|
analyzers/dataframe/MCParticle.h
Outdated
| ROOT::VecOps::RVec<int> ind) ; | ||
|
|
||
|
|
||
| ROOT::VecOps::RVec<edm4hep::MCParticleData> get(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in); |
There was a problem hiding this comment.
missing a documentation line
clementhelsens
left a comment
There was a problem hiding this comment.
some more thoughts
analyzers/dataframe/MCParticle.h
Outdated
| ROOT::VecOps::RVec<int> ind) ; | ||
|
|
||
|
|
||
| /// get a list of MCParticle from a list of indices |
There was a problem hiding this comment.
I think you should write somethig like: return a sub list of MCParticles
analyzers/dataframe/MCParticle.cc
Outdated
| return result; | ||
| } | ||
|
|
||
| ROOT::VecOps::RVec<edm4hep::MCParticleData> MCParticle::get_MC_from_indices(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::MCParticleData> in){ |
There was a problem hiding this comment.
I think I would go for somehting like get_subMC
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.