Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
genie::supernova::GSNovaModel Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/GenieSNova/src/GSNovaModel.h"

Inheritance diagram for genie::supernova::GSNovaModel:
genie::supernova::GeneratorBase

Public Member Functions

 GSNovaModel (std::string filename)
 
void ReadModel (std::string filename)
 
const genie::PDGCodeListPdgList ()
 Get model features. More...
 
void AddGenerator (GFluxGenerator)
 Populate model with generators. More...
 
void GenerateNext (GenParticle &)
 Generate next particle. More...
 
bool End ()
 Check if there are no active generators left. More...
 
void Reload ()
 Reactivate all generators. More...
 
void SetEmin (double Emin)
 
void SetProbScale (double Scale)
 
const std::list< GFluxGeneratorActiveGenerators ()
 Access to generators. More...
 
const double GetIntegral () const
 
const Limits< double > & LimsE () const
 
const Limits< double > & LimsT () const
 

Protected Member Functions

std::list< GFluxGenerator >::iterator SelectGenerator ()
 

Protected Attributes

genie::PDGCodeList fPdgList
 
std::list< GFluxGeneratorfGeneratorsActive
 list of particles More...
 
std::list< GFluxGeneratorfGeneratorsDead
 
double fIntegral
 
Limits< double > fLimsE
 Total flux integral. More...
 
Limits< double > fLimsT
 Energy range. More...
 

Detailed Description

Definition at line 17 of file GSNovaModel.h.

Constructor & Destructor Documentation

GSNovaModel::GSNovaModel ( std::string  filename)

Definition at line 18 of file GSNovaModel.cxx.

References ReadModel().

19 {
20  this->ReadModel(filename);
21 }
string filename
Definition: shutoffs.py:106
void ReadModel(std::string filename)
Definition: GSNovaModel.cxx:42

Member Function Documentation

const std::list< GFluxGenerator > GSNovaModel::ActiveGenerators ( )

Access to generators.

Definition at line 188 of file GSNovaModel.cxx.

References fGeneratorsActive.

Referenced by genie::supernova::GFluxSNova::Charge().

188  {
189  return fGeneratorsActive;
190 }
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
void GSNovaModel::AddGenerator ( GFluxGenerator  generator)

Populate model with generators.

Definition at line 86 of file GSNovaModel.cxx.

References fGeneratorsDead, genie::supernova::GeneratorBase::fIntegral, genie::supernova::GeneratorBase::fLimsE, genie::supernova::GeneratorBase::fLimsT, fPdgList, genie::supernova::GeneratorBase::GetIntegral(), genie::supernova::GeneratorBase::LimsE(), genie::supernova::GeneratorBase::LimsT(), LOG, genie::supernova::GFluxGenerator::PDG(), pNOTICE, genie::PDGCodeList::push_back(), and genie::supernova::Limits< T >::Update().

Referenced by ReadModel().

87 {
88  // Add new generator to the model
89  LOG("GSNovaModel", pNOTICE) << "Add generator for pdg=" << generator.PDG()
90  << ", integral=" << generator.GetIntegral();
91 
92  //update generators list
93  fGeneratorsDead.push_back(generator);
94 
95  //update integral
96  fIntegral += generator.GetIntegral();
97 
98  //update pdg list
99  fPdgList.push_back(generator.PDG());
100 
101  //update limits
102  fLimsE.Update(generator.LimsE());
103  fLimsT.Update(generator.LimsT());
104 }
genie::PDGCodeList fPdgList
Definition: GSNovaModel.h:45
const Limits< double > & LimsT() const
std::list< GFluxGenerator > fGeneratorsDead
Definition: GSNovaModel.h:49
const Limits< double > & LimsE() const
const double GetIntegral() const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
Limits< double > fLimsE
Total flux integral.
Definition: GeneratorBase.h:22
Limits< double > fLimsT
Energy range.
Definition: GeneratorBase.h:23
void Update(const Limits< T > &other)
Definition: Limits.h:25
#define pNOTICE
Definition: Messenger.h:62
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:67
bool GSNovaModel::End ( void  )

Check if there are no active generators left.

Definition at line 140 of file GSNovaModel.cxx.

References fGeneratorsActive.

Referenced by genie::supernova::GFluxSNova::End(), and GenerateNext().

141 {
142  return fGeneratorsActive.empty();
143 }
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
void GSNovaModel::GenerateNext ( GenParticle particle)

Generate next particle.

Definition at line 108 of file GSNovaModel.cxx.

References ana::assert(), End(), fGeneratorsActive, fGeneratorsDead, LOG, pDEBUG, pNOTICE, and SelectGenerator().

Referenced by genie::supernova::GFluxSNova::GenerateNext().

109 {
110  // Generate next particle and fill it to the argument
111  if (this->End()) return;
112 
113  // (Randomly) select from which generator we will take the input
114  auto itGenerator = this->SelectGenerator();
115  assert (itGenerator != fGeneratorsActive.end());
116 
117  GFluxGenerator& gen =* itGenerator;
118  LOG("GSNovaModel", pDEBUG) << "Using generator [" << gen.PDG() << "],"
119  << "t=" << gen.T()
120  << ",e=" << gen.E();
121 
122  // Fill the generated calues (T,E) to the part
123  gen.FillParticle(particle);
124 
125  //Generate a new particle in this generator
126  gen.GenerateNext();
127  if (gen.End()) {
128  LOG("GSNovaModel", pNOTICE) << "Finishing generator #" << gen.PDG();
129 
130  // Move generator to Dead list
131  fGeneratorsDead.splice(fGeneratorsDead.begin(), fGeneratorsActive, itGenerator);
132  LOG("GSNovaModel", pNOTICE) << fGeneratorsActive.size() << " left";
133  }
134 
135  LOG("GSNovaModel", pDEBUG) << "Done";
136 }
bool End()
Check if there are no active generators left.
std::list< GFluxGenerator > fGeneratorsDead
Definition: GSNovaModel.h:49
std::list< GFluxGenerator >::iterator SelectGenerator()
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
assert(nhit_max >=nhit_nbins)
#define pNOTICE
Definition: Messenger.h:62
#define pDEBUG
Definition: Messenger.h:64
const double GeneratorBase::GetIntegral ( ) const
inherited
const Limits< double > & GeneratorBase::LimsE ( ) const
inherited

Definition at line 22 of file GeneratorBase.cxx.

References genie::supernova::GeneratorBase::fLimsE.

Referenced by AddGenerator(), and genie::supernova::GFluxSNova::MaxEnergy().

23 {
24  return fLimsE;
25 }
Limits< double > fLimsE
Total flux integral.
Definition: GeneratorBase.h:22
const Limits< double > & GeneratorBase::LimsT ( ) const
inherited

Definition at line 29 of file GeneratorBase.cxx.

References genie::supernova::GeneratorBase::fLimsT.

Referenced by AddGenerator().

30 {
31  return fLimsT;
32 }
Limits< double > fLimsT
Energy range.
Definition: GeneratorBase.h:23
const genie::PDGCodeList & GSNovaModel::PdgList ( )

Get model features.

Definition at line 79 of file GSNovaModel.cxx.

References fPdgList.

Referenced by genie::supernova::GFluxSNova::FluxParticles().

80 {
81  return fPdgList;
82 }
genie::PDGCodeList fPdgList
Definition: GSNovaModel.h:45
void GSNovaModel::ReadModel ( std::string  filename)

Definition at line 42 of file GSNovaModel.cxx.

References AddGenerator(), MakeMiniprodValidationCuts::f, compareCafs::histName, ScaleHist(), SetProbScale(), and string.

Referenced by GSNovaModel().

43 {
44  TFile f(filename.data(), "READ");
45  if (!f.IsOpen()) {
46  throw std::runtime_error("Error opening SN model file " + filename);
47  }
48 
49  std::map<int, std::string> histMap = {
50  { 12, "fluence_e" },
51  {-12, "fluence_ae"},
52  { 14, "fluence_x" },
53  {-14, "fluence_ax"}
54  };
55 
56  int histPDG;
58  for(auto& histMapEntry: histMap){
59  histPDG = histMapEntry.first;
60  histName = histMapEntry.second;
61 
62  TH2* hFlux = (TH2*)f.Get(histName.data());
63  if (!hFlux) {
64  throw std::runtime_error("Failed to read histogram \'"
65  + histName
66  + "\' from file \'"
67  + filename + "\'");
68  }
69 
70  this->AddGenerator(GFluxGenerator(histPDG, ScaleHist(hFlux)));
71  }
72 
73  this->SetProbScale(1.0);
74  f.Close();
75 }
string filename
Definition: shutoffs.py:106
TH2 * ScaleHist(TH2 *hist)
Definition: GSNovaModel.cxx:25
void AddGenerator(GFluxGenerator)
Populate model with generators.
Definition: GSNovaModel.cxx:86
void SetProbScale(double Scale)
enum BeamMode string
void GSNovaModel::Reload ( )

Reactivate all generators.

Definition at line 147 of file GSNovaModel.cxx.

References fGeneratorsActive, fGeneratorsDead, LOG, and pDEBUG.

Referenced by SetProbScale().

148 {
149  // Move all generators to active state
151 
152  // Reload all generators
153  for (auto &gen: fGeneratorsActive) {
154  LOG("GSNovaModel", pDEBUG) << "Reloading generator " << gen.PDG();
155  gen.Reload();
156  gen.GenerateNext();
157  }
158 }
std::list< GFluxGenerator > fGeneratorsDead
Definition: GSNovaModel.h:49
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
#define pDEBUG
Definition: Messenger.h:64
std::list< GFluxGenerator >::iterator GSNovaModel::SelectGenerator ( )
protected

Definition at line 194 of file GSNovaModel.cxx.

References compare(), fGeneratorsActive, LOG, and pDEBUG.

Referenced by GenerateNext().

195 {
196  // For timed distribution: select the earliest particle in time
197  LOG("GSNovaModel", pDEBUG) << "Select from " << fGeneratorsActive.size() << " active generators";
198 
199  return std::min_element(fGeneratorsActive.begin(), fGeneratorsActive.end(), compare);
200 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
bool compare(const GFluxGenerator &g1, const GFluxGenerator &g2)
#define pDEBUG
Definition: Messenger.h:64
void GSNovaModel::SetEmin ( double  Emin)

Definition at line 162 of file GSNovaModel.cxx.

References fGeneratorsActive.

163 {
164  for (auto& gen: fGeneratorsActive) gen.SetEmin(Emin);
165 }
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
void GSNovaModel::SetProbScale ( double  Scale)

Definition at line 169 of file GSNovaModel.cxx.

References fGeneratorsActive, fGeneratorsDead, LOG, pNOTICE, Reload(), and scale.

Referenced by genie::supernova::GFluxSNova::Charge(), and ReadModel().

170 {
171  LOG("GSNovaModel", pNOTICE) << "Set Probability scale:" << scale;
172 
173  for (auto& gen: fGeneratorsDead) gen.SetProbScale(scale);
174  for (auto& gen: fGeneratorsActive) gen.SetProbScale(scale);
175 
176  this->Reload();
177 }
std::list< GFluxGenerator > fGeneratorsDead
Definition: GSNovaModel.h:49
Double_t scale
Definition: plot.C:25
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
std::list< GFluxGenerator > fGeneratorsActive
list of particles
Definition: GSNovaModel.h:48
void Reload()
Reactivate all generators.
#define pNOTICE
Definition: Messenger.h:62

Member Data Documentation

std::list<GFluxGenerator> genie::supernova::GSNovaModel::fGeneratorsActive
protected

list of particles

Flux containers

Definition at line 48 of file GSNovaModel.h.

Referenced by ActiveGenerators(), End(), GenerateNext(), Reload(), SelectGenerator(), SetEmin(), and SetProbScale().

std::list<GFluxGenerator> genie::supernova::GSNovaModel::fGeneratorsDead
protected

Definition at line 49 of file GSNovaModel.h.

Referenced by AddGenerator(), GenerateNext(), Reload(), and SetProbScale().

double genie::supernova::GeneratorBase::fIntegral
protectedinherited
Limits<double> genie::supernova::GeneratorBase::fLimsE
protectedinherited
Limits<double> genie::supernova::GeneratorBase::fLimsT
protectedinherited
genie::PDGCodeList genie::supernova::GSNovaModel::fPdgList
protected

Definition at line 45 of file GSNovaModel.h.

Referenced by AddGenerator(), and PdgList().


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