InterGen_Neugen Class Reference

InteractionGenerator interface.to NEUGEN3. More...

#include <InterGen_Neugen.h>

Inheritance diagram for InterGen_Neugen:
InteractionGenerator

List of all members.

Public Member Functions

 InterGen_Neugen ()
virtual ~InterGen_Neugen ()
virtual void Configure (const char *option="")
 public interface goes here
virtual double CalcXsec (TParticle &nu, TParticle &tgt)
 Generate an event.
virtual void Generate (TParticle &nu, TParticle &tgt)
 Generate an event.
virtual int GetErrorCode ()
 Return the generated event info.
virtual unsigned int GetNumParticles ()
virtual TParticle GetGeneratedParticle (unsigned int i)

Private Attributes

TParticle fNu
TParticle fTgt
int fGenError

Detailed Description

InteractionGenerator interface.to NEUGEN3.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.2
Date:
Date
2006/06/06 05:06:26

Contact: rhatcher@fnal.gov

Created on: Wed Apr 13 18:16:24 2005

Id
InterGen_Neugen.h,v 1.2 2006/06/06 05:06:26 rhatcher Exp

Definition at line 27 of file InterGen_Neugen.h.


Constructor & Destructor Documentation

InterGen_Neugen::InterGen_Neugen (  ) 

Definition at line 56 of file InterGen_Neugen.cxx.

References Msg::kDebug, and MSG.

00057 {
00058     MSG("EvtKin",Msg::kDebug) << "InterGen_Neugen ctor" << endl;
00059 }

InterGen_Neugen::~InterGen_Neugen (  )  [virtual]

Definition at line 62 of file InterGen_Neugen.cxx.

References Msg::kDebug, and MSG.

00063 {
00064     MSG("EvtKin",Msg::kDebug) << "InterGen_Neugen dtor" << endl;
00065 }


Member Function Documentation

double InterGen_Neugen::CalcXsec ( TParticle &  nu,
TParticle &  tgt 
) [virtual]

Generate an event.

Implements InteractionGenerator.

Definition at line 175 of file InterGen_Neugen.cxx.

References StdHepUtil::getIonA(), StdHepUtil::getIonZ(), and total_xsec_().

00176 {
00177     // calculate cross section
00178     int   nucode  = nu.GetPdgCode();
00179     float enu     = nu.Energy();
00180     int   ipdgtgt = tgt.GetPdgCode();
00181     int   ia = StdHepUtil::getIonA(ipdgtgt);
00182     int   iz = StdHepUtil::getIonZ(ipdgtgt);
00183     float sigma = 0;
00184 
00185     total_xsec_(&nucode,&ia,&iz,&enu,&sigma);
00186     return sigma;
00187 
00188 }

void InterGen_Neugen::Configure ( const char *  option = ""  )  [virtual]

public interface goes here

Implements InteractionGenerator.

Definition at line 68 of file InterGen_Neugen.cxx.

References calc_xsectable_(), Registry::Get(), Registry::GetDouble(), Registry::GetInt(), Registry::GetType(), initialize_configuration_(), Msg::kDebug, Registry::Key(), Msg::kWarning, model_choice_(), MSG, padstrbuffer(), Registry::Print(), print_configuration_(), set_parameters_(), and Cfg::StringToRegistry().

00069 {
00070     MSG("EvtKin",Msg::kDebug)
00071         << "InterGen_Neugen::Configure()" << endl
00072         << "   '" << option  << "'" << endl;
00073  
00074     // for now use MINOS code to parse options
00075     Registry r;
00076     Cfg::StringToRegistry(r,option);
00077     r.SetName("InterGen_Neugen config");
00078     r.Print();
00079 
00080     const char* configname = "";
00081     int configversion = 0;
00082     bool gotName = r.Get("ConfigName",configname);
00083     bool gotVers = r.Get("ConfigVersion",configversion);
00084 
00085     const char* modelstr = "";
00086     bool gotModels = r.Get("Models",modelstr);
00087     Registry r_models;
00088     Cfg::StringToRegistry(r_models,modelstr);
00089     r_models.SetName("InterGen_Neugen model choice");
00090     if (gotModels) r_models.Print();
00091 
00092     const char* paramstr = "";
00093     bool gotParams = r.Get("Params",paramstr);
00094     Registry r_params;
00095     Cfg::StringToRegistry(r_params,paramstr);
00096     r_params.SetName("InterGen_Neugen parameters");
00097     if (gotParams) r_params.Print();
00098 
00099     if (gotName && gotVers) {
00100         // make these static because otherwise 
00101         // flakey thing sometimes happen (optimizer?, register?)
00102         static bool  iok = false;
00103         static int   istrlen = 0;
00104         static int   ival = 0;
00105         static float val = 0.;
00106 
00107         istrlen = strlen(configname);
00108         ival = configversion;
00109         initialize_configuration_(padstrbuffer(configname,12),
00110                                   &istrlen,&ival,&iok);
00111         const char* status = "successful";
00112         if (!iok) status = "failed";
00113         MSG("EvtKin",Msg::kWarning)
00114             << status << " Config '" << configname
00115             << "' version " << configversion << endl;
00116 
00117         if (gotModels) {
00118             bool success = true;
00119             Registry::RegistryKey rk = r_models.Key();
00120             const char* keyname;
00121             while ( ( keyname = rk() ) ) {
00122                 std::string valType = r_models.GetType(keyname).name();
00123                 if ( "i" != valType ) {
00124                     MSG("EvtKin",Msg::kWarning)
00125                         << "Models wrong type: " << valType << endl;
00126                 } else {
00127                     istrlen = strlen(keyname);
00128                     ival    = r_models.GetInt(keyname);
00129                     iok     = false;
00130                     model_choice_(padstrbuffer(keyname,16),
00131                                   &istrlen,&ival,&iok);
00132                     if (!iok) {
00133                         success = false;
00134                         MSG("EvtKin",Msg::kWarning)
00135                             << "Model choice failed: " 
00136                             << keyname << " " << ival << endl;
00137                     } // model_choice failed
00138                 } // value right/wrong type
00139             } // loop over model keynames
00140             if (!success) {
00141                 r_models.Print();
00142             }
00143         } // gotModels
00144 
00145         if (gotParams) {
00146             bool success = true;
00147             Registry::RegistryKey rk = r_params.Key();
00148             const char* keyname;
00149             while ( ( keyname = rk() ) ) {
00150                 std::string valType = r_params.GetType(keyname).name();
00151                 if ( "d" != valType ) {
00152                     MSG("EvtKin",Msg::kWarning)
00153                         << "Param wrong type: " << valType << endl;
00154                 } else {
00155                     istrlen = strlen(keyname);
00156                     val     = r_params.GetDouble(keyname);
00157                     set_parameters_(padstrbuffer(keyname,12),&istrlen,&val);
00158                 } // value right/wrong type
00159             } // loop over param keynames
00160             if (!success) {
00161                 r_params.Print();
00162             }
00163         } // got Params
00164 
00165     } // config
00166     print_configuration_();
00167 
00168     int recalcxsec = 0;
00169     r.Get("RecalcXsec",recalcxsec);
00170     if (recalcxsec) calc_xsectable_();
00171 
00172 }

void InterGen_Neugen::Generate ( TParticle &  nu,
TParticle &  tgt 
) [virtual]

Generate an event.

Implements InteractionGenerator.

Definition at line 191 of file InterGen_Neugen.cxx.

References fGenError, fNu, fTgt, generate_nu_event_(), StdHepUtil::getIonA(), StdHepUtil::getIonZ(), GetNumParticles(), Msg::kWarning, and MSG.

00192 {
00193     fGenError = 0;
00194     fNu       = nu;
00195     fTgt      = tgt;
00196 
00197     int   nucode  = fNu.GetPdgCode();
00198     float enu     = fNu.Energy();  // f77 code expects float
00199     int   ipdgtgt = fTgt.GetPdgCode();
00200     int   ia = StdHepUtil::getIonA(ipdgtgt);
00201     int   iz = StdHepUtil::getIonZ(ipdgtgt);
00202 
00203     // at enu=0.105 "Unable to generate event in SCATTERING"
00204     // at enu=0.100 "cross section = 0 in SELECT_INTERACTION" and STOP
00205     // protect ourselves
00206     if (enu < 0.1) {
00207         MSG("EvtKin",Msg::kWarning)
00208             << "InterGen_Neugen::Generate Enu=" << enu 
00209             << " is less than NEUGEN will handle, skip it" << endl;
00210         HEPEVT.nhep = 0;
00211         fGenError = 2;
00212         return;
00213     }
00214 
00215 
00216     // call the fortran subroutine
00217     generate_nu_event_(&nucode,&enu,&ia,&iz);
00218 
00219     if (GetNumParticles() <= 0) fGenError = 1;
00220 
00221 }

int InterGen_Neugen::GetErrorCode (  )  [virtual]

Return the generated event info.

Implements InteractionGenerator.

Definition at line 224 of file InterGen_Neugen.cxx.

References fGenError.

00225 {
00226     return fGenError;
00227 }

TParticle InterGen_Neugen::GetGeneratedParticle ( unsigned int  i  )  [virtual]

Implements InteractionGenerator.

Definition at line 236 of file InterGen_Neugen.cxx.

References fTgt.

00237 {
00238 
00239     // neugen assume neutrino along z direction
00240     // rotate into frame of original neutrino
00241     TLorentzVector p4(HEPEVT.phep[i][0],HEPEVT.phep[i][1],
00242                       HEPEVT.phep[i][2],HEPEVT.phep[i][3]);
00243 
00244     // account for vertex position
00245     TLorentzVector vtx_offset;
00246     fTgt.ProductionVertex(vtx_offset);
00247     TLorentzVector genpos(HEPEVT.vhep[i][0],HEPEVT.vhep[i][1],
00248                           HEPEVT.vhep[i][2],HEPEVT.vhep[i][3]);
00249     TLorentzVector position = genpos + vtx_offset;
00250 
00251     // mother-daughter links are 1-based in fortran
00252     // convert them to 0-based for use in C++
00253     TParticle part(HEPEVT.idhep[i],HEPEVT.isthep[i],
00254                    HEPEVT.jmohep[i][0]-1,HEPEVT.jmohep[i][1]-1,
00255                    HEPEVT.jdahep[i][0]-1,HEPEVT.jdahep[i][1]-1,
00256                    p4,position);
00257     part.SetCalcMass(HEPEVT.phep[i][4]);
00258     return part;                     
00259 }

unsigned int InterGen_Neugen::GetNumParticles (  )  [virtual]

Implements InteractionGenerator.

Definition at line 230 of file InterGen_Neugen.cxx.

Referenced by Generate().

00231 {
00232     return HEPEVT.nhep;
00233 }


Member Data Documentation

Definition at line 51 of file InterGen_Neugen.h.

Referenced by Generate(), and GetErrorCode().

TParticle InterGen_Neugen::fNu [private]

Definition at line 49 of file InterGen_Neugen.h.

Referenced by Generate().

TParticle InterGen_Neugen::fTgt [private]

Definition at line 50 of file InterGen_Neugen.h.

Referenced by Generate(), and GetGeneratedParticle().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1