Commit ac13e057ee0858bf7c2da2b16a5f70d53c0e416c

Authored by Jürgen Knödlseder
1 parent 063fa825

Set observation identifier in ctobssim::run() method

Showing 1 changed file with 8 additions and 11 deletions
src/ctobssim/ctobssim.cpp
@@ -342,6 +342,13 @@ void ctobssim::run(void) @@ -342,6 +342,13 @@ void ctobssim::run(void)
342 continue; 342 continue;
343 } 343 }
344 344
  345 + // If observation identifier is not yet set then set it now
  346 + if (obs->id().empty()) {
  347 + char buffer[256];
  348 + std::sprintf(buffer, "%6.6d", i + m_startindex);
  349 + obs->id(std::string(buffer));
  350 + }
  351 +
345 // Remove now all events from the event list but keep the 352 // Remove now all events from the event list but keep the
346 // event list information such as ROI, Good Time Intervals, 353 // event list information such as ROI, Good Time Intervals,
347 // energy boundaries. This will also keep additional columns 354 // energy boundaries. This will also keep additional columns
@@ -634,13 +641,13 @@ void ctobssim::get_parameters(void) @@ -634,13 +641,13 @@ void ctobssim::get_parameters(void)
634 m_eslices = (*this)["eslices"].integer(); 641 m_eslices = (*this)["eslices"].integer();
635 m_apply_edisp = (*this)["edisp"].boolean(); 642 m_apply_edisp = (*this)["edisp"].boolean();
636 m_max_rate = (*this)["maxrate"].real(); 643 m_max_rate = (*this)["maxrate"].real();
  644 + m_startindex = (*this)["startindex"].integer();
637 645
638 // Optionally read ahead parameters so that they get correctly 646 // Optionally read ahead parameters so that they get correctly
639 // dumped into the log file 647 // dumped into the log file
640 if (read_ahead()) { 648 if (read_ahead()) {
641 m_outevents = (*this)["outevents"].filename(); 649 m_outevents = (*this)["outevents"].filename();
642 m_prefix = (*this)["prefix"].string(); 650 m_prefix = (*this)["prefix"].string();
643 - m_startindex = (*this)["startindex"].integer();  
644 } 651 }
645 652
646 // Initialise random number generators. We initialise here one random 653 // Initialise random number generators. We initialise here one random
@@ -1676,11 +1683,6 @@ void ctobssim::save_fits(void) @@ -1676,11 +1683,6 @@ void ctobssim::save_fits(void)
1676 // Get CTA observation from observation container 1683 // Get CTA observation from observation container
1677 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]); 1684 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]);
1678 1685
1679 - // Store OBS_ID  
1680 - char buffer[256];  
1681 - std::sprintf(buffer, "%6.6d", m_startindex);  
1682 - obs->id(std::string(buffer));  
1683 -  
1684 // Log filename 1686 // Log filename
1685 log_value(NORMAL, "Event list file", m_outevents); 1687 log_value(NORMAL, "Event list file", m_outevents);
1686 1688
@@ -1733,11 +1735,6 @@ void ctobssim::save_xml(void) @@ -1733,11 +1735,6 @@ void ctobssim::save_xml(void)
1733 // Store output file name in observation 1735 // Store output file name in observation
1734 obs->eventfile(outfile); 1736 obs->eventfile(outfile);
1735 1737
1736 - // Store OBS_ID  
1737 - char buffer[256];  
1738 - std::sprintf(buffer, "%6.6d", i + m_startindex);  
1739 - obs->id(std::string(buffer));  
1740 -  
1741 // Log filename 1738 // Log filename
1742 log_value(NORMAL, "Event list file", outfile); 1739 log_value(NORMAL, "Event list file", outfile);
1743 1740