/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/SIO/RunEventMap.cc

Go to the documentation of this file.
00001 #include "SIO/RunEventMap.h"
00002 
00003 //#include "EVENT/LCIO.h"
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 //     std::cout << " *****************RunEventMap::add : " << re.RunNum <<", "<< re.EvtNum 
00026 //            << " this: " << this
00027 //            << *this << std::endl ;
00028 
00029     if( p.second ) {  // if event/run exists don't count as new entry
00030 
00031       if( re.EvtNum > -1 ) 
00032         ++ _nEvt ;
00033       else {
00034         ++ _nRun ;
00035         //      std::cout << " *****************RunEventMap::add : " << re << std::endl ;
00036       }
00037     } else {    // overwrite with new entry
00038       
00039       //      std::cout << " *****************RunEventMap::add - overwriting : " << re << " -> "  <<   (long64) re  <<
00040       //        std::hex <<  "0x" << (long64) re   << std::dec << std::endl ;
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 }

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7