GENIEGenerator
Loading...
Searching...
No Matches
HadronTransporter.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, 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
38using namespace genie;
39using namespace genie::utils;
40using namespace genie::constants;
41
42//___________________________________________________________________________
44EventRecordVisitorI("genie::HadronTransporter")
45{
46
47}
48//___________________________________________________________________________
50EventRecordVisitorI("genie::HadronTransporter", config)
51{
52
53}
54//___________________________________________________________________________
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";
82 fHadTranspModel->ProcessEventRecord(evrec);
83
84 // Process Event record for the cascade reweight if required:
85 if(fCascadeReweight) fCascadeReweight->ProcessEventRecord(evrec);
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//___________________________________________________________________________
132//___________________________________________________________________________
133void 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
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
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
static AlgConfigPool * Instance()
virtual const Registry & GetConfig(void) const
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
const Algorithm * SubAlg(const RgKey &registry_key) const
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition Algorithm.h:98
In this module, the event weight is set depending on the FSI fate. The weights are set depending on t...
STDHEP-like event record entry that can fit a particle or a nucleus.
string Name(void) const
Name that corresponds to the PDG code.
void SetFirstMother(int m)
void SetStatus(GHepStatus_t s)
GHepStatus_t Status(void) const
GENIE's GHEP MC event record.
Definition GHepRecord.h:45
virtual GHepParticle * TargetNucleus(void) const
virtual void AddParticle(const GHepParticle &p)
const EventRecordVisitorI * fCascadeReweight
Cascade reweight member.
void ProcessEventRecord(GHepRecord *event_rec) const
void Configure(const Registry &config)
void TransportInTransparentNuc(GHepRecord *ev) const
bool fEnabled
hadron transport enabled?
const EventRecordVisitorI * fHadTranspModel
hadron transport MC to use
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
bool Exists(RgKey key) const
item with input key exists?
Definition Registry.cxx:563
void Set(RgIMapPair entry)
Definition Registry.cxx:267
Basic constants.
Simple functions for loading and reading nucleus dependent keys from config files.
Root of GENIE utility namespaces.
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
@ kIStHadronInTheNucleus
Definition GHepStatus.h:37
@ kIStStableFinalState
Definition GHepStatus.h:30