Commit 24ddfae76d308d86f98bcd4bd5e87841c3be2b0f

Authored by Jürgen Knödlseder
1 parent 74c18e2e

Delete any existing event list in ctobssim before appending new simulated events.

ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.1.0 released 3 * Version 1.1.0 released
4 ======================== 4 ========================
5 5
  6 + Delete existing events before simulation in ctobssim (#1663)
6 Add csiactcopy script (#1661) 7 Add csiactcopy script (#1661)
7 ctselect allows usage of non-default events and GTI extensions (#1598) 8 ctselect allows usage of non-default events and GTI extensions (#1598)
8 9
@@ -28,7 +28,11 @@ None @@ -28,7 +28,11 @@ None
28 28
29 5. ctobssim - CTA observation simulation 29 5. ctobssim - CTA observation simulation
30 ---------------------------------------- 30 ----------------------------------------
31 -None 31 +Any existing events in an event list are now removed before starting the
  32 +simulation to enable providing an existing event file on input from which
  33 +only the observation attributes are extracted (for example GTI, ROI, energy
  34 +range, etc.) while the measured events are replaced by the simulated ones
  35 +(#1663).
32 36
33 37
34 6. ctselect - CTA event selection 38 6. ctselect - CTA event selection
src/ctobssim/ctobssim.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctobssim - Observation simulator tool * 2 * ctobssim - Observation simulator tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2011-2015 by Juergen Knoedlseder * 4 + * copyright (C) 2011-2016 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -360,6 +360,14 @@ void ctobssim::run(void) @@ -360,6 +360,14 @@ void ctobssim::run(void)
360 continue; 360 continue;
361 } 361 }
362 362
  363 + // Remove now all events from the event list but keep the
  364 + // event list information such as ROI, Good Time Intervals,
  365 + // energy boundaries. This will also keep additional columns
  366 + // in an event list file.
  367 + GCTAEventList* events =
  368 + static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events()));
  369 + events->remove(0, events->size());
  370 +
363 // Work on a clone of the CTA observation. This makes sure that 371 // Work on a clone of the CTA observation. This makes sure that
364 // any memory allocated for computing (for example a response 372 // any memory allocated for computing (for example a response
365 // cache) is properly de-allocated on exit of this run 373 // cache) is properly de-allocated on exit of this run
@@ -407,7 +415,8 @@ void ctobssim::run(void) @@ -407,7 +415,8 @@ void ctobssim::run(void)
407 // to avoid multiple threads writing simultaneously 415 // to avoid multiple threads writing simultaneously
408 #pragma omp critical 416 #pragma omp critical
409 { 417 {
410 - obs_clone.save(outfile, clobber()); 418 + //obs_clone.save(outfile, clobber());
  419 + obs->save(outfile, clobber());
411 } 420 }
412 421
413 // Dispose events 422 // Dispose events