FACT++  1.0
bool RescheduleLastSources ( vector< Source > &  obs)

Definition at line 304 of file makeschedule.cc.

References begin, and end.

Referenced by main().

305 {
306  // If observation time is smaller than 40min for the first source
307  // extend it to 40min if zenith angle will not go above 60deg.
308  const int last = obs.size()-1;
309  if (obs.size()<2 || obs[last].duration()>=40./24/60 || obs[last].name=="SLEEP" || obs[last-1].name=="SLEEP")
310  return false;
311 
312  cout << "Last source [" << obs[last].name << "] detected < 40min" << endl;
313 
314  const double obs1_duration = obs[last].end - 40./24/60 - obs[last-1].begin;
315  const double obs0_begin = obs[last].end - 40./24/60;
316 
317  // Check that:
318  // - the duration for the shrunken source obs[1] is still above 40min
319  // - obs[0] does not exceed 60deg at the end of its new window
320  // - obs[0] does not exceed any limit within the new window
321 
322  if (obs1_duration>=40./24/60 && obs[last].IsRangeValid(obs0_begin, obs[last].begin))
323  {
324  obs[last].begin = obs0_begin;
325  obs[last-1].end = obs0_begin;
326 
327  cout << "Last source [" << obs[last].name << "] extended to 40min" << endl;
328 
329  return false;
330  }
331 
332  // Try to remove the last source, check if second source fullfills all limits
333  if (obs[last-1].IsRangeValid(obs[last].begin, obs[last].end))
334  {
335  cout << "Last source [" << obs[last].name << "] removed" << endl;
336 
337  obs[last-1].end = obs[last].end;
338  obs.pop_back();
339 
340  return true;
341  }
342 
343  // Try to remove the second last source, check if the first source fullfills all limits
344  if (obs[last].IsRangeValid(obs[last-1].begin, obs[last-1].end))
345  {
346  cout << "Second last source [" << obs[last-1].name << "] removed" << endl;
347 
348  obs[last].begin = obs[last-1].begin;
349  obs.erase(obs.begin()+obs.size()-2);
350 
351  if (obs.size()==0 || obs[last-1].name!=obs[last-2].name)
352  return true;
353 
354  obs[last-2].end = obs[last-1].end;
355  obs.pop_back();
356 
357  cout << "Combined last two indentical sources [" << obs[last-1].name << "] into one observation" << endl;
358 
359  return true;
360  }
361 
362  cout << "No reschedule possible within limit." << endl;
363 
364  return false;
365 }
double begin
double end

+ Here is the caller graph for this function: