Skip to content
Snippets Groups Projects
Commit cb27f4f4 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

implement the rotation.

parent fe3b8e8a
No related branches found
No related tags found
No related merge requests found
#include "GtBeamBackgroundTool.h" #include "GtBeamBackgroundTool.h"
#include "IBeamBackgroundFileParser.h" #include "IBeamBackgroundFileParser.h"
#include "BeamBackgroundFileParserV0.h" #include "BeamBackgroundFileParserV0.h"
#include "TVector3.h" // for rotation
DECLARE_COMPONENT(GtBeamBackgroundTool) DECLARE_COMPONENT(GtBeamBackgroundTool)
StatusCode GtBeamBackgroundTool::initialize() { StatusCode GtBeamBackgroundTool::initialize() {
...@@ -9,8 +11,17 @@ StatusCode GtBeamBackgroundTool::initialize() { ...@@ -9,8 +11,17 @@ StatusCode GtBeamBackgroundTool::initialize() {
// create the instances of the background parsers // create the instances of the background parsers
for (auto& [label, inputfn]: m_inputmaps) { for (auto& [label, inputfn]: m_inputmaps) {
double beamE = 120.;
m_beaminputs[label] = std::make_shared<BeamBackgroundFileParserV0>(inputfn, 11, 125.); 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 // check the size
...@@ -43,6 +54,17 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) { ...@@ -43,6 +54,17 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) {
// fill the value // fill the value
float charge = beamdata.pdgid == 11 ? -1: 1; 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 // create the MC particle
edm4hep::MCParticle mcp = event.m_mc_vec.create(); edm4hep::MCParticle mcp = event.m_mc_vec.create();
mcp.setPDG(beamdata.pdgid); mcp.setPDG(beamdata.pdgid);
...@@ -51,8 +73,8 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) { ...@@ -51,8 +73,8 @@ bool GtBeamBackgroundTool::mutate(MyHepMC::GenEvent& event) {
mcp.setCharge(static_cast<float>(charge)); mcp.setCharge(static_cast<float>(charge));
mcp.setTime(beamdata.t); mcp.setTime(beamdata.t);
mcp.setMass(beamdata.mass); mcp.setMass(beamdata.mass);
mcp.setVertex(edm4hep::Vector3d(beamdata.x,beamdata.y,beamdata.z)); mcp.setVertex(edm4hep::Vector3d(pos.X(), pos.Y(), pos.Z()));
mcp.setMomentum(edm4hep::Vector3f(beamdata.px,beamdata.py,beamdata.pz)); mcp.setMomentum(edm4hep::Vector3f(mom.X(), mom.Y(), mom.Z()));
} }
......
...@@ -51,6 +51,12 @@ private: ...@@ -51,6 +51,12 @@ private:
Gaudi::Property<std::map<std::string, std::string>> m_fomatmaps{this, "InputFormatMap"}; Gaudi::Property<std::map<std::string, std::string>> m_fomatmaps{this, "InputFormatMap"};
Gaudi::Property<std::map<std::string, double>> m_ratemaps {this, "InputRateMap"}; 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: private:
std::map<std::string, std::shared_ptr<IBeamBackgroundFileParser>> m_beaminputs; std::map<std::string, std::shared_ptr<IBeamBackgroundFileParser>> m_beaminputs;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment