Belle II Software  release-05-01-25
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 35 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 77 of file SGCosmic.cc.

78 {
79  int charge = 0; // Initialization of charge
80  double dr, pt, phi, dz, tanl;
81 
82  while (true) {
83 
84  genCosmic(m_params.level, charge, dr, phi, pt, dz, tanl);
85 
87  p.setStatus(MCParticle::c_PrimaryParticle);
88 
89  if (1 == charge) {
90  p.setPDG(-13);
91  } else if (-1 == charge) {
92  p.setPDG(13);
93  } else {
94  continue;
95  }
96  p.setMassFromPDG();
97  p.setFirstDaughter(0);
98  p.setLastDaughter(0);
99 
100 #ifdef DEBUG
101  if (1 == m_params.level) ofs_cosmic1g << charge << " " << dr << " " << phi << " "
102  << pt << " " << dz << " " << tanl << endl;
103  else if (2 == m_params.level) ofs_cosmic2g << charge << " " << dr << " " << phi << " "
104  << pt << " " << dz << " " << tanl << endl;
105 #endif
106 
107  // Simulate helix parameter at perigee
108  float bz = BFieldManager::getField(0, 0, 0).Z() / Unit::T; // Magnetic field
109  const float EPS = 0.0001; // Avoid using zero magnetic field
110  if (fabs(bz) < EPS) bz = EPS; // Set the value of the magnetic field to a small number
111  float d0, phi0, omega, z0, tanLambda; // The definition is the same as in the Helix class
112  d0 = dr;
113  phi0 = phi;
114  omega = (double)charge / (pt * Helix::getAlpha(bz));
115  z0 = dz;
116  tanLambda = tanl;
117  Helix CosmicMCHelix(d0, phi0, omega, z0, tanLambda);
118 
119  const float cylindricalR = m_params.cylindricalR; // radius (cm) of generation
120  float arcLength;
121  // Get arc length at ToP radius
122  arcLength = CosmicMCHelix.getArcLength2DAtCylindricalR(cylindricalR);
123  if (isnan(arcLength)) continue;
124 
125  // Calculate coordinates and momentum at ToP radius
126  TVector3 vector;
127  vector = CosmicMCHelix.getPositionAtArcLength2D(arcLength);
128  double vx = vector[0];
129  double vy = vector[1];
130  double vz = vector[2];
131  vector = CosmicMCHelix.getMomentumAtArcLength2D(arcLength, bz);
132  double px = - vector[0];
133  double py = - vector[1];
134  double pz = - vector[2];
135  double m = p.getMass();
136  double e = sqrt(px * px + py * py + pz * pz + m * m);
137 
138 #ifdef DEBUG
139  if (1 == m_params.level) ofs_cosmic1c << vx << " " << vy << " " << vz << " "
140  << px << " " << py << " " << pz << endl;
141  else if (2 == m_params.level) ofs_cosmic2c << vx << " " << vy << " " << vz << " "
142  << px << " " << py << " " << pz << endl;
143 #endif
144 
145  p.setMomentum(px, py, pz);
146  p.setEnergy(e);
147  p.setProductionVertex(vx, vy, vz);
148  p.addStatus(MCParticle::c_StableInGenerator);
149 
150  return true;
151  }
152  return false;
153 }

The documentation for this class was generated from the following files:
Belle2::EvtPDLUtil::charge
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:46
prepareAsicCrosstalkSimDB.e
e
aux.
Definition: prepareAsicCrosstalkSimDB.py:53
Belle2::BFieldManager::getField
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:110
Belle2::SGCosmic::m_params
Parameters m_params
All relevant parameters.
Definition: SGCosmic.h:95
Belle2::Unit::T
static const double T
[tesla]
Definition: Unit.h:130
Belle2::SGCosmic::genCosmic
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:155
Belle2::MCParticleGraph::addParticle
GraphParticle & addParticle()
Add new particle to the graph.
Definition: MCParticleGraph.h:305
Belle2::CDC::Helix
Helix parameter class.
Definition: Helix.h:51
Belle2::MCParticle::c_StableInGenerator
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
Definition: MCParticle.h:60
Belle2::SGCosmic::Parameters::level
int level
Generator version: level 1 (default) or 2.
Definition: SGCosmic.h:46
Belle2::SGCosmic::Parameters::cylindricalR
double cylindricalR
Cylindrical radius of generation.
Definition: SGCosmic.h:66
Belle2::MCParticleGraph::GraphParticle
Class to represent Particle data in graph.
Definition: MCParticleGraph.h:86
Belle2::MCParticle::c_PrimaryParticle
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:58