Skip to content

Commit

Permalink
Revert "Flipping x angle boost (#61)"
Browse files Browse the repository at this point in the history
This reverts commit 7653458.
  • Loading branch information
kjvbrt authored Feb 8, 2024
1 parent 5c3826d commit 0fb066d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
66 changes: 36 additions & 30 deletions SimG4Components/src/SimG4CrossingAngleBoost.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#include "SimG4CrossingAngleBoost.h"

// k4SimGeant4
#include "SimG4Common/ParticleInformation.h"
#include "SimG4Common/Units.h"

// Geant4
#include "G4Event.hh"

// CLHEP
#include "CLHEP/Units/PhysicalConstants.h"

// EDM4HEP
#include "edm4hep/MCParticleCollection.h"

// DD4hep
#include "DD4hep/Segmentations.h"


DECLARE_COMPONENT(SimG4CrossingAngleBoost)

Expand Down Expand Up @@ -44,55 +54,52 @@ StatusCode SimG4CrossingAngleBoost::execute() {
debug() << "Input particle collection size: " << inParticles->size()
<< endmsg;

double alpha = -m_alpha;
double alpha = m_alpha;
double gamma = std::sqrt(1 + std::pow(std::tan(alpha), 2));
double betagamma = std::tan(alpha);

for (auto const& inParticle: *inParticles) {
auto outParticle = inParticle.clone();

double e = std::sqrt(std::pow(inParticle.getMomentum().x, 2) +
std::pow(inParticle.getMomentum().y, 2) +
std::pow(inParticle.getMomentum().z, 2) +
std::pow(inParticle.getMass(), 2));

debug() << "---------------------------------------------------" << endmsg;
debug() << "Particle:" << endmsg;
debug() << " - PDG ID: " << inParticle.getPDG() << endmsg;
debug() << " - mass: " << inParticle.getMass() << endmsg;
debug() << " - PDG ID: " << outParticle.getPDG() << endmsg;
debug() << " - time: " << outParticle.getTime() << endmsg;
debug() << " - vertex: " << endmsg;
debug() << " - x: " << inParticle.getVertex().x << endmsg;
debug() << " - y: " << inParticle.getVertex().y << endmsg;
debug() << " - z: " << inParticle.getVertex().z << endmsg;
debug() << " - x: " << outParticle.getVertex().x << endmsg;
debug() << " - y: " << outParticle.getVertex().y << endmsg;
debug() << " - z: " << outParticle.getVertex().z << endmsg;
debug() << " - momentum: " << endmsg;
debug() << " - px: " << inParticle.getMomentum().x << endmsg;
debug() << " - py: " << inParticle.getMomentum().y << endmsg;
debug() << " - pz: " << inParticle.getMomentum().z << endmsg;
debug() << " - energy: " << e << endmsg;

double x = gamma * inParticle.getVertex().x +
betagamma * CLHEP::c_light * inParticle.getTime();
double y = inParticle.getVertex().y;
double z = inParticle.getVertex().z;

float px = betagamma * e + gamma * inParticle.getMomentum().x;
float py = inParticle.getMomentum().y;
float pz = inParticle.getMomentum().z;
debug() << " - px: " << outParticle.getMomentum().x << endmsg;
debug() << " - py: " << outParticle.getMomentum().y << endmsg;
debug() << " - pz: " << outParticle.getMomentum().z << endmsg;

double t = gamma * outParticle.getTime() +
betagamma * outParticle.getVertex().x / CLHEP::c_light;
double x = gamma * outParticle.getVertex().x +
betagamma * CLHEP::c_light * outParticle.getTime();
double y = outParticle.getVertex().y;
double z = outParticle.getVertex().z;

double e2 = pow(outParticle.getMomentum().x, 2) +
pow(outParticle.getMomentum().y, 2) +
pow(outParticle.getMomentum().z, 2) +
pow(outParticle.getMass(), 2);
float px = betagamma * std::sqrt(e2) + gamma * outParticle.getMomentum().x;
float py = outParticle.getMomentum().y;
float pz = outParticle.getMomentum().z;

outParticle.setTime(t);
outParticle.setVertex({x, y, z});
outParticle.setMomentum({px, py, pz});
double eb = std::sqrt(std::pow(outParticle.getMomentum().x, 2) +
std::pow(outParticle.getMomentum().y, 2) +
std::pow(outParticle.getMomentum().z, 2) +
std::pow(outParticle.getMass(), 2));

debug() << "" << endmsg;
debug() << "~~~ BOOST ~~~" << endmsg;
debug() << "" << endmsg;

debug() << "Particle:" << endmsg;
debug() << " - PDG ID: " << outParticle.getPDG() << endmsg;
debug() << " - mass: " << outParticle.getMass() << endmsg;
debug() << " - time: " << outParticle.getTime() << endmsg;
debug() << " - vertex: " << endmsg;
debug() << " - x: " << outParticle.getVertex().x << endmsg;
debug() << " - y: " << outParticle.getVertex().y << endmsg;
Expand All @@ -101,7 +108,6 @@ StatusCode SimG4CrossingAngleBoost::execute() {
debug() << " - px: " << outParticle.getMomentum().x << endmsg;
debug() << " - py: " << outParticle.getMomentum().y << endmsg;
debug() << " - pz: " << outParticle.getMomentum().z << endmsg;
debug() << " - energy: " << eb << endmsg;

outParticles->push_back(outParticle);
}
Expand Down
3 changes: 3 additions & 0 deletions SimG4Components/src/SimG4CrossingAngleBoost.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

// Gaudi
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"

// FCCSW
#include "k4FWCore/DataHandle.h"
#include "SimG4Interface/ISimG4SaveOutputTool.h"
#include "SimG4Interface/ISimG4ParticleSmearTool.h"

// datamodel
namespace edm4hep {
Expand Down

0 comments on commit 0fb066d

Please sign in to comment.