File indexing completed on 2025-08-06 08:16:41
0001
0002 from ROOT import TCanvas, TFile, TH1F,TH2F,TH3F, TF1, TGraph, gROOT
0003 import os
0004 import re
0005 import glob
0006 import sys
0007
0008 gROOT.SetBatch(True)
0009
0010 dirName = '/sphenix/user/shulga/Work/TpcPadPlane_phi_coresoftware/coresoftware/calibrations/tpc/fillSpaceChargeMaps/Files/'
0011
0012
0013 h_names = []
0014 for i in range(30):
0015 h_names.append('_h_SC_ibf_{}'.format(i))
0016 h_names.append('_h_SC_prim_{}'.format(i))
0017
0018
0019
0020 ib = sys.argv[1]
0021 bX = sys.argv[2]
0022
0023
0024 print(bX)
0025 name = 'mdc2_ADCBins_UseFieldMaps_hist_G4Hits_sHijing_0-12fm_bX{}*'.format(bX)
0026 outputName = './Files/Summary_hist_mdc2_UseFieldMaps_AA_event_{}_bX{}_new.root'.format(ib,bX)
0027
0028 filePattern = dirName+name
0029 files = sorted(glob.glob(filePattern))
0030
0031
0032 histos = []
0033 for n,file in enumerate(files):
0034
0035 f = TFile.Open(file)
0036 print(file)
0037 for h,h_name in enumerate(h_names):
0038 newName=h_name+'_{}'.format(n)
0039 if n==0:
0040 newName=h_name
0041
0042 hist = f.Get(h_name).Clone(newName)
0043 if n==0:
0044 histos.append(hist)
0045 if n>0:
0046 histos[h].Add(hist)
0047 hist.SetDirectory(0)
0048
0049
0050
0051 outfile = TFile(outputName, "RECREATE")
0052 for hist in histos:
0053 hist.Sumw2(False)
0054 hist.Write()
0055 outfile.Write()
0056 outfile.Close()
0057
0058
0059
0060 for file in files :
0061 if os.path.exists(file):
0062 os.remove(file)
0063 else:
0064 print("Can not delete the file as it doesn't exist:{}",file)
0065