TGraphAsymmErrorsStreamer_v1.cpp

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

Generated on Mon Feb 6 14:01:35 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6