Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::VertexGenerator Class Reference

#include <VertexGenerator.h>

Inheritance diagram for genie::VertexGenerator:
genie::EventRecordVisitorI genie::Algorithm

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)
 
- 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
 
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< boolfOwnerships
 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 <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

June 16, 2007

Copyright (c) 2003-2020, 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 }
static Config * config
Definition: config.cpp:1054
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.

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.

85 {
87  this->LoadConfig();
88 }
static Config * config
Definition: config.cpp:1054
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.

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 
122  if(is_coh||is_ve) {
123  // ** For COH or ve- set a vertex positon on the nuclear boundary
124  //
125  LOG("Vtx", pINFO) << "Setting vertex on the nuclear boundary";
126  double phi = 2*kPi * rnd->RndFsi().Rndm();
127  double cosphi = TMath::Cos(phi);
128  double sinphi = TMath::Sin(phi);
129  double costheta = -1 + 2 * rnd->RndFsi().Rndm();
130  double sintheta = TMath::Sqrt(1-costheta*costheta);
131  vtx.SetX(R*sintheta*cosphi);
132  vtx.SetY(R*sintheta*sinphi);
133  vtx.SetZ(R*costheta);
134  }
135  else {
136  // ** For other events on nuclear targets set the interaction vertex
137  // ** using the requested method: either using a realistic nuclear
138  // ** density or by setting it uniformly within the nucleus
139  //
140  if(realistic) {
141  // Generate the vertex using a realistic nuclear density
142  //
143  LOG("Vtx", pINFO)
144  << "Generating vertex according to a realistic nuclear density profile";
145  // get inputs to the rejection method
146  double ymax = -1;
147  double rmax = 3*R;
148  double dr = R/40.;
149  for(double r = 0; r < rmax; r+=dr) {
150  ymax = TMath::Max(ymax, r*r * utils::nuclear::Density(r,(int)A));
151  }
152  ymax *= 1.2;
153 
154  // select a vertex using the rejection method
155  unsigned int iter = 0;
156  while(1) {
157  iter++;
158 
159  // throw an exception if it hasn't find a solution after many attempts
160  if(iter > kRjMaxIterations) {
161  LOG("Vtx", pWARN)
162  << "Couldn't generate a vertex position after " << iter << " iterations";
163  //evrec->EventFlags()->SetBitNumber(kGenericErr, true);
165  exception.SetReason("Couldn't generate vertex");
166  exception.SwitchOnFastForward();
167  throw exception;
168  }
169 
170  double r = rmax * rnd->RndFsi().Rndm();
171  double t = ymax * rnd->RndFsi().Rndm();
172  double y = r*r * utils::nuclear::Density(r,(int)A);
173  if(y > ymax) {
174  LOG("Vtx", pERROR)
175  << "y = " << y << " > ymax = " << ymax
176  << " for r = " << r << ", A = " << A;
177  }
178  bool accept = (t < y);
179  if(accept) {
180  double phi = 2*kPi * rnd->RndFsi().Rndm();
181  double cosphi = TMath::Cos(phi);
182  double sinphi = TMath::Sin(phi);
183  double costheta = -1 + 2 * rnd->RndFsi().Rndm();
184  double sintheta = TMath::Sqrt(1-costheta*costheta);
185  vtx.SetX(r*sintheta*cosphi);
186  vtx.SetY(r*sintheta*sinphi);
187  vtx.SetZ(r*costheta);
188  break;
189  }
190  }//w(1)
191  } //use density?
192 
193  if(uniform) {
194  // Generate the vertex uniformly within the nucleus
195  //
196  LOG("Vtx", pINFO)
197  << "Generating intranuclear vertex uniformly in volume";
198  while(vtx.Mag() > R) {
199  vtx.SetX(-R + 2*R * rnd->RndFsi().Rndm());
200  vtx.SetY(-R + 2*R * rnd->RndFsi().Rndm());
201  vtx.SetZ(-R + 2*R * rnd->RndFsi().Rndm());
202  }
203  }// uniform?
204 
205  } // coh or ve-?
206  //} // nuclear target ?
207 
208  LOG("Vtx", pINFO)
209  << "Generated vtx @ r = " << vtx.Mag() << " fm / "
210  << print::Vec3AsString(&vtx);
211  return vtx;
212 }
int fVtxGenMethod
vtx generation method (0: uniform, 1: according to nuclear density [def])
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
Definition: ProcessInfo.cxx:99
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
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
#define pWARN
Definition: Messenger.h:60
#define A
Definition: memgrp.cpp:38
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
static const double kPi
Definition: Constants.h:37
string Vec3AsString(const TVector3 *vec)
Definition: PrintUtils.cxx:80
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void VertexGenerator::LoadConfig ( void  )
private

Definition at line 90 of file VertexGenerator.cxx.

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.

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
p
Definition: test.py:223
#define pINFO
Definition: Messenger.h:62
bool IsIon(int pdgc)
Definition: PDGUtils.cxx:39
bool IsPseudoParticle(int pdgc)
Definition: PDGUtils.cxx:24
#define A
Definition: memgrp.cpp:38
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.

int genie::VertexGenerator::fVtxGenMethod
private

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

Definition at line 49 of file VertexGenerator.h.


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