Skip to content

Commit

Permalink
Merge pull request #256 from tmadlener/rm-explicit-types
Browse files Browse the repository at this point in the history
Remove explicit mentionings of MCParticle momentum type
  • Loading branch information
mirguest authored Dec 11, 2023
2 parents cc6174b + d54176d commit c508332
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Analysis/DumpEvent/src/DumpMCParticleAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ StatusCode DumpMCParticleAlg::execute(){
m_charge[m_nParticles] = particle.getCharge();
m_time[m_nParticles] = particle.getTime();
m_mass[m_nParticles] = particle.getMass();
const edm4hep::Vector3d& vertex = particle.getVertex();
const auto& vertex = particle.getVertex();
m_vx[m_nParticles] = vertex.x;
m_vy[m_nParticles] = vertex.y;
m_vz[m_nParticles] = vertex.z;
const edm4hep::Vector3f& momentum = particle.getMomentum();
const auto& momentum = particle.getMomentum();
m_px[m_nParticles] = momentum.x;
m_py[m_nParticles] = momentum.y;
m_pz[m_nParticles] = momentum.z;
Expand Down
4 changes: 2 additions & 2 deletions Digitisers/SimpleDigi/src/TPCDigiAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ StatusCode TPCDigiAlg::execute()
if(mcp.isAvailable()){

// get the pt of the MCParticle, this will used later to uses nominal smearing for low momentum rubish
const edm4hep::Vector3f momentumMC= mcp.getMomentum() ;
const auto& momentumMC= mcp.getMomentum() ;
ptSqrdMC = momentumMC[0]*momentumMC[0]+momentumMC[1]*momentumMC[1] ;

debug() << " mcp id = " << mcp.id()
Expand Down Expand Up @@ -1057,7 +1057,7 @@ StatusCode TPCDigiAlg::execute()
auto mcp = (_tpcHitMap[ seed_hit ]).getMCParticle() ;
if(mcp.isAvailable()) {
++_NLostPhysicsTPCHits;
const edm4hep::Vector3f mom= mcp.getMomentum() ;
const auto& mom= mcp.getMomentum() ;
double ptSQRD = mom[0]*mom[0]+mom[1]*mom[1] ;
if( ptSQRD > (0.2*0.2) ) ++_NLostPhysicsAbove02GeVPtTPCHits ;
if( ptSQRD > 1.0 ) ++_NLostPhysicsAbove1GeVPtTPCHits ;
Expand Down
18 changes: 5 additions & 13 deletions Reconstruction/RecGenfitAlg/src/GenfitTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

//cpp
#include <cfloat>
#include <type_traits>

const int GenfitTrack::s_PDG[2][5]
={{-11,-13,211,321,2212},{11,13,-211,-321,-2212}};
Expand Down Expand Up @@ -123,16 +124,17 @@ bool GenfitTrack::createGenfitTrackFromMCParticle(int pidType,
const edm4hep::MCParticle& mcParticle, double eventStartTime)
{
///get track parameters from McParticle
edm4hep::Vector3d mcPocaPos = mcParticle.getVertex();//mm
edm4hep::Vector3f mcPocaMom = mcParticle.getMomentum();//GeV
const auto& mcPocaPos = mcParticle.getVertex();//mm
const auto& mcPocaMom = mcParticle.getMomentum();//GeV
if(m_debug>=2)std::cout<<"seedPos poca "<< mcPocaPos.x
<<" "<<mcPocaPos.y<<" "<<mcPocaPos.z<<" mm "<<std::endl;
if(m_debug>=2)std::cout<<"seedMom poca "<< mcPocaMom.x
<<" "<<mcPocaMom.y<<" "<<mcPocaMom.z<<" GeV "<<std::endl;

///Pivot to first layer to avoid correction of beam pipe
edm4hep::Vector3d firstLayerPos(1e9,1e9,1e9);
edm4hep::Vector3f firstLayerMom(1e9,1e9,1e9);
using MomentumT = std::remove_cv_t<std::remove_reference_t<decltype(mcPocaMom)>>;
MomentumT firstLayerMom{1e9,1e9,1e9};
pivotToFirstLayer(mcPocaPos,mcPocaMom,firstLayerPos,firstLayerMom);

//TODO convert unit
Expand Down Expand Up @@ -827,13 +829,3 @@ bool GenfitTrack::storeTrack(edm4hep::MutableReconstructedParticle& recParticle,

return true;
}

void GenfitTrack::pivotToFirstLayer(edm4hep::Vector3d& pos,
edm4hep::Vector3f& mom, edm4hep::Vector3d& firstPos,
edm4hep::Vector3f& firstMom)
{
//FIXME, TODO
firstPos=pos;
firstMom=mom;
}

9 changes: 7 additions & 2 deletions Reconstruction/RecGenfitAlg/src/GenfitTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ class GenfitTrack {
int ndfCut=1e9, double chi2Cut=1.e9);

///A tool to convert track to the first layer of DC
void pivotToFirstLayer(edm4hep::Vector3d& pos,edm4hep::Vector3f& mom,
edm4hep::Vector3d& firstPos, edm4hep::Vector3f& firstMom);
template<typename MomT>
void pivotToFirstLayer(const edm4hep::Vector3d& pos, const MomT& mom,
edm4hep::Vector3d& firstPos, MomT& firstMom) {
//FIXME, TODO
firstPos=pos;
firstMom=mom;
}

/// Copy a track to event
//void CopyATrack()const;
Expand Down
2 changes: 1 addition & 1 deletion Reconstruction/RecGenfitAlg/src/RecGenfitAlgDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void RecGenfitAlgDC::debugEvent()
m_mcIndex=iHit;
int iMcParticle=0;
for(auto mcParticle : *mcParticleCol){
edm4hep::Vector3f mcPocaMom = mcParticle.getMomentum();//GeV
const auto& mcPocaMom = mcParticle.getMomentum();//GeV
float px=mcPocaMom.x;
float py=mcPocaMom.y;
float pz=mcPocaMom.z;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ StatusCode TruthTrackerAlg::execute()
mcParticleVertexSmeared.z=
CLHEP::RandGauss::shoot(mcParticleVertex.z,m_resVertexZ);
///Momentum
edm4hep::Vector3f mcParticleMom=mcParticle.getMomentum();//GeV
const auto& mcParticleMom=mcParticle.getMomentum();//GeV
double mcParticlePt=sqrt(mcParticleMom.x*mcParticleMom.x+
mcParticleMom.y*mcParticleMom.y);
//double mcParticlePtSmeared=
Expand Down
2 changes: 1 addition & 1 deletion Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) {
particle_def = particletbl->FindParticle(pdgcode);
}
// momentum
const edm4hep::Vector3f& momentum = p.getMomentum();
const auto& momentum = p.getMomentum();
G4PrimaryParticle* g4prim = new G4PrimaryParticle(particle_def,
momentum.x*CLHEP::GeV,
momentum.y*CLHEP::GeV,
Expand Down

0 comments on commit c508332

Please sign in to comment.