diff --git a/Generator/src/GtBeamBackgroundTool.cpp b/Generator/src/GtBeamBackgroundTool.cpp index a2d3d983ef4dd49105f894a6595fb71c30d83e63..c093caa74cc320745084d85b80829fc0d7421f17 100644 --- a/Generator/src/GtBeamBackgroundTool.cpp +++ b/Generator/src/GtBeamBackgroundTool.cpp @@ -1,6 +1,8 @@ #include "GtBeamBackgroundTool.h" #include "IBeamBackgroundFileParser.h" #include "BeamBackgroundFileParserV0.h" + +#include "TVector3.h" // for rotation DECLARE_COMPONENT(GtBeamBackgroundTool) StatusCode GtBeamBackgroundTool::initialize() { @@ -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 @@ -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); @@ -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())); } diff --git a/Generator/src/GtBeamBackgroundTool.h b/Generator/src/GtBeamBackgroundTool.h index 90fa37f83ee89c7c983de9113853c162696105fe..8e0af8e5777a834e7b42f441f2de5e8766e463bc 100644 --- a/Generator/src/GtBeamBackgroundTool.h +++ b/Generator/src/GtBeamBackgroundTool.h @@ -51,6 +51,12 @@ private: 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;