-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Lorentz transformer algorithm (#46)
- Loading branch information
Showing
14 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/algorithms/clas12/event_builder_filter/EventBuilderFilter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#pragma once | ||
|
||
#include "services/Algorithm.h" | ||
#include <set> | ||
|
||
namespace iguana::clas12 { | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
src/algorithms/clas12/lorentz_transformer/LorentzTransformer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "LorentzTransformer.h" | ||
|
||
namespace iguana::clas12 { | ||
|
||
void LorentzTransformer::Start(hipo::banklist& banks) { | ||
|
||
CacheOption("frame", std::string{"mirror"}, o_frame); | ||
CacheBankIndex(banks, "REC::Particle", b_particle); | ||
|
||
// define transformation function | ||
// TODO: add more useful frames, e.g., Breit | ||
if(o_frame == "mirror") { // reverses the momentum, just for demonstration | ||
m_transform = [] (float& px, float& py, float& pz, float& e) { | ||
px = -px; | ||
py = -py; | ||
pz = -pz; | ||
}; | ||
} | ||
else | ||
Throw(fmt::format("unknown frame '{}'", o_frame)); | ||
|
||
} | ||
|
||
|
||
void LorentzTransformer::Run(hipo::banklist& banks) const { | ||
auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); | ||
ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); | ||
for(int row = 0; row < particleBank.getRows(); row++) { | ||
auto px = particleBank.getFloat("px", row); | ||
auto py = particleBank.getFloat("py", row); | ||
auto pz = particleBank.getFloat("pz", row); | ||
float e = 0.0; // TODO: get the energy | ||
Transform(px, py, pz, e); | ||
particleBank.putFloat("px", row, px); | ||
particleBank.putFloat("py", row, py); | ||
particleBank.putFloat("pz", row, pz); | ||
} | ||
ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); | ||
} | ||
|
||
|
||
void LorentzTransformer::Transform(float& px, float& py, float& pz, float& e) const { | ||
m_transform(px, py, pz, e); | ||
} | ||
|
||
|
||
void LorentzTransformer::Stop() { | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/algorithms/clas12/lorentz_transformer/LorentzTransformer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include "services/Algorithm.h" | ||
|
||
namespace iguana::clas12 { | ||
|
||
/// @brief Lorentz transform momenta in `REC::Particle` (or similar banks) | ||
/// | ||
/// Available frames are: | ||
/// - `"mirror"`: reverse the momentum (just a demo) | ||
class LorentzTransformer : public Algorithm { | ||
|
||
public: | ||
|
||
/// @see `Algorithm::Algorithm` | ||
LorentzTransformer(std::string name="lorentz_transformer") : Algorithm(name) {} | ||
~LorentzTransformer() {} | ||
|
||
void Start(hipo::banklist& banks) override; | ||
void Run(hipo::banklist& banks) const override; | ||
void Stop() override; | ||
|
||
/// **Action function**: transform the 4-momentum @f$p=(p_x,p_y,p_z,E)@f$ to the specified frame | ||
/// @param px @f$p_x@f$ | ||
/// @param py @f$p_y@f$ | ||
/// @param pz @f$p_z@f$ | ||
/// @param e @f$E@f$ | ||
void Transform(float& px, float& py, float& pz, float& e) const; | ||
|
||
private: | ||
|
||
/// `hipo::banklist` index for the particle bank | ||
int b_particle; | ||
|
||
/// configuration options | ||
std::string o_frame; | ||
|
||
/// Lorentz transformation function | ||
std::function<void(float&,float&,float&,float&)> m_transform; | ||
|
||
}; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters