GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HadronTransporter.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6 
7  Costas Andreopoulos <c.andreopoulos \at cern.ch>
8  University of Liverpool
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Sep 15, 2009 - CA
14  IsFake() is no longer available in GHepParticle.Use pdg::IsPseudoParticle()
15  @ Nov 17, 2011 - CA
16  Removed unused GenerateVertex() method. This is handled by another module.
17 
18 */
19 //____________________________________________________________________________
20 
21 #include <cstdlib>
22 
37 
38 using namespace genie;
39 using namespace genie::utils;
40 using namespace genie::constants;
41 
42 //___________________________________________________________________________
44 EventRecordVisitorI("genie::HadronTransporter")
45 {
46 
47 }
48 //___________________________________________________________________________
50 EventRecordVisitorI("genie::HadronTransporter", config)
51 {
52 
53 }
54 //___________________________________________________________________________
56 {
57 
58 }
59 //___________________________________________________________________________
61 {
62  // Return if the neutrino was not scatterred off a nuclear target
63  GHepParticle * nucltgt = evrec->TargetNucleus();
64  if (!nucltgt) {
65  LOG("HadTransp", pINFO)
66  << "No nuclear target found - Hadron transporter exits";
67  return;
68  }
69 
70  // If rescattering is turned off but the interaction was on a nuclear
71  // target then simply transfer the hadrons outside the nucleus inhibiting
72  // any rescattering
73  if(!fEnabled) {
74  LOG("HadTransp", pNOTICE)
75  << "*** Intranuclear rescattering has been turned off";
76  this->TransportInTransparentNuc(evrec);
77  return;
78  }
79 
80  // Use the specified intrsnuclear rescattering model
81  LOG("HadTransp", pINFO) << "Calling the selected hadron transport MC";
83 
84  // Process Event record for the cascade reweight if required:
86 
87  return ;
88 }
89 //___________________________________________________________________________
91 {
92 // Transport all hadrons assuming a transparent nucleus - used when the
93 // realistic hadron transport is tuned off.
94 
95  LOG("HadTransp", pNOTICE)
96  << "Getting the nucleons out of the nucleus as if it was transparent";
97 
98  TObjArrayIter piter(evrec);
99  GHepParticle * p = 0;
100  int icurr=-1;
101 
102  while( (p = (GHepParticle *) piter.Next()) )
103  {
104  icurr++;
105  assert(p);
106 
107  // Check whether the particle needs rescattering, otherwise skip it
108 
109  bool had_in_nuc = (p->Status() == kIStHadronInTheNucleus);
110  if(!had_in_nuc) continue;
111 
112  LOG("HadTransp", pINFO)
113  << "Transporting " << p->Name() << " out of the nuclear target";
114 
115  // move it outside the nucleus
116  GHepParticle * cp = new GHepParticle(*p); // create a clone
117 
118  cp->SetFirstMother(icurr); // clone's mother
119  cp->SetStatus(kIStStableFinalState); // mark it & done with it
120 
121  evrec->AddParticle(*cp); // add it at the event record
122 
123  //LOG("HadronTransporter", pDEBUG) << *evrec;
124  }
125 }
126 //___________________________________________________________________________
128 {
129  Algorithm::Configure(config);
130  this->LoadConfig();
131 }
132 //___________________________________________________________________________
133 void HadronTransporter::Configure(string param_set)
134 {
135  Algorithm::Configure(param_set);
136 
137  Registry * algos = AlgConfigPool::Instance() -> GlobalParameterList() ;
138  Registry r( "HadronTransporter_specific", false ) ;
139 
140  r.Set("HadronTransp-Enable", algos -> GetBool("HadronTransp-Enable") ) ;
141  r.Set("HadronTransp-Model", algos -> GetAlg("HadronTransp-Model") ) ;
142  if( algos->Exists("CascadeReweightAlg") ) {
143  r.Set("CascadeReweightAlg", algos -> GetAlg("CascadeReweightAlg") ) ;
144  }
145 
147 
148  this->LoadConfig();
149 }
150 //___________________________________________________________________________
152 {
153  bool good_config = true ;
154 
155  fHadTranspModel = 0;
156  GetParam("HadronTransp-Enable", fEnabled ) ;
157 
158  LOG("HadTransp", pDEBUG)
159  << "Hadron transport was " << ((fEnabled) ? "" : "not ") << " enabled";
160  if(fEnabled) {
161  RgAlg hadtransp_model ;
162  GetParam( "HadronTransp-Model", hadtransp_model ) ;
163  LOG("HadTransp", pDEBUG)
164  << "Loading the hadron transport model: " << hadtransp_model;
165 
166  fHadTranspModel =
167  dynamic_cast<const EventRecordVisitorI *> ( this -> SubAlg("HadronTransp-Model") );
168 
169  if(!fHadTranspModel){
170  good_config = false ;
171  LOG("HadronTransporter", pERROR) << "The SubAlg HadronTransp-Model is not a XSecAlgorithmI";
172  }
173 
174  // Read optional CascadeReweight EventRecordVisitorI
175  fCascadeReweight = nullptr;
176  if( GetConfig().Exists("CascadeReweightAlg") ) {
177  fCascadeReweight = dynamic_cast<const CascadeReweight *> ( this->SubAlg("CascadeReweightAlg") );
178  if( !fCascadeReweight ) {
179  good_config = false ;
180  LOG("HadronTransporter", pERROR) << "The required CascadeReweightAlg does not exist. AlgID is : " << SubAlg("CascadeReweightAlg")->Id() ;
181  }
182  }
183 
184  if( ! good_config ) {
185  LOG("HadronTransporter", pERROR) << "Configuration has failed.";
186  exit(78) ;
187  }
188  }
189 }
190 //___________________________________________________________________________
191 
192 
void SetFirstMother(int m)
Definition: GHepParticle.h:132
void ProcessEventRecord(GHepRecord *event_rec) const
bool fEnabled
hadron transport enabled?
void TransportInTransparentNuc(GHepRecord *ev) const
#define pERROR
Definition: Messenger.h:59
Defines the EventRecordVisitorI interface. Concrete implementations of this interface use the &#39;Visito...
GHepStatus_t Status(void) const
Definition: GHepParticle.h:64
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
const EventRecordVisitorI * fHadTranspModel
hadron transport MC to use
string Name(void) const
Name that corresponds to the PDG code.
const EventRecordVisitorI * fCascadeReweight
Cascade reweight member.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual void ProcessEventRecord(GHepRecord *event_rec) const =0
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
virtual GHepParticle * TargetNucleus(void) const
Definition: GHepRecord.cxx:293
#define pINFO
Definition: Messenger.h:62
void Configure(const Registry &config)
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:98
void SetStatus(GHepStatus_t s)
Definition: GHepParticle.h:126
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
In this module, the event weight is set depending on the FSI fate. The weights are set depending on t...
virtual void AddParticle(const GHepParticle &p)
Definition: GHepRecord.cxx:499
bool Exists(RgKey key) const
item with input key exists?
Definition: Registry.cxx:563
#define pNOTICE
Definition: Messenger.h:61
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
bool GetBool(xmlDocPtr xml_doc, string node_path)
void Set(RgIMapPair entry)
Definition: Registry.cxx:267
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:39
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345