def __init__(self, indir=None, bindir=None, gfile=None, verb="q"): """ This is the default massBinner constructor. Kwargs: indir (string): The full file path to the top directory. bindir (string): The full file path to the directory where the new mass bin directories will be written. gfile (string): The name of the .gamp file to be binned. (/Without/ the .gamp extension.) verb (string): either "q" for quiet or "v" for verbose. """ self.indir = indir self.bindir = bindir self.Control = np.load( os.path.join(sys.argv[1], "GUI", "Control_List.npy")) self.Qfile = os.path.join(sys.argv[1], "QFactor.txt") self.pFfile = os.path.join(sys.argv[1], "events.pf") self.gfile = gfile + ".gamp" self.nfile = gfile + ".npy" self.verb = verb self.gampT = gampTranslator(os.path.join(self.indir, self.gfile)) if not os.path.isfile(os.path.join(self.indir, self.nfile)): if self.verb == "v": print "Starting translator, for", self.gfile self.gampList = self.gampT.translate( os.path.join(self.indir, self.nfile)) elif os.path.isfile(os.path.join(self.indir, self.nfile)): self.gampList = np.load(os.path.join(self.indir, self.nfile)) self.nBins = int(((int(self.Control[3]) - int(self.Control[2])) / int(self.Control[4]))) + 1 self.bins = np.zeros(shape=(self.nBins, int(self.gampList.shape[0])))
def __init__(self, mode, indir, gfile): """ Default generatAlphas constructor Kwargs: mode (int): 8 = p pi+ pi- pi0, 22 = p p+ p-, 24 = p k+ k-, 42 = gamma p --> p Ks Ks (pi+ pi- pi+ pi-) indir (string): Full file path to directory of file gfile (string): File name without .gamp extension. """ self.mode = mode self.indir = indir self.gfile = gfile + ".gamp" self.nfile = gfile + ".npy" f = gfile.partition(".")[0] self.gampT = gampTranslator(os.path.join(self.indir, self.gfile)) if not os.path.isfile(os.path.join(self.indir, self.nfile)): self.gampT.translate(os.path.join(self.indir, self.nfile)) self.gampList = numpy.load(os.path.join(self.indir, self.nfile)) self.alphaName = "alpha" + f + ".txt" self.alphalist = [] if self.mode == "8": self.analyze8() if self.mode == "22": self.analyze22() if self.mode == "24" or self.mode == 24: self.analyze24() if self.mode == "42": self.analyze42() if self.mode == "EtaPiN": self.analyzeEtaPiN
def __init__(self,indir=None,bindir=None,gfile=None,verb="q"): """ This is the default massBinner constructor. Kwargs: indir (string): The full file path to the top directory. bindir (string): The full file path to the directory where the new mass bin directories will be written. gfile (string): The name of the .gamp file to be binned. (/Without/ the .gamp extension.) verb (string): either "q" for quiet or "v" for verbose. """ self.indir = indir self.bindir = bindir self.Control = np.load(os.path.join(sys.argv[1],"GUI","Control_List.npy")) self.Qfile = os.path.join(sys.argv[1],"QFactor.txt") self.pFfile = os.path.join(sys.argv[1],"events.pf") self.gfile = gfile+".gamp" self.nfile = gfile+".npy" self.verb = verb self.gampT = gampTranslator(os.path.join(self.indir,self.gfile)) if not os.path.isfile(os.path.join(self.indir,self.nfile)): if self.verb == "v": print "Starting translator, for",self.gfile self.gampList=self.gampT.translate(os.path.join(self.indir,self.nfile)) elif os.path.isfile(os.path.join(self.indir,self.nfile)): self.gampList=np.load(os.path.join(self.indir,self.nfile)) self.nBins = int(((int(self.Control[3])-int(self.Control[2]))/int(self.Control[4])))+1 self.bins = np.zeros(shape=(self.nBins,int(self.gampList.shape[0])))
def __init__(self,indir,gFile): self.indir = indir self.gfile = gFile+".gamp" self.nfile = gFile+".npy" self.gampT = gampTranslator(os.path.join(self.indir,self.gfile)) if not os.path.isfile(os.path.join(self.indir,self.nfile)): self.gampT.translate(os.path.join(self.indir,self.nfile)) self.gampList=numpy.load(os.path.join(self.indir,self.nfile))
def execute(self, inputGampFile, outputRawGampFile, outputAccGampFile, inputPfFile, outputPFGampFile): """ This function does the bulk of the simulation work for PyPWA simulation. Args: inputGampFile (file): Open file with the flat .gamp events. outputRawGampFile (file): Open file for the events that only pass the weight filter. outputAccGampFile (file): Open file for the events that pass both the weight and p/f filter. inputPfFile (file): Open file with the acceptance of the events (p/f). outputPFGampFile (file): Open file for the events that only pass the p/f filter. """ #igreader=gampReader(gampFile=inputGampFile) #inputGampEvents=igreader.readGamp() gampT = gampTranslator( os.path.join( os.path.split(inputGampFile.name)[0], os.path.split(inputGampFile.name)[1])) if not os.path.isfile( os.path.join( os.path.split(inputGampFile.name)[0], "events.npy")): gampT.translate( os.path.join( os.path.split(inputGampFile.name)[0], "events.npy")) gampList = numpy.load( os.path.join(os.path.split(inputGampFile.name)[0], "events.npy")) pf = inputPfFile pflist = pf.readlines() wList = self.iList[:] / self.iMax wnList = numpy.zeros(shape=(wList.shape[0])) for wn in range(len(wList)): if wList[wn] > random(): wnList[wn] = 1 numpy.save( os.path.join(os.path.split(inputGampFile.name)[0], "wnList"), wnList) for wn in range(len(wnList)): wnEvent = gampT.writeEvent(gampList[wn, :, :]) if float(pflist[wn]) == 1.0: wnEvent.writeGamp(outputPFGampFile) if wnList[wn] == 1: wnEvent.writeGamp(outputRawGampFile) if wnList[wn] == 1 and float(pflist[wn]) == 1.0: wnEvent.writeGamp(outputAccGampFile) inputGampFile.close() inputPfFile.close() outputPFGampFile.close() outputRawGampFile.close() outputAccGampFile.close()
def execute(self,inputGampFile,outputRawGampFile,outputAccGampFile,inputPfFile,outputPFGampFile): """ This function does the bulk of the simulation work for PyPWA simulation. Args: inputGampFile (file): Open file with the flat .gamp events. outputRawGampFile (file): Open file for the events that only pass the weight filter. outputAccGampFile (file): Open file for the events that pass both the weight and p/f filter. inputPfFile (file): Open file with the acceptance of the events (p/f). outputPFGampFile (file): Open file for the events that only pass the p/f filter. """ #igreader=gampReader(gampFile=inputGampFile) #inputGampEvents=igreader.readGamp() gampT = gampTranslator(os.path.join(os.path.split(inputGampFile.name)[0],os.path.split(inputGampFile.name)[1])) if not os.path.isfile(os.path.join(os.path.split(inputGampFile.name)[0],"events.npy")): gampT.translate(os.path.join(os.path.split(inputGampFile.name)[0],"events.npy")) gampList=numpy.load(os.path.join(os.path.split(inputGampFile.name)[0],"events.npy")) pf = inputPfFile pflist = pf.readlines() wList=self.iList[:]/self.iMax wnList=numpy.zeros(shape=(wList.shape[0])) for wn in range(len(wList)): if wList[wn]>random(): wnList[wn] = 1 numpy.save(os.path.join(os.path.split(inputGampFile.name)[0],"wnList"),wnList) for wn in range(len(wnList)): wnEvent = gampT.writeEvent(gampList[wn,:,:]) if float(pflist[wn])==1.0: wnEvent.writeGamp(outputPFGampFile) if wnList[wn] == 1: wnEvent.writeGamp(outputRawGampFile) if wnList[wn] == 1 and float(pflist[wn])==1.0: wnEvent.writeGamp(outputAccGampFile) inputGampFile.close() inputPfFile.close() outputPFGampFile.close() outputRawGampFile.close() outputAccGampFile.close()