Example #1
0
 def _put_th1(self, cursor, name):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 8
     if len(self._fields["_fBuffer"]) != 0:
         raise NotImplementedError
     buff = (
         self._put_tnamed(cursor, name, self._fTitle) +
         self._put_tattline(cursor) + self._put_tattfill(cursor) +
         self._put_tattmarker(cursor) +
         cursor.put_fields(self._format_th1_1, self._fields["_fNcells"]) +
         self._put_taxis(cursor, self._fXaxis) +
         self._put_taxis(cursor, self._fYaxis) +
         self._put_taxis(cursor, self._fZaxis) + cursor.put_fields(
             self._format_th1_2, self._fields["_fBarOffset"],
             self._fields["_fBarWidth"], self._fields["_fEntries"],
             self._fields["_fTsumw"], self._fields["_fTsumw2"],
             self._fields["_fTsumwx"], self._fields["_fTsumwx2"],
             self._fields["_fMaximum"], self._fields["_fMinimum"],
             self._fields["_fNormFactor"]) +
         self._put_tarray(cursor, self._fields["_fContour"]) +
         self._put_tarray(cursor, self._fields["_fSumw2"]) +
         cursor.put_string(self._fields["_fOption"]) +
         self._put_tlist(cursor, self._fields["_fFunctions"]) +
         cursor.put_fields(
             self._format_th1_3,
             self._fields["_fBufferSize"],
             0,  # FIXME: empty fBuffer
             self._fields["_fBinStatErrOpt"],
             self._fields["_fStatOverflows"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #2
0
 def _write(self, context, cursor, name, compression, key, keycursor, util):
     self.util = util
     self.util.set_obj(self)
     copy_cursor = copy(cursor)
     write_cursor = copy(cursor)
     self.keycursor = keycursor
     cursor.skip(self._format_cntvers.size)
     if "TH1" in self._fClassName.decode("utf-8"):
         vers = 3
         buff = self._put_th1(cursor, name) + self._put_tarray(
             cursor, self._valuesarray)
     elif "TH2" in self._fClassName.decode("utf-8"):
         vers = 4
         buff = self._put_th2(cursor, name) + self._put_tarray(
             cursor, self._valuesarray)
     elif "TH3" in self._fClassName.decode("utf-8"):
         vers = 4
         buff = self._put_th3(cursor, name) + self._put_tarray(
             cursor, self._valuesarray)
     elif "TProfile" == self._fClassName.decode("utf-8"):
         vers = 7
         buff = (self._put_th1d(cursor, name) +
                 self._put_tarray(cursor, self._fields["_fBinEntries"]) +
                 cursor.put_fields(
                     self._format_tprofile, self._fields["_fErrorMode"],
                     self._fields["_fYmin"], self._fields["_fYmax"],
                     self._fields["_fTsumwy"], self._fields["_fTsumwy2"]) +
                 self._put_tarray(cursor, self._fields["_fBinSumw2"]))
     elif "TProfile2D" == self._fClassName.decode("utf-8"):
         vers = 8
         buff = (self._put_th2d(cursor, name) +
                 self._put_tarray(cursor, self._fields["_fBinEntries"]) +
                 cursor.put_fields(
                     self._format_tprofile, self._fields["_fErrorMode"],
                     self._fields["_fZmin"], self._fields["_fZmax"],
                     self._fields["_fTsumwz"], self._fields["_fTsumwz2"]) +
                 self._put_tarray(cursor, self._fields["_fBinSumw2"]))
     elif "TProfile3D" == self._fClassName.decode("utf-8"):
         vers = 8
         buff = (self._put_th3d(cursor, name) +
                 self._put_tarray(cursor, self._fields["_fBinEntries"]) +
                 cursor.put_fields(
                     self._format_tprofile, self._fields["_fErrorMode"],
                     self._fields["_fTmin"], self._fields["_fTmax"],
                     self._fields["_fTsumwt"], self._fields["_fTsumwt2"]) +
                 self._put_tarray(cursor, self._fields["_fBinSumw2"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     givenbytes = copy_cursor.put_fields(self._format_cntvers, cnt,
                                         vers) + buff
     uproot3.write.compress.write(context, write_cursor, givenbytes,
                                  compression, key, keycursor)
Example #3
0
 def _put_tlist(self, cursor, values):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 5
     buff = b""
     givenbytes = (self._put_tobject(cursor) + cursor.put_string(b"") +
                   cursor.put_fields(self._format_tlist1, len(values)))
     for value in values:
         buff += self.util.put_objany(cursor, (value, "TObjString"),
                                      self.keycursor)
         buff += cursor.put_fields(self._format_tlist2, 0)
         buff += b""  # cursor.bytes(source, n)
     givenbytes += buff
     length = len(givenbytes) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt,
                                   vers) + givenbytes
Example #4
0
 def _put_taxis(self, cursor, axis):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 10
     buff = (
         self._put_tnamed(cursor, axis["_fName"], axis["_fTitle"]) +
         self._put_tattaxis(cursor, axis) +
         cursor.put_fields(self._format_taxis_1, axis["_fNbins"],
                           axis["_fXmin"], axis["_fXmax"]) +
         self._put_tarray(cursor, axis["_fXbins"]) + cursor.put_fields(
             self._format_taxis_2, axis["_fFirst"], axis["_fLast"],
             axis["_fBits2"], axis["_fTimeDisplay"]) +
         cursor.put_string(axis["_fTimeFormat"]) + self.util.put_objany(
             cursor, (axis["_fLabels"], "THashList"), self.keycursor) +
         self.util.put_objany(cursor,
                              (axis["_fModLabs"], "TList"), self.keycursor))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #5
0
 def _put_tattfill(self, cursor):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 2
     buff = (cursor.put_fields(self._format_tattfill,
                               self._fields["_fFillColor"],
                               self._fields["_fFillStyle"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #6
0
 def _put_th2(self, cursor, name):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 5
     buff = (self._put_th1(cursor, name) + cursor.put_fields(
         self._format_th2_1, self._fields["_fScalefactor"],
         self._fields["_fTsumwy"], self._fields["_fTsumwy2"],
         self._fields["_fTsumwxy"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #7
0
 def _put_th3(self, cursor, name):
     vers = 6
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     buff = (self._put_th1(cursor, name) +
             self._put_tatt3d(cursor) + cursor.put_fields(
                 self._format_th3_1, self._fields["_fTsumwy"],
                 self._fields["_fTsumwy2"], self._fields["_fTsumwxy"],
                 self._fields["_fTsumwz"], self._fields["_fTsumwz2"],
                 self._fields["_fTsumwxz"], self._fields["_fTsumwyz"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #8
0
 def _put_tattaxis(self, cursor, axis):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 4
     buff = (cursor.put_fields(self._format_tattaxis, axis["_fNdivisions"],
                               axis["_fAxisColor"], axis["_fLabelColor"],
                               axis["_fLabelFont"], axis["_fLabelOffset"],
                               axis["_fLabelSize"], axis["_fTickLength"],
                               axis["_fTitleOffset"], axis["_fTitleSize"],
                               axis["_fTitleColor"], axis["_fTitleFont"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot3.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Example #9
0
 def _put_tarray(self, cursor, values):
     return cursor.put_fields(self._format_tarray,
                              values.size) + cursor.put_array(values)
Example #10
0
 def _put_tobject(self, cursor):
     return cursor.put_fields(self._format_tobject1, 1, 0,
                              numpy.uint32(0x03000000))