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

Definition at line 244 of file makeschedule.cc.

References begin, and end.

Referenced by main().

245 {
246  if (obs.size()<2 || obs[0].duration()>=40./24/60 || obs[0].name=="SLEEP" || obs[1].name=="SLEEP")
247  return false;
248 
249  cout << "First source [" << obs[0].name << "] detected < 40min" << endl;
250 
251  const double obs1_duration = obs[1].end - obs[0].begin - 40./24/60;
252  const double obs0_end = obs[0].begin + 40./24/60;
253 
254  // Check that:
255  // - the duration for the shrunken source obs[1] is still above 40min
256  // - obs[0] does not exceed 60deg at the end of its new window
257  // - obs[0] does not exceed any limit within the new window
258 
259  if (obs1_duration>=40./24/60 && obs[0].IsRangeValid(obs[0].end, obs0_end))
260  {
261  obs[0].end = obs0_end;
262  obs[1].begin = obs0_end;
263 
264  cout << "First source [" << obs[0].name << "] extended to 40min" << endl;
265 
266  return false;
267  }
268 
269  // Try to remove the first source, check if second source fullfills all limits
270  if (obs[1].IsRangeValid(obs[0].begin, obs[0].end))
271  {
272  cout << "First source [" << obs[0].name << "] removed" << endl;
273 
274  obs[1].begin = obs[0].begin;
275  obs.erase(obs.begin());
276 
277  return true;
278  }
279 
280  // Try to remove the second source, check if the first source fullfills all limits
281  if (obs[0].IsRangeValid(obs[1].begin, obs[1].end))
282  {
283  cout << "Second source [" << obs[1].name << "] removed" << endl;
284 
285  obs[0].end = obs[1].end;
286  obs.erase(obs.begin()+1);
287 
288  if (obs.size()==0 || obs[0].name!=obs[1].name)
289  return true;
290 
291  obs[0].end = obs[1].end;
292  obs.erase(obs.begin()+1);
293 
294  cout << "Combined first two indentical sources [" << obs[0].name << "] into one observation" << endl;
295 
296  return true;
297  }
298 
299  cout << "No reschedule possible within limit." << endl;
300 
301  return false;
302 }
double begin
double end

+ Here is the caller graph for this function: