Skip to content
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ To apply formatting to a file:
```
clang-format -i -style=file /path/to/file.cpp
```
Note that this will reformat the entire file.
If you are preparing a PR, you can instead use
```
git clang-format --style=file $(git merge-base upstream/master HEAD)
```
to only format the lines you changed (avoids bloating your PR - unless you wish to clean up the whole file 😉).
39 changes: 28 additions & 11 deletions analyzers/dataframe/FCCAnalyses/MCParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#define MCPARTICLE_ANALYZERS_H

#include <cmath>
#include <functional>
#include <vector>

#include "FCCAnalyses/Utils.h"
#include "ROOT/RVec.hxx"
#include "TLorentzVector.h"
#include "edm4hep/MCParticleData.h"
Expand All @@ -30,26 +32,32 @@ namespace MCParticle{
bool operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
};

/// Template implementation for basic selection function on MC particle data.
using MCParticleSelection = Utils::selByPredicate<edm4hep::MCParticleData>;

/// select MCParticles with transverse momentum greater than a minimum value [GeV]
struct sel_pt {
struct sel_pt : MCParticleSelection {
sel_pt(float arg_min_pt);
float m_min_pt = 20; //> transverse momentum threshold [GeV]
ROOT::VecOps::RVec<edm4hep::MCParticleData> operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
};

/// select MCParticles with absolute pseudorapidity less than a max value
struct sel_eta : MCParticleSelection {
sel_eta(float arg_max_eta);
};

/// select MCParticles with their status
struct sel_genStatus {
struct sel_genStatus : MCParticleSelection {
sel_genStatus(int arg_status);
int m_status = 1; //> Generator status
ROOT::VecOps::RVec<edm4hep::MCParticleData> operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
};

/// select MCParticles with their PDG id
struct sel_pdgID {
struct sel_pdgID : MCParticleSelection {
sel_pdgID(int arg_pdg, bool arg_chargeconjugate);
int m_pdg = 13;
bool m_chargeconjugate = true;
ROOT::VecOps::RVec<edm4hep::MCParticleData> operator() (ROOT::VecOps::RVec<edm4hep::MCParticleData> in);
};

/// select MCParticles with a non-zero charge
struct sel_charged : MCParticleSelection {
sel_charged();
};

/// get MC history tree for a given MCParticle index
Expand Down Expand Up @@ -116,7 +124,6 @@ namespace MCParticle{
ROOT::VecOps::RVec<edm4hep::MCParticleData> in ,
ROOT::VecOps::RVec<int> ind);


/// return the parent index of a given list of MC particles
ROOT::VecOps::RVec<int> get_parentid(ROOT::VecOps::RVec<int> mcind, ROOT::VecOps::RVec<edm4hep::MCParticleData> mc, ROOT::VecOps::RVec<int> parents);

Expand Down Expand Up @@ -210,6 +217,16 @@ namespace MCParticle{
/// return the list of stable particles from the decay of a mother particle, looking at the full decay chain recursively. i is the mother index in the Particle block
std::vector<int> get_list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) ;

/// return the list of stable particles from the decays of a mother particle,
/// looking at the full decay chain recursively. i is the list of mother
/// indices to process in the Particle block. Will return a vector of vectors
/// - each vector is the set of children for one of the mothers in the input
/// vector
ROOT::VecOps::RVec<ROOT::VecOps::RVec<int>>
get_lists_of_stable_particles_from_decays(
ROOT::VecOps::RVec<int> i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in,
ROOT::VecOps::RVec<int> ind);

/// return the list of particles from the decay of a mother particle. i is the mother index in the Particle block.
std::vector<int> get_list_of_particles_from_decay( int i,
ROOT::VecOps::RVec<edm4hep::MCParticleData> in,
Expand Down
44 changes: 38 additions & 6 deletions analyzers/dataframe/FCCAnalyses/ReconstructedParticle2MC.h
Comment thread
kjvbrt marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,44 @@ namespace ReconstructedParticle2MC{
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> reco,
ROOT::VecOps::RVec<edm4hep::MCParticleData> mc) ;

/// select ReconstructedParticles matched to the (stable) MC particles whose indices are passed in a list
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> selRP_matched_to_list( ROOT::VecOps::RVec<int> mcParticles_indices,
ROOT::VecOps::RVec<int> recind,
ROOT::VecOps::RVec<int> mcind,
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> reco,
ROOT::VecOps::RVec<edm4hep::MCParticleData> mc) ;
/// select ReconstructedParticles matched to the MC particles whose indices
/// are passed in a list
/// @param mcParticles_indices indices of the MC particles to look up
/// @param recind: reco index component of the MCRecoAssociations
/// @param mcind: mc index component of the MCRecoAssociations
/// @param reco: full reco particle list (ReconstructedParticles)
/// @param mc: full mc particle list (Particles)
/// @param require_stable: if set to true, will only match stable particles.
/// @return List of ReconstructedParticle candidates with length corresponding
/// to the number of *stable* MC particles in the mcParticles_indices vector.
/// In presence of unstable particles, no 1:1 correspondence. For
/// non-reconstructed stable MC particles, a dummy particle will be inserted.
/// If 1:1 length correspondence is required, set require_stable to false.
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> selRP_matched_to_list(
const ROOT::VecOps::RVec<int> &mcParticles_indices,
const ROOT::VecOps::RVec<int> &recind,
const ROOT::VecOps::RVec<int> &mcind,
const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> &reco,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mc,
bool require_stable = true);
/// select indices of ReconstructedParticles matched to the MC particles whose
/// indices are passed in a list
/// @param mcParticles_indices indices of the MC particles to look up
/// @param recind: reco index component of the MCRecoAssociations
/// @param mcind: mc index component of the MCRecoAssociations
/// @param mc: full mc particle list (Particles)
/// @param require_stable: if set to true, will only match stable particles.
/// @return List of ReconstructedParticle candidates with length corresponding
/// to the number of *stable* MC particles in the mcParticles_indices vector.
/// In presence of unstable particles, no 1:1 correspondence. For
/// non-reconstructed stable MC particles, a "-1" entry will be inserted. If
/// 1:1 length correspondence is required, set require_stable to false.
ROOT::VecOps::RVec<int> selRP_indices_matched_to_list(
const ROOT::VecOps::RVec<int> &mcParticles_indices,
const ROOT::VecOps::RVec<int> &recind,
const ROOT::VecOps::RVec<int> &mcind,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mc,
bool require_stable = true);

/// return the index of the MC particle that is associated to a given track (via the track-reco association)
int getTrack2MC_index ( int track_index,
Expand Down
Loading