Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-19 09:18:45

0001 #!/usr/bin/env python3
0002 from ROOT import TCanvas, TFile, TH1F,TH2F,TH3F, TF1, TGraph, gROOT
0003 import os
0004 import re
0005 import glob
0006 
0007 gROOT.SetBatch(True)
0008 
0009 dirName = '/sphenix/user/shulga/Work/IBF/DistortionMap/Files/'
0010 bXs = [1508071, 3016509, 4524020, 6032112, 7540028, 9048092, 10556072, 12064371, 13572143, 15080178, 16588072, 18096105]
0011 #bXs = [18096105]
0012 h_names = ['_h_hits','_h_R','_h_DC_E']
0013 for i in range(30):
0014     h_names.append('_h_SC_ibf_{}'.format(i))
0015     h_names.append('_h_SC_prim_{}'.format(i))
0016 
0017 
0018 for ib,bX in enumerate(bXs):
0019     print(bX)
0020     name = 'mdc2_ADCBins_UseFieldMaps_hist_G4Hits_sHijing_0-12fm_bX{}*'.format(bX)
0021     outputName = '/sphenix/user/shulga/Work/IBF/DistortionMap/Files/Summary_hist_mdc2_UseFieldMaps_AA_event_{}_bX{}.root'.format(ib,bX)
0022 
0023     filePattern = dirName+name
0024     files = sorted(glob.glob(filePattern))
0025     #print(files)
0026     #n=0
0027     histos = []
0028     for n,file in enumerate(files):
0029         #h=0
0030         f = TFile.Open(file)
0031         for h,h_name in enumerate(h_names):
0032             newName=h_name+'_{}'.format(n)
0033             if n==0:
0034                 newName=h_name
0035             hist = f.Get(h_name).Clone(h_name)
0036             if n==0:
0037                 histos.append(hist)
0038             if n>0:
0039                 histos[h].Add(hist) 
0040             hist.SetDirectory(0)
0041             #h+=1
0042         #n+=1
0043 
0044     outfile = TFile(outputName, "RECREATE")
0045     for hist in histos:
0046         hist.Sumw2(False)
0047         hist.Write()
0048     outfile.Write()
0049     outfile.Close()
0050 #print(files)
0051 #
0052 #