Skip to content

Commit

Permalink
Merge pull request #247 from EmanuelPerez/UpdatedVertexing
Browse files Browse the repository at this point in the history
Updated vertexing: link to the code that is in Delphes
  • Loading branch information
kjvbrt authored Mar 27, 2023
2 parents 59f33f8 + bc83431 commit d6858e3
Show file tree
Hide file tree
Showing 17 changed files with 1,103 additions and 759 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ find_package(podio)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
find_package(FastJet)

find_package( Delphes REQUIRED )


if(WITH_ACTS)
find_package( Acts COMPONENTS Core )
Expand Down
14 changes: 14 additions & 0 deletions analyzers/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ find_package(Vdt)

message(STATUS "includes-------------------------- dataframe edm4hep: ${EDM4HEP_INCLUDE_DIRS}")
message(STATUS "includes-------------------------- dataframe podio : ${podio_INCLUDE_DIR}")
message(STATUS "includes-------------------------- dataframe delphes: ${DELPHES_INCLUDE_DIR}")
message(STATUS "includes-------------------------- dataframe delphes EXt TrkCov: ${DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR}")
message(STATUS "includes-------------------------- dataframe delphes EXt: ${DELPHES_EXTERNALS_INCLUDE_DIR}")

include_directories(${DELPHES_INCLUDE_DIR}
${DELPHES_EXTERNALS_INCLUDE_DIR}
${DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR}
)


file(GLOB sources src/*.cc)
Expand Down Expand Up @@ -41,8 +49,13 @@ target_include_directories(FCCAnalyses PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/addons>
$<INSTALL_INTERFACE:include>
${VDT_INCLUDE_DIR}
${DELPHES_INCLUDE_DIR}
${DELPHES_EXTERNALS_INCLUDE_DIR}
${DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR}
)

message(STATUS " ====== DELPHES LIBRARY = " ${DELPHES_LIBRARY} )
message(STATUS " ====== DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR = " ${DELPHES_EXTERNALS_TKCOV_INCLUDE_DIR} )


target_link_libraries(FCCAnalyses
Expand All @@ -53,6 +66,7 @@ target_link_libraries(FCCAnalyses
EDM4HEP::edm4hep
EDM4HEP::edm4hepDict
podio::podio
${DELPHES_LIBRARY}
${ADDONS_LIBRARIES}
gfortran # todo: why necessary?
)
Expand Down
3 changes: 3 additions & 0 deletions analyzers/dataframe/FCCAnalyses/ReconstructedParticle2Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
#include <vector>

#include "ROOT/RVec.hxx"
#include "edm4hep/Quantity.h"
#include "edm4hep/ReconstructedParticleData.h"
#include "edm4hep/TrackData.h"
#include "edm4hep/TrackState.h"
#include "edm4hep/TrackerHitData.h"
#include <TVectorD.h>
#include <TVector3.h>
#include <TLorentzVector.h>
Expand Down
35 changes: 34 additions & 1 deletion analyzers/dataframe/FCCAnalyses/SmearObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#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
Expand Down Expand Up @@ -45,6 +46,38 @@ namespace FCCAnalyses
/// 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 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::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
{
Expand Down
17 changes: 12 additions & 5 deletions analyzers/dataframe/FCCAnalyses/VertexFitterSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "edm4hep/VertexData.h"
#include "edm4hep/Vertex.h"

#include "VertexFit.h" // from Delphes - updates Franco, Jul 2022
#include "VertexMore.h"


/** Vertex interface using Franco Bedeshi's code.
This represents a set functions and utilities to perfom vertexing from a list of tracks.
Expand Down Expand Up @@ -52,12 +55,10 @@ namespace VertexFitterSimple{
double bsc_x=0., double bsc_y=0., double bsc_z=0. ) ;

/// Return the tracks that are flagged as coming from the primary vertex
ROOT::VecOps::RVec<edm4hep::TrackState> get_PrimaryTracks( VertexingUtils::FCCAnalysesVertex initialVertex,
ROOT::VecOps::RVec<edm4hep::TrackState> tracks,
ROOT::VecOps::RVec<edm4hep::TrackState> get_PrimaryTracks( ROOT::VecOps::RVec<edm4hep::TrackState> tracks,
bool BeamSpotConstraint,
double bsc_sigmax, double bsc_sigmay, double bsc_sigmaz,
double bsc_x, double bsc_y, double bsc_z,
int ipass = 0 ) ;
double bsc_x, double bsc_y, double bsc_z ) ;


/// Return the tracks that are NOT flagged as coming from the primary vertex
Expand All @@ -69,7 +70,7 @@ namespace VertexFitterSimple{
ROOT::VecOps::RVec<edm4hep::TrackState> primaryTracks ) ;



/*
Double_t FastRv(TVectorD p1, TVectorD p2) ;
TMatrixDSym RegInv3(TMatrixDSym &Smat0) ;
TMatrixD Fill_A(TVectorD par, Double_t phi) ;
Expand All @@ -80,6 +81,12 @@ namespace VertexFitterSimple{
TVectorD XPtoPar(TVector3 x, TVector3 p, Double_t Q);
TVector3 ParToP(TVectorD Par);
TVectorD XPtoPar(TVector3 x, TVector3 p, Double_t Q);
TVector3 ParToP(TVectorD Par);
*/



}//end NS VertexFitterSimple

}//end NS FCCAnalyses
Expand Down
30 changes: 27 additions & 3 deletions analyzers/dataframe/FCCAnalyses/VertexingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@

#include "fastjet/JetDefinition.hh"


/** Vertexing utilities
*/
namespace FCCAnalyses{

namespace VertexingUtils{

/// from delphes: returns track state parameters (delphes convention) for a given vertex (x), momentum (p) and charge
TVectorD XPtoPar(TVector3 x, TVector3 p, Double_t Q);

/// from delphes: returns the momentum corresponding to a given track state
TVector3 ParToP(TVectorD Par);


/// Structure to keep useful track information that is related to the vertex
struct FCCAnalysesVertex{
edm4hep::VertexData vertex;
Expand Down Expand Up @@ -285,14 +293,30 @@ namespace VertexingUtils{
ROOT::VecOps::RVec<ROOT::VecOps::RVec<TVector3>> get_position_SV( ROOT::VecOps::RVec<ROOT::VecOps::RVec<FCCAnalysesVertex>> vertices );
// --- for get_SV_jets --- //

// --- Internal methods needed by the code of Franco B :
float get_trackMom( edm4hep::TrackState & atrack );
TVectorD get_trackParam( edm4hep::TrackState & atrack) ;
TMatrixDSym get_trackCov( edm4hep::TrackState & atrack) ;


// --- Conversion methods between the Delphes and edm4hep conventions

/// convert track parameters, from edm4hep to delphes conventions
TVectorD Edm4hep2Delphes_TrackParam( const TVectorD& param, bool Units_mm );
/// convert track parameters, from delphes to edm4hep conventions
TVectorD Delphes2Edm4hep_TrackParam( const TVectorD& param, bool Units_mm );
/// convert track covariance matrix, from edm4hep to delphes conventions
TMatrixDSym Edm4hep2Delphes_TrackCovMatrix( const std::array<float, 21>& covMatrix, bool Units_mm );
/// convert track covariance matrix, from delphes to edm4hep conventions
std::array<float, 21> Delphes2Edm4hep_TrackCovMatrix( const TMatrixDSym& cov, bool Units_mm ) ;


/// --- Internal methods needed by the code of Franco B:
TVectorD get_trackParam( edm4hep::TrackState & atrack, bool Units_mm = false) ;
TMatrixDSym get_trackCov( edm4hep::TrackState & atrack, bool Units_mm = false) ;

TVectorD ParToACTS(TVectorD Par);
TMatrixDSym CovToACTS(TMatrixDSym Cov,TVectorD Par);



}//end NS VertexingUtils

}//end NS FCCAnalyses
Expand Down
Loading

0 comments on commit d6858e3

Please sign in to comment.