a.openEB(nof,rootfilename,fileList, p.numberofEntries, histList, 0) # Same procedure, going to results directory. retdir = os.getcwd() print "Current working directory %s" % retdir os.chdir(p.resultPath + '/' + p.folderName + '/') folder = 'itEB'+str(int(time.time())) os.system('mkdir ' + folder) os.chdir(os.getcwd() + '/' + folder +'/') retdir = os.getcwd() print "Directory changed successfully %s" % retdir #fits the histograms and saves 1D in tree if p.splitPhotons == True: htime1, fitdata1 = snf.fitTime(histList1,htime1) htime2, fitdata2 = snf.fitTime(histList2,htime2) a.saveEB(p.runNumber,dataList1,dataList2,histList1,histList2,htime1,htime2,fitdata1,fitdata2) np.save("TimeResponseEB1_0T.npy", dataList1) np.save("TimeResponseEB2_0T.npy", dataList2) #Tacks on histogram to canvas frame and ouputs on canvas a.printPrettyPictureEB(p.runNumber,htime1,htime2) else: htime, fitdata = snf.fitTime(histList,htime) a.saveEB(p.runNumber,dataList,0,histList,0,htime,0,fitdata,0) np.save("TimeResponseEB_0T.npy", dataList) a.printPrettyPictureEB(p.runNumber,htime1,0)
for k in range(0,len(fileList)): if "2015A_EcalNtp_" in fileList[k]: rootFile = rt.TFile.Open(fileList[k]) rTree = rootFile.Get("Tree_Optim") print "successfully cut branch from " + fileList[k] #rootFile.Print("v") #fills the histogram with data # histList = snf.stackTime(rTree,histList, 0, 0, 0) histList1,histList2 = snf.stackTime(rTree,histList1, histList2, 1, 0) rootFile.Close() #fits the histograms # htime = snf.fitTime(histList,htime) htime1 = snf.fitTime(histList1,htime1) htime2 = snf.fitTime(histList2,htime2) ## Getting back to program file ## # Check current working directory. retdir = os.getcwd() print "Current working directory %s" % retdir # Now change the directory os.chdir( startdir + '/result/') # Check current working directory. retdir = os.getcwd() print "Directory changed successfully %s" % retdir
filedata = f.read() f.close() newscript = filedata.replace("p.runNumber", str(p.runNumber)) f = open('fast_restack.py','w') f.write(newscript) f.close() #returns to the result folder made os.chdir(retdir) #saving run info to a numpy file for reference later np.save(p.runNumber+"ClusterRunInfoEE.npy", runinfo) if p.splitPhotons == True: htimep1, hlaserp1, fitdatap1, seedmapp1 = snf.fitTime(histListp1,transListp1,htimep1,hlaserp1,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"pp1_",p.graphs2printEE) htimem1, hlaserm1, fitdatam1, seedmapm1 = snf.fitTime(histListm1,transListm1,htimem1,hlaserm1,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"mp1_",p.graphs2printEE) htimep2, hlaserp2, fitdatap2, seedmapp2 = snf.fitTime(histListp2,transListp2,htimep2,hlaserp2,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"pp2_",p.graphs2printEE) htimem2, hlaserm2, fitdatam2, seedmapm2 = snf.fitTime(histListm2,transListm2,htimem2,hlaserm2,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"mp2_",p.graphs2printEE) #saving all 1D histograms in tree a.saveEE(p.runNumber,dataListp,dataListm,histListp1,histListp2,histListm1,histListm2,transListp1,transListp2,transListm1,transListm2,htimep1,htimep2,htimem1,htimem2,hlaserp1,hlaserp2,hlaserm1,hlaserm2,fitdatap1,fitdatap2,fitdatam1,fitdatam2,seedmapp1,seedmapm1,seedmapp2,seedmapm2) #Tacks on histogram to canvas frame and ouputs on canvas a.printPrettyPictureEE(p.runNumber,htimep1,htimep2,htimem1,htimem2,hlaserp1,hlaserp2,hlaserm1,hlaserm2,seedmapp1,seedmapm1,seedmapp2,seedmapm2) else: htimep,hlaserp,fitdatap,seedmapp = snf.fitTime(histListp,transListp,htimep,hlaserp,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"pc_",p.graphs2printEE) htimem,hlaserm,fitdatam,seedmapm = snf.fitTime(histListm,transListm,htimem,hlaserm,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"mc_",p.graphs2printEE) #saving all 1D histograms in tree a.saveEE(p.runNumber,dataListp,dataListm,histListp,0,histListm,0,transListp,0,transListm,0,htimep,0,htimem,0,hlaserp,0,hlaserm,0,fitdatap,0,fitdatam,0,seedmapp,0,seedmapm,0)
if "2015A_EcalNtp_" in fileList[k]: rootFile = rt.TFile.Open(fileList[k]) rTree = rootFile.Get("Tree_Optim") print "successfully cut branch from " + fileList[k] #rootFile.Print("v") #fills the histogram with data # histListp, histListm = snf.stackTime(rTree,histListp, histListm, 0, 0) histListp1, histListm1, histListp2, histListm2 = snf.stackTime(rTree,histListp1, histListm1, histListp2, histListm2) rootFile.Close() #fits the histograms # htimep = snf.fitTime(histListp,htimep) # htimem = snf.fitTime(histListm,htimem) htimep1 = snf.fitTime(histListp1,htimep1) htimem1 = snf.fitTime(histListm1,htimem1) htimep2 = snf.fitTime(histListp2,htimep2) htimem2 = snf.fitTime(histListm2,htimem2) ## Getting back to program file ## # Check current working directory. retdir = os.getcwd() print "Current working directory %s" % retdir # Now change the directory os.chdir( startdir + '/result/') # Check current working directory. retdir = os.getcwd()
filedata = f.read() f.close() newscript = filedata.replace("p.runNumber", str(p.runNumber)) f = open('fast_restack.py','w') f.write(newscript) f.close() #returns to the result folder made os.chdir(retdir) #saving run info to a numpy file for reference later np.save(p.runNumber+"IndivRunInfoEB.npy", runinfo) #fits the histograms and saves 1D in tree if p.splitPhotons == True: htime1, hlaser1, fitdata1, seedmap1 = snf.fitTime(histList1,transList1,htime1,hlaser1,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"p1_",p.graphs2printEB) htime2, hlaser2, fitdata2, seedmap2 = snf.fitTime(histList2,transList2,htime2,hlaser2,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"p2_",p.graphs2printEB) #saving all 1D and 2D histogram(s) in tree a.saveEB(p.runNumber,dataList1,dataList2,histList1,histList2,transList1,transList2,htime1,htime2,hlaser1,hlaser2,fitdata1,fitdata2,seedmap1,seedmap2) #Tacks on histogram to canvas frame and ouputs on canvas a.printPrettyPictureEB(p.runNumber,htime1,htime2,hlaser1,hlaser2,seedmap1,seedmap2) else: htime, hlaser, fitdata, seedmap = snf.fitTime(histList,transList,htime,hlaser,p.minStat,p.minNormal,p.includeSeedMap,p.manualHitCounterCut,"c_",p.graphs2printEB) a.saveEB(p.runNumber,dataList,0,histList,0,transList,0,htime,0,hlaser,0,fitdata,0,seedmap,0) a.printPrettyPictureEB(p.runNumber,htime,0,hlaser,0,seedmap,0)
for x in range (0,101): for y in range (0,101): histnamep = "time on plus sc (%i,%i)" %(x,y) histtitlep = "time response (ns) for plus crystal (%i,%i)" %(x,y) histnamem = "time on minus sc (%i,%i)" %(x,y) histtitlem = "time response (ns) for minus crystal (%i,%i)" %(x,y) histListp[x][y] = rt.TH1F(histnamep,histtitlep,1000,-30,30) histListm[x][y] = rt.TH1F(histnamem,histtitlem,1000,-30,30) #fills the histogram with data runinfo = a.openEE(rTree,histListp, histListm, 0, 0) #fits the histograms htimep = snf.fitTime(histListp,htimep) htimem = snf.fitTime(histListm,htimem) # Same procedure, going back to directory where results are printed retdir = os.getcwd() print "Current working directory %s" % retdir os.chdir(resultLocation + '/' + p.folderName + '/') folder = 'ctEE' + datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') os.system('mkdir ' + folder) os.chdir(os.getcwd() + '/' + folder +'/') retdir = os.getcwd() print "Directory changed successfully %s" % retdir shutil.copyfile(stardir + '/' + 'unpack.py', retdir + '/unpack.py') #saving run info to a numpy file for reference later np.save(p.runNumber+"RunInfoEEAll.npy", runinfo)