def readGamp(self): """ This function returns a list of gampEvents from the specified gamp file. """ contents=self.gampFile.readlines() self.nParticles=int(contents[0]) nLinesPerEvent=self.nParticles+1 i=0 while i <len(contents): event=[] for line in contents[i+1:i+nLinesPerEvent]: event.append(self.parseParticle(line)) i+=nLinesPerEvent self.events.append(gampEvent(particles=event)) return self.events
def readGamp(self): """ This function parses a whole gamp file and returns a list of all gamp events. Returns: List of all gampEvents contained within self.gampFile. """ contents = self.gampFile.readlines() self.nParticles = int(contents[0]) nLinesPerEvent = self.nParticles + 1 i = 0 while i < len(contents): event = [] for line in contents[i + 1:i + nLinesPerEvent]: event.append(self.parseParticle(line)) i += nLinesPerEvent self.events.append(gampEvent(particles=event)) return self.events
def readGamp(self): """ This function parses a whole gamp file and returns a list of all gamp events. Returns: List of all gampEvents contained within self.gampFile. """ contents=self.gampFile.readlines() self.nParticles=int(contents[0]) nLinesPerEvent=self.nParticles+1 i=0 while i <len(contents): event=[] for line in contents[i+1:i+nLinesPerEvent]: event.append(self.parseParticle(line)) i+=nLinesPerEvent self.events.append(gampEvent(particles=event)) return self.events
def writeEvent(self, dataSlice): """ This function takes a slice of the events array ([n,:,:]) and returns the pythonPWA gampEvent object of that slice. Args: dataSlice (numpy ndarray): The 2 densional array of a single event fron the events 3D array. Returns: gampEvent """ nPart = dataSlice[0, 0] event = [] for i in range(int(nPart)): dataList = dataSlice[i + 1, :] particle = gampParticle(particleID=dataList[0], particleCharge=dataList[1], particleXMomentum=dataList[2], particleYMomentum=dataList[3], particleZMomentum=dataList[4], particleE=dataList[5]) event.append(particle) return gampEvent(particles=event)
def writeEvent(self,dataSlice): """ This function takes a slice of the events array ([n,:,:]) and returns the pythonPWA gampEvent object of that slice. Args: dataSlice (numpy ndarray): The 2 densional array of a single event fron the events 3D array. Returns: gampEvent """ nPart = dataSlice[0,0] event = [] for i in range(int(nPart)): dataList = dataSlice[i+1,:] particle=gampParticle(particleID=dataList[0], particleCharge=dataList[1], particleXMomentum=dataList[2], particleYMomentum=dataList[3], particleZMomentum=dataList[4], particleE=dataList[5]) event.append(particle) return gampEvent(particles=event)