00001
00002
00003
00004
00005
00006
00007 #include "SIO_recordManager.h"
00008 #include "SIO_record.h"
00009 #include "SIO_definitions.h"
00010 #include "SIO_functions.h"
00011
00012 #include "CalorimeterSIO.h"
00013 #include <stdio.h>
00014 #include <vector>
00015 using std::vector;
00016
00017
00018 const double cm = 10.0;
00019 const double GeV = 1000.0;
00020
00021
00022 CalorimeterSIO::CalorimeterSIO( const char* i_name, vector<CalorimeterHit> calHits) : SIO_block(i_name), _calHits(calHits)
00023 {
00024
00025 SIO_record* record;
00026 record = SIO_recordManager::get( "LCD_LCDG4_Event" );
00027 if (record != NULL)
00028 record->connect(this);
00029 }
00030
00031
00032 void CalorimeterSIO::clear()
00033
00034 {
00035 _calHits.erase(_calHits.begin(),_calHits.end());
00036 }
00037
00038 void CalorimeterSIO::addHit(CalorimeterHit hit)
00039 {
00040 _calHits.push_back(hit);
00041 }
00042
00043
00044
00045
00046 unsigned int CalorimeterSIO::xfer
00047 (
00048 SIO_stream* stream,
00049 SIO_operation op,
00050 unsigned int version
00051 )
00052 {
00053
00054 if(op || version) ;
00055
00056 unsigned int status;
00057
00058
00059 int nHits = _calHits.size();
00060 status = SIO_DATA( stream, &nHits, 1 );
00061
00062
00063
00064 std::vector<CalorimeterHit>::const_iterator it;
00065 for(it=_calHits.begin(); it!=_calHits.end(); ++it)
00066 {
00067 CalorimeterHit hit = *it;
00068
00069 unsigned int id = hit.id();
00070 SIO_DATA(stream, &id, 1);
00071
00072 float energy = hit.energy()/GeV;
00073 SIO_DATA(stream, &energy, 1);
00074
00075
00076
00077
00078
00079 CalorimeterHit::McEnergyMap mcmap = hit.getMcEnergyMap();
00080 CalorimeterHit::McEnergyMap::const_iterator mapit;
00081 int mapsize = mcmap.size();
00082 SIO_DATA(stream, &mapsize, 1)
00083 for(mapit = mcmap.begin(); mapit!=mcmap.end(); ++mapit)
00084 {
00085
00086 SIO_PNTR(stream, &((*mapit).first) );
00087
00088 float energy = mapit->second / GeV;
00089 SIO_DATA(stream, &energy, 1);
00090
00091 }
00092 }
00093
00094
00095
00096
00097 return( SIO_BLOCK_SUCCESS );
00098 }
00099
00100
00101
00102
00103
00104 #define SIO_CALORIMETER_MAJOR 1
00105 #define SIO_CALORIMETER_MINOR 0
00106
00107 unsigned int CalorimeterSIO::version()
00108 { return( SIO_VERSION_ENCODE( SIO_CALORIMETER_MAJOR,
00109 SIO_CALORIMETER_MINOR ) ); }