def event(self): geoCache = Belle2.VXD.GeoCache.getInstance() mcpart = Belle2.PyStoreArray('MCParticles') for part in mcpart: mctraj = part.getRelationsTo('MCParticleTrajectorys') #if(len(mctraj) > 0): #print(mc) pxd_clusters = Belle2.PyStoreArray('PXDClusters') #print("event=", Belle2.PyStoreObj('EventMetaData').obj().getEvent()) for cluster in pxd_clusters: mcparticles = cluster.getRelationsTo('MCParticles') #print(len(mcparticles)) # Event identification self.data.exp = Belle2.PyStoreObj( 'EventMetaData').obj().getExperiment() self.data.run = Belle2.PyStoreObj('EventMetaData').obj().getRun() self.data.evt = Belle2.PyStoreObj('EventMetaData').obj().getEvent() # Sensor identification vxd_id = cluster.getSensorID() self.data.vxd_id = vxd_id.getID() self.data.layer = vxd_id.getLayerNumber() self.data.ladder = vxd_id.getLadderNumber() self.data.sensor = vxd_id.getSensorNumber() #Find digits in cluster digits = cluster.getRelationsTo('PXDDigits') mc_part = cluster.getRelationsTo('MCParticles') true_parts = cluster.getRelationsTo('PXDTrueHits') sim_parts0 = cluster.getRelationsTo('PXDSimHits') #print(len(digits)) info = geoCache.get(vxd_id) r_local = ROOT.TVector3(cluster.getU(), cluster.getV(), 0) r_global = info.pointToGlobal(r_local) self.data.cls_u = r_local.X() self.data.cls_v = r_local.Y() self.data.cls_w = r_local.Z() self.data.cls_x = r_global.X() self.data.cls_y = r_global.Y() self.data.cls_z = r_global.Z() # Cluster size and charge self.data.cls_uSize = cluster.getUSize() self.data.cls_vSize = cluster.getVSize() self.data.charge = cluster.getCharge() self.data.seed_charge = cluster.getSeedCharge() # Fill tree self.file.cd() self.tree.Fill()
def initialize(self): """ Initialise module before any events are processed""" # Create a StoreArray to save predictions to self.e_e_info = Belle2.PyStoreObj('EventExtraInfo') self.e_e_info.registerInDataStore() # Apparently needed to make thread safe self.model = None
def event(self): """ Return True if event is fine, False otherwise """ someOK = False EventMetaData = Belle2.PyStoreObj('EventMetaData') event = EventMetaData.getEvent() digits = Belle2.PyStoreArray('EKLMDigits') hit2ds = Belle2.PyStoreArray('EKLMHit2ds') self.hist_nDigit.Fill(len(digits)) self.hist_nHit2d.Fill(len(hit2ds)) super(EventInspectorEKLM, self).return_value(someOK)
def initialize(self): '''Create a member to access event info StoreArray''' self.eventinfo = Belle2.PyStoreObj('EventMetaData') self.index_names = ['label', 'evtNum', 'arrayIndex'] # Dataframe to hold training data, format: (label, Dataframe of event particles, event level vars) self.columns = [ 'PDG', 'mass', 'charge', 'energy', 'prodTime', 'x', 'y', 'z', 'px', 'py', 'pz', 'nDaughters', 'status', 'motherPDG', 'motherIndex', ] self.events_list = [] self.decay_str_list = [] # If the evtNum file does not exist we need to create it self.create_evtNum_file = False try: # Eventually want to have series of LFN: [eventNums] # self.evtNum_series = pd.read_hdf(self.evt_num_file, 'evtNum') self.evtNum_arr = np.load(self.evt_num_file).tolist() b2.B2INFO('Event file {} loaded'.format(self.evt_num_file)) # except FileNotFoundError: # For pd series except IOError: b2.B2INFO('Event file {} not found, creating'.format( self.evt_num_file)) self.create_evtNum_file = True self.evtNum_arr = []
def event(self): """ Return True if event is fine, False otherwise """ someOK = False EventMetaData = Belle2.PyStoreObj('EventMetaData') event = EventMetaData.getEvent() rawklms = Belle2.PyStoreArray('RawKLMs') digits = Belle2.PyStoreArray('EKLMDigits') hit2ds = Belle2.PyStoreArray('EKLMHit2ds') #klmdigi = Belle2.PyStoreArray('KLMDigitEventInfo') #eklmids = Belle2.PyStoreArray('EKLMHitBases') self.hist_nDigit.Fill(len(digits)) self.hist_nHit2d.Fill(len(hit2ds)) for copper in range(0, len(rawklms)): rawklm = rawklms[copper] if rawklm.GetNumEntries() != 1: print('##0 Event', event, 'copper', copper, ' getNumEntries=', rawklm.GetNumEntries()) continue nodeID = rawklm.GetNodeID(0) - self.BKLM_ID if nodeID >= self.EKLM_ID - self.BKLM_ID: nodeID = nodeID - (self.EKLM_ID - self.BKLM_ID) + 4 self.hist_rawKLMnodeID.Fill(nodeID, copper) if (nodeID < 0) or (nodeID > 4): # skip EKLM nodes continue for digit in digits: sector = digit.getSector() endcap = digit.getEndcap() time = digit.getTime() ctime = digit.getCTime() tdc = digit.getTDC() #klmdigi = digit.getRelatedTo('KLMDigitEventInfo') #triggtime = digit.getRelativeCTime() #print (ctime, tdc)#, triggtime) #print(time) self.hist_time.Fill(time) self.hist_ctime.Fill(ctime) self.hist_tdc.Fill(tdc) if (endcap == 1): self.hist_BackwardSectorOccupancy.Fill(sector) self.hist_BackwardSectorbyctime.Fill(sector, ctime) else: self.hist_ForwardSectorOccupancy.Fill(sector) self.hist_ForwardSectorbyctime.Fill(sector, ctime) self.hist_EndcapOccupancy.Fill(endcap) for hit2d in hit2ds: sector = hit2d.getSector() endcap = hit2d.getEndcap() layer = hit2d.getLayer() gx = hit2d.getPositionX() gy = hit2d.getPositionY() gz = hit2d.getPositionZ() if (endcap == 1): self.hist_occupancyBackwardXY.Fill(gx, gy) self.hist_LayeroccupancyBackwardRZ.Fill(layer, gz) self.hist_LayeroccupancyBackward.Fill(layer) self.hist_occupancyBackwardXYPerLayer[layer - 1].Fill(gx, gy) else: self.hist_occupancyForwardXY.Fill(gx, gy) self.hist_LayeroccupancyForwardRZ.Fill(layer, gz) self.hist_LayeroccupancyForward.Fill(layer) self.hist_occupancyForwardXYPerLayer[layer - 1].Fill(gx, gy) super(EventInspectorEKLM, self).return_value(someOK)
def endRun(self): EventMetaData = Belle2.PyStoreObj('EventMetaData') print('endRun', EventMetaData.getRun())
def event(self): geoCache = Belle2.VXD.GeoCache.getInstance() trg = Belle2.PyStoreArray('TRGSummary') gdl_25 = ((trgSum.getPsnmBits(0) & 0x6000000) > 25); gdl_26 = ((trgSum.getPsnmBits(0) & 0x4000000) > 26); if gdl_25 != 0 or gld_26 != 0: pxd_clusters = Belle2.PyStoreArray('PXDClusters') #print("event=", Belle2.PyStoreObj('EventMetaData').obj().getEvent()) for cluster in pxd_clusters: # Event identification self.data.exp = Belle2.PyStoreObj('EventMetaData').obj().getExperiment() self.data.run = Belle2.PyStoreObj('EventMetaData').obj().getRun() self.data.evt = Belle2.PyStoreObj('EventMetaData').obj().getEvent() # Sensor identification vxd_id = cluster.getSensorID() self.data.vxd_id = vxd_id.getID() self.data.layer = vxd_id.getLayerNumber() self.data.ladder = vxd_id.getLadderNumber() self.data.sensor = vxd_id.getSensorNumber() #Find digits in cluster digits = cluster.getRelationsTo('PXDDigits') mc_part = cluster.getRelationsTo('MCParticles') true_parts = cluster.getRelationsTo('PXDTrueHits') sim_parts0 = cluster.getRelationsTo('PXDSimHits') #for sim_part in sim_parts0: #print("sim_part0") #for true_part in true_parts: #print("true_part") #sim_parts = cluster.getRelationsTo('PXDSimHits') #for sim_part in sim_parts: #print("sim_part") #print(sim_part.getBackgroundTag()) #for particle in mc_part: #sim_parts = particle.getRelationsTo('PXDSimHits') #for sim_part in sim_parts: #print("sim_part") #print(sim_part.getBackgroundTag()) # if particle.isPrimaryParticle() == True: # i = i + 1 # print(i) #Get u,v coordinates of each digit #print ("new cluster") #for digit in digits: # print(digit.getSensorID()) #static VXD::GeoCache& geo = VXD::GeoCache::getInstance(); #const VXD::SensorInfoBase& info = geo.get(sensorID); #abs_pos = info.pointToGlobal(local_pos) info = geoCache.get(vxd_id) r_local = ROOT.TVector3(cluster.getU(), cluster.getV(), 0) r_global = info.pointToGlobal(r_local) self.data.cls_u = r_local.X() self.data.cls_v = r_local.Y() self.data.cls_w = r_local.Z() self.data.cls_x = r_global.X() self.data.cls_y = r_global.Y() self.data.cls_z = r_global.Z() # Cluster size and charge self.data.cls_uSize = cluster.getUSize() self.data.cls_vSize = cluster.getVSize() self.data.charge = cluster.getCharge() self.data.seed_charge = cluster.getSeedCharge() # Fill tree self.file.cd() self.tree.Fill()