GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::VertexGenerator Class Reference

#include <VertexGenerator.h>

Inheritance diagram for genie::VertexGenerator:
Inheritance graph
[legend]
Collaboration diagram for genie::VertexGenerator:
Collaboration graph
[legend]

Public Member Functions

 VertexGenerator ()
 
 VertexGenerator (string config)
 
 ~VertexGenerator ()
 
void ProcessEventRecord (GHepRecord *event_rec) const
 
void Configure (const Registry &config)
 
void Configure (string param_set)
 
TVector3 GenerateVertex (const Interaction *in, double A) const
 
- Public Member Functions inherited from genie::EventRecordVisitorI
virtual ~EventRecordVisitorI ()
 
- Public Member Functions inherited from genie::Algorithm
virtual ~Algorithm ()
 
virtual void FindConfig (void)
 
virtual const RegistryGetConfig (void) const
 
RegistryGetOwnedConfig (void)
 
virtual const AlgIdId (void) const
 Get algorithm ID. More...
 
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status. More...
 
virtual bool AllowReconfig (void) const
 
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm. More...
 
virtual void SetId (const AlgId &id)
 Set algorithm ID. More...
 
virtual void SetId (string name, string config)
 
const AlgorithmSubAlg (const RgKey &registry_key) const
 
void AdoptConfig (void)
 
void AdoptSubstructure (void)
 
virtual void Print (ostream &stream) const
 Print algorithm info. More...
 

Private Member Functions

void LoadConfig (void)
 

Private Attributes

int fVtxGenMethod
 vtx generation method (0: uniform, 1: according to nuclear density [def]) More...
 
double fR0
 parameter controlling nuclear sizes More...
 

Additional Inherited Members

- Static Public Member Functions inherited from genie::Algorithm
static string BuildParamVectKey (const std::string &comm_name, unsigned int i)
 
static string BuildParamVectSizeKey (const std::string &comm_name)
 
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
 
static string BuildParamMatRowSizeKey (const std::string &comm_name)
 
static string BuildParamMatColSizeKey (const std::string &comm_name)
 
- Protected Member Functions inherited from genie::EventRecordVisitorI
 EventRecordVisitorI ()
 
 EventRecordVisitorI (string name)
 
 EventRecordVisitorI (string name, string config)
 
- Protected Member Functions inherited from genie::Algorithm
 Algorithm ()
 
 Algorithm (string name)
 
 Algorithm (string name, string config)
 
void Initialize (void)
 
void DeleteConfig (void)
 
void DeleteSubstructure (void)
 
RegistryExtractLocalConfig (const Registry &in) const
 
RegistryExtractLowerConfig (const Registry &in, const string &alg_key) const
 Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key. More...
 
template<class T >
bool GetParam (const RgKey &name, T &p, bool is_top_call=true) const
 
template<class T >
bool GetParamDef (const RgKey &name, T &p, const T &def) const
 
template<class T >
int GetParamVect (const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
 Handle to load vectors of parameters. More...
 
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
template<class T >
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters. More...
 
template<class T >
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
 
int GetParamMatKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
int AddTopRegistry (Registry *rp, bool owns=true)
 add registry with top priority, also update ownership More...
 
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership More...
 
int MergeTopRegistry (const Registry &r)
 
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships. More...
 
- Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
 
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...) More...
 
AlgId fID
 algorithm name and configuration set More...
 
vector< Registry * > fConfVect
 
vector< bool > fOwnerships
 ownership for every registry in fConfVect More...
 
AlgStatus_t fStatus
 algorithm execution status More...
 
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool) More...
 

Detailed Description

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
June 16, 2007
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 27 of file VertexGenerator.h.

Constructor & Destructor Documentation

VertexGenerator::VertexGenerator ( )

Definition at line 34 of file VertexGenerator.cxx.

34  :
35 EventRecordVisitorI("genie::VertexGenerator")
36 {
37 
38 }
VertexGenerator::VertexGenerator ( string  config)

Definition at line 40 of file VertexGenerator.cxx.

40  :
41 EventRecordVisitorI("genie::VertexGenerator", config)
42 {
43 
44 }
VertexGenerator::~VertexGenerator ( )

Definition at line 46 of file VertexGenerator.cxx.

47 {
48 
49 }

Member Function Documentation

void VertexGenerator::Configure ( const Registry config)
virtual

Configure the algorithm with an external registry The registry is merged with the top level registry if it is owned, Otherwise a copy of it is added with the highest priority

Reimplemented from genie::Algorithm.

Definition at line 78 of file VertexGenerator.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

Referenced by genie::LwlynSmithQELCCPXSec::Integral().

79 {
80  Algorithm::Configure(config);
81  this->LoadConfig();
82 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void VertexGenerator::Configure ( string  config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented from genie::Algorithm.

Definition at line 84 of file VertexGenerator.cxx.

References genie::Algorithm::Configure(), and LoadConfig().

85 {
86  Algorithm::Configure(config);
87  this->LoadConfig();
88 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
TVector3 VertexGenerator::GenerateVertex ( const Interaction in,
double  A 
) const

Definition at line 98 of file VertexGenerator.cxx.

References genie::units::A, genie::utils::nuclear::Density(), fR0, fVtxGenMethod, genie::RandomGen::Instance(), genie::ProcessInfo::IsCoherentElastic(), genie::ProcessInfo::IsCoherentProduction(), genie::ProcessInfo::IsGlashowResonance(), genie::ProcessInfo::IsIMDAnnihilation(), genie::ProcessInfo::IsInverseMuDecay(), genie::ProcessInfo::IsNuElectronElastic(), genie::ProcessInfo::IsPhotonCoherent(), genie::ProcessInfo::IsPhotonResonance(), genie::constants::kPi, genie::controls::kRjMaxIterations, LOG, pERROR, pINFO, genie::Interaction::ProcInfo(), pWARN, genie::RandomGen::RndFsi(), genie::exceptions::EVGThreadException::SetReason(), genie::exceptions::EVGThreadException::SwitchOnFastForward(), and genie::utils::print::Vec3AsString().

Referenced by genie::LwlynSmithQELCCPXSec::Integral(), genie::NewQELXSec::Integrate(), and ProcessEventRecord().

99  {
100  RandomGen * rnd = RandomGen::Instance();
101  TVector3 vtx(999999.,999999.,999999.);
102 
103  //GHepParticle * nucltgt = evrec->TargetNucleus();
104 
105  bool uniform = fVtxGenMethod==0;
106  bool realistic = !uniform;
107 
108  //if(!nucltgt) {
109  //vtx.SetXYZ(0.,0.,0.);
110  //}
111  //else {
112  //double A = nucltgt->A();
113  double R = fR0 * TMath::Power(A, 1./3.);
114 
115  //Interaction * interaction = evrec->Summary();
116  const ProcessInfo & proc_info = interaction->ProcInfo();
117  bool is_coh = proc_info.IsCoherentProduction() || proc_info.IsCoherentElastic();
118  bool is_ve = proc_info.IsInverseMuDecay() ||
119  proc_info.IsIMDAnnihilation() ||
120  proc_info.IsNuElectronElastic() ||
121  proc_info.IsGlashowResonance() ||
122  proc_info.IsPhotonResonance() ||
123  proc_info.IsPhotonCoherent();
124 
125  if(is_coh||is_ve) {
126  // ** For COH or ve- set a vertex positon on the nuclear boundary
127  //
128  LOG("Vtx", pINFO) << "Setting vertex on the nuclear boundary";
129  double phi = 2*kPi * rnd->RndFsi().Rndm();
130  double cosphi = TMath::Cos(phi);
131  double sinphi = TMath::Sin(phi);
132  double costheta = -1 + 2 * rnd->RndFsi().Rndm();
133  double sintheta = TMath::Sqrt(1-costheta*costheta);
134  vtx.SetX(R*sintheta*cosphi);
135  vtx.SetY(R*sintheta*sinphi);
136  vtx.SetZ(R*costheta);
137  }
138  else {
139  // ** For other events on nuclear targets set the interaction vertex
140  // ** using the requested method: either using a realistic nuclear
141  // ** density or by setting it uniformly within the nucleus
142  //
143  if(realistic) {
144  // Generate the vertex using a realistic nuclear density
145  //
146  LOG("Vtx", pINFO)
147  << "Generating vertex according to a realistic nuclear density profile";
148  // get inputs to the rejection method
149  double ymax = -1;
150  double rmax = 3*R;
151  double dr = R/40.;
152  for(double r = 0; r < rmax; r+=dr) {
153  ymax = TMath::Max(ymax, r*r * utils::nuclear::Density(r,(int)A));
154  }
155  ymax *= 1.2;
156 
157  // select a vertex using the rejection method
158  unsigned int iter = 0;
159  while(1) {
160  iter++;
161 
162  // throw an exception if it hasn't find a solution after many attempts
163  if(iter > kRjMaxIterations) {
164  LOG("Vtx", pWARN)
165  << "Couldn't generate a vertex position after " << iter << " iterations";
166  //evrec->EventFlags()->SetBitNumber(kGenericErr, true);
168  exception.SetReason("Couldn't generate vertex");
169  exception.SwitchOnFastForward();
170  throw exception;
171  }
172 
173  double r = rmax * rnd->RndFsi().Rndm();
174  double t = ymax * rnd->RndFsi().Rndm();
175  double y = r*r * utils::nuclear::Density(r,(int)A);
176  if(y > ymax) {
177  LOG("Vtx", pERROR)
178  << "y = " << y << " > ymax = " << ymax
179  << " for r = " << r << ", A = " << A;
180  }
181  bool accept = (t < y);
182  if(accept) {
183  double phi = 2*kPi * rnd->RndFsi().Rndm();
184  double cosphi = TMath::Cos(phi);
185  double sinphi = TMath::Sin(phi);
186  double costheta = -1 + 2 * rnd->RndFsi().Rndm();
187  double sintheta = TMath::Sqrt(1-costheta*costheta);
188  vtx.SetX(r*sintheta*cosphi);
189  vtx.SetY(r*sintheta*sinphi);
190  vtx.SetZ(r*costheta);
191  break;
192  }
193  }//w(1)
194  } //use density?
195 
196  if(uniform) {
197  // Generate the vertex uniformly within the nucleus
198  //
199  LOG("Vtx", pINFO)
200  << "Generating intranuclear vertex uniformly in volume";
201  while(vtx.Mag() > R) {
202  vtx.SetX(-R + 2*R * rnd->RndFsi().Rndm());
203  vtx.SetY(-R + 2*R * rnd->RndFsi().Rndm());
204  vtx.SetZ(-R + 2*R * rnd->RndFsi().Rndm());
205  }
206  }// uniform?
207 
208  } // coh or ve-?
209  //} // nuclear target ?
210 
211  LOG("Vtx", pINFO)
212  << "Generated vtx @ r = " << vtx.Mag() << " fm / "
213  << print::Vec3AsString(&vtx);
214  return vtx;
215 }
int fVtxGenMethod
vtx generation method (0: uniform, 1: according to nuclear density [def])
bool IsPhotonResonance(void) const
double fR0
parameter controlling nuclear sizes
TRandom3 & RndFsi(void) const
rnd number generator used by intranuclear cascade monte carlos
Definition: RandomGen.h:59
#define pERROR
Definition: Messenger.h:59
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
double Density(double r, int A, double ring=0.)
bool IsInverseMuDecay(void) const
bool IsCoherentProduction(void) const
bool IsIMDAnnihilation(void) const
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
An exception thrown by EventRecordVisitorI when the normal processing sequence has to be disrupted (f...
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool IsCoherentElastic(void) const
bool IsNuElectronElastic(void) const
static constexpr double A
Definition: Units.h:74
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition: ProcessInfo.h:46
#define pINFO
Definition: Messenger.h:62
bool IsPhotonCoherent(void) const
#define pWARN
Definition: Messenger.h:60
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
bool IsGlashowResonance(void) const
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:80
void VertexGenerator::LoadConfig ( void  )
private

Definition at line 90 of file VertexGenerator.cxx.

References fR0, fVtxGenMethod, and genie::Algorithm::GetParam().

Referenced by Configure().

91 {
92 
93  GetParam( "VtxGenerationMethod", fVtxGenMethod ) ;
94  GetParam( "NUCL-R0", fR0 ) ; //fm
95 
96 }
int fVtxGenMethod
vtx generation method (0: uniform, 1: according to nuclear density [def])
double fR0
parameter controlling nuclear sizes
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
void VertexGenerator::ProcessEventRecord ( GHepRecord event_rec) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 51 of file VertexGenerator.cxx.

References genie::units::A, genie::GHepParticle::A(), GenerateVertex(), genie::pdg::IsIon(), genie::pdg::IsPseudoParticle(), LOG, genie::GHepParticle::Name(), genie::GHepParticle::Pdg(), pINFO, genie::GHepParticle::SetPosition(), genie::GHepRecord::Summary(), and genie::GHepRecord::TargetNucleus().

52 {
53 // generate a vtx and set it to all GHEP physical particles
54  Interaction * interaction = evrec->Summary();
55  GHepParticle * nucltgt = evrec->TargetNucleus();
56  TVector3 vtx(9999999.,999999.,999999.);
57  if(!nucltgt){
58  vtx.SetXYZ(0.,0.,0.);
59  }else{
60  double A = nucltgt->A();
61  vtx = GenerateVertex(interaction,A);
62  }
63 
64  // Copy the vertex info to the particles already in the event record
65  //
66  TObjArrayIter piter(evrec);
67  GHepParticle * p = 0;
68  while( (p = (GHepParticle *) piter.Next()) )
69  {
70  if(pdg::IsPseudoParticle(p->Pdg())) continue;
71  if(pdg::IsIon (p->Pdg())) continue;
72 
73  LOG("Vtx", pINFO) << "Setting vertex position for: " << p->Name();
74  p->SetPosition(vtx.x(), vtx.y(), vtx.z(), 0.);
75  }
76 }
TVector3 GenerateVertex(const Interaction *in, double A) const
int Pdg(void) const
Definition: GHepParticle.h:63
string Name(void) const
Name that corresponds to the PDG code.
Summary information for an interaction.
Definition: Interaction.h:56
void SetPosition(const TLorentzVector &v4)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double A
Definition: Units.h:74
#define pINFO
Definition: Messenger.h:62
bool IsIon(int pdgc)
Definition: PDGUtils.cxx:42
bool IsPseudoParticle(int pdgc)
Definition: PDGUtils.cxx:27
int A(void) const
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39

Member Data Documentation

double genie::VertexGenerator::fR0
private

parameter controlling nuclear sizes

Definition at line 50 of file VertexGenerator.h.

Referenced by GenerateVertex(), and LoadConfig().

int genie::VertexGenerator::fVtxGenMethod
private

vtx generation method (0: uniform, 1: according to nuclear density [def])

Definition at line 49 of file VertexGenerator.h.

Referenced by GenerateVertex(), and LoadConfig().


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