Exemple #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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #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) | uproot.const.kByteCountMask
     givenbytes = copy_cursor.put_fields(self._format_cntvers, cnt,
                                         vers) + buff
     uproot.write.compress.write(context, write_cursor, givenbytes,
                                 compression, key, keycursor)
Exemple #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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + givenbytes
Exemple #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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #6
0
 def put_tleafS(self, cursor):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 1
     fMinimum = 0
     fMaximum = 0
     buff = self.put_tleaf(cursor) + cursor.put_fields(self._format_tleafS1, fMinimum, fMaximum)
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #7
0
 def put_rootiofeatures(self, cursor):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 0
     fIOBits = 0
     cursor.skip(4)
     buff = b"\x1a\xa1/\x10" + cursor.put_fields(self._format_rootiofeatures, fIOBits)
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #8
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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #9
0
 def write(self, cursor):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 13
     buff = (
         self.put_tnamed(cursor,
                         self.name,
                         self.nametitle,
                         hexbytes=numpy.uint32(0x03400000)) +
         self.put_tattfill(cursor) + cursor.put_fields(
             self._format_tbranch1, self.fields["_fCompress"],
             self.fields["_fBasketSize"], self.fields["_fEntryOffsetLen"],
             self.fields["_fWriteBasket"], self.fields["_fEntryNumber"]) +
         self.put_rootiofeatures(cursor) + cursor.put_fields(
             self._format_tbranch2, self.fields["_fOffset"],
             self.fields["_fMaxBaskets"], self.fields["_fSplitLevel"],
             self.fields["_fEntries"], self.fields["_fFirstEntry"],
             self.fields["_fTotBytes"], self.fields["_fZipBytes"]) +
         self.put_tobjarray(
             cursor, self.fields["_fBranches"], classname="TBranch") +
         self.put_tobjarray(cursor,
                            self.fields["_fLeaves"][0],
                            classname=self.fields["_fLeaves"][1]) +
         #self.put_tobjarray(cursor, self.fields["fBaskets"]) +
         b"@\x00\x00\x15\x00\x03\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
     )
     cursor.skip(
         len(b"@\x00\x00\x15\x00\x03\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
             ))
     buff += (b"\x01")
     cursor.skip(len(b"\x01"))
     buff += (cursor.put_array(self.fields["_fBasketBytes"]) + b"\x01")
     cursor.skip(len(b"\x01"))
     buff += (cursor.put_array(self.fields["_fBasketEntry"]) + b"\x01")
     cursor.skip(len(b"\x01"))
     buff += (cursor.put_array(self.fields["_fBasketSeek"]) +
              cursor.put_string(self.fields["_fFileName"]))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #10
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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #11
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) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #12
0
 def put_tleaf(self, cursor):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 2
     fLen = 1
     fLenType = numpy.dtype(self.type).itemsize
     fOffset = 0
     fIsRange = False
     fIsUnsigned = False
     fLeafCount = None
     buff = (self.put_tnamed(cursor, self.name, self.title) +
             cursor.put_fields(self._format_tleaf1, fLen, fLenType, fOffset, fIsRange, fIsUnsigned) +
             self.util.put_objany(cursor, (fLeafCount, "TLeaf"), self.keycursor))
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #13
0
 def put_tobjarray(self, cursor, values, classname, fBits=50331648):
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     buff = self._skiptobj(cursor, fBits)
     vers = 3
     try:
         size = len(values)
     except TypeError:
         size = 1
         values = [values]
     low = 0
     buff += cursor.put_string(b"") + cursor.put_fields(self._format_tobjarray1, size, low)
     for value in values:
         buff += self.util.put_objany(cursor, (value, classname), self.keycursor)
     length = len(buff) + self._format_cntvers.size
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #14
0
 def write(self, cursor):
     if self.compression != None:
         self.fields["_fCompress"] = self.compression.code
     copy_cursor = copy(cursor)
     cursor.skip(self._format_cntvers.size)
     vers = 13
     buff = (self.put_tnamed(cursor, self.name, self.nametitle, hexbytes=numpy.uint32(0x03400000)) +
             self.put_tattfill(cursor))
     self.branch_compress_cursor = copy(cursor)
     buff += (cursor.put_fields(self._format_tbranch11,
                               self.fields["_fCompress"],
                               self.fields["_fBasketSize"],
                               self.fields["_fEntryOffsetLen"]))
     self._writebasket_cursor = copy(cursor)
     buff += (cursor.put_fields(self._format_tbranch12,
                                self.fields["_fWriteBasket"],
                                self.fields["_fEntryNumber"]) +
             self.put_rootiofeatures(cursor) +
             cursor.put_fields(self._format_tbranch21,
                               self.fields["_fOffset"],
                               self.fields["_fMaxBaskets"],
                               self.fields["_fSplitLevel"]))
     self._fentries_cursor = copy(cursor)
     buff += (cursor.put_fields(self._format_fentries, self.fields["_fEntries"]))
     buff += cursor.put_fields(self._format_tbranch22, self.fields["_fFirstEntry"])
     self._tbranch_size_cursor = copy(cursor)
     buff += (cursor.put_fields(self._format_branch_size,
                               self.fields["_fTotBytes"],
                               self.fields["_fZipBytes"]) +
             self.put_tobjarray(cursor, self.fields["_fBranches"], classname="TBranch") +
             self.put_tobjarray(cursor, self.fields["_fLeaves"][0], classname=self.fields["_fLeaves"][1]) +
             cursor.put_data(self.fields["_fBaskets"]))
     buff += b"\x01"
     cursor.skip(len(b"\x01"))
     self._fbasketbytes_cursor = copy(cursor)
     buff += cursor.put_array(self.fields["_fBasketBytes"])
     buff += b"\x01"
     cursor.skip(len(b"\x01"))
     self._fbasketentry_cursor = copy(cursor)
     buff += (cursor.put_array(self.fields["_fBasketEntry"]) + b"\x01")
     cursor.skip(len(b"\x01"))
     self._fbasketseek_cursor = copy(cursor)
     buff += (cursor.put_array(self.fields["_fBasketSeek"]) + cursor.put_string(self.fields["_fFileName"]))
     length = (len(buff) + self._format_cntvers.size)
     cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
     return copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
Exemple #15
0
 def _skiptobj(self, cursor, fBits):
     version = 1
     buff = cursor.put_fields(self._format_skiptobj1, version)
     fUniqueID = 0
     buff += cursor.put_fields(self._format_skiptobj2, fUniqueID, fBits)
     return buff
Exemple #16
0
 def put_tobject(self, cursor):
     return cursor.put_fields(self._format_tobject1, 1, 0,
                              numpy.uint32(0x03000000))
Exemple #17
0
 def put_tobject(self, cursor, hexbytes):
     return cursor.put_fields(self._format_tobject1, 1, 0, hexbytes)
Exemple #18
0
    def write(self, context, cursor, name, key, keycursor, util):
        copy_cursor = copy(cursor)
        self.tree_write_cursor = copy(cursor)
        self.write_name = name
        self.write_key = key
        self.write_keycursor = keycursor
        self.util = util
        self.util.set_obj(self)

        cursor.skip(self._format_cntvers.size)
        vers = 20

        for branch in self.fields["_fBranches"]:
            branch.util = self.util
            branch.keycursor = self.write_keycursor

        self.fields["_fClusterRangeEnd"] = numpy.array(self.fields["_fClusterRangeEnd"], dtype="int64", copy=False)
        self.fields["_fClusterSize"] = numpy.array(self.fields["_fClusterSize"], dtype="int64", copy=False)
        self.fields["_fIndexValues"] = numpy.array(self.fields["_fIndexValues"], dtype=">f8", copy=False)
        self.fields["_fIndex"] = numpy.array(self.fields["_fIndex"], dtype=">i8", copy=False)

        buff = (self.put_tnamed(cursor, name, self.fTitle, hexbytes=numpy.uint32(0x03000008)) +
                self.put_tattline(cursor) +
                self.put_tattfill(cursor) +
                self.put_tattmarker(cursor))
        self.size_cursor = copy(cursor)
        buff += (cursor.put_fields(self._format_ttree, self.fields["_fEntries"],
                                   self.fields["_fTotBytes"],
                                   self.fields["_fZipBytes"],
                                   self.fields["_fSavedBytes"],
                                   self.fields["_fFlushedBytes"],
                                   self.fields["_fWeight"],
                                   self.fields["_fTimerInterval"],
                                   self.fields["_fScanField"],
                                   self.fields["_fUpdate"],
                                   self.fields["_fDefaultEntryOffsetLen"],
                                   self.fields["_fNClusterRange"],
                                   self.fields["_fMaxEntries"],
                                   self.fields["_fMaxEntryLoop"],
                                   self.fields["_fMaxVirtualSize"],
                                   self.fields["_fAutoSave"],
                                   self.fields["_fAutoFlush"],
                                   self.fields["_fEstimate"]))
        buff += b"\x00"
        cursor.skip(len(b"\x00"))
        buff += cursor.put_array(self.fields["_fClusterRangeEnd"])
        buff += b"\x00"
        cursor.skip(len(b"\x00"))
        buff += (cursor.put_array(self.fields["_fClusterSize"]))
        buff += (self.put_rootiofeatures(cursor) +
                 self.put_tobjarray(cursor, self.fields["_fBranches"], "TBranch", fBits=50348032))
        if self.fields["_fBranches"] == []:
            buff += self.put_tobjarray(cursor, self.fields["_fLeaves"], "TLeaf")
        else:
            buff += self.put_tobjarray(cursor, [self.fields["_fLeaves"][i][0] for i in range(len(self.fields["_fLeaves"]))],
                                       classname=[self.fields["_fLeaves"][i][1] for i in range(len(self.fields["_fLeaves"]))])
        buff += (self.util.put_objany(cursor, (self.fields["_fAliases"], "TList"), self.write_keycursor) +
                 self.put_tarray(cursor, self.fields["_fIndexValues"]) +
                 self.put_tarray(cursor, self.fields["_fIndex"]) +
                 self.util.put_objany(cursor, (self.fields["_fTreeIndex"], "TVirtualIndex"), self.write_keycursor) +
                 self.util.put_objany(cursor, (self.fields["_fFriends"], "TList"), self.write_keycursor) +
                 self.util.put_objany(cursor, (self.fields["_fUserInfo"], "TList"), self.write_keycursor) +
                 self.util.put_objany(cursor, (self.fields["_fBranchRef"], "TBranchRef"), self.write_keycursor))
        length = len(buff) + self._format_cntvers.size
        cnt = numpy.int64(length - 4) | uproot.const.kByteCountMask
        givenbytes = copy_cursor.put_fields(self._format_cntvers, cnt, vers) + buff
        uproot.write.compress.write(context, copy(self.tree_write_cursor), givenbytes, None, key, copy(self.write_keycursor))
Exemple #19
0
 def put_tarray(self, cursor, values):
     return cursor.put_fields(self._format_tarray, values.size) + cursor.put_array(values)