def test08ElementAccess(self): """Test access to elements in matrix and array objects.""" n = 3 v = TVectorF(n) m = TMatrixD(n, n) for i in range(n): self.assertEqual(v[i], 0.0) for j in range(n): self.assertEqual(m[i][j], 0.0)
def test3TVector(self): """Test TVector2/3/T behavior""" import math N = 51 # TVectorF is a typedef of floats v = TVectorF(N) for i in range(N): v[i] = i * i for j in v: self.assertEqual(round(v[int(math.sqrt(j) + 0.5)] - j, 5), 0)
nevents_without_btag_sf = hist_without_btag_sf.GetBinContent( i_bin) if n_jets == n_jets_max: for i in range(i_bin + 1, hist_with_btag_sf.GetNbinsX() + 1): # include overflow nevents_with_btag_sf += hist_with_btag_sf.GetBinContent( i) nevents_without_btag_sf += hist_without_btag_sf.GetBinContent( i) # print nevents_with_btag_sf # print nevents_without_btag_sf # print nevents_with_btag_sf / nevents_without_btag_sf sf = nevents_without_btag_sf / nevents_with_btag_sf print sf sf_outfile.cd() sf_name = '_'.join( ['sf', year, channel, process, 'njets' + str(n_jets)]) sf_vec = TVectorF(1) # float vector with one element sf_vec[0] = sf # map.Add(TString(sf_name), sf) sf_outfile.WriteObject(sf_vec, sf_name) # sf_outfile.cd() # sf_outfile.WriteObject(map, 'map') sf_outfile.Close()