Skip to content

Commit

Permalink
Separated analyzers using Collections into independent headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed May 2, 2024
1 parent 404d931 commit 9b014c2
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 201 deletions.
9 changes: 9 additions & 0 deletions analyzers/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ if(NOT WITH_ACTS)
list(FILTER sources EXCLUDE REGEX "VertexFinderActs.cc")
endif()

if(NOT WITH_SOURCE)
list(FILTER headers EXCLUDE REGEX "AssociationSource.h")
list(FILTER sources EXCLUDE REGEX "AssociationSource.cc")
list(FILTER headers EXCLUDE REGEX "ReconstructedParticleSource.h")
list(FILTER sources EXCLUDE REGEX "ReconstructedParticleSource.cc")
list(FILTER headers EXCLUDE REGEX "TrackSource.h")
list(FILTER sources EXCLUDE REGEX "TrackSource.cc")
endif()

message(STATUS "includes headers ${headers}")
message(STATUS "includes sources ${sources}")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ASSOCIATION_ANALYZERS_H
#define ASSOCIATION_ANALYZERS_H
#ifndef ASSOCIATION_SOURCE_ANALYZERS_H
#define ASSOCIATION_SOURCE_ANALYZERS_H

// EDM4hep
#include "edm4hep/MCRecoParticleAssociationCollection.h"
Expand Down Expand Up @@ -69,4 +69,4 @@ namespace FCCAnalyses :: Association {
};
} /* FCCAnalyses::Association */

#endif /* ASSOCIATION_ANALYZERS_H */
#endif /* ASSOCIATION_SOURCE_ANALYZERS_H */
25 changes: 15 additions & 10 deletions analyzers/dataframe/FCCAnalyses/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@

//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 std::vector<std::string>+;

#pragma link C++ class ROOT::VecOps::RVec<TLorentzVector>+;
#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>>+;
// EDM4hep
#pragma link C++ class ROOT::VecOps::RVec<edm4hep::TrackState>+;
#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<podio::ObjectID>+;
#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<TVector3>+;
#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<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 ROOT::VecOps::RVec<ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>>+;
#pragma link C++ class ROOT::VecOps::RVec<std::vector<float>>+;
#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<TVector3>>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<TLorentzVector>>+;

//to load all other functions
#pragma link C++ function dummyLoader;
Expand Down
57 changes: 1 addition & 56 deletions analyzers/dataframe/FCCAnalyses/ReconstructedParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

// EDM4hep
#include "edm4hep/ReconstructedParticleData.h"
#include "edm4hep/ReconstructedParticleCollection.h"
#include "edm4hep/MCRecoParticleAssociationCollection.h"
#include "edm4hep/ParticleIDData.h"

namespace FCCAnalyses{
Expand Down Expand Up @@ -103,60 +101,12 @@ namespace ReconstructedParticle{
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> operator() (ROOT::VecOps::RVec<bool> tags, ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in);
};


/**
* \brief Analyzer to select reconstructed particles associated with a
* specified PDG ID.
*
* \param pdgID Desired PDG ID.
* \param chargeConjugateAllowed Whether to allow also charge conjugate
* PDG ID. Default value false --- charge conjugate not allowed.
*/
struct selPDG {
selPDG(const int pdgID, const bool chargeConjugateAllowed = false);
const int m_pdg;
const bool m_chargeConjugateAllowed;
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::MCRecoParticleAssociationCollection& inAssocColl);
};


/**
* \brief Analyzer to select specified number of reconstructed particles
*
* \param size Desired number of particles
*/
struct selUpTo {
selUpTo(const size_t size);
const size_t m_size;
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::ReconstructedParticleCollection& inColl);
};


/**
* \brief Analyzer to select reconstructed particles by generator status
*
* \param status Desired generator status of the particles
*/
struct sel_genStatus {
sel_genStatus(const int status);
const int m_status;
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::MCRecoParticleAssociationCollection& inAssocColl);
};


/// return reconstructed particles
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> get(ROOT::VecOps::RVec<int> index, ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in);

/// return the transverse momenta of the input ReconstructedParticles
ROOT::VecOps::RVec<float> get_pt(ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in);

/// return the transverse momenta of the input ReconstructedParticles
ROOT::VecOps::RVec<float>
getPt(const edm4hep::ReconstructedParticleCollection& inParticles);

/// return the momenta of the input ReconstructedParticles
ROOT::VecOps::RVec<float> get_p(ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in);

Expand Down Expand Up @@ -202,7 +152,7 @@ namespace ReconstructedParticle{
/// return the TlorentzVector of the one input ReconstructedParticle
TLorentzVector get_tlv(edm4hep::ReconstructedParticleData in);

/// return visible 4-momentum vector
/// return visible 4-momentum vector
TLorentzVector get_P4vis(ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> in);

/// concatenate both input vectors and return the resulting vector
Expand All @@ -219,11 +169,6 @@ namespace ReconstructedParticle{

/// get number of b-jets
int getJet_ntags(ROOT::VecOps::RVec<bool> in);

/// reorder input ReconstructedParticles by pT
edm4hep::ReconstructedParticleCollection
sortByPt(const edm4hep::ReconstructedParticleCollection& inParticles);

}//end NS ReconstructedParticle

}//end NS FCCAnalyses
Expand Down
126 changes: 126 additions & 0 deletions analyzers/dataframe/FCCAnalyses/ReconstructedParticleSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#ifndef RECONSTRUCTED_PARTICLE_SOURCE_ANALYZERS_H
#define RECONSTRUCTED_PARTICLE_SOURCE_ANALYZERS_H

// ROOT
#include "ROOT/RVec.hxx"

// EDM4hep
#include "edm4hep/ReconstructedParticleCollection.h"
#include "edm4hep/MCRecoParticleAssociationCollection.h"

namespace FCCAnalyses :: ReconstructedParticle {
/**
* \brief Analyzer to select reconstructed particles associated with MC
* particle of the specified PDG ID.
*/
struct selPDG {
/**
* \brief Constructor.
*
* \param[in] pdgID Desired value of the PDG ID.
*/
explicit selPDG(const int pdgID);
const int m_pdg;
/**
* \brief Operator over the input particle collection.
*
* \param[in] inAssocColl Input collection of the MC-reco associations.
* \param[out] result Collection of the reconstructed particles associated
* with the MC particle with the desired PDG ID.
*/
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::MCRecoParticleAssociationCollection& inAssocColl);
};


/**
* \brief Analyzer to select reconstructed particles associated with MC
* particle with the specified absolute value of the PDG ID.
*/
struct selAbsPDG {
/**
* \brief Constructor.
*
* \param[in] pdgID Desired absolute value of the PDG ID.
*/
explicit selAbsPDG(const int pdgID);
const int m_absPdg;
/**
* \brief Operator over input particle associations collection.
*
* \param[in] inAssocColl Input collection of the MC-reco associations.
* \param[out] result Collection of the reconstructed particles associated
* with the MC particle with the absolute value of the
* desired PDG ID.
*/
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::MCRecoParticleAssociationCollection& inAssocColl);
};


/**
* \brief Analyzer to select specified number of reconstructed particles.
*/
struct selUpTo {
/**
* \brief Constructor.
*
* \param[in] size Desired number of reconstructed particles.
*/
explicit selUpTo(const size_t size);
const size_t m_size;
/**
* \brief Operator over input particle associations collection.
*
* \param[out] inColl Input collection of reconstructed particles.
* \param[out] result Output collection of reconstructed particles.
*/
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::ReconstructedParticleCollection& inColl);
};


/**
* \brief Analyzer to select reconstructed particles associated with the MC
* particle of the desired generator status.
*/
struct selGenStatus {
/**
* \brief Constructor.
*
* \param[in] status Desired generator status of the MC particle.
*/
explicit selGenStatus(const int status);
const int m_status;
/**
* \brief Operator over input particle associations collection.
*
* \param[in] inColl Input collection of the MC-reco particle associations.
* \param[out] result Output collection of reconstructed particles.
*/
edm4hep::ReconstructedParticleCollection operator() (
const edm4hep::MCRecoParticleAssociationCollection& inAssocColl);
};


/**
* \brief Get transverse momenta (pT) of the input particles.
*
* \param[in] inParticles Input particles.
* \param[out] result Vector of particle pTs.
*/
ROOT::VecOps::RVec<double>
getPt(const edm4hep::ReconstructedParticleCollection& inParticles);


/**
* \brief Sort input particles by pT.
*
* \param[in] inParticles Input particles.
* \param[out] result Sorted collection of particles.
*/
edm4hep::ReconstructedParticleCollection
sortByPt(const edm4hep::ReconstructedParticleCollection& inParticles);
} /* FCCAnalyses :: ReconstructedParticle */

#endif /* RECONSTRUCTED_PARTICLE_SOURCE_ANALYZERS_H */
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef FCCANALYSES_TRACK_ANALYZERS_H
#define FCCANALYSES_TRACK_ANALYZERS_H
#ifndef TRACK_SOURCE_ANALYZERS_H
#define TRACK_SOURCE_ANALYZERS_H

// std
#include <cstddef>


// ROOT
#include "ROOT/RVec.hxx"
Expand All @@ -19,7 +23,7 @@ namespace FCCAnalyses {
* PDG ID. Default value false --- charge conjugate not allowed.
*/
struct selPDG {
selPDG(const int pdgID, const bool chargeConjugateAllowed = false);
explicit selPDG(const int pdgID, const bool chargeConjugateAllowed = false);
const int m_pdg;
const bool m_chargeConjugateAllowed;
edm4hep::TrackCollection operator() (
Expand All @@ -42,4 +46,4 @@ namespace FCCAnalyses {
}
}

#endif /* FCCANALYSES_TRACK_ANALYZERS_H */
#endif /* TRACK_SOURCE_ANALYZERS_H */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "FCCAnalyses/Association.h"
#include "FCCAnalyses/AssociationSource.h"

// std
#include <cstdlib>
Expand Down
Loading

0 comments on commit 9b014c2

Please sign in to comment.