@@ -318,7 +318,7 @@ def fill_TimeResHisto(k, dt, h2D, out_list, tagin, title_tag, canvas, save_canva
318318 line .SetLineWidth (2 )
319319 line .SetLineStyle (10 )
320320
321- selection = '1'
321+ selection = '(amp[{nch}] != 0 && integral[{nch}] != 0)' . format ( nch = k )
322322
323323 '''=========================== Amplitude ==========================='''
324324 if 'Amp' in configurations .plots :
@@ -582,10 +582,10 @@ def fill_TimeResHisto(k, dt, h2D, out_list, tagin, title_tag, canvas, save_canva
582582
583583
584584 if 'PosWeight' in configurations .plots :
585- ''' -------------Avg amp-----------'''
586585 h = rt .TH2D ('h_amp_aux' + str (k ), title , N_bins [0 ], - width + dx , width + dx , N_bins [1 ], - width + dy , width + dy )
587586 chain .Project ('h_amp_aux' + str (k ), var , selection )
588587
588+ ''' -------------Avg amp-----------'''
589589 name = 'h_amp_weight_pos_' + str (k )
590590 title = 'Average peak amplitude channel {} in selected event' .format (k )
591591 h_w = rt .TH2D (name , title , N_bins [0 ], - width + dx , width + dx , N_bins [1 ], - width + dy , width + dy )
@@ -665,14 +665,49 @@ def fill_TimeResHisto(k, dt, h2D, out_list, tagin, title_tag, canvas, save_canva
665665 chain .Project (name , var , weights )
666666
667667 h_w .Divide (h )
668- h_w .GetZaxis ().SetRangeUser (h_w .GetMaximum ()* 0.8 , h_w .GetMaximum ())
668+ arr , pos = rootTH2_to_np (h_w )
669+ arr = arr [arr != 0 ]
670+ h_w .GetZaxis ().SetRangeUser (np .percentile (arr ,10 ), np .percentile (arr ,99 ))
669671 h_w .SetStats (0 )
670672 canvas ['int_w_pos' ][k ] = rt .TCanvas ('c_int_w_pos_' + str (k ), 'c_int_w_pos_' + str (k ), 800 , 600 )
671673 h_w .DrawCopy ('colz' )
672674 Set_2D_colz_graphics ()
673675 canvas ['int_w_pos' ][k ].Update ()
674676 canvas ['int_w_pos' ][k ].SaveAs (out_dir + '/PositionXY_int_weight_ch{:02d}.png' .format (k ))
675677
678+ ''' -------------Avg risetime-----------'''
679+ name = 'h_risetime_weight_pos_' + str (k )
680+ title = 'Average risetime channel {} in selected event' .format (k )
681+ h_w = rt .TH2D (name , title , N_bins [0 ], - width + dx , width + dx , N_bins [1 ], - width + dy , width + dy )
682+ h_w .SetXTitle ('x [mm]' )
683+ h_w .SetYTitle ('y [mm]' )
684+ h_w .SetZTitle ('Average risetime [mV/ns]' )
685+
686+ weights = '(' + selection + ') * -risetime[' + str (k ) + ']'
687+ chain .Project (name , var , weights )
688+
689+ h_w .Divide (h )
690+ arr , pos = rootTH2_to_np (h_w )
691+ arr = arr [arr != 0 ]
692+ h_w .GetZaxis ().SetRangeUser (np .percentile (arr ,10 ), np .percentile (arr ,99 ))
693+ h_w .SetStats (0 )
694+ canvas ['int_w_pos' ][k ] = rt .TCanvas ('c_risetime_w_pos_' + str (k ), 'c_risetime_w_pos_' + str (k ), 800 , 600 )
695+ h_w .DrawCopy ('colz' )
696+ Set_2D_colz_graphics ()
697+ if not conf ['SiPM' ] == 'None' :
698+ x_start , x_stop , y_start , y_stop = conf ['SiPM_sel' ]['limits' ]
699+
700+ line .SetLineStyle (9 )
701+ line .SetLineColor (46 )
702+ line .SetLineWidth (2 )
703+ line .DrawLine (x_start , y_start , x_stop , y_start )
704+ line .DrawLine (x_start , y_stop , x_stop , y_stop )
705+ line .DrawLine (x_start , y_start , x_start , y_stop )
706+ line .DrawLine (x_stop , y_start , x_stop , y_stop )
707+
708+ canvas ['int_w_pos' ][k ].Update ()
709+ canvas ['int_w_pos' ][k ].SaveAs (out_dir + '/PositionXY_risetime_weight_ch{:02d}.png' .format (k ))
710+
676711 '''=========================== End Selections ==========================='''
677712 conf ['sel' ] = selection
678713 # print conf['sel']
@@ -730,7 +765,8 @@ def fill_TimeResHisto(k, dt, h2D, out_list, tagin, title_tag, canvas, save_canva
730765 s2 = '{y} < {y2}-{d} && {y} > {y1}+{d} && {x} < {x2}-{d} && {x} > {x1}+{d}'
731766 s = '!({} && !({}))' .format (s1 , s2 )
732767 # s = '!({})'.format(s1)
733- # selection += ' && ' + s.format(x=conf['x_rot'], y = conf['y_rot'], d=0.25, x1=x1, x2=x2, y1=y1, y2=y2)
768+ selection += ' && ' + s .format (x = conf ['x_rot' ], y = conf ['y_rot' ], d = 0.25 , x1 = x1 , x2 = x2 , y1 = y1 , y2 = y2 )
769+
734770 # selection += ' && ' + configurations.channel[kk]['SiPM_sel']['cut']
735771
736772 if chain .GetEntries (selection ) < 5 :
@@ -854,7 +890,7 @@ def fill_TimeResHisto(k, dt, h2D, out_list, tagin, title_tag, canvas, save_canva
854890 ResRaw , 'TimeResRaw2D' ,
855891 'Raw' ,
856892 canvas ,
857- not 'TimeRes2DAmp' in configurations .plots )
893+ not ( 'TimeRes2DAmp' in configurations .plots ) )
858894
859895
860896 if 'TimeRes2DAmp' in configurations .plots :
0 commit comments