Belle II Software development
MCInitialParticles Class Reference

This class contains the initial state for the given event. More...

#include <MCInitialParticles.h>

Inheritance diagram for MCInitialParticles:
BeamParameters

Public Types

enum  EGenerationFlags {
  c_generateCMS = 1 << 0 ,
  c_smearBeamEnergy = 1 << 1 ,
  c_smearBeamDirection = 1 << 2 ,
  c_smearBeam = c_smearBeamEnergy | c_smearBeamDirection ,
  c_smearVertex = 1 << 3 ,
  c_smearALL = c_smearVertex | c_smearBeam
}
 Possible Flags for initial event generation. More...
 

Public Member Functions

 MCInitialParticles ()
 Default constructor.
 
 MCInitialParticles (const MCInitialParticles &b)
 Copy constructor.
 
MCInitialParticlesoperator= (const MCInitialParticles &b)
 Assignment operator.
 
bool operator== (const MCInitialParticles &b) const
 Equality operator.
 
virtual ~MCInitialParticles ()
 Free memory of the LorentzRotation if it was created.
 
void set (const ROOT::Math::PxPyPzEVector &her, const ROOT::Math::PxPyPzEVector &ler, const ROOT::Math::XYZVector &vertex)
 Set the initial event values, i.e.
 
void setByLorentzTransformation (double Ecms, double bX, double bY, double bZ, double angleXZ, double angleYZ, const ROOT::Math::XYZVector &vertex)
 Initialize the event values from CMS energy and parameters of the Lorentz transformation between LAB and CMS.
 
void setHER (const ROOT::Math::PxPyPzEVector &her)
 Set the High Energy Beam 4-momentum.
 
void setLER (const ROOT::Math::PxPyPzEVector &ler)
 Set the Low Energy Beam 4-momentum.
 
void setVertex (const ROOT::Math::XYZVector &vertex)
 Set the vertex position.
 
void setTime (double time)
 Set collision time.
 
virtual void setGenerationFlags (int flags)
 Set the generation flags to be used for event generation (ORed combination of EGenerationFlags)
 
const ROOT::Math::PxPyPzEVector & getHER () const
 Get 4vector of the high energy beam.
 
const ROOT::Math::PxPyPzEVector & getLER () const
 Get 4vector of the low energy beam.
 
const ROOT::Math::XYZVector & getVertex () const
 Get the position of the collision.
 
double getTime () const
 Get collision time.
 
double getEnergy () const
 Get the actual collision energy (in lab system)
 
double getMass () const
 Get the invariant mass of the collision (= energy in CMS)
 
ROOT::Math::XYZVector getBoostVector () const
 Get the boost vector (velocity of system produced in the collision)
 
ROOT::Math::PxPyPzEVector getBoostedHER () const
 Get the 4-vector of electron beam in CM system obtained by pure boost.
 
const ROOT::Math::LorentzRotation & getLabToCMS () const
 Return the LorentzRotation to convert from lab to CMS frame.
 
const ROOT::Math::LorentzRotation & getCMSToLab () const
 Return the LorentzRotation to convert from CMS to lab frame.
 
bool getValidFlag () const
 Get the flag to check if a valid MCInitialParticles object was already generated and filled in an event.
 
int getGenerationFlags () const
 Get the generation flags to be used for event generation (ORed combination of EGenerationFlags)
 
bool hasGenerationFlags (int flags) const
 Check if a certain set of EGenerationFlags is set.
 
std::string getGenerationFlagString (const std::string &separator=" ") const
 Return string representation of all active flags for printing.
 

Static Public Member Functions

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.
 

Protected Attributes

int m_generationFlags {0}
 Flags to be used when generating events.
 

Private Member Functions

void calculateBoost () const
 Calculate the Lorentz transformations LAB->CMS & CMS->LAB if necessary.
 
void resetBoost ()
 Reset cached transformations after changing parameters.
 
 ClassDef (MCInitialParticles, 5)
 ROOT Dictionary.
 

Private Attributes

ROOT::Math::PxPyPzEVector m_her
 HER 4vector.
 
ROOT::Math::PxPyPzEVector m_ler
 LER 4vector.
 
ROOT::Math::XYZVector m_vertex
 collision position
 
double m_time = 0
 collision time
 
ROOT::Math::LorentzRotation * m_labToCMS {nullptr}
 Boost from Lab into CMS.
 
ROOT::Math::LorentzRotation * m_CMSToLab {nullptr}
 transient
 
double m_invariantMass {0.0}
 transient
 
ROOT::Math::PxPyPzEVector m_boostedHER
 transient
 
bool m_validFlag = false
 transient
 

Detailed Description

This class contains the initial state for the given event.

This is not to be confused with the nominal beam parameters but is an event dependent info which contains all implemented smearing effects. It is only set in Montecarlo.

Definition at line 30 of file MCInitialParticles.h.

Member Enumeration Documentation

◆ EGenerationFlags

Possible Flags for initial event generation.

Enumerator
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)

c_smearBeam 

smear the full beam momentum (energy and direction)

c_smearVertex 

smear vertex

c_smearALL 

smear all

Definition at line 35 of file MCInitialParticles.h.

35 {
37 c_generateCMS = 1 << 0,
39 c_smearBeamEnergy = 1 << 1,
41 c_smearBeamDirection = 1 << 2,
45 c_smearVertex = 1 << 3,
48 };
@ c_smearBeam
smear the full beam momentum (energy and direction)
@ 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)

Constructor & Destructor Documentation

◆ MCInitialParticles() [1/2]

MCInitialParticles ( )
inline

Default constructor.

Definition at line 51 of file MCInitialParticles.h.

51: TObject() {}

◆ MCInitialParticles() [2/2]

MCInitialParticles ( const MCInitialParticles b)
inline

Copy constructor.

Definition at line 54 of file MCInitialParticles.h.

54 : TObject(), m_her(b.m_her), m_ler(b.m_ler),
55 m_vertex(b.m_vertex), m_validFlag(b.m_validFlag), m_generationFlags(b.m_generationFlags) {}
int m_generationFlags
Flags to be used when generating events.
ROOT::Math::PxPyPzEVector m_ler
LER 4vector.
ROOT::Math::PxPyPzEVector m_her
HER 4vector.
ROOT::Math::XYZVector m_vertex
collision position

◆ ~MCInitialParticles()

virtual ~MCInitialParticles ( )
inlinevirtual

Free memory of the LorentzRotation if it was created.

Definition at line 88 of file MCInitialParticles.h.

88{ resetBoost(); }
void resetBoost()
Reset cached transformations after changing parameters.

Member Function Documentation

◆ cmsToLab()

ROOT::Math::LorentzRotation cmsToLab ( double  bX,
double  bY,
double  bZ,
double  angleXZ,
double  angleYZ 
)
static

Return the LorentzRotation from CMS to LAB based on the following parameters.

Parameters
bXx-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
bYy-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
bZz-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
angleXZangle in the XZ plane of the collision axis in the CM system obtained by pure boost
angleYZangle in the YZ plane of the collision axis in the CM system obtained by pure boost

Definition at line 31 of file MCInitialParticles.cc.

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}
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ getBoostedHER()

ROOT::Math::PxPyPzEVector getBoostedHER ( ) const
inline

Get the 4-vector of electron beam in CM system obtained by pure boost.

Definition at line 184 of file MCInitialParticles.h.

184{ calculateBoost(); return m_boostedHER; }
ROOT::Math::PxPyPzEVector m_boostedHER
transient
void calculateBoost() const
Calculate the Lorentz transformations LAB->CMS & CMS->LAB if necessary.

◆ getBoostVector()

ROOT::Math::XYZVector getBoostVector ( ) const
inline

Get the boost vector (velocity of system produced in the collision)

Definition at line 181 of file MCInitialParticles.h.

181{ calculateBoost(); return -(m_her + m_ler).BoostToCM(); }

◆ getCMSToLab()

const ROOT::Math::LorentzRotation & getCMSToLab ( ) const
inline

Return the LorentzRotation to convert from CMS to lab frame.

Definition at line 193 of file MCInitialParticles.h.

194 {
195 calculateBoost(); return *m_CMSToLab;
196 }
ROOT::Math::LorentzRotation * m_CMSToLab
transient

◆ getEnergy()

double getEnergy ( ) const
inline

Get the actual collision energy (in lab system)

Definition at line 175 of file MCInitialParticles.h.

175{ return (m_her + m_ler).E(); }

◆ getGenerationFlags()

int getGenerationFlags ( ) const
inline

Get the generation flags to be used for event generation (ORed combination of EGenerationFlags)

Definition at line 202 of file MCInitialParticles.h.

202{ return m_generationFlags; }

◆ getGenerationFlagString()

std::string getGenerationFlagString ( const std::string &  separator = " ") const

Return string representation of all active flags for printing.

Parameters
separatorseparation string to be put between flags

Definition at line 13 of file MCInitialParticles.cc.

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}
bool hasGenerationFlags(int flags) const
Check if a certain set of EGenerationFlags is set.

◆ getHER()

const ROOT::Math::PxPyPzEVector & getHER ( ) const
inline

Get 4vector of the high energy beam.

Definition at line 163 of file MCInitialParticles.h.

163{ return m_her; }

◆ getLabToCMS()

const ROOT::Math::LorentzRotation & getLabToCMS ( ) const
inline

Return the LorentzRotation to convert from lab to CMS frame.

Definition at line 187 of file MCInitialParticles.h.

188 {
189 calculateBoost(); return *m_labToCMS;
190 }
ROOT::Math::LorentzRotation * m_labToCMS
Boost from Lab into CMS.

◆ getLER()

const ROOT::Math::PxPyPzEVector & getLER ( ) const
inline

Get 4vector of the low energy beam.

Definition at line 166 of file MCInitialParticles.h.

166{ return m_ler; }

◆ getMass()

double getMass ( ) const
inline

Get the invariant mass of the collision (= energy in CMS)

Definition at line 178 of file MCInitialParticles.h.

178{ calculateBoost(); return m_invariantMass; }

◆ getTime()

double getTime ( ) const
inline

Get collision time.

Definition at line 172 of file MCInitialParticles.h.

172{return m_time;}
double m_time
collision time

◆ getValidFlag()

bool getValidFlag ( ) const
inline

Get the flag to check if a valid MCInitialParticles object was already generated and filled in an event.

Definition at line 199 of file MCInitialParticles.h.

199{ return m_validFlag; }

◆ getVertex()

const ROOT::Math::XYZVector & getVertex ( ) const
inline

Get the position of the collision.

Definition at line 169 of file MCInitialParticles.h.

169{ return m_vertex; }

◆ hasGenerationFlags()

bool hasGenerationFlags ( int  flags) const
inline

Check if a certain set of EGenerationFlags is set.

Definition at line 205 of file MCInitialParticles.h.

205{ return (m_generationFlags & flags) == flags; }

◆ operator=()

MCInitialParticles & operator= ( const MCInitialParticles b)
inline

Assignment operator.

Definition at line 58 of file MCInitialParticles.h.

59 {
60 m_her = b.m_her; m_ler = b.m_ler; m_vertex = b.m_vertex;
61 m_validFlag = b.m_validFlag; m_generationFlags = b.m_generationFlags;
62 resetBoost();
63 return *this;
64 }

◆ operator==()

bool operator== ( const MCInitialParticles b) const
inline

Equality operator.

Definition at line 67 of file MCInitialParticles.h.

68 {
69 // FIXME: sin(x) returns slightly different values on
70 // different platforms in some cases so we cannot just do an equality
71 // comparison. We need to do this more elegantly, this is just for
72 // testing if it solves all problems
73#if defined(MCP_DBL_CMP) || defined(MCP_VEC3_CMP) || defined(MCP_VEC4_CMP)
74#error Macro already defined, cannot continue
75#endif
76#define MCP_DBL_CMP(a,b,x) ((a.X()==b.X())||(std::abs(a.X()-b.X())<1e-10))
77#define MCP_VEC3_CMP(a,b) (MCP_DBL_CMP(a,b,X) && MCP_DBL_CMP(a,b,Y) && MCP_DBL_CMP(a,b,Z))
78#define MCP_VEC4_CMP(a,b) (MCP_VEC3_CMP(a,b) && MCP_DBL_CMP(a,b,E))
79 return MCP_VEC4_CMP(m_her, b.m_her) && MCP_VEC4_CMP(m_ler, b.m_ler) && MCP_VEC3_CMP(m_vertex, b.m_vertex)
80 && m_validFlag == b.m_validFlag &&
81 m_generationFlags == b.m_generationFlags;
82#undef MCP_DBL_CMP
83#undef MCP_VEC3_CMP
84#undef MCP_VEC4_CMP
85 }

◆ set()

void set ( const ROOT::Math::PxPyPzEVector &  her,
const ROOT::Math::PxPyPzEVector &  ler,
const ROOT::Math::XYZVector &  vertex 
)
inline

Set the initial event values, i.e.

the four momenta of both beams and the vertex

Parameters
her4vector of the high energy beam
ler4vector of the low energy beam
vertexposition of the actual collision vertex

Definition at line 96 of file MCInitialParticles.h.

97 {
98 m_her = her;
99 m_ler = ler;
100 m_vertex = vertex;
101 m_validFlag = true;
102 resetBoost();
103 }

◆ setByLorentzTransformation()

void setByLorentzTransformation ( double  Ecms,
double  bX,
double  bY,
double  bZ,
double  angleXZ,
double  angleYZ,
const ROOT::Math::XYZVector &  vertex 
)
inline

Initialize the event values from CMS energy and parameters of the Lorentz transformation between LAB and CMS.

In addition the vertex is also initialized.

Parameters
Ecmscentre-of-mass energy of the collision
bXx-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
bYy-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
bZz-component of the boost vector, i.e. of (pHER + pLER) / (eHER + eLER), where pHER & pLER are momentum 3-vectors
angleXZangle in the XZ plane of the collision axis in the CM system obtained by pure boost
angleYZangle in the YZ plane of the collision axis in the CM system obtained by pure boost
vertexposition of the actual collision vertex

Definition at line 115 of file MCInitialParticles.h.

117 {
118 if (m_labToCMS) delete m_labToCMS;
119 if (m_CMSToLab) delete m_CMSToLab;
120
121 m_invariantMass = Ecms;
122 m_CMSToLab = new ROOT::Math::LorentzRotation();
123 m_labToCMS = new ROOT::Math::LorentzRotation();
124 *m_CMSToLab = cmsToLab(bX, bY, bZ, angleXZ, angleYZ);
125 *m_labToCMS = m_CMSToLab->Inverse();
126
127 const double me = Const::electron.getMass();
128 double p = sqrt(Ecms * Ecms / 4 - me * me);
129 m_her = (*m_CMSToLab) * ROOT::Math::PxPyPzEVector(0.0, 0.0, p, Ecms / 2);
130 m_ler = (*m_CMSToLab) * ROOT::Math::PxPyPzEVector(0.0, 0.0, -p, Ecms / 2);
131
132 m_vertex = vertex;
133 m_validFlag = true;
134 }
double getMass() const
Particle mass.
Definition: UnitConst.cc:356
static const ChargedStable electron
electron particle
Definition: Const.h:659
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.
static const double me
electron mass
Definition: beamHelpers.h:177

◆ setGenerationFlags()

virtual void setGenerationFlags ( int  flags)
inlinevirtual

Set the generation flags to be used for event generation (ORed combination of EGenerationFlags)

Reimplemented in BeamParameters.

Definition at line 160 of file MCInitialParticles.h.

160{ m_generationFlags = flags; }

◆ setHER()

void setHER ( const ROOT::Math::PxPyPzEVector &  her)
inline

Set the High Energy Beam 4-momentum.

Definition at line 137 of file MCInitialParticles.h.

138 {
139 m_her = her;
140 resetBoost();
141 }

◆ setLER()

void setLER ( const ROOT::Math::PxPyPzEVector &  ler)
inline

Set the Low Energy Beam 4-momentum.

Definition at line 144 of file MCInitialParticles.h.

145 {
146 m_ler = ler;
147 resetBoost();
148 }

◆ setTime()

void setTime ( double  time)
inline

Set collision time.

Definition at line 157 of file MCInitialParticles.h.

157{m_time = time;}

◆ setVertex()

void setVertex ( const ROOT::Math::XYZVector &  vertex)
inline

Set the vertex position.

Definition at line 151 of file MCInitialParticles.h.

152 {
153 m_vertex = vertex;
154 }

Member Data Documentation

◆ m_boostedHER

ROOT::Math::PxPyPzEVector m_boostedHER
mutableprivate

transient

HER 4-momentum in CM frame obtained by pure boost (calculated on first use, not saved to file)

Definition at line 242 of file MCInitialParticles.h.

◆ m_CMSToLab

ROOT::Math::LorentzRotation* m_CMSToLab {nullptr}
mutableprivate

transient

Boost from CMS into lab. (calculated on first use, not saved to file)

Definition at line 238 of file MCInitialParticles.h.

◆ m_generationFlags

int m_generationFlags {0}
protected

Flags to be used when generating events.

Definition at line 249 of file MCInitialParticles.h.

◆ m_her

ROOT::Math::PxPyPzEVector m_her
private

HER 4vector.

Definition at line 228 of file MCInitialParticles.h.

◆ m_invariantMass

double m_invariantMass {0.0}
mutableprivate

transient

invariant mass of HER+LER (calculated on first use, not saved to file)

Definition at line 240 of file MCInitialParticles.h.

◆ m_labToCMS

ROOT::Math::LorentzRotation* m_labToCMS {nullptr}
mutableprivate

Boost from Lab into CMS.

(calculated on first use, not saved to file)

Definition at line 236 of file MCInitialParticles.h.

◆ m_ler

ROOT::Math::PxPyPzEVector m_ler
private

LER 4vector.

Definition at line 230 of file MCInitialParticles.h.

◆ m_time

double m_time = 0
private

collision time

Definition at line 234 of file MCInitialParticles.h.

◆ m_validFlag

bool m_validFlag = false
private

transient

Flag to check if a valid MCInitialParticles object was already generated and filled in an event.

Definition at line 244 of file MCInitialParticles.h.

◆ m_vertex

ROOT::Math::XYZVector m_vertex
private

collision position

Definition at line 232 of file MCInitialParticles.h.


The documentation for this class was generated from the following files: