diff --git a/macros/CCEScan/TEMP_Fills.dat b/macros/CCEScan/TEMP_Fills.dat index 0600dbd..994443e 100755 --- a/macros/CCEScan/TEMP_Fills.dat +++ b/macros/CCEScan/TEMP_Fills.dat @@ -1,3 +1 @@ -3108 -3478 -4643 +4856 diff --git a/macros/CCEScan/batch/hadd.py b/macros/CCEScan/batch/hadd.py index f58b465..82fdc61 100644 --- a/macros/CCEScan/batch/hadd.py +++ b/macros/CCEScan/batch/hadd.py @@ -15,18 +15,68 @@ # UTC time (ignore time zone) dec15 = float(calendar.timegm(datetime.strptime('15/12/2015', '%d/%m/%Y').timetuple())) +haddcmd = os.path.expandvars('$ROOTSYS') + '/bin/hadd' def modtime(f): return os.path.getmtime(f) -files_to_hadd = [] -for f in files: - if modtime(f) > dec15 and 'temp_' in f: - files_to_hadd.append(f) +files_to_hadd = {} -#print files_to_hadd -target = temp_dir + '/CCEScan.root' -haddstring = "hadd -f %s %s" % (target, " ".join(files_to_hadd)) +sectors = [] +#with open('%s/TTsectors.dat' % os.path.dirname(pwd), 'rb') as sectsfile: +# for line in sectsfile: +# sectors.append(str(line).strip()) -print haddstring -os.system(haddstring) +with open('%s/ITsectors.dat' % os.path.dirname(pwd), 'rb') as sectsfile: + for line in sectsfile: + sectors.append(str(line).strip()) + +print sectors + +for sector in sectors: + files_to_hadd[sector] = {} + files_to_hadd[sector]['list'] = [] + files_to_hadd[sector]['target'] = temp_dir + '/landauFit_%s.root' % sector + for f in files: + if modtime(f) > dec15 and 'temp_' in f and sector in f and '.root' in f: + files_to_hadd[sector]['list'].append(f) + +sector_files = [] + +def hadd(): + + for sector in sectors: + haddstring = "%s -f %s %s\n" % (haddcmd, files_to_hadd[sector]['target'], " ".join(files_to_hadd[sector]['list'])) + + with open('hadd-%s.sh' % sector, 'wb') as exefile: + exefile.write(haddstring) + os.system('bash hadd-%s.sh' % sector) + os.system('rm hadd-%s.sh' % sector) + + sector_files.append(files_to_hadd[sector]['target']) + #sector_files.extend([files_to_hadd[sector]['target'] for sector in sectors]) + + target = temp_dir + '/CCEScan_temp.root' + with open('haddAll.sh', 'wb') as exefile: + exefile.write('%s -f %s %s\n' % (haddcmd, target, ' '.join(sector_files))) + exefile.write('%s -f %s %s %s\n' % (haddcmd, temp_dir + '/CCEScan_temp_all.root', target, temp_dir + '/CCEScan.root')) + exefile.write('cp %s %s\n' % (temp_dir + '/CCEScan.root', temp_dir + 'CCEScan_BK.root')) + + os.system('bash haddAll.sh') + os.system('rm haddAll.sh') + + +def cleanup(): + with open('cleanup.sh', 'wb') as cleanfile: + for sector in sectors: + for f in files_to_hadd[sector]['list']: + cleanfile.write('rm %s\n' % f) + for f in sector_files: + cleanfile.write('rm %s\n' % f) + + cleanfile.write('rm %s\n' % (temp_dir + '/CCEScan.root')) + cleanfile.write('mv %s %s\n' % (temp_dir + '/CCEScan_temp_all.root', temp_dir + '/CCEScan.root')) + + os.system('bash cleanup.sh') + os.system('rm cleanup.sh') + diff --git a/macros/CCEScan/landauFit b/macros/CCEScan/landauFit index 7f86419..af96281 100755 --- a/macros/CCEScan/landauFit +++ b/macros/CCEScan/landauFit Binary files differ diff --git a/macros/CCEScan/pulseFit b/macros/CCEScan/pulseFit index 338979f..6b01615 100755 --- a/macros/CCEScan/pulseFit +++ b/macros/CCEScan/pulseFit Binary files differ diff --git a/macros/CCEScan/voltageFit_spline b/macros/CCEScan/voltageFit_spline index 8e2a273..5103753 100755 --- a/macros/CCEScan/voltageFit_spline +++ b/macros/CCEScan/voltageFit_spline Binary files differ