00001
00002 #include "lcio/Count.hh"
00003 #include "lcio.h"
00004
00005 #include "IO/LCReader.h"
00006 #include "IO/LCEventListener.h"
00007 #include "IO/LCRunListener.h"
00008
00009 #include "EVENT/LCIO.h"
00010
00011
00012 #include "tools/MicroException.hh"
00013
00014
00015 #include <iostream>
00016 #include <algorithm>
00017
00018 using namespace std ;
00019 using namespace lcio ;
00020
00021
00022
00023 Count::Count(const string _filename):counter(0), compute(false)
00024 {
00025
00026
00027 LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
00028 lcReader->open(_filename);
00029
00030 lcReader->registerLCEventListener( this ) ;
00031 lcReader->readStream() ;
00032 }
00033
00034 Count::~Count(){
00035 }
00036
00037 void Count::processEvent( LCEvent * evt ) {
00038
00039 counter++ ;
00040 compute = true;
00041 }
00042
00043 unsigned int Count::getNumberOfEvent()
00044 {
00045 if ( !compute )
00046 {
00047 throw MicroException("Number of event not compute yet");
00048 }
00049
00050 return counter;
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077