Skip to content

Commit

Permalink
implement the rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mirguest committed Oct 13, 2021
1 parent fe3b8e8 commit cb27f4f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
30 changes: 26 additions & 4 deletions Generator/src/GtBeamBackgroundTool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "GtBeamBackgroundTool.h"
#include "IBeamBackgroundFileParser.h"
#include "BeamBackgroundFileParserV0.h"

#include "TVector3.h" // for rotation
DECLARE_COMPONENT(GtBeamBackgroundTool)

StatusCode GtBeamBackgroundTool::initialize() {
Expand All @@ -9,8 +11,17 @@ StatusCode GtBeamBackgroundTool::initialize() {
// create the instances of the background parsers

for (auto& [label, inputfn]: m_inputmaps) {

m_beaminputs[label] = std::make_shared<BeamBackgroundFileParserV0>(inputfn, 11, 125.);
double beamE = 120.;
auto itBeamE = m_Ebeammaps.find(label);
if (itBeamE != m_Ebeammaps.end()) {
beamE = itBeamE->second;
}
info() << "Initializing beam background ... "
<< label << " "
<< beamE << " "
<< inputfn
<< endmsg;
m_beaminputs[label] = std::make_shared<BeamBackgroundFileParserV0>(inputfn, 11, beamE);
}

// check the size
Expand Down Expand Up @@ -43,6 +54,17 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) {
// fill the value
float charge = beamdata.pdgid == 11 ? -1: 1;

TVector3 pos(beamdata.x,beamdata.y,beamdata.z);
TVector3 mom(beamdata.px,beamdata.py,beamdata.pz);

auto itrot = m_rotYmaps.find(label);
if (itrot != m_rotYmaps.end() ) {
info() << "Apply rotation along Y " << itrot->second << endmsg;

pos.RotateY(itrot->second);
mom.RotateY(itrot->second);
}

// create the MC particle
edm4hep::MCParticle mcp = event.m_mc_vec.create();
mcp.setPDG(beamdata.pdgid);
Expand All @@ -51,8 +73,8 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) {
mcp.setCharge(static_cast<float>(charge));
mcp.setTime(beamdata.t);
mcp.setMass(beamdata.mass);
mcp.setVertex(edm4hep::Vector3d(beamdata.x,beamdata.y,beamdata.z));
mcp.setMomentum(edm4hep::Vector3f(beamdata.px,beamdata.py,beamdata.pz));
mcp.setVertex(edm4hep::Vector3d(pos.X(), pos.Y(), pos.Z()));
mcp.setMomentum(edm4hep::Vector3f(mom.X(), mom.Y(), mom.Z()));

}

Expand Down
6 changes: 6 additions & 0 deletions Generator/src/GtBeamBackgroundTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class GtBeamBackgroundTool: public extends<AlgTool, IGenTool> {
Gaudi::Property<std::map<std::string, std::string>> m_fomatmaps{this, "InputFormatMap"};
Gaudi::Property<std::map<std::string, double>> m_ratemaps {this, "InputRateMap"};

// unit of beam energy: GeV
Gaudi::Property<std::map<std::string, double>> m_Ebeammaps{this, "InputBeamEnergyMap"};

// unit of the rotation along Y: rad
Gaudi::Property<std::map<std::string, double>> m_rotYmaps {this, "RotationAlongYMap"};

private:
std::map<std::string, std::shared_ptr<IBeamBackgroundFileParser>> m_beaminputs;

Expand Down

0 comments on commit cb27f4f

Please sign in to comment.