/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DrawGe68EnergySub.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Isolates Ge68 spectrum like EnergyStatsDiff and then isolates smaller peak by subtracting larger gaussian.
00004 # Creats two graphs, one of the fit of the larger peak alone and the other of the resulting smaller peak with fit.
00005 #
00006 #  Usage:
00007 #   nuwa.py DrawEnergySub
00008 
00009 # Load DybPython
00010 from DybPython.DybPythonAlg import DybPythonAlg
00011 from GaudiPython import SUCCESS, FAILURE
00012 from GaudiPython import gbl
00013 from decimal import *
00014 from math import sqrt
00015 import array
00016 
00017 # Make shortcuts to any ROOT classes you want to use
00018 TF1 = gbl.TF1
00019 TCanvas = gbl.TCanvas
00020 gbl.gStyle.SetPalette(1)
00021 gbl.gStyle.SetOptFit(1)
00022 
00023 # Make your algorithm
00024 class DrawEnergyFigsAlg(DybPythonAlg):
00025     "Algorithm to draw figures from the energy statistics file"
00026     def __init__(self,name):
00027         DybPythonAlg.__init__(self,name)
00028         return
00029 
00030     def initialize(self):
00031         status = DybPythonAlg.initialize(self)
00032         if status.isFailure(): return status
00033         self.info("initializing")
00034 
00035         return SUCCESS
00036 
00037     def execute(self):
00038         self.info("executing")
00039         
00040         return SUCCESS
00041         
00042     def finalize(self):
00043         self.info("finalizing")
00044 
00045         canvas = TCanvas()
00046 
00047 
00048         hist=self.stats["/file0/energy/reconEnergy"]
00049         histnosrc=self.stats["/file1/energy/reconEnergy"]
00050 
00051         hist.Sumw2()
00052         histnosrc.Sumw2()
00053 
00054         histfinal=hist.Clone()
00055         histfinal.SetName("nobgEnergyFit")
00056         histfinal.Add(histnosrc,-0.057)
00057 
00058 
00059         peak2 = TF1("m1","gaus",0.8,1.5)
00060         total = TF1("mtotal", "gaus(0) + gaus(3)", 0, 1.5)
00061         histfinal.Fit(peak2,"R")
00062         canvas.SaveAs("nobgEnergyFit1.png")
00063 
00064         histclone=histfinal.Clone()
00065         for iBin in range(0,250):
00066           prevContent = histfinal.GetBinContent(iBin)
00067           prevContent -= peak2.Eval(histfinal.GetBinCenter(iBin))
00068           histclone.SetBinContent(iBin,prevContent)
00069         histfinal = histclone
00070         histfinal.Draw()
00071         histfinal.Fit("gaus","","",0.0,0.85)
00072 
00073         canvas.SaveAs("nobgEnergyFit2.png")
00074 
00075 
00076         
00077         status = DybPythonAlg.finalize(self)
00078         return status
00079 
00080 
00081 #####  Job Configuration for nuwa.py ########################################
00082 
00083 def configure():
00084     from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00085     statsSvc = StatisticsSvc()
00086     statsSvc.Input ={"file0":"stats_run.root", "file1":"100000StatsnoSRC.root"}
00087     return
00088 
00089 def run(app):
00090     '''
00091     Configure and add an algorithm to job
00092     '''
00093     app.ExtSvc += ["StatisticsSvc"]
00094     energyFigsAlg = DrawEnergyFigsAlg("MyEnergyFigs")
00095     app.addAlgorithm(energyFigsAlg)
00096     pass
00097 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:54:37 for Calibration by doxygen 1.7.4