Belle II Software  release-08-01-10
SGCosmic Class Reference

Class to generate tracks in the cosmics generator and store them in a MCParticle graph. More...

#include <SGCosmic.h>

Collaboration diagram for SGCosmic:

Classes

struct  Parameters
 Struct to keep all necessary parameters for the cosmic generator. More...
 

Public Member Functions

 SGCosmic ()
 Default constructor.
 
 ~SGCosmic ()
 Default destructor.
 
bool generateEvent (MCParticleGraph &graph)
 Generates the next event and store the result in the given MCParticle graph. More...
 
bool setParameters (const Parameters &parameters)
 Sets the parameters for generating the Particles.
 

Protected Attributes

Parameters m_params
 All relevant parameters.
 

Private Member Functions

double findMax (const double *dim, const int num)
 Finds maximum value in an array.
 
void genCosmic (const int level, int &charge, double &dr, double &phi, double &Pt, double &dz, double &tanl)
 Generates cosmic events according to tabulated distributions in 5-dimensional space: dr, phi, Pt, dz, tanl.
 
int muChargeFlag (const double)
 Generates the muon charge according to the positively/negatively charged muon ratio.
 
void mkdist_v1 (const int charge, double *)
 Generates distributions in 5-parameter space for different particle charges.
 
int mkDr_pos_v1 (const double dr, const float rndm)
 Generates vertex distributions in the radial direction dr by accept-reject method for positively charged particles.
 
int mkDr_neg_v1 (const double dr, const float rndm)
 Generates vertex distributions in the radial direction dr by accept-reject method for negatively.
 
int mkPhi_pos_v1 (const double phi, const float rndm)
 Generates azimuthal angle phi distributions by accept-reject method for positively charged particles.
 
int mkPhi_neg_v1 (const double phi, const float rndm)
 Generates azimuthal angle phi distributions by accept-reject method for negatively charged particles.
 
int mkPt_pos_v1 (const double pt, const float rndm)
 Generates transverse momentum pt distributions by accept-reject method for positively charged particles.
 
int mkPt_neg_v1 (const double pt, const float rndm)
 Generates transverse momentum pt distributions by accept-reject method for negatively charged particles.
 
int mkDz_pos_v1 (const double dz, const float rndm)
 Generates z vertex dz distributions by accept-reject method for positively charged particles.
 
int mkDz_neg_v1 (const double dz, const float rndm)
 Generates z vertex dz distributions by accept-reject method for negatively charged particles.
 
int mkTanl_pos_v1 (const double tanl, const float rndm)
 Generates tangent of the polar angle tanl distributions by accept-reject method for positively charged particles.
 
int mkTanl_neg_v1 (const double tanl, const float rndm)
 Generates tangent of the polar angle tanl distributions by accept-reject method for negatively charged particles.
 
void mkdist_v2 (const int charge, double *)
 Generates distributions in 5-parameter space for different particle charges.
 
int mkDr_pos_v2 (const double dr, const float rndm)
 Generates vertex distributions in the radial direction dr by accept-reject method for positively charged particles.
 
int mkDr_neg_v2 (const double dr, const float rndm)
 Generates vertex distributions in the radial direction dr by accept-reject method for negatively charged particles.
 
int mkPhi_pos_v2 (const double phi, const float rndm)
 Generates azimuthal angle phi distributions by accept-reject method for positively charged particles.
 
int mkPhi_neg_v2 (const double phi, const float rndm)
 Generates azimuthal angle phi distributions by accept-reject method for negatively charged particles.
 
int mkPt_pos_v2 (const double pt, const float rndm)
 Generates transverse momentum pt distributions by accept-reject method for positively charged particles.
 
int mkPt_neg_v2 (const double pt, const float rndm)
 Generates transverse momentum pt distributions by accept-reject method for negatively charged particles.
 
int mkDz_pos_v2 (const double dz, const float rndm)
 Generates z vertex dz distributions by accept-reject method for positively charged particles.
 
int mkDz_neg_v2 (const double dz, const float rndm)
 Generates z vertex dz distributions by accept-reject method for negatively charged particles.
 
int mkTanl_pos_v2 (const double tanl, const float rndm)
 Generates tangent of the polar angle tanl distributions by accept-reject method for positively charged particles.
 
int mkTanl_neg_v2 (const double tanl, const float rndm)
 Generates tangent of the polar angle tanl distributions by accept-reject method for negatively charged particles.
 

Detailed Description

Class to generate tracks in the cosmics generator and store them in a MCParticle graph.

The class supports two version (levels) of event generation with IP and pt parameters.

Definition at line 23 of file SGCosmic.h.

Member Function Documentation

◆ generateEvent()

bool generateEvent ( MCParticleGraph graph)

Generates the next event and store the result in the given MCParticle graph.

Returns
true if the event was generated.

Definition at line 74 of file SGCosmic.cc.

75 {
76  int charge = 0; // Initialization of charge
77  double dr, pt, phi, dz, tanl;
78 
79  while (true) {
80 
81  genCosmic(m_params.level, charge, dr, phi, pt, dz, tanl);
82 
84  p.setStatus(MCParticle::c_PrimaryParticle);
85 
86  if (1 == charge) {
87  p.setPDG(-13);
88  } else if (-1 == charge) {
89  p.setPDG(13);
90  } else {
91  continue;
92  }
93  p.setMassFromPDG();
94  p.setFirstDaughter(0);
95  p.setLastDaughter(0);
96 
97 #ifdef DEBUG
98  if (1 == m_params.level) ofs_cosmic1g << charge << " " << dr << " " << phi << " "
99  << pt << " " << dz << " " << tanl << endl;
100  else if (2 == m_params.level) ofs_cosmic2g << charge << " " << dr << " " << phi << " "
101  << pt << " " << dz << " " << tanl << endl;
102 #endif
103 
104  // Simulate helix parameter at perigee
105  float bz = BFieldManager::getField(0, 0, 0).Z() / Unit::T; // Magnetic field
106  const float EPS = 0.0001; // Avoid using zero magnetic field
107  if (fabs(bz) < EPS) bz = EPS; // Set the value of the magnetic field to a small number
108  float d0, phi0, omega, z0, tanLambda; // The definition is the same as in the Helix class
109  d0 = dr;
110  phi0 = phi;
111  omega = (double)charge / (pt * Helix::getAlpha(bz));
112  z0 = dz;
113  tanLambda = tanl;
114  Helix CosmicMCHelix(d0, phi0, omega, z0, tanLambda);
115 
116  const float cylindricalR = m_params.cylindricalR; // radius (cm) of generation
117  float arcLength;
118  // Get arc length at ToP radius
119  arcLength = CosmicMCHelix.getArcLength2DAtCylindricalR(cylindricalR);
120  if (isnan(arcLength)) continue;
121 
122  // Calculate coordinates and momentum at ToP radius
123  ROOT::Math::XYZVector vector;
124  vector = CosmicMCHelix.getPositionAtArcLength2D(- arcLength);
125  double vx = vector.x();
126  double vy = vector.y();
127  double vz = vector.z();
128  vector = CosmicMCHelix.getMomentumAtArcLength2D(- arcLength, bz);
129  double px = vector.x();
130  double py = vector.y();
131  double pz = vector.z();
132  double m = p.getMass();
133  double e = sqrt(px * px + py * py + pz * pz + m * m);
134 
135 #ifdef DEBUG
136  if (1 == m_params.level) ofs_cosmic1c << vx << " " << vy << " " << vz << " "
137  << px << " " << py << " " << pz << endl;
138  else if (2 == m_params.level) ofs_cosmic2c << vx << " " << vy << " " << vz << " "
139  << px << " " << py << " " << pz << endl;
140 #endif
141 
142  p.setMomentum(px, py, pz);
143  p.setEnergy(e);
144  p.setProductionVertex(vx, vy, vz);
145  p.addStatus(MCParticle::c_StableInGenerator);
146 
147  return true;
148  }
149  return false;
150 }
Helix parameter class.
Definition: Helix.h:48
Class to represent Particle data in graph.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
Definition: MCParticle.h:49
void genCosmic(const int level, int &charge, double &dr, double &phi, double &Pt, double &dz, double &tanl)
Generates cosmic events according to tabulated distributions in 5-dimensional space: dr,...
Definition: SGCosmic.cc:152
Parameters m_params
All relevant parameters.
Definition: SGCosmic.h:83
static const double T
[tesla]
Definition: Unit.h:120
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
GraphParticle & addParticle()
Add new particle to the graph.
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44
double cylindricalR
Cylindrical radius of generation.
Definition: SGCosmic.h:54
int level
Generator version: level 1 (default) or 2.
Definition: SGCosmic.h:34

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