00001 #include "SIO/RunEventMap.h"
00002
00003
00004
00005 #include <iostream>
00006
00007
00008 namespace SIO {
00009
00010 const int RunEventMap::NPos ;
00011
00012 RunEventMap::RunEventMap() :
00013 _nRun( 0 ) ,
00014 _nEvt( 0 ) {
00015 }
00016
00017 RunEventMap::~RunEventMap(){ }
00018
00019
00020 void RunEventMap::add(const RunEvent& re, long64 pos ) {
00021
00022 std::pair< Map_IT, bool> p =
00023 _map.insert( std::make_pair( (long64) re , pos ) ) ;
00024
00025
00026
00027
00028
00029 if( p.second ) {
00030
00031 if( re.EvtNum > -1 )
00032 ++ _nEvt ;
00033 else {
00034 ++ _nRun ;
00035
00036 }
00037 } else {
00038
00039
00040
00041
00042 p.first->second = pos ;
00043
00044 }
00045 }
00046
00047 long64 RunEventMap::getPosition( long64 re ) {
00048
00049 Map_IT it = _map.find( re ) ;
00050
00051 return ( it != _map.end() ? it->second : NPos ) ;
00052 }
00053
00054
00055 RunEvent RunEventMap::minRunEvent() {
00056
00057 if( _map.empty() )
00058 return RunEvent( -1 , -1 ) ;
00059
00060 return _map.begin()->first ;
00061
00062 }
00063
00064 RunEvent RunEventMap::maxRunEvent() {
00065
00066 if( _map.empty() )
00067 return RunEvent( -1 , -1 ) ;
00068
00069 Map_IT it = _map.end() ;
00070
00071 --it ;
00072
00073 return it->first ;
00074
00075 }
00076
00077 std::ostream & operator<<(std::ostream& os, const RunEventMap& rm ) {
00078
00079 os << " ------- RunEventMap : " << std::endl ;
00080
00081 for( RunEventMap::Map_cIT it = rm.begin() ; it != rm.end() ; ++it ){
00082
00083 os << " " << RunEvent( it->first).RunNum
00084 << ", " << RunEvent( it->first).EvtNum << " : " << it->second << std::endl; }
00085
00086 return os ;
00087 }
00088
00089
00090 }