From 715c28b11c565bd3bb18cfc9b224babe6bcb055f Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Sun, 23 Jan 2011 03:21:58 +0000 Subject: [PATCH] adapt to new model class structure --- src/ctobssim/ctobssim.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index edbb5d3..4ec91d1 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -201,8 +201,33 @@ GPhotons ctobssim::simulate_photons(void) // Load models GModels models(m_infile); - // Simulate photons - GPhotons photons = models.mc(m_area, dir, m_rad, emin, emax, tmin, tmax, m_ran); + // Allocate photons + GPhotons photons; + + // Simulate photons for all sky models + for (int i = 0; i < models.size(); ++i) { + + // Get sky model (NULL if not a sky model) + GModelSky* model = dynamic_cast(models(i)); + + // If we have a sky model then simulate photons + if (model != NULL) { + + // Get photons + GPhotons p = model->mc(m_area, dir, m_rad, emin, emax, tmin, tmax, m_ran); + + // Reserve new space for photons + photons.reserve(photons.size() + p.size()); + + // Add photons to list + for (int k = 0; k < p.size(); ++k) { + p[k].mcid(i); + photons.push_back(p[k]); + } + + } // endif: model was a sky model + + } // endfor: looped over models // Dump simulation results if (logNormal()) { -- libgit2 0.21.4