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::COHDNuEventGenerator Class Reference

Generates complete COHDNu events. Is a concrete implementation of the EventRecordVisitorI interface. More...

#include <COHDNuEventGenerator.h>

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

Public Member Functions

 COHDNuEventGenerator ()
 
 COHDNuEventGenerator (string config)
 
 ~COHDNuEventGenerator ()
 
void ProcessEventRecord (GHepRecord *event) const
 
void Configure (const Registry &config)
 
void Configure (string config)
 
- 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)
 
void GenerateKinematics (GHepRecord *event) const
 
void AddFinalStateDarkNeutrino (GHepRecord *event) const
 
void AddRecoilNucleus (GHepRecord *event) const
 

Private Attributes

const XSecAlgorithmIfXSecModel
 
bool fGenerateUniformly
 
double fSafetyFactor
 
double fMaxXSecDiffTolerance
 
double fDNuMass
 
double fDNuMass2
 

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

Generates complete COHDNu events. Is a concrete implementation of the EventRecordVisitorI interface.

Author
Iker de Icaza <i.de-icaza-astiz sussex.ac.uk> University of Sussex

Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool

Created:
June 30, 2020
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 31 of file COHDNuEventGenerator.h.

Constructor & Destructor Documentation

COHDNuEventGenerator::COHDNuEventGenerator ( )

Definition at line 46 of file COHDNuEventGenerator.cxx.

46  :
47  EventRecordVisitorI("genie::COHDNuEventGenerator")
48 {
49 
50 }
COHDNuEventGenerator::COHDNuEventGenerator ( string  config)

Definition at line 52 of file COHDNuEventGenerator.cxx.

52  :
53  EventRecordVisitorI("genie::COHDNuEventGenerator", config)
54 {
55 
56 }
COHDNuEventGenerator::~COHDNuEventGenerator ( )

Definition at line 58 of file COHDNuEventGenerator.cxx.

59 {
60 
61 }

Member Function Documentation

void COHDNuEventGenerator::AddFinalStateDarkNeutrino ( GHepRecord event) const
private

Definition at line 185 of file COHDNuEventGenerator.cxx.

References genie::kIStDecayedState, genie::kPdgAntiDarkNeutrino, genie::kPdgDarkNeutrino, genie::GHepRecord::ProbePosition(), and genie::GHepParticle::X4().

Referenced by ProcessEventRecord().

186 {
187  GHepParticle * probe = event->Probe();
188 
189  const TLorentzVector & vtx = *(probe->X4());
190  TLorentzVector x4l(vtx); // position 4-vector
191 
192  event->AddParticle(probe -> Pdg() > 0 ? kPdgDarkNeutrino : kPdgAntiDarkNeutrino,
194  event->ProbePosition(), event->TargetNucleusPosition(),
195  -1,-1, event->Summary()->Kine().FSLeptonP4(), x4l);
196 }
const int kPdgAntiDarkNeutrino
Definition: PDGCodes.h:222
const TLorentzVector * X4(void) const
Definition: GHepParticle.h:79
virtual int ProbePosition(void) const
Definition: GHepRecord.cxx:352
const int kPdgDarkNeutrino
Definition: PDGCodes.h:221
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
void COHDNuEventGenerator::AddRecoilNucleus ( GHepRecord event) const
private

Definition at line 198 of file COHDNuEventGenerator.cxx.

References genie::GHepParticle::FirstDaughter(), genie::kIStStableFinalState, LOG, genie::utils::print::P4AsString(), genie::GHepParticle::Pdg(), pNOTICE, genie::GHepRecord::TargetNucleus(), and genie::GHepParticle::X4().

Referenced by ProcessEventRecord().

199 {
200  GHepParticle * probe = event->Probe();
201  GHepParticle * target = event->TargetNucleus();
202  GHepParticle * fsl = event->Particle(probe->FirstDaughter());
203 
204  const TLorentzVector & p4probe = * ( probe -> P4() );
205  const TLorentzVector & p4target = * ( target -> P4() );
206  const TLorentzVector & p4fsl = * ( fsl -> P4() );
207 
208  const TLorentzVector & p4recoil = p4probe + p4target - p4fsl;
209 
210  LOG("COHDNu", pNOTICE)
211  << "Recoil 4-momentum: " << utils::print::P4AsString(&p4recoil);
212 
213  const TLorentzVector & vtx = *(probe->X4());
214 
215  event->AddParticle(event->TargetNucleus()->Pdg(),
217  event->TargetNucleusPosition(), event->ProbePosition(),
218  -1,-1, p4recoil, vtx);
219 }
int FirstDaughter(void) const
Definition: GHepParticle.h:68
string P4AsString(const TLorentzVector *p)
Definition: PrintUtils.cxx:27
int Pdg(void) const
Definition: GHepParticle.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:293
const TLorentzVector * X4(void) const
Definition: GHepParticle.h:79
#define pNOTICE
Definition: Messenger.h:61
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
void COHDNuEventGenerator::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 221 of file COHDNuEventGenerator.cxx.

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

222 {
223  Algorithm::Configure(config);
224  this->LoadConfig();
225 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void COHDNuEventGenerator::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 227 of file COHDNuEventGenerator.cxx.

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

228 {
229  Algorithm::Configure(config);
230  this->LoadConfig();
231 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void COHDNuEventGenerator::GenerateKinematics ( GHepRecord event) const
private

Definition at line 70 of file COHDNuEventGenerator.cxx.

References genie::Kinematics::ClearRunningValues(), genie::units::cm2, genie::EventGeneratorI::CrossSectionAlg(), fDNuMass, fDNuMass2, fGenerateUniformly, fMaxXSecDiffTolerance, fSafetyFactor, fXSecModel, gQ2, genie::Interaction::InitState(), genie::RunningThreadInfo::Instance(), genie::RandomGen::Instance(), genie::utils::gsl::dXSec_dEDNu_E::IntegrationRange(), genie::Interaction::KinePtr(), genie::kISkipKinematicChk, genie::kISkipProcessChk, genie::kKineGenErr, genie::constants::kPi, genie::kPSEDNufE, genie::kRfLab, genie::controls::kRjMaxIterations, LOG, genie::Target::Mass(), genie::Range1D_t::max, genie::Range1D_t::min, genie::GHepParticle::P4(), pFATAL, pINFO, genie::InitialState::ProbeE(), pWARN, genie::RandomGen::RndKine(), genie::RunningThreadInfo::RunningThread(), genie::Kinematics::SetFSLeptonP4(), genie::Kinematics::SetQ2(), genie::exceptions::EVGThreadException::SetReason(), genie::exceptions::EVGThreadException::SwitchOnFastForward(), and genie::InitialState::Tgt().

Referenced by ProcessEventRecord().

71 {
72  Interaction * interaction = event->Summary();
73  interaction->SetBit(kISkipProcessChk);
74  interaction->SetBit(kISkipKinematicChk);
75 
76  // Get the random number generators
78 
79  // Get the kinematical limits
80  const InitialState & init_state = interaction -> InitState();
81  double E_nu = init_state.ProbeE(kRfLab);
82 
83  // Access cross section algorithm for running thread
85  const EventGeneratorI * evg = rtinfo->RunningThread();
86  fXSecModel = evg->CrossSectionAlg();
87 
88  double gDNuE = -1; // generated Dark Neutrino Energy
89  double gxsec = -1; // dsig/dDENu at generated DNuE
90 
91  // Generate kinematics
92  if(fGenerateUniformly) {
93  LOG("COHDNu", pFATAL)
94  << "Option to generate kinematics uniformly not supported";
95  exit(1);
96  }
97  else {
98  // For the subsequent kinematic selection with the rejection method:
99  // Calculate the max differential cross section.
100  // Always at Q^2 = 0 for energies and model tested,
101  // but go ahead and do the calculation nevertheless.
102  utils::gsl::dXSec_dEDNu_E xsec_func(fXSecModel, interaction, fDNuMass, -1.);
103  Range1D_t DNuEnergy = xsec_func.IntegrationRange();
104  double dDNuE = DNuEnergy.max - DNuEnergy.min;
105  ROOT::Math::BrentMinimizer1D minimizer;
106  minimizer.SetFunction( xsec_func, DNuEnergy.min, DNuEnergy.max);
107  minimizer.Minimize(1000, 1, 1E-5);
108  double DNuE_for_xsec_max = minimizer.XMinimum();
109  double xsec_max = -1. * xsec_func(DNuE_for_xsec_max); // xsec in units of 1E-38 cm2/GeV
110 
111  // Try to select a valid E_N
112  unsigned int iter = 0;
113  while(1) {
114  iter++;
115  if(iter > kRjMaxIterations) {
116  LOG("COHDNu", pWARN)
117  << "*** Could not select a valid DNuE after " << iter << " iterations";
118  event->EventFlags()->SetBitNumber(kKineGenErr, true);
120  exception.SetReason("Couldn't select kinematics");
121  exception.SwitchOnFastForward();
122  throw exception;
123  } // max iterations
124 
125  gDNuE = DNuEnergy.min + dDNuE * rnd->RndKine().Rndm();
126  LOG("COHDNu", pINFO) << "Trying: E_N = " << gDNuE;
127 
128  // Computing cross section for the current kinematics
129  gxsec = -1. * xsec_func(gDNuE);
130 
131  if(gxsec > xsec_max) {
132  double frac = TMath::Abs(gxsec-xsec_max)/xsec_max;
133  if(frac > fMaxXSecDiffTolerance) {
134  LOG("COHDNu", pWARN)
135  << "Current computed cross-section (" << gxsec/(units::cm2)
136  << " cm2/GeV^2) exceeds the maximum cross-section ("
137  << xsec_max/(units::cm2) << " beyond the specified tolerance";
138  }
139  }
140 
141  // Decide whether to accept the current kinematic point
142  double t = fSafetyFactor * xsec_max * rnd->RndKine().Rndm();
143  //this->AssertXSecLimits(interaction, gxsec, xsec_max);
144  LOG("COHDNu", pINFO)
145  << "dxsec/dQ2 = " << gxsec/(units::cm2) << " cm2/GeV^2"
146  << "J = 1, rnd = " << t;
147  bool accept = (t<gxsec);
148  if(accept) break; // exit loop
149  } // 1
150  } // generate uniformly
151 
152  // reset bits
153  interaction->ResetBit(kISkipProcessChk);
154  interaction->ResetBit(kISkipKinematicChk);
155 
156  double M_target = interaction->InitState().Tgt().Mass();
157 
158  double ETimesM = E_nu * M_target;
159  double EPlusM = E_nu + M_target;
160 
161  double p_DNu = TMath::Sqrt(gDNuE*gDNuE - fDNuMass2);
162  double cos_theta_DNu = (gDNuE*EPlusM - ETimesM - 0.5*fDNuMass2) / (E_nu * p_DNu);
163  double theta_DNu = TMath::ACos(cos_theta_DNu);
164 
165  // Take a unit vector along the neutrino direction @ the LAB
166  GHepParticle * probe = event->Probe();
167  TVector3 unit_nudir = probe->P4()->Vect().Unit();
168 
169  TVector3 DNu_3vector = TVector3(0,0,0);
170  double phi = 2.*kPi * rnd->RndKine().Rndm();
171  DNu_3vector.SetMagThetaPhi(p_DNu, theta_DNu, phi);
172  DNu_3vector.RotateUz(unit_nudir);
173  TLorentzVector P4_DNu = TLorentzVector(DNu_3vector, gDNuE);
174  interaction->KinePtr()->SetFSLeptonP4(P4_DNu);
175 
176  // lock selected kinematics & clear running values
177  double gQ2 = -(P4_DNu - *(probe->P4())).M2();
178  interaction->KinePtr()->SetQ2(gQ2, true);
179  interaction->KinePtr()->ClearRunningValues();
180 
181  // Set the cross section for the selected kinematics
182  event->SetDiffXSec(gxsec * (1E-38*units::cm2), kPSEDNufE);
183 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
void SetQ2(double Q2, bool selected=false)
Definition: Kinematics.cxx:255
const TLorentzVector * P4(void) const
Definition: GHepParticle.h:78
Kinematics * KinePtr(void) const
Definition: Interaction.h:76
A simple [min,max] interval for doubles.
Definition: Range1.h:42
#define pFATAL
Definition: Messenger.h:56
Defines the EventGeneratorI interface.
const XSecAlgorithmI * fXSecModel
double Mass(void) const
Definition: Target.cxx:224
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
Summary information for an interaction.
Definition: Interaction.h:56
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
void SetFSLeptonP4(const TLorentzVector &p4)
Definition: Kinematics.cxx:297
static constexpr double cm2
Definition: Units.h:69
#define pINFO
Definition: Messenger.h:62
TRandom3 & RndKine(void) const
rnd number generator used by kinematics generators
Definition: RandomGen.h:50
#define pWARN
Definition: Messenger.h:60
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
Definition: Interaction.h:48
static RunningThreadInfo * Instance(void)
double max
Definition: Range1.h:53
virtual const XSecAlgorithmI * CrossSectionAlg(void) const =0
double gQ2
Definition: gtestDISSF.cxx:55
const InitialState & InitState(void) const
Definition: Interaction.h:69
double min
Definition: Range1.h:52
void ClearRunningValues(void)
Definition: Kinematics.cxx:347
const Target & Tgt(void) const
Definition: InitialState.h:66
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
const EventGeneratorI * RunningThread(void)
double ProbeE(RefFrame_t rf) const
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
Keep info on the event generation thread currently on charge. This is used so that event generation m...
const UInt_t kISkipProcessChk
if set, skip process validity checks
Definition: Interaction.h:47
Initial State information.
Definition: InitialState.h:48
void COHDNuEventGenerator::LoadConfig ( void  )
private

Definition at line 233 of file COHDNuEventGenerator.cxx.

References fDNuMass, fDNuMass2, fGenerateUniformly, fMaxXSecDiffTolerance, fSafetyFactor, fXSecModel, genie::Algorithm::GetParam(), and genie::Algorithm::GetParamDef().

Referenced by Configure().

234 {
235  fXSecModel = 0;
236 
237  // max xsec safety factor (for rejection method) and min cached energy
238  this->GetParamDef( "MaxXSec-SafetyFactor", fSafetyFactor, 1.05 ) ;
239 
240  // Generate kinematics uniformly over allowed phase space and compute
241  // an event weight?
242  this->GetParamDef( "UniformOverPhaseSpace", fGenerateUniformly, false ) ;
243 
244  // Maximum allowed fractional cross section deviation from maxim cross
245  // section used in rejection method
246  this->GetParamDef( "MaxXSec-DiffTolerance", fMaxXSecDiffTolerance, 999999. ) ;
247  assert(fMaxXSecDiffTolerance>=0);
248 
249  fDNuMass = 0.;
250  this->GetParam("Dark-NeutrinoMass", fDNuMass);
252 
253 }
const XSecAlgorithmI * fXSecModel
bool GetParamDef(const RgKey &name, T &p, const T &def) const
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
void COHDNuEventGenerator::ProcessEventRecord ( GHepRecord event) const
virtual

Implements genie::EventRecordVisitorI.

Definition at line 63 of file COHDNuEventGenerator.cxx.

References AddFinalStateDarkNeutrino(), AddRecoilNucleus(), and GenerateKinematics().

64 {
65  this -> GenerateKinematics (event);
66  this -> AddFinalStateDarkNeutrino (event);
67  this -> AddRecoilNucleus (event);
68 }
void GenerateKinematics(GHepRecord *event) const
void AddRecoilNucleus(GHepRecord *event) const
void AddFinalStateDarkNeutrino(GHepRecord *event) const

Member Data Documentation

double genie::COHDNuEventGenerator::fDNuMass
private

Definition at line 62 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().

double genie::COHDNuEventGenerator::fDNuMass2
private

Definition at line 62 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().

bool genie::COHDNuEventGenerator::fGenerateUniformly
private

Definition at line 58 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().

double genie::COHDNuEventGenerator::fMaxXSecDiffTolerance
private

Definition at line 60 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().

double genie::COHDNuEventGenerator::fSafetyFactor
private

Definition at line 59 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().

const XSecAlgorithmI* genie::COHDNuEventGenerator::fXSecModel
mutableprivate

Definition at line 56 of file COHDNuEventGenerator.h.

Referenced by GenerateKinematics(), and LoadConfig().


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