Commit 3f7f791d12bd5d0336d6540bca25e2771f939ddf

Authored by L. Tibaldo
1 parent 0adb50d5

debugging

include/GModelSpectralExponential.hpp
... ... @@ -83,8 +83,8 @@ public:
83 83 virtual std::string print(const GChatter& chatter = NORMAL) const;
84 84  
85 85 // Other methods
86   - void exponent(const GModelSpectral& spec);
87   - const GModelSpectral* exponent(void) const;
  86 + void exponent(const GModelSpectral* spec);
  87 + const GModelSpectral* exponent(void) const;
88 88  
89 89 protected:
90 90 // Protected methods
... ... @@ -97,7 +97,7 @@ protected:
97 97 class flux_kern : public GFunction {
98 98 public:
99 99 // Constructor
100   - flux_kern(const GModelSpectral& spec) : m_exp(spec) {}
  100 + flux_kern(const GModelSpectral* spec) : m_exp(spec) {}
101 101  
102 102 // Method
103 103 double eval(const double& x) {
... ... @@ -107,14 +107,14 @@ protected:
107 107 return value;
108 108 }
109 109 protected:
110   - mutable GModelSpectral* m_exp;
  110 + const GModelSpectral* m_exp;
111 111 };
112 112  
113 113 // Class to determine the integral energy flux, derived from flux_kern
114 114 class eflux_kern : public flux_kern {
115 115 public:
116 116 // Constructor
117   - eflux_kern(const GModelSpectral& spec) : flux_kern(spec) {}
  117 + eflux_kern(const GModelSpectral* spec) : flux_kern(spec) {}
118 118  
119 119 // Method
120 120 double eval(const double& x) {
... ... @@ -122,9 +122,10 @@ protected:
122 122 }
123 123 };
124 124  
  125 +
125 126 // Protected members
126 127 std::string m_type; //!< Model type
127   - mutable GModelSpectral* m_exponent; //!< Exponent
  128 + GModelSpectral* m_exponent; //!< Exponent
128 129  
129 130 // MC cache
130 131 mutable GModelSpectralNodes m_mc_spectrum; //!< MC spectrum cache
... ... @@ -159,4 +160,4 @@ std::string GModelSpectralExponential::type(void) const
159 160 return (m_type);
160 161 }
161 162  
162   -#endif /* GMODELSPECTRALMULTIPLICATIVE_HPP */
  163 +#endif /* GMODELSPECTRALEXPONENTIAL_HPP */
... ...
src/model/GModelSpectralExponential.cpp
... ... @@ -41,8 +41,8 @@
41 41 /* __ Constants __________________________________________________________ */
42 42  
43 43 /* __ Globals ____________________________________________________________ */
44   -const GModelSpectralExponential g_spectral_multi_seed;
45   -const GModelSpectralRegistry g_spectral_multi_registry(&g_spectral_multi_seed);
  44 +const GModelSpectralExponential g_spectral_expo_seed;
  45 +const GModelSpectralRegistry g_spectral_expo_registry(&g_spectral_expo_seed);
46 46  
47 47 /* __ Method name definitions ____________________________________________ */
48 48 #define G_MC "GModelSpectralExponential::mc(GEnergy&, GEnergy&, GTime&, "\
... ... @@ -284,30 +284,31 @@ double GModelSpectralExponential::eval(const GEnergy&amp; srcEng,
284 284 * Computes the photon flux of Exponential spectral model
285 285 ***************************************************************************/
286 286 double GModelSpectralExponential::flux(const GEnergy& emin,
287   - const GEnergy& emax) const
  287 + const GEnergy& emax) const
288 288 {
289   - // Initialise flux
290   - double flux = 0.0;
  289 + // Initialise flux
  290 + double flux = 0.0;
291 291  
292   - // Compute only if integration range is valid and exponent are available
293   - if (emin < emax && m_exponent != NULL) {
  292 + // Compute only if integration range is valid and exponent are available
  293 + if (emin < emax && m_exponent != NULL) {
294 294  
295   - // Initialise function to integrate
296   - flux_kern kernel(m_exponent);
  295 + // Initialise function to integrate
  296 + flux_kern kernel(m_exponent);
297 297  
298   - // Initialise integral class with function
299   - GIntegral integral(&kernel);
  298 + // Initialise integral class with function
  299 + GIntegral integral(&kernel);
300 300  
301   - // Set integration precision
302   - integral.eps(1.0e-8);
  301 + // Set integration precision
  302 + integral.eps(1.0e-8);
303 303  
304   - // Calculate integral between emin and emax
305   - flux = integral.romberg(emin.MeV(), emax.MeV());
  304 + // Calculate integral between emin and emax
  305 + flux = integral.romberg(emin.MeV(), emax.MeV());
306 306  
307   - } // endif: integration range was valid
  307 + } // endif: integration range was valid
  308 +
  309 + // Return flux
  310 + return flux;
308 311  
309   - // Return flux
310   - return flux;
311 312 }
312 313  
313 314  
... ... @@ -321,30 +322,31 @@ double GModelSpectralExponential::flux(const GEnergy&amp; emin,
321 322 * Computes the energy flux of Exponential spectral model
322 323 ***************************************************************************/
323 324 double GModelSpectralExponential::eflux(const GEnergy& emin,
324   - const GEnergy& emax) const
  325 + const GEnergy& emax) const
325 326 {
326   - // Initialise eflux
327   - double eflux = 0.0;
  327 + // Initialise eflux
  328 + double eflux = 0.0;
328 329  
329   - // Compute only if integration range is valid and exponent are available
330   - if (emin < emax && m_exponent != NULL) {
  330 + // Compute only if integration range is valid and exponent are available
  331 + if (emin < emax && m_exponent != NULL) {
331 332  
332   - // Initialise function to integrate
333   - eflux_kern kernel(m_exponent);
  333 + // Initialise function to integrate
  334 + eflux_kern kernel(m_exponent);
334 335  
335   - // Initialise integral class with function
336   - GIntegral integral(&kernel);
  336 + // Initialise integral class with function
  337 + GIntegral integral(&kernel);
337 338  
338   - // Set integration precision
339   - integral.eps(1.0e-8);
  339 + // Set integration precision
  340 + integral.eps(1.0e-8);
340 341  
341   - // Calculate integral between emin and emax
342   - eflux = integral.romberg(emin.MeV(), emax.MeV());
  342 + // Calculate integral between emin and emax
  343 + eflux = integral.romberg(emin.MeV(), emax.MeV());
343 344  
344   - } // endif: integration range was valid
  345 + } // endif: integration range was valid
345 346  
346   - // Return flux
347   - return eflux;
  347 + // Return flux
  348 + return eflux;
  349 +
348 350 }
349 351  
350 352  
... ... @@ -411,7 +413,7 @@ void GModelSpectralExponential::read(const GXmlElement&amp; xml)
411 413 GModelSpectral* ptr = registry.alloc(*spec);
412 414  
413 415 // Set spectral component as exponent
414   - exponent(*ptr);
  416 + exponent(ptr);
415 417  
416 418 // Free spectral model
417 419 delete ptr;
... ... @@ -496,20 +498,20 @@ void GModelSpectralExponential::write(GXmlElement&amp; xml) const
496 498 *
497 499 * Set a spectral model as exponent
498 500 ***************************************************************************/
499   -void GModelSpectralExponential::exponent(const GModelSpectral& spec)
  501 +void GModelSpectralExponential::exponent(const GModelSpectral* spec)
500 502 {
501 503 // Set exponent
502   - m_exponent = spec.clone();
  504 + m_exponent = spec->clone();
503 505  
504 506 // Get number of spectral parameters from model
505 507 int npars = m_exponent->size();
506 508  
507 509 // Store pointers to spectral parameters
508 510 m_pars.clear();
509   - for (int ipar = 0; ipar < spec->size(); ++ipar) {
  511 + for (int ipar = 0; ipar < npars; ++ipar) {
510 512  
511 513 // Get model parameter reference
512   - GModelPar& par = spec->operator[](ipar);
  514 + GModelPar& par = m_exponent->operator[](ipar);
513 515  
514 516 // Append model parameter pointer to internal container
515 517 m_pars.push_back(&par);
... ... @@ -520,21 +522,18 @@ void GModelSpectralExponential::exponent(const GModelSpectral&amp; spec)
520 522  
521 523 }
522 524  
523   -
524 525 /***********************************************************************//**
525 526 * @brief Return exponent
526   - *
527   - * @return Pointer to spectral model.
528 527 *
529   - * Returns the exponent of the Exponential spectral model.
  528 + * Returns pointer to exponent spectral model
530 529 ***************************************************************************/
531   -const GModelSpectral* GModelSpectralExponential::component(void) const
  530 +const GModelSpectral* GModelSpectralExponential::exponent(void) const
532 531 {
533   - // Return exponent
  532 + // Returns exponent
534 533 return m_exponent;
  534 +
535 535 }
536 536  
537   -
538 537 /***********************************************************************//**
539 538 * @brief Print Exponential spectral model information
540 539 *
... ... @@ -583,7 +582,7 @@ void GModelSpectralExponential::init_members(void)
583 582 m_type = "Exponential";
584 583  
585 584 // Clear exponent
586   - m_exponent.clear();
  585 + m_exponent->clear();
587 586  
588 587 // Clear MC cache
589 588 m_mc_spectrum.clear();
... ... @@ -613,7 +612,7 @@ void GModelSpectralExponential::copy_members(const GModelSpectralExponential&amp; mo
613 612 m_mc_values = model.m_mc_values;
614 613  
615 614 // Set exponent
616   - m_exponent.clear();
  615 + m_exponent->clear();
617 616 exponent(model.m_exponent);
618 617  
619 618 // Return
... ...