00001
00002 #include "lcio/AddDifSynchro.hh"
00003 #include "lcio.h"
00004
00005 #include "IO/LCWriter.h"
00006 #include "IO/LCReader.h"
00007 #include "IO/LCEventListener.h"
00008 #include "IO/LCRunListener.h"
00009
00010 #include "EVENT/LCIO.h"
00011 #include "EVENT/TrackerRawData.h"
00012
00013 #include "IMPL/LCEventImpl.h"
00014 #include "IMPL/LCCollectionVec.h"
00015 #include "IMPL/SimCalorimeterHitImpl.h"
00016 #include "IMPL/CalorimeterHitImpl.h"
00017 #include "IMPL/MCParticleImpl.h"
00018 #include "IMPL/TrackerHitImpl.h"
00019 #include "IMPL/TrackImpl.h"
00020 #include "IMPL/ClusterImpl.h"
00021 #include "IMPL/ReconstructedParticleImpl.h"
00022 #include "IMPL/VertexImpl.h"
00023
00024 #include "IMPL/LCFlagImpl.h"
00025 #include "UTIL/LCTOOLS.h"
00026 #include "UTIL/PIDHandler.h"
00027
00028 #include "IMPL/LCRelationImpl.h"
00029
00030 #include "UTIL/LCRelationNavigator.h"
00031
00032 #include <iostream>
00033 #include <algorithm>
00034
00035 using namespace std ;
00036 using namespace lcio ;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 AddDifSynchro::AddDifSynchro(const string _difSyncrhoFileName, const string _outputFile) : nEvent(0) , difSyncrhoFileName(_difSyncrhoFileName){
00056
00057
00058
00059
00060 IO::LCReader* lcReader = IOIMPL::LCFactory::getInstance()->createLCReader() ;
00061 lcReader->open( difSyncrhoFileName ) ;
00062 LCEvent* evt = NULL;
00063
00064 while( (evt = lcReader->readNextEvent()) != 0 )
00065 {
00066 syncEvtId.push_back(evt->getParameters().getIntVal("Dif_syncro" ));
00067 }
00068
00069
00070 lcWrt = LCFactory::getInstance()->createLCWriter() ;
00071
00072 try{
00073 lcWrt->setCompressionLevel( 9 ) ;
00074 lcWrt->open( _outputFile , LCIO::WRITE_NEW ) ;
00075 }
00076
00077 catch(IOException& e){
00078 cout << "[RunEventProcessor()] Can't open file for writing - "
00079 << e.what() << endl ;
00080 exit(1) ;
00081 }
00082
00083 }
00084
00085 AddDifSynchro::~AddDifSynchro(){
00086
00087
00088 cout << endl << "Done !" << endl;
00089 lcWrt->close() ;
00090 delete lcWrt ;
00091 }
00092
00093 void AddDifSynchro::processEvent( LCEvent * evt ) {
00094
00095
00096 nEvent ++ ;
00097 lcWrt->writeEvent( evt ) ;
00098 }
00099
00100 void AddDifSynchro::modifyEvent( LCEvent * evt ) {
00101
00102
00103
00104 int difEvtId = syncEvtId.front();
00105
00106 syncEvtId.pop_front();
00107 evt->parameters().setValue("Dif_syncro",difEvtId ) ;
00108 cout << "Write Event[" << evt->getEventNumber() << "] \r" << flush;
00109
00110 }
00111
00112
00113 void AddDifSynchro::processRunHeader( LCRunHeader* run){
00114
00115
00116 lcWrt->writeRunHeader( run ) ;
00117 cout << "Write Run Header"<< endl;
00118 }
00119
00120 void AddDifSynchro::modifyRunHeader(LCRunHeader* run){;}
00121
00122
00123