863
867
for plot_axis in [ "residual_pt", "residual_pz" ] :
864
868
plot = plot_dict[tracker][component+plot_axis]
866
errors = array.array( 'd' )
870
rms_error = array.array( 'd' )
867
871
bin_size = array.array( 'd' )
868
872
bins = array.array( 'd' )
869
873
rms = array.array( 'd' )
874
mean = array.array( 'd' )
875
mean_error = array.array( 'd' )
871
# width = int( plot.GetNbinsX() / RESOLUTION_BINS )
872
877
width = plot.GetXaxis().GetBinWidth(1)
873
878
for i in range( 0, plot.GetXaxis().GetNbins() ) :
874
879
projection = plot.ProjectionY( \
875
880
tracker+component+plot_axis+'_pro_'+str(i), i, (i+1) )
876
# tracker+component+plot_axis+'_pro_'+str(i), i*width, (i+1)*width )
878
# plot_mean = plot.GetXaxis().GetBinCenter( i*width ) + width*0.5
879
882
plot_mean = plot.GetXaxis().GetBinCenter( i ) + width
880
_, _, pro_std, pro_std_err = \
883
pro_mean, pro_mean_err, pro_std, pro_std_err = \
881
884
analysis.tools.fit_gaussian(projection)
883
886
bin_size.append( width*0.5 )
884
errors.append( pro_std_err )
885
887
bins.append( plot_mean )
886
888
rms.append( pro_std )
889
rms_error.append( pro_std_err )
890
mean.append( pro_mean )
891
mean_error.append( pro_mean_err )
888
893
if len(bins) != 0 :
889
894
resolution_graph = ROOT.TGraphErrors( len(bins), \
890
bins, rms, bin_size, errors )
895
bins, rms, bin_size, rms_error )
896
bias_graph = ROOT.TGraphErrors( len(bins), \
897
bins, mean, bin_size, mean_error )
892
899
resolution_graph = None
894
902
plot_dict[tracker][component+plot_axis+'_resolution'] = \
904
plot_dict[tracker][component+plot_axis+'_bias'] = bias_graph
951
960
"momentum to consider for analysis." )
963
parser.add_argument( '--selection_file', default=None, \
964
help='Name of a JSON file containing the events to analyses' )
955
968
parser.add_argument( '--not_require_cluster', action="store_true", \
956
969
help="Don't require a cluster in the reference plane" )
979
992
PT_MIN = namespace.pt_window[0]
980
993
PT_MAX = namespace.pt_window[1]
981
994
PT_BIN_WIDTH = namespace.pt_bin
996
if namespace.selection_file is not None :
998
with open(namespace.selection_file, 'r') as infile :
999
GOOD_EVENTS = json.load(infile)
1001
SELECT_EVENTS = False
982
1002
except BaseException as ex:
1007
1027
while file_reader.next_event() and \
1008
1028
file_reader.get_total_num_events() != namespace.max_num_events :
1031
filename = file_reader.get_current_filename()
1032
spill = str(file_reader.get_current_spill_number())
1033
event = file_reader.get_current_event_number()
1034
if filename not in GOOD_EVENTS :
1036
if spill not in GOOD_EVENTS[filename] :
1038
if event not in GOOD_EVENTS[filename][spill] :
1010
1042
sys.stdout.write(
1011
1043
' Spill ' + str(file_reader.get_current_spill_number()) + \