CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/JetMETCorrections/InterpolationTables/src/DualAxis.cc

Go to the documentation of this file.
00001 #include "JetMETCorrections/InterpolationTables/interface/DualAxis.h"
00002 
00003 #include "Alignment/Geners/interface/binaryIO.hh"
00004 #include "Alignment/Geners/interface/IOException.hh"
00005 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
00006 
00007 namespace npstat {
00008     bool DualAxis::write(std::ostream& of) const
00009     {
00010         unsigned char c = uniform_;
00011         gs::write_pod(of, c);
00012         if (uniform_)
00013             return !of.fail() && u_.classId().write(of) && u_.write(of);
00014         else
00015             return !of.fail() && a_.classId().write(of) && a_.write(of);
00016     }
00017 
00018     DualAxis* DualAxis::read(const gs::ClassId& id, std::istream& in)
00019     {
00020         static const gs::ClassId current(gs::ClassId::makeId<DualAxis>());
00021         current.ensureSameId(id);
00022 
00023         unsigned char c;
00024         gs::read_pod(in, &c);
00025         gs::ClassId clid(in, 1);
00026         if (in.fail())
00027             throw gs::IOReadFailure("In npstat::DualAxis::read: "
00028                                     "input stream failure");
00029         if (c)
00030         {
00031             CPP11_auto_ptr<UniformAxis> axis(UniformAxis::read(clid, in));
00032             return new DualAxis(*axis);
00033         }
00034         else
00035         {
00036             CPP11_auto_ptr<GridAxis> axis(GridAxis::read(clid, in));
00037             return new DualAxis(*axis);
00038         }
00039     }
00040 }