Skip to content

Commit

Permalink
Merge pull request #268 from selvaggi/master
Browse files Browse the repository at this point in the history
Improvements and bug fixes in dNdx, time and energy smearing
  • Loading branch information
kjvbrt authored Apr 4, 2023
2 parents dfe033e + d0ccef1 commit 1a18ecb
Show file tree
Hide file tree
Showing 4 changed files with 724 additions and 633 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,11 @@ obtain a suitable version of it from CVMFS thanks to LCG:
```
source /cvmfs/sft.cern.ch/lcg/contrib/clang/14.0.6/x86_64-centos7/setup.sh
```

Then to apply formatting to a given file:
```
clang-format -i -style=file /path/to/file.cpp
```

Another way to obtain a recent version of `clang-format` is through downloading
[Key4hep Spack instance](https://key4hep.github.io/key4hep-doc/spack-build-instructions-for-librarians/spack-setup.html#downloading-a-spack-instance).
154 changes: 78 additions & 76 deletions analyzers/dataframe/FCCAnalyses/SmearObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,96 +4,98 @@
#include <cmath>
#include <vector>

#include "FCCAnalyses/ReconstructedParticle2Track.h"
#include "ROOT/RVec.hxx"
#include "TLorentzVector.h"
#include "TMatrixDSym.h"
#include "TRandom.h"
#include <TMath.h>
#include "ROOT/RVec.hxx"
#include "edm4hep/MCParticleData.h"
#include "edm4hep/TrackData.h"
#include "edm4hep/TrackState.h"
#include "FCCAnalyses/ReconstructedParticle2Track.h"

namespace FCCAnalyses
{
#include <TMath.h>

namespace SmearObjects
{
namespace FCCAnalyses {

/// for a given MC particle, returns a "track state", i.e. a vector of 5 helix parameters, in Delphes convention
TVectorD TrackParamFromMC_DelphesConv(edm4hep::MCParticleData aMCParticle);
namespace SmearObjects {

/// generates new track states, by rescaling the covariance matrix of the tracks
struct SmearedTracks
{
bool m_debug;
TRandom m_random;
float m_smear_parameters[5];
SmearedTracks(float smear_d0, float smear_phi, float smear_omega, float smear_z0, float smear_tlambda, bool debug);
ROOT::VecOps::RVec<edm4hep::TrackState> operator()(
const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> &allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackState> &alltracks,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};
/// for a given MC particle, returns a "track state", i.e. a vector of 5 helix
/// parameters, in Delphes convention
TVectorD TrackParamFromMC_DelphesConv(edm4hep::MCParticleData aMCParticle);

/// used to validate the method above. Stores the "MC-truth track states", in a collection that runs parallel to the full collection of tracks.
ROOT::VecOps::RVec<edm4hep::TrackState> mcTrackParameters(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> &allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackState> &alltracks,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
/// generates new track states, by rescaling the covariance matrix of the tracks
struct SmearedTracks {
bool m_debug;
TRandom m_random;
float m_smear_parameters[5];
SmearedTracks(float smear_d0, float smear_phi, float smear_omega,
float smear_z0, float smear_tlambda, bool debug);
ROOT::VecOps::RVec<edm4hep::TrackState>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackState> &alltracks,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};

/// generates random values for a vector, given the covariance matrix of its components, using a Choleski decomposition. Code from Franco Bedeschi
TVectorD CovSmear(TVectorD x, TMatrixDSym C, TRandom *ran, bool debug);
/// used to validate the method above. Stores the "MC-truth track states", in a
/// collection that runs parallel to the full collection of tracks.
ROOT::VecOps::RVec<edm4hep::TrackState> mcTrackParameters(
const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackState> &alltracks,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);

/// generates new track dNdx, by rescaling the poisson error of the cluster
/// count
struct SmearedTracksdNdx {
bool m_debug;
TRandom m_random;
float m_scale;
SmearedTracksdNdx(float m_scale, bool debug);
ROOT::VecOps::RVec<edm4hep::Quantity>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::Quantity> &dNdx,
const ROOT::VecOps::RVec<float> &length,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};
/// generates random values for a vector, given the covariance matrix of its
/// components, using a Choleski decomposition. Code from Franco Bedeschi
TVectorD CovSmear(TVectorD x, TMatrixDSym C, TRandom *ran, bool debug);

/// generates new tracker hits, by rescaling the timing measurement
struct SmearedTracksTOF {
bool m_debug;
TRandom m_random;
float m_scale;
SmearedTracksTOF(float m_scale, bool debug);
ROOT::VecOps::RVec<edm4hep::TrackerHitData>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackerHitData> &trackerhits,
const ROOT::VecOps::RVec<float> &length,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};
/// generates new track dNdx, by rescaling the poisson error of the cluster
/// count
struct SmearedTracksdNdx {
bool m_debug;
TRandom m_random;
float m_scale;
SmearedTracksdNdx(float m_scale, bool debug);
ROOT::VecOps::RVec<edm4hep::Quantity>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::Quantity> &dNdx,
const ROOT::VecOps::RVec<float> &length,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};

/// generates new tracker hits, by rescaling the timing measurement
struct SmearedTracksTOF {
bool m_debug;
TRandom m_random;
float m_scale;
SmearedTracksTOF(float m_scale, bool debug);
ROOT::VecOps::RVec<edm4hep::TrackerHitData>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<edm4hep::TrackData> &trackdata,
const ROOT::VecOps::RVec<edm4hep::TrackerHitData> &trackerhits,
const ROOT::VecOps::RVec<float> &length,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};

/// generates new reco particles, smeared by given parameters
struct SmearedReconstructedParticle
{
bool m_debug;
float m_scale;
int m_type;
int m_mode;
SmearedReconstructedParticle(float scale, int type, int mode, bool debug);
/// generates new reco particles, smeared by given parameters
struct SmearedReconstructedParticle {
bool m_debug;
float m_scale;
int m_type;
int m_mode;
SmearedReconstructedParticle(float scale, int type, int mode, bool debug);

ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> operator()(
const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> &allRecoParticles,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
operator()(const ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData>
&allRecoParticles,
const ROOT::VecOps::RVec<int> &RP2MC_indices,
const ROOT::VecOps::RVec<edm4hep::MCParticleData> &mcParticles);
};

}
}
} // namespace SmearObjects
} // namespace FCCAnalyses

#endif
Loading

0 comments on commit 1a18ecb

Please sign in to comment.