16 #include <Geant4/G4ParticleTable.hh>
17 #include <Geant4/G4ParticleDefinition.hh>
20 #include <TGenPhaseSpace.h>
31 _enable_geom_cut(true),
32 _enable_real_mom_dist(true),
33 _ctau(2.6E-8*29979245800.),
45 for(
int i = 0; i < 6; ++i) _pz_dist[i] =
nullptr;
57 _ineve = findNode::getClass<PHG4InEvent>(topNode,
"PHG4INEVENT");
65 _pt_dist =
new TF1(
"PtDistr",
"TMath::Landau(x, 0.416742, 0.174227)", 0., _pt_max);
66 _pz_dist[0] =
new TF1(
"PzDistr1",
"0.161*(x^-2.396)", _mom_min, _mom_max);
67 _pz_dist[1] =
new TF1(
"PzDistr2",
"0.527*(x^-1.996)", _mom_min, _mom_max);
68 _pz_dist[2] =
new TF1(
"PzDistr3",
"0.489*(x^-2.200)", _mom_min, _mom_max);
69 _pz_dist[3] =
new TF1(
"PzDistr4",
"0.302*(x^-1.900)", _mom_min, _mom_max);
70 _pz_dist[4] =
new TF1(
"PzDistr5",
"0.174*(x^-1.750)", _mom_min, _mom_max);
71 _pz_dist[5] =
new TF1(
"PzDistr6",
"0.909*(x^-1.850)", _mom_min > 8. ? _mom_min : 8., _mom_max);
82 for(
int i = 0; i < 6; ++i)
84 if(_pz_dist[i] !=
nullptr)
delete _pz_dist[i];
86 if(_pt_dist !=
nullptr)
delete _pt_dist;
92 bool accepted =
false;
97 generateMotherParticle();
100 decayMotherParticle();
102 accepted = _enable_geom_cut ? geometryCut() :
true;
106 if(
Verbosity() > 10) std::cout <<
"Generated single muon within acceptance after " << nTries <<
" tries." << std::endl;
108 int pdgcode = _truth->
motherPid > 0 ? 13 : -13;
120 double e = TMath::Sqrt(_truth->
muMom.Mag2() + _m_muon*_m_muon);
135 void SQSingleMuonGen::generateMotherParticle()
137 int pid = _rndm.Rndm() < _charge_ratio ? 211 : -211;
141 if(_enable_real_mom_dist)
143 pt = _pt_dist->GetRandom();
146 pz = _pz_dist[0]->GetRandom();
150 pz = _pz_dist[1]->GetRandom();
154 pz = _pz_dist[2]->GetRandom();
158 pz = _pz_dist[3]->GetRandom();
162 pz = _pz_dist[4]->GetRandom();
166 pz = _pz_dist[5]->GetRandom();
171 pz = _mom_min + (_mom_max - _mom_min)*_rndm.Rndm();
172 pt = _rndm.Rndm()*_pt_max;
175 double phi = _rndm.Rndm()*TMath::TwoPi();
176 double px = pt*TMath::Cos(phi);
177 double py = pt*TMath::Sin(phi);
180 _truth->
motherMom = TVector3(px, py, pz);
183 void SQSingleMuonGen::decayMotherParticle()
185 TGenPhaseSpace evtgen;
186 double m[2] = {_m_muon, 0.};
190 evtgen.SetDecay(W, 2, m);
193 TLorentzVector* p = evtgen.GetDecay(0);
194 _truth->
muMom = p->Vect();
197 double ctau1 = _ctau*W.Gamma();
202 bool SQSingleMuonGen::geometryCut()
204 if(fabs(_truth->
muMom.Px()/_truth->
muMom.Pz()) > 0.15)
return false;
205 if(fabs(_truth->
muMom.Py()/_truth->
muMom.Pz()) > 0.15)
return false;
206 if(_truth->
muMom.Mag() < 10.)
return false;
212 bool SQSingleMuonGen::generatePrimaryVtx()
215 _truth->
motherVtx.SetXYZ(_vtx_x0, _vtx_y0, z);
@ VERBOSITY_A_LOT
Output a lot of messages.
virtual int Verbosity() const
Gets the verbosity of this module.
PHBoolean addNode(PHNode *)
virtual double get_DoubleFlag(const std::string &name) const
int AddParticle(const int vtxid, PHG4Particle *particle)
int AddVtx(const double x, const double y, const double z, const double t)
virtual void identify(std::ostream &os=std::cout) const
std::string get_pdgname(const int pdgcode) const
virtual void set_parent_id(const int i)
virtual void set_vtx_id(const int i)
virtual void set_pid(const int i)
virtual void set_e(const double e)
virtual void set_py(const double x)
virtual void set_track_id(const int i)
virtual void set_name(const std::string &name)
virtual void set_px(const double x)
virtual void set_pz(const double x)
PHNode * findFirst(const std::string &, const std::string &)
virtual ~SQSingleMuonGen()
SQSingleMuonGen(const std::string &name="SINGLEGEN")
int InitRun(PHCompositeNode *topNode)
int process_event(PHCompositeNode *topNode)
static recoConsts * instance()