Last active
June 22, 2016 04:58
-
-
Save jyoshida-sci/2ed6d829dc96ec24ec82 to your computer and use it in GitHub Desktop.
scan0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on 2016/02/05 | |
@author: jyoshida-sci | |
""" | |
import scan0 | |
import numpy as np | |
scan0filenmame = "em55-12_good.scan0" | |
#scan0filenmame = "em064-12_good.scan0" | |
scanresults = scan0.ReadScan0(scan0filenmame) | |
fout = open(scan0filenmame + '_selected.txt', 'w') | |
count = 0 | |
for i, sr in enumerate(scanresults): | |
if sr['header']['LastPlate']==12 and sr['header']['LastLayer']==3: | |
continue | |
if sr['header']['LastPlate']<3: | |
continue | |
if 'Int' in sr['layers'][-1]['str']: | |
# if sr['layers'][-1]['str'].find(’Int’) > -1: # same condition | |
# if sr['layers'][-1]['str'].count('Int') > 0: # same condition | |
continue | |
l_dxdz = sr['layers'][1]['l_dxdz'] | |
l_dydz = sr['layers'][1]['l_dydz'] | |
tantheta = np.sqrt(l_dxdz**2 + l_dydz**2) | |
mystr = "{0} {1} ".format(count ,i) | |
mystr += "{0}-{1} ".format(sr['header']['trackid'], sr['layers'][0]['Candidate']) | |
mystr += "{0:.3f}".format(tantheta) | |
mystr += "\n" | |
mystr += " " + sr['layers'][1]['str'] | |
mystr += " " + sr['layers'][-1]['str'] | |
mystr += "\n" | |
mystr += "starttime:\n" | |
mystr += "OK: through / rho-stop / sigma-stop / decay / beamint\n" | |
mystr += "NG: gridmark-bad / patternmatch-bad / surfdetect-bad\n" | |
mystr += " scattering\n" | |
mystr += " haze / poor-grain\n" | |
mystr += " compton / another-track\n" | |
mystr += "endtime:\n" | |
mystr += " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n" | |
fout.write(mystr) | |
count +=1 | |
fout.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on 2016/06/22 | |
@author: jyoshida-sci | |
""" | |
import re | |
def ReadPred(filename): | |
predictions = [] | |
for line in open(filename, 'r'): | |
if line[0]=="#": | |
continue | |
itemList = re.split("\s+", line.strip()) | |
prediction = {} | |
prediction['str'] = line | |
prediction['track'] = int(itemList[0]) | |
prediction['sub'] = int(itemList[1])#トラックの候補が複数あるときのための番号。 | |
prediction['run'] = int(itemList[2]) | |
prediction['spill'] = int(itemList[3]) | |
prediction['event'] = int(itemList[4]) | |
prediction['Kmom'] = float(itemList[5]) | |
prediction['MissMass'] = float(itemList[6]) | |
prediction['MissMom'] = float(itemList[7]) | |
prediction['Missdxdz'] = float(itemList[8]) | |
prediction['Missdydz'] = float(itemList[9]) | |
prediction['Lcand'] = int(itemList[10]) | |
prediction['Lbr'] = int(itemList[11]) | |
prediction['Rcand'] = int(itemList[12]) | |
prediction['Rbr'] = int(itemList[13]) | |
prediction['x'] = float(itemList[14]) | |
prediction['dxdz'] = float(itemList[15]) | |
prediction['y'] = float(itemList[16]) | |
prediction['dydz'] = float(itemList[17]) | |
prediction['infoflag'] = int(itemList[18]) | |
prediction['flag'] = int(itemList[19])#ムーバーのガタ補正の必要の有無を示す。 flag = 0 の時はガタの補正が必要。 | |
predictions.append(prediction) | |
return predictions | |
''' | |
トラックの付加情報を示す。 | |
* 1の位 : Ξ-が崩壊している可能性が大きい。 | |
* 10の位 : エマルション中で生成して、バンドルの方向に飛び出したと思われる。 | |
* 100の位 : エマルションをつき抜けている可能性が大きい。 | |
* 1000の位 : ストップしている可能性が大きい。 | |
''' | |
if __name__ == '__main__': | |
predfilenmame = "em64all.pred" | |
#scan0filenmame = "em064-12_good.scan0" | |
predictions = ReadPred(predfilenmame) | |
assert(1==1) | |
# assert(1==5)#error OK | |
assert(predictions[0]['track'] == 1) | |
assert(predictions[0]['infoflag'] == 1001) | |
assert(predictions[0]['flag'] == 1) | |
assert(predictions[0]['Rbr'] == 25155) | |
assert(predictions[262]['track'] == 182) | |
assert(predictions[262]['infoflag'] == 100) | |
assert(predictions[262]['flag'] == 1) | |
assert(predictions[262]['Rbr'] == 18093) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on 2016/02/05 | |
@author: jyoshida-sci | |
""" | |
import re | |
def ReadScan0(filename): | |
scanresults = [] | |
scanresult = {} | |
layers = [] | |
for line in open(filename, 'r'): | |
if line[0]=="#": | |
continue | |
itemList = re.split("\s+", line.strip()) | |
if itemList[0] == "a": | |
scanresult = {} | |
header = {} | |
layers = [] | |
header['str'] = line | |
header['LastPlate'] = int(itemList[1]) | |
header['LastLayer'] = int(itemList[2]) | |
header['track'] = int(itemList[3]) | |
header['sub'] = int(itemList[4])#トラックの候補が複数あるときのための番号。 | |
header['run'] = int(itemList[5]) | |
header['spill'] = int(itemList[6]) | |
header['event'] = int(itemList[7]) | |
header['Kmom'] = float(itemList[8]) | |
header['MissMass'] = float(itemList[9]) | |
header['MissMom'] = float(itemList[10]) | |
header['Lcand'] = int(itemList[11]) | |
header['Lbr'] = int(itemList[12]) | |
header['Rcand'] = int(itemList[13]) | |
header['Rbr'] = int(itemList[14]) | |
header['x'] = float(itemList[15]) | |
header['dxdz'] = float(itemList[16]) | |
header['y'] = float(itemList[17]) | |
header['dydz'] = float(itemList[18]) | |
header['infoflag'] = int(itemList[19]) | |
header['flag'] = int(itemList[20])#ムーバーのガタ補正の必要の有無を示す。 flag = 0 の時はガタの補正が必要。 | |
header['trackid'] = int(itemList[3]) * 100 + int(itemList[4]) | |
scanresult['header'] = header | |
continue | |
if itemList[0] == "s": | |
summary = {} | |
summary['str'] = line | |
summary['category'] = int(itemList[1]) #バーテックスの種類 | |
summary['boldness'] = int(itemList[2])#トラックの太さ (0:thin、1:gray、2:black、3:thick) | |
summary['ntrack'] = int(itemList[3])#放出 fine track の数 | |
summary['nbold'] = int(itemList[4])#放出 bold track の数 | |
summary['pi_dx'] = float(itemList[5])#崩壊トラック用。放出πの方向 (dx, dy, dz) | |
summary['pi_dy'] = float(itemList[6]) | |
summary['pi_dz'] = float(itemList[7]) | |
scanresult['summary'] = summary | |
scanresult['layers'] = layers | |
scanresults.append(scanresult) | |
continue | |
#normal layer info | |
layer = {} | |
layer['str'] = line | |
layer['Plate'] = int(itemList[0]) | |
layer['Layer'] = int(itemList[1]) | |
layer['Candidate'] = int(itemList[2]) | |
layer['x'] = float(itemList[3])#実験室座標系 mover座標系のことだとおもう。9時方向がx+方向、12時方向がy+方向 | |
layer['dxdz'] = float(itemList[4]) | |
layer['y'] = float(itemList[5]) | |
layer['dydz'] = float(itemList[6]) | |
layer['l_x'] = float(itemList[7])#ローカル座標系 顕微鏡ステージの座標系のことだとおもう。3時方向がx+方向、12時方向がy+方向 | |
layer['l_dxdz'] = float(itemList[8]) | |
layer['l_y'] = float(itemList[9]) | |
layer['l_dydz'] = float(itemList[10]) | |
layer['value'] = int(itemList[11])#いまのところ不明 20150205 jyoshida | |
layer['comment'] = "" | |
if len(itemList) >= 13: | |
layer['comment'] = itemList[12] | |
layers.append(layer) | |
return scanresults | |
''' | |
トラックの付加情報を示す。 | |
* 1の位 : Ξ-が崩壊している可能性が大きい。 | |
* 10の位 : エマルション中で生成して、バンドルの方向に飛び出したと思われる。 | |
* 100の位 : エマルションをつき抜けている可能性が大きい。 | |
* 1000の位 : ストップしている可能性が大きい。 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment