Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

BdbMinimumInterval.cc

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // File and Version Information
00003 //      $Id: BdbMinimumInterval.cc,v 1.1 2005/09/19 04:29:01 jtinslay Exp $
00004 //
00005 // Description:
00006 //      BdbMinimumInterval.
00007 //      Simple utility to find the minimum validity interval given
00008 //      a vector of validity intervals. Assumes all input intervals
00009 //      contain at least one common time point.
00010 //
00011 // Environment:
00012 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00013 //
00014 // Author List:
00015 //      Jane Tinslay                
00016 //
00017 // Copyright Information:
00018 //      Copyright (C) 2005          SLAC
00019 //
00020 //-----------------------------------------------------------------------------
00021 #include "BaBar/BaBar.hh"
00022 
00023 //-----------------------
00024 // This Class's Header --
00025 //-----------------------
00026 #include "BdbTime/BdbMinimumInterval.hh"
00027 
00028 //-------------------------------
00029 // Collaborating Class Headers --
00030 //-------------------------------
00031 #include "BdbTime/BdbIntervalBase.hh"
00032 #include "BdbTime/BdbTime.hh"
00033 
00034 namespace BdbMinimumInterval {
00035 
00036   BdbIntervalBase findInterval(const vector<BdbIntervalBase>& intervals)
00037   {
00038     BdbIntervalBase result;
00039 
00040     BdbTime begin(BdbTime::minusInfinity);
00041     BdbTime end(BdbTime::plusInfinity);
00042     
00043     vector<BdbIntervalBase>::const_iterator iter = intervals.begin();
00044     
00045     while (iter != intervals.end()) {
00046       if (iter->beginTime() > begin) begin = iter->beginTime();
00047       if (iter->endTime() < end) end = iter->endTime();
00048       iter++;
00049     }
00050     
00051     result.setBeginTime(begin);
00052     result.setEndTime(end);
00053 
00054     return result;
00055   }
00056 }

Generated on Mon Dec 5 18:21:58 2005 for CDB by doxygen1.3-rc3