def getCocktailSum(e0, e1, eCocktail, uCocktail):
<EOL>mask = (eCocktail >= e0) & (eCocktail <= e1)<EOL>if np.any(mask):<EOL><INDENT>idx = getMaskIndices(mask)<EOL>eCl, eCu = eCocktail[idx[<NUM_LIT:0>]], eCocktail[idx[<NUM_LIT:1>]]<EOL>not_coinc_low, not_coinc_upp = (eCl != e0), (eCu != e1)<EOL>uCocktailSum = fsum(uCocktail[mask[:-<NUM_LIT:1>]][:-<NUM_LIT:1>])<EOL>logging.debug('<STR_LIT>'.format(uCocktailSum))<EOL>if not_coinc_low:<EOL><INDENT>eCl_bw = eCl - eCocktail[idx[<NUM_LIT:0>]-<NUM_LIT:1>]<EOL>corr_low = (eCl - e0) / eCl_bw<EOL>abs_corr_low = float(corr_low) * uCocktail[idx[<NUM_LIT:0>]-<NUM_LIT:1>]<EOL>uCocktailSum += abs_corr_low<EOL>logging.debug(('<STR_LIT>' % (<EOL>e0, eCl, eCl - e0, eCl_bw, corr_low<EOL>)).format(abs_corr_low, uCocktailSum))<EOL><DEDENT>if not_coinc_upp:<EOL><INDENT>if idx[<NUM_LIT:1>]+<NUM_LIT:1> < len(eCocktail):<EOL><INDENT>eCu_bw = eCocktail[idx[<NUM_LIT:1>]+<NUM_LIT:1>] - eCu<EOL>corr_upp = (e1 - eCu) / eCu_bw<EOL>abs_corr_upp = float(corr_upp) * uCocktail[idx[<NUM_LIT:1>]]<EOL><DEDENT>else:<EOL><INDENT>abs_corr_upp = eCu_bw = corr_upp = <NUM_LIT:0><EOL><DEDENT>uCocktailSum += abs_corr_upp<EOL>logging.debug(('<STR_LIT>' % (<EOL>e1, eCu, e1 - eCu, eCu_bw, corr_upp<EOL>)).format(abs_corr_upp, uCocktailSum))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>mask = (eCocktail >= e0)<EOL>idx = getMaskIndices(mask) <EOL>if idx[<NUM_LIT:0>] == idx[<NUM_LIT:1>] and idx[<NUM_LIT:0>] == len(eCocktail)-<NUM_LIT:1>:<EOL><INDENT>corr = (e1 - e0) / (eCocktail[idx[<NUM_LIT:0>]] - eCocktail[idx[<NUM_LIT:0>]-<NUM_LIT:1>])<EOL>uCocktailSum = float(corr) * uCocktail[idx[<NUM_LIT:0>]-<NUM_LIT:1>]<EOL><DEDENT>else: <EOL><INDENT>corr = (e1 - e0) / (eCocktail[idx[<NUM_LIT:0>]+<NUM_LIT:1>] - eCocktail[idx[<NUM_LIT:0>]])<EOL>uCocktailSum = float(corr) * uCocktail[idx[<NUM_LIT:0>]]<EOL><DEDENT>logging.debug('<STR_LIT>'.format(uCocktailSum))<EOL><DEDENT>return uCocktailSum<EOL>
get the cocktail sum for a given data bin range