Belle II Software  release-08-01-10
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 
11 using namespace Belle2;
12 
13 std::string MCInitialParticles::getGenerationFlagString(const std::string& separator) const
14 {
15  std::string flags = "";
16  const std::vector<std::pair<int, std::string>> flagvalues{
17  {c_generateCMS, "generateCMS"},
18  {c_smearBeamEnergy, "smearBeamEnergy"},
19  {c_smearBeamDirection, "smearBeamDirection"},
20  {c_smearVertex, "smearVertex"}
21  };
22  for (auto& i : flagvalues) {
23  if (hasGenerationFlags(i.first)) {
24  if (flags.size() > 0) flags += separator;
25  flags += i.second;
26  }
27  }
28  return flags;
29 }
30 
31 ROOT::Math::LorentzRotation MCInitialParticles::cmsToLab(double bX, double bY, double bZ, double angleXZ, double angleYZ)
32 {
33  //boost to CM frame
34  ROOT::Math::LorentzRotation boost(ROOT::Math::Boost(-1.*ROOT::Math::XYZVector(bX, bY, bZ)));
35 
36 
37  //rotation such that the collision axis is aligned with z-axis
38  ROOT::Math::XYZVector zaxis(0., 0., 1.); //target collision axis
39 
40  double tanAngleXZ = tan(angleXZ);
41  double tanAngleYZ = tan(angleYZ);
42  double Norm = 1 / sqrt(1 + pow(tanAngleXZ, 2) + pow(tanAngleYZ, 2));
43  ROOT::Math::XYZVector electronCMS(Norm * tanAngleXZ, Norm * tanAngleYZ, Norm); //current collision axis
44 
45  ROOT::Math::XYZVector rotAxis = zaxis.Cross(electronCMS);
46  double rotangle = asin(rotAxis.R());
47 
48  ROOT::Math::LorentzRotation rotation(ROOT::Math::AxisAngle(rotAxis, -rotangle));
49 
50 
51  ROOT::Math::LorentzRotation trans = rotation * boost;
52  ROOT::Math::LorentzRotation transI = trans.Inverse();
53  return transI;
54 }
@ 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.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double tan(double a)
tan for double
Definition: beamHelpers.h:31
Abstract base class for different kinds of events.