text
stringlengths
0
828
storedfile = self(storedfile).create()
md5 = hashlib.md5()
url = self(storedfile).getUrl() + ""/addchunk""
if file_obj is None:
with open(local_file_path, 'rb') as filecontents:
upload_chunks(url, storedfile, filecontents)
else:
upload_chunks(url, storedfile, file_obj)
return self(storedfile).update()"
4190,"def lookup_cc_partner(nu_pid):
""""""Lookup the charge current partner
Takes as an input neutrino nu_pid is a PDG code, then returns
the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign
""""""
neutrino_type = math.fabs(nu_pid)
assert neutrino_type in [12, 14, 16]
cc_partner = neutrino_type - 1 # get e, mu, tau
cc_partner = math.copysign(
cc_partner, nu_pid) # make sure matter/antimatter
cc_partner = int(cc_partner) # convert to int
return cc_partner"
4191,"def _set_vector_value(self, var_name, value):
""""""Private""""""
self.particle[var_name] = convert_3vector_to_dict(value)
for coord in self.particle[var_name].keys():
new_value = Distribution(self.particle[var_name][coord])
self.particle[var_name][coord] = new_value"
4192,"def _get_next_events(self, material):
""""""Get next events from Genie ROOT file
Looks over the generator""""""
f = ROOT.TFile(self.filenames[material])
try:
t = f.Get('gst')
n = t.GetEntries()
except:
self.log.critical('Could not open the ROOT file with Genie events')
raise
for i in range(n):
t.GetEntry(i)
next_events = []
position = convert_3vector_to_dict([self.particle['position']['x'].get_cache(),
self.particle['position']['y'].get_cache(),
self.particle['position']['z'].get_cache()])
lepton_event = {}
if t.El ** 2 - (t.pxl ** 2 + t.pyl ** 2 + t.pzl ** 2) < 1e-7:
lepton_event['pid'] = self.particle[
'pid'].get() # Either NC or ES
else:
lepton_event['pid'] = lookup_cc_partner(
self.particle['pid'].get())
# units: GeV -> MeV
momentum_vector = [1000 * x for x in [t.pxl, t.pyl, t.pzl]]
lepton_event['momentum'] = convert_3vector_to_dict(momentum_vector)
lepton_event['position'] = position
next_events.append(lepton_event)
for j in range(t.nf): # nf, number final hadronic states
hadron_event = {}
hadron_event['pid'] = t.pdgf[j]
hadron_event['position'] = position
# units: GeV -> MeV
momentum_vector = [1000 * x for x in [t.pxf[j], t.pyf[j], t.pzf[j]]]
hadron_event['momentum'] = convert_3vector_to_dict(momentum_vector)
next_events.append(hadron_event)
event_type = {}
event_type['vertex'] = position
to_save = {} # maps our names to Genie gst names
to_save['incoming_neutrino'] = 'neu'
to_save['neutrino_energy'] = 'Ev'
to_save['target_material'] = 'tgt'
for key, value in to_save.iteritems():
self.log.info('%s : %s' % (key, str(t.__getattr__(value))))
event_type[key] = t.__getattr__(value)
self.log.debug('Event type:')
for my_type in ['qel', 'res', 'dis', 'coh', 'dfr',
'imd', 'nuel', 'em']:
if t.__getattr__(my_type) == 1:
self.log.debug('\t%s', my_type)