00001 #include "../DoubleTriggerNoiseTestResult.h"
00002 #include "DoubleTriggerNoiseTestResultStreamer_v3.h"
00003 #include <vector>
00004
00005 using namespace Sct;
00006
00007 namespace SctData {
00008 namespace IO {
00009
00010
00011 unsigned DoubleTriggerNoiseTestResultStreamer_v3::s_version=3;
00012
00013 DoubleTriggerNoiseTestResultStreamer_v3::DoubleTriggerNoiseTestResultStreamer_v3() throw() {
00014 }
00015
00016 bool DoubleTriggerNoiseTestResultStreamer_v3::inMap = IOManager::addToMap("SctData::DoubleTriggerNoiseTestResult", auto_ptr<Streamer>(new DoubleTriggerNoiseTestResultStreamer_v3()));
00017
00018 shared_ptr<Streamable> DoubleTriggerNoiseTestResultStreamer_v3::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00019 shared_ptr<Streamable> ad (new DoubleTriggerNoiseTestResult());
00020 read(in, *ad, manager);
00021 return ad;
00022 }
00023
00024 void DoubleTriggerNoiseTestResultStreamer_v3::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00025
00026 manager.writeImpl(out, ob, "SctData::TestResult");
00027 const DoubleTriggerNoiseTestResult& result=dynamic_cast<const DoubleTriggerNoiseTestResult&>(ob);
00028
00029 float* vals=new float[nChipModule];
00030 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00031 vals[ichip]=result.getPedestalOccupancy(ichip);
00032 }
00033 out.put(vals,nChipModule);
00034
00035 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00036 vals[ichip]=result.getPeakOccupancy(ichip);
00037 }
00038 out.put(vals,nChipModule);
00039
00040 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00041 vals[ichip]=result.getPeakOccupancyBin(ichip);
00042 }
00043 out.put(vals,nChipModule);
00044
00045 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00046 vals[ichip]=result.getPeakRatio(ichip);
00047 }
00048 out.put(vals,nChipModule);
00049 delete[] vals;
00050 }
00051
00052 void DoubleTriggerNoiseTestResultStreamer_v3::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00053 manager.readImpl(in, ob, "SctData::TestResult");
00054 DoubleTriggerNoiseTestResult& result=dynamic_cast<DoubleTriggerNoiseTestResult&>(ob);
00055
00056 float* peaks;
00057 float* peakbins;
00058 float* peakratios;
00059 float* peds;
00060
00061 unsigned length;
00062 in.get(&peds, length);
00063 if (length!=nChipModule) throw StreamCorruptedException("Wrong size of data",__FILE__, __LINE__);
00064 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00065 result.setPedestalOccupancy(ichip, peds[ichip]);
00066 }
00067
00068 in.get(&peaks, length);
00069 if (length!=nChipModule) throw StreamCorruptedException("Wrong size of data",__FILE__, __LINE__);
00070 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00071 result.setPeakOccupancy(ichip, peaks[ichip]);
00072 }
00073
00074 in.get(&peakbins, length);
00075 if (length!=nChipModule) throw StreamCorruptedException("Wrong size of data",__FILE__, __LINE__);
00076 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00077 result.setPeakOccupancyBin(ichip, peakbins[ichip]);
00078 }
00079
00080 in.get(&peakratios, length);
00081 if (length!=nChipModule) throw StreamCorruptedException("Wrong size of data",__FILE__, __LINE__);
00082 for (unsigned ichip=0; ichip<nChipModule; ++ichip){
00083 result.setPeakRatio(ichip, peakratios[ichip]);
00084 }
00085
00086 delete[] peds;
00087 delete[] peaks;
00088 delete[] peakratios;
00089 delete[] peakbins;
00090 }
00091
00092 }
00093 }