Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

TGraphAsymmErrorsStreamer.cpp

Go to the documentation of this file.
00001 #include "Sct/OutOfRangeError.h"
00002 #include "TGraphAsymmErrorsStreamer.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 TGraphAsymmErrorsStreamer::TGraphAsymmErrorsStreamer() throw() {}
00016 bool TGraphAsymmErrorsStreamer::inMap = IOManager::addToMap(TGraphAsymmErrors::Class()->GetName(), auto_ptr<Streamer>(new TGraphAsymmErrorsStreamer()));
00017 
00018 void TGraphAsymmErrorsStreamer::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00020     TGraphStreamer::write(out, ob, manager);
00021     const RootStreamableAdapter& ad = dynamic_cast<const RootStreamableAdapter&>(ob);
00022     TGraphAsymmErrors* g = dynamic_cast<TGraphAsymmErrors*>(ad.getObject());
00023 
00024     double* error = g->GetEXhigh();
00025     out.put(error, g->GetN());
00026     error = g->GetEXlow();
00027     out.put(error, g->GetN());
00028 
00029     error = g->GetEYhigh();
00030     out.put(error, g->GetN());
00031     error = g->GetEYlow();
00032     out.put(error, g->GetN());
00033 }
00034 
00035 void TGraphAsymmErrorsStreamer::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00037     TGraphStreamer::read(in, ob, manager);
00038     RootStreamableAdapter& ad = dynamic_cast<RootStreamableAdapter&>(ob);
00039     TGraphAsymmErrors* g = dynamic_cast<TGraphAsymmErrors*>(ad.getObject());
00040 
00041     double* exl=0, *exh=0, *eyl=0, *eyh=0;
00042     size_t size = 0;
00043     in.get(&exh, size);
00044     if ((int) size != g->GetN())
00045         throw OutOfRangeError<int>("TGraphAsymmErrors A", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00046 
00047     in.get(&exl, size);
00048     if ((int) size != g->GetN())
00049         throw OutOfRangeError<int>("TGraphAsymmErrors B", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00050 
00051     in.get(&eyh, size);
00052     if ((int) size != g->GetN())
00053         throw OutOfRangeError<int>("TGraphAsymmErrors C", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00054 
00055     in.get(&eyl, size);
00056     if ((int) size != g->GetN())
00057         throw OutOfRangeError<int>("TGraphAsymmErrors D", __FILE__, __LINE__ ,size, g->GetN(), g->GetN());
00058 
00059     for (int i=0; i<g->GetN(); ++i) {
00060         g->SetPointError(i, exl[i], exh[i], eyl[i], eyh[i]);
00061     }
00062 
00063     delete [] exl;
00064     delete [] exh;
00065     delete [] eyl;
00066     delete [] eyh;
00067 }
00068 
00069 
00070 shared_ptr<Streamable> TGraphAsymmErrorsStreamer::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00071     shared_ptr<Streamable> ad (new RootStreamableAdapter(*new TGraphAsymmErrorsFix()));
00072 
00073     read(in, *ad, manager);
00074     return ad;
00075 }
00076 }
00077 
00078 }
00079 

Generated on Mon Dec 15 19:36:20 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3