00001 #include "Sct/OutOfRangeError.h"
00002 #include "TGraphAsymmErrorsStreamer_v1.h"
00003
00004 #include "../RootStreamableAdapter.h"
00005
00007 #include "../TGraphAsymmErrorsFix.h"
00008 #include <TClass.h>
00009
00010 using namespace Sct;
00011
00012 namespace SctData {
00013 namespace IO {
00014
00015
00016 unsigned TGraphAsymmErrorsStreamer_v1::s_version=1;
00017
00018 TGraphAsymmErrorsStreamer_v1::TGraphAsymmErrorsStreamer_v1() throw() {}
00019 bool TGraphAsymmErrorsStreamer_v1::inMap = IOManager::addToMap(TGraphAsymmErrors::Class()->GetName(), auto_ptr<Streamer>(new TGraphAsymmErrorsStreamer_v1()));
00020
00021 void TGraphAsymmErrorsStreamer_v1::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00023 manager.writeImpl(out, ob, "TGraph");
00024 const RootStreamableAdapter& ad = dynamic_cast<const RootStreamableAdapter&>(ob);
00025 TGraphAsymmErrors* g = dynamic_cast<TGraphAsymmErrors*>(ad.getObject());
00026
00027 double* error = g->GetEXhigh();
00028 out.put(error, g->GetN());
00029 error = g->GetEXlow();
00030 out.put(error, g->GetN());
00031
00032 error = g->GetEYhigh();
00033 out.put(error, g->GetN());
00034 error = g->GetEYlow();
00035 out.put(error, g->GetN());
00036 }
00037
00038 void TGraphAsymmErrorsStreamer_v1::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00040 manager.readImpl(in, ob, "TGraph");
00041 RootStreamableAdapter& ad = dynamic_cast<RootStreamableAdapter&>(ob);
00042 TGraphAsymmErrors* g = dynamic_cast<TGraphAsymmErrors*>(ad.getObject());
00043
00044 double* exl=0, *exh=0, *eyl=0, *eyh=0;
00045 size_t size = 0;
00046 in.get(&exh, size);
00047 if ((int) size != g->GetN())
00048 throw OutOfRangeError<int>("TGraphAsymmErrors A", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00049
00050 in.get(&exl, size);
00051 if ((int) size != g->GetN())
00052 throw OutOfRangeError<int>("TGraphAsymmErrors B", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00053
00054 in.get(&eyh, size);
00055 if ((int) size != g->GetN())
00056 throw OutOfRangeError<int>("TGraphAsymmErrors C", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00057
00058 in.get(&eyl, size);
00059 if ((int) size != g->GetN())
00060 throw OutOfRangeError<int>("TGraphAsymmErrors D", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00061
00062 for (int i=0; i<g->GetN(); ++i) {
00063 g->SetPointError(i, exl[i], exh[i], eyl[i], eyh[i]);
00064 }
00065
00066 delete [] exl;
00067 delete [] exh;
00068 delete [] eyl;
00069 delete [] eyh;
00070 }
00071
00072
00073 shared_ptr<Streamable> TGraphAsymmErrorsStreamer_v1::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00074 shared_ptr<Streamable> ad (new RootStreamableAdapter(*new TGraphAsymmErrorsFix()));
00075
00076 read(in, *ad, manager);
00077 return ad;
00078 }
00079 }
00080
00081 }
00082