Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
clementhelsens authored Nov 8, 2022
2 parents f70eea2 + 91025ad commit b0f780a
Show file tree
Hide file tree
Showing 21 changed files with 3,412 additions and 34 deletions.
9 changes: 7 additions & 2 deletions addons/ONNXRuntime/src/WeaverInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ rv::RVec<float> WeaverInterface::run(const rv::RVec<ConstituentVars>& constituen
ConstituentVars jc;
for (size_t j = 0; j < params.var_names.size(); ++j) { // transform and add the proper amount of padding
const auto& var_name = params.var_names.at(j);
if (std::find(variables_names_.begin(), variables_names_.end(), "pfcand_mask") == variables_names_.end())
jc = ConstituentVars(constituents.at(0).size(), 1.f);
//if (std::find(variables_names_.begin(), variables_names_.end(), "pfcand_mask") == variables_names_.end())
// jc = ConstituentVars(constituents.at(0).size(), 1.f);

if (var_name.find("_mask") != std::string::npos) {
jc = ConstituentVars(constituents.at(0).size(), 1.f);
}

else
jc = constituents.at(variablePos(var_name));
const auto& var_info = params.info(var_name);
Expand Down
12 changes: 12 additions & 0 deletions analyzers/dataframe/FCCAnalyses/CaloNtupleizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ namespace CaloNtupleizer{

void loadGeometry(std::string xmlGeometryPath, std::string readoutName);

/// select layers
struct sel_layers {
public:
sel_layers(int arg_min=0, int arg_max=10);
ROOT::VecOps::RVec<edm4hep::CalorimeterHitData> operator()(const ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>& in);

private:
int _min;//> min layer
int _max;//> max layer
};


// calo hits (single cells)
ROOT::VecOps::RVec<float> getCaloHit_x (const ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>& in);
ROOT::VecOps::RVec<float> getCaloHit_y (const ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>& in);
Expand Down
240 changes: 240 additions & 0 deletions analyzers/dataframe/FCCAnalyses/JetConstituentsUtils.h

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions analyzers/dataframe/FCCAnalyses/ReconstructedParticle2Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,48 @@
#include "ROOT/RVec.hxx"
#include "edm4hep/ReconstructedParticleData.h"
#include "edm4hep/TrackState.h"
#include <TVectorD.h>
#include <TVector3.h>
#include <TMath.h>
#include <iostream>

namespace FCCAnalyses{

namespace ReconstructedParticle2Track{

//compute the magnetic field Bz
ROOT::VecOps::RVec<float> getRP2TRK_Bz(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& rps,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks); //here computed for all particles passed

float Bz(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& rps,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks); //here only computed for the first charged particle encountered


ROOT::VecOps::RVec<float> XPtoPar_dxy(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& in,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks,
const TVector3& x,
const float& Bz);

ROOT::VecOps::RVec<float> XPtoPar_dz(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& in,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks,
const TVector3& V,
const float& Bz);

ROOT::VecOps::RVec<float> XPtoPar_phi(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& in,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks,
const TVector3& V,
const float& Bz);

ROOT::VecOps::RVec<float> XPtoPar_C(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& in,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks,
const TVector3& V,
const float& Bz);

ROOT::VecOps::RVec<float> XPtoPar_ct(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>& in,
const ROOT::VecOps::RVec<edm4hep::TrackState>& tracks,
const TVector3& V,
const float& Bz);

/// Return the D0 of a track to a reconstructed particle
ROOT::VecOps::RVec<float> getRP2TRK_D0 (ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in,
ROOT::VecOps::RVec<edm4hep::TrackState> tracks);
Expand Down
2 changes: 1 addition & 1 deletion analyzers/dataframe/FCCAnalyses/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FCCAnalyses {
namespace Utils {

template<typename T> inline auto getsize( T& vec){ return vec.size();};

template<typename T> inline ROOT::VecOps::RVec<ROOT::VecOps::RVec<T> > as_vector(const ROOT::VecOps::RVec<T>& in){return ROOT::VecOps::RVec<ROOT::VecOps::RVec<T> >(1, in);};
}
}

Expand Down
27 changes: 27 additions & 0 deletions analyzers/dataframe/FCCAnalyses/WeaverUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef FCCAnalyses_WEAVERUTILS_h
#define FCCAnalyses_WEAVERUTILS_h

#include <ROOT/RVec.hxx>

namespace FCCAnalyses {
namespace WeaverUtils {

/// Compute all weights given a collection of input variables
/// \note This helper should not be used directly in RDataFrame examples
ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>> compute_weights(
const ROOT::VecOps::RVec<ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>>>&);

/// Setup the ONNXRuntime instance using Weaver-provided parameters
void setup_weaver(const std::string&, const std::string&, const ROOT::VecOps::RVec<std::string>&);

/// Compute all weights given an unspecified collection of input variables
template <typename... Args>
ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>> get_weights(Args&&... args) {
return compute_weights(std::vector<ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>>>{std::forward<Args>(args)...});
}
/// Get one specific weight previously computed
ROOT::VecOps::RVec<float> get_weight(const ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>>&, int);
} // namespace WeaverUtils
} // namespace FCCAnalyses

#endif
12 changes: 12 additions & 0 deletions analyzers/dataframe/src/CaloNtupleizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ void loadGeometry(std::string xmlGeometryPath, std::string readoutName){
}


sel_layers::sel_layers(int arg_min, int arg_max) : _min(arg_min), _max(arg_max) {};
ROOT::VecOps::RVec<edm4hep::CalorimeterHitData> sel_layers::operator() (const ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>& in) {

ROOT::VecOps::RVec<edm4hep::CalorimeterHitData> res;
for (auto & p: in){
dd4hep::DDSegmentation::CellID cellId = p.cellID;
int layer = m_decoder->get(cellId, "layer");
if (layer>_min && layer<_max)res.emplace_back(p);
}
return res;
}

// calo hit
ROOT::VecOps::RVec<float> getCaloHit_x (const ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>& in){
ROOT::VecOps::RVec<float> result;
Expand Down
Loading

0 comments on commit b0f780a

Please sign in to comment.