Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Oct 1, 2024
1 parent c2aa199 commit eb6dffe
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 139 deletions.
18 changes: 9 additions & 9 deletions analyzers/dataframe/FCCAnalyses/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
* @brief FCC analyzers collection.
*/
namespace FCCAnalyses {
using Vec_b = ROOT::VecOps::RVec<bool>;
using Vec_d = ROOT::VecOps::RVec<double>;
using Vec_f = ROOT::VecOps::RVec<float>;
using Vec_i = ROOT::VecOps::RVec<int>;
using Vec_ui = ROOT::VecOps::RVec<unsigned int>;
using Vec_b = ROOT::VecOps::RVec<bool>;
using Vec_d = ROOT::VecOps::RVec<double>;
using Vec_f = ROOT::VecOps::RVec<float>;
using Vec_i = ROOT::VecOps::RVec<int>;
using Vec_ui = ROOT::VecOps::RVec<unsigned int>;

using rp = edm4hep::ReconstructedParticleData;
using Vec_rp = ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>;
using Vec_mc = ROOT::VecOps::RVec<edm4hep::MCParticleData>;
using Vec_tlv = ROOT::VecOps::RVec<TLorentzVector>;
using rp = edm4hep::ReconstructedParticleData;
using Vec_rp = ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>;
using Vec_mc = ROOT::VecOps::RVec<edm4hep::MCParticleData>;
using Vec_tlv = ROOT::VecOps::RVec<TLorentzVector>;
} // namespace FCCAnalyses

#endif
32 changes: 19 additions & 13 deletions analyzers/dataframe/FCCAnalyses/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

//Dictionaries for output objects
#pragma link C++ class std::vector<TLorentzVector>+;
#pragma link C++ class ROOT::VecOps::RVec<TLorentzVector>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<TLorentzVector>>+;
#pragma link C++ class ROOT::VecOps::RVec<TVector3>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<TVector3>>+;
#pragma link C++ class ROOT::VecOps::RVec < TLorentzVector> + ;
#pragma link C++ class ROOT::VecOps::RVec < ROOT::VecOps::RVec < \
TLorentzVector>> + \
;
#pragma link C++ class ROOT::VecOps::RVec < TVector3> + ;
#pragma link C++ class ROOT::VecOps::RVec < ROOT::VecOps::RVec < TVector3>> + ;

#pragma link C++ class std::vector<std::string>+;

Expand All @@ -20,24 +22,28 @@
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::VertexData>+;
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>+;
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::CalorimeterHitData>+;
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::ClusterData>+;
#pragma link C++ class ROOT::VecOps::RVec < edm4hep::ClusterData> + ;
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::Vector3d>+;
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::MCParticleData>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>>+;
#pragma link C++ class ROOT::VecOps::RVec < ROOT::VecOps::RVec < \
edm4hep::ReconstructedParticleData>> + \
;

// Vectors
#pragma link C++ class ROOT::VecOps::RVec<std::vector<int>>+;
#pragma link C++ class ROOT::VecOps::RVec<std::vector<float>>+;
#pragma link C++ class ROOT::VecOps::RVec<std::vector<double>>+;
#pragma link C++ class ROOT::VecOps::RVec < std::vector < int>> + ;
#pragma link C++ class ROOT::VecOps::RVec < std::vector < float>> + ;
#pragma link C++ class ROOT::VecOps::RVec < std::vector < double>> + ;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<int>>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<float>>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<double>>+;
#pragma link C++ class std::vector<std::vector<int>>+;
#pragma link C++ class std::vector<std::vector<float>>+;
#pragma link C++ class std::vector<std::vector<double>>+;
#pragma link C++ class std::vector < std::vector < int>> + ;
#pragma link C++ class std::vector < std::vector < float>> + ;
#pragma link C++ class std::vector < std::vector < double>> + ;

#pragma link C++ class ROOT::VecOps::RVec<FCCAnalyses::VertexingUtils::FCCAnalysesVertex>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<FCCAnalyses::VertexingUtils::FCCAnalysesVertex>>+;
#pragma link C++ class ROOT::VecOps::RVec < ROOT::VecOps::RVec < \
FCCAnalyses::VertexingUtils::FCCAnalysesVertex>> + \
;

//to load all other functions
#pragma link C++ function dummyLoader;
Expand Down
4 changes: 0 additions & 4 deletions analyzers/dataframe/src/ReconstructedParticle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> sel_type::operator()(
return result;
}


/// sel_absType
sel_absType::sel_absType(const int type) : m_type(type) {
if (m_type < 0) {
Expand All @@ -60,7 +59,6 @@ ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> sel_absType::operator()(
return result;
}


/// sel_pt
sel_pt::sel_pt(float arg_min_pt) : m_min_pt(arg_min_pt) {};
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> sel_pt::operator() (ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in) {
Expand Down Expand Up @@ -121,7 +119,6 @@ ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> sel_charge::operator() (
return result;
}


resonanceBuilder::resonanceBuilder(float arg_resonance_mass) {m_resonance_mass = arg_resonance_mass;}
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> resonanceBuilder::operator()(ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> legs) {
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> result;
Expand Down Expand Up @@ -251,7 +248,6 @@ ROOT::VecOps::RVec<float> get_pt(ROOT::VecOps::RVec<edm4hep::ReconstructedPartic
return result;
}


ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> merge(ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> x, ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> y) {
//to be keept as ROOT::VecOps::RVec
std::vector<edm4hep::ReconstructedParticleData> result;
Expand Down
2 changes: 0 additions & 2 deletions examples/FCChh/HH_bbtautau/analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
#include "ReconstructedParticle2Track.h"
#include "MCParticle.h"


auto _m = edm4hep::ReconstructedParticleData();


// Reproduce Heppy analysis
int main(int argc, char* argv[]){

Expand Down
60 changes: 30 additions & 30 deletions tests/integration/data_source.cxx
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// ROOT
#include <ROOT/RVec.hxx>
#include <ROOT/RDataFrame.hxx>
#include <ROOT/RLogger.hxx>
#include <ROOT/RVec.hxx>
#include <TCanvas.h>

// PODIO
#include <podio/DataSource.h>

// EDM4hep
#include <edm4hep/ReconstructedParticle.h>
#include <edm4hep/RecoMCParticleLinkCollection.h>
#include <edm4hep/MCParticle.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/RecoMCParticleLinkCollection.h>
#include <edm4hep/ReconstructedParticle.h>
#include <edm4hep/SimCalorimeterHitCollection.h>

edm4hep::MCParticleCollection selElectrons(const edm4hep::MCParticleCollection& inParticles) {
edm4hep::MCParticleCollection
selElectrons(const edm4hep::MCParticleCollection &inParticles) {
edm4hep::MCParticleCollection electrons;
electrons.setSubsetCollection();
for (auto particle: inParticles) {
for (auto particle : inParticles) {
if (particle.getPDG() == 11) {
auto electron = edm4hep::MCParticle(particle);
electrons.push_back(electron);
Expand All @@ -31,24 +32,24 @@ struct selPDG {
selPDG(int pdg, bool chargeConjugateAllowed);
const int m_pdg;
const bool m_chargeConjugateAllowed;
edm4hep::MCParticleCollection operator() (const edm4hep::MCParticleCollection& inParticles);
edm4hep::MCParticleCollection
operator()(const edm4hep::MCParticleCollection &inParticles);
};

selPDG::selPDG(int pdg,
bool chargeConjugateAllowed) : m_pdg(pdg),
m_chargeConjugateAllowed(chargeConjugateAllowed) {};
selPDG::selPDG(int pdg, bool chargeConjugateAllowed)
: m_pdg(pdg), m_chargeConjugateAllowed(chargeConjugateAllowed){};

edm4hep::MCParticleCollection selPDG::operator() (const edm4hep::MCParticleCollection& inParticles) {
edm4hep::MCParticleCollection
selPDG::operator()(const edm4hep::MCParticleCollection &inParticles) {
edm4hep::MCParticleCollection result;
result.setSubsetCollection();
for (auto particle: inParticles) {
for (auto particle : inParticles) {
if (m_chargeConjugateAllowed) {
if (std::abs(particle.getPDG() ) == std::abs(m_pdg)) {
if (std::abs(particle.getPDG()) == std::abs(m_pdg)) {
result.push_back(particle);
}
}
else {
if(particle.getPDG() == m_pdg) {
} else {
if (particle.getPDG() == m_pdg) {
result.push_back(particle);
}
}
Expand All @@ -57,24 +58,26 @@ edm4hep::MCParticleCollection selPDG::operator() (const edm4hep::MCParticleColle
return result;
}

ROOT::VecOps::RVec<float> getPx(const edm4hep::MCParticleCollection& inParticles) {
ROOT::VecOps::RVec<float>
getPx(const edm4hep::MCParticleCollection &inParticles) {
ROOT::VecOps::RVec<float> result;
for (auto particle: inParticles) {
for (auto particle : inParticles) {
result.push_back(particle.getMomentum().x);
}

return result;
}

edm4hep::MCParticleCollection get_stable_particles_from_decay(edm4hep::MCParticle in) {
edm4hep::MCParticleCollection
get_stable_particles_from_decay(edm4hep::MCParticle in) {
edm4hep::MCParticleCollection result;
result.setSubsetCollection();

auto daughters = in.getDaughters();
if (daughters.size() != 0) { // particle is unstable
for (const auto& daughter : daughters) {
if (daughters.size() != 0) { // particle is unstable
for (const auto &daughter : daughters) {
auto stable_daughters = get_stable_particles_from_decay(daughter);
for (const auto& stable_daughter : stable_daughters) {
for (const auto &stable_daughter : stable_daughters) {
result.push_back(stable_daughter);
}
}
Expand All @@ -85,12 +88,12 @@ edm4hep::MCParticleCollection get_stable_particles_from_decay(edm4hep::MCParticl
return result;
}

edm4hep::MCParticle get_mcParticle(
const edm4hep::ReconstructedParticle& recoParticle,
const edm4hep::RecoMCParticleLinkCollection& assocColl) {
edm4hep::MCParticle
get_mcParticle(const edm4hep::ReconstructedParticle &recoParticle,
const edm4hep::RecoMCParticleLinkCollection &assocColl) {
edm4hep::MCParticle no_result;

for (const auto& assoc: assocColl) {
for (const auto &assoc : assocColl) {
if (assoc.getFrom() == recoParticle) {
return assoc.getTo();
}
Expand All @@ -99,12 +102,9 @@ edm4hep::MCParticle get_mcParticle(
return no_result;
}


int main(int argc, const char *argv[]) {
auto verbosity = ROOT::Experimental::RLogScopedVerbosity(
ROOT::Detail::RDF::RDFLogChannel(),
ROOT::Experimental::ELogLevel::kInfo
);
ROOT::Detail::RDF::RDFLogChannel(), ROOT::Experimental::ELogLevel::kInfo);

int nThreads = 1;
if (argc > 1) {
Expand All @@ -126,7 +126,7 @@ int main(int argc, const char *argv[]) {
// rdf.Describe().Print();
// std::cout << std::endl;

std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl;
std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl;

auto rdf2 = rdf.Define("particles_px", getPx, {"Particle"});
// auto rdf3 = rdf2.Define("electrons", selElectrons, {"MCParticles"});
Expand Down
Loading

0 comments on commit eb6dffe

Please sign in to comment.