Commit 715c28b11c565bd3bb18cfc9b224babe6bcb055f
1 parent
9fb10f84
adapt to new model class structure
Showing
1 changed file
with
27 additions
and
2 deletions
src/ctobssim/ctobssim.cpp
| @@ -201,8 +201,33 @@ GPhotons ctobssim::simulate_photons(void) | @@ -201,8 +201,33 @@ GPhotons ctobssim::simulate_photons(void) | ||
| 201 | // Load models | 201 | // Load models |
| 202 | GModels models(m_infile); | 202 | GModels models(m_infile); |
| 203 | 203 | ||
| 204 | - // Simulate photons | ||
| 205 | - GPhotons photons = models.mc(m_area, dir, m_rad, emin, emax, tmin, tmax, m_ran); | 204 | + // Allocate photons |
| 205 | + GPhotons photons; | ||
| 206 | + | ||
| 207 | + // Simulate photons for all sky models | ||
| 208 | + for (int i = 0; i < models.size(); ++i) { | ||
| 209 | + | ||
| 210 | + // Get sky model (NULL if not a sky model) | ||
| 211 | + GModelSky* model = dynamic_cast<GModelSky*>(models(i)); | ||
| 212 | + | ||
| 213 | + // If we have a sky model then simulate photons | ||
| 214 | + if (model != NULL) { | ||
| 215 | + | ||
| 216 | + // Get photons | ||
| 217 | + GPhotons p = model->mc(m_area, dir, m_rad, emin, emax, tmin, tmax, m_ran); | ||
| 218 | + | ||
| 219 | + // Reserve new space for photons | ||
| 220 | + photons.reserve(photons.size() + p.size()); | ||
| 221 | + | ||
| 222 | + // Add photons to list | ||
| 223 | + for (int k = 0; k < p.size(); ++k) { | ||
| 224 | + p[k].mcid(i); | ||
| 225 | + photons.push_back(p[k]); | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + } // endif: model was a sky model | ||
| 229 | + | ||
| 230 | + } // endfor: looped over models | ||
| 206 | 231 | ||
| 207 | // Dump simulation results | 232 | // Dump simulation results |
| 208 | if (logNormal()) { | 233 | if (logNormal()) { |