Belle II Software development
MCInitialParticles.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/dataobjects/MCInitialParticles.h>
10#include <framework/utilities/MathHelpers.h>
11
12using namespace Belle2;
13
14std::string MCInitialParticles::getGenerationFlagString(const std::string& separator) const
15{
16 std::string flags = "";
17 const std::vector<std::pair<int, std::string>> flagvalues{
18 {c_generateCMS, "generateCMS"},
19 {c_smearBeamEnergy, "smearBeamEnergy"},
20 {c_smearBeamDirection, "smearBeamDirection"},
21 {c_smearVertex, "smearVertex"}
22 };
23 for (const auto& i : flagvalues) {
24 if (hasGenerationFlags(i.first)) {
25 if (flags.size() > 0) flags += separator;
26 flags += i.second;
27 }
28 }
29 return flags;
30}
31
32ROOT::Math::LorentzRotation MCInitialParticles::cmsToLab(double bX, double bY, double bZ, double angleXZ, double angleYZ)
33{
34 //boost to CM frame
35 ROOT::Math::LorentzRotation boost(ROOT::Math::Boost(-1.*ROOT::Math::XYZVector(bX, bY, bZ)));
36
37
38 //rotation such that the collision axis is aligned with z-axis
39 ROOT::Math::XYZVector zaxis(0., 0., 1.); //target collision axis
40
41 double tanAngleXZ = tan(angleXZ);
42 double tanAngleYZ = tan(angleYZ);
43 double Norm = 1 / sqrt(1 + square(tanAngleXZ) + square(tanAngleYZ));
44 ROOT::Math::XYZVector electronCMS(Norm * tanAngleXZ, Norm * tanAngleYZ, Norm); //current collision axis
45
46 ROOT::Math::XYZVector rotAxis = zaxis.Cross(electronCMS);
47 double rotangle = asin(rotAxis.R());
48
49 ROOT::Math::LorentzRotation rotation(ROOT::Math::AxisAngle(rotAxis, -rotangle));
50
51
52 ROOT::Math::LorentzRotation trans = rotation * boost;
53 ROOT::Math::LorentzRotation transI = trans.Inverse();
54 return transI;
55}
@ c_generateCMS
generate initial event in CMS instead of lab
@ c_smearBeamEnergy
smear energy of HER and LER (but not direction)
@ c_smearBeamDirection
smear direction of HER and LER (but not energy)
std::string getGenerationFlagString(const std::string &separator=" ") const
Return string representation of all active flags for printing.
static ROOT::Math::LorentzRotation cmsToLab(double bX, double bY, double bZ, double angleXZ, double angleYZ)
Return the LorentzRotation from CMS to LAB based on the following parameters.
bool hasGenerationFlags(int flags) const
Check if a certain set of EGenerationFlags is set.
constexpr T square(const T &x)
Calculate the square of the input.
Definition MathHelpers.h:21
double tan(double a)
tan for double
Definition beamHelpers.h:31
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.