Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:22

0001 #include "JetMETCorrections/InterpolationTables/interface/DualHistoAxis.h"
0002 
0003 #include "Alignment/Geners/interface/binaryIO.hh"
0004 #include "Alignment/Geners/interface/IOException.hh"
0005 #include <memory>
0006 
0007 namespace npstat {
0008   bool DualHistoAxis::write(std::ostream& of) const {
0009     unsigned char c = uniform_;
0010     gs::write_pod(of, c);
0011     if (uniform_)
0012       return !of.fail() && u_.classId().write(of) && u_.write(of);
0013     else
0014       return !of.fail() && a_.classId().write(of) && a_.write(of);
0015   }
0016 
0017   DualHistoAxis* DualHistoAxis::read(const gs::ClassId& id, std::istream& in) {
0018     static const gs::ClassId current(gs::ClassId::makeId<DualHistoAxis>());
0019     current.ensureSameId(id);
0020 
0021     unsigned char c;
0022     gs::read_pod(in, &c);
0023     gs::ClassId clid(in, 1);
0024     if (in.fail())
0025       throw gs::IOReadFailure(
0026           "In npstat::DualHistoAxis::read: "
0027           "input stream failure");
0028     if (c) {
0029       std::unique_ptr<HistoAxis> axis(HistoAxis::read(clid, in));
0030       return new DualHistoAxis(*axis);
0031     } else {
0032       std::unique_ptr<NUHistoAxis> axis(NUHistoAxis::read(clid, in));
0033       return new DualHistoAxis(*axis);
0034     }
0035   }
0036 }  // namespace npstat