def InternalConfigure(self, config_dict): super().InternalConfigure(config_dict) self.a_min, self.a_max = reader.read_param(config_dict, "paramRange", "required")["a"] self.b_min, self.b_max = reader.read_param(config_dict, "paramRange", "required")["b"] self.x_min, self.x_max = reader.read_param(config_dict, "paramRange", "required")["x"] self.y_min, self.y_max = reader.read_param(config_dict, "paramRange", "required")["y"] self.width_min, self.width_max = reader.read_param(config_dict, "paramRange", "required")["width"] return True
def InternalConfigure(self, config_dict={}): ''' Required class attributes: - volume [m3] - density [1/m3] - experiment duration [s] - neutrino mass [eV] - energy window [KEmin,KEmax] - background [counts/eV/s] - energy resolution [eV] ''' self.KEmin, self.KEmax = reader.read_param( config_dict, "energy_window", [ Constants.tritium_endpoint() - 1e3, Constants.tritium_endpoint() + 1e3 ]) self.volume = reader.read_param(config_dict, "volume", 1e-6) self.density = reader.read_param(config_dict, "density", 1e18) self.duration = reader.read_param(config_dict, "duration", 1e18) self.neutrinomass = reader.read_param(config_dict, "neutrino_mass", 1e18) self.background = reader.read_param(config_dict, "background", 1e-6) self.poisson_fluctuations = reader.read_param(config_dict, "poisson_fluctuations", False) self.energy_resolution = reader.read_param(config_dict, "energy_resolution", 0) self.numberDecays = reader.read_param(config_dict, "number_decays", -1) return True
def InternalConfigure(self, params): ''' Args: object_type: class of the object to read in the file object_name: name of the tree followed by the name of the object use_katydid: retro-compatibility to Katydid namespace ''' super().InternalConfigure(params) self.object_type = reader.read_param(params, "object_type", "TMultiTrackEventData") self.object_name = reader.read_param(params, "object_name", "multiTrackEvents:Event") self.use_katydid = reader.read_param(params, "use_katydid", False) return True
def InternalConfigure(self, params): ''' Configure ''' # Initialize Canvas # try: # self.rootcanvas = RootCanvas.RootCanvas(params, optStat=0) # except: self.rootcanvas = RootCanvas(params, optStat=0) # Read other parameters self.namedata = reader.read_param(params, 'variables', "required") self.multipleHistos = False if isinstance(self.namedata, list): self.multipleHistos = True if self.multipleHistos: self.histos = [] for var in self.namedata: aParamsDict = params aParamsDict.update({"variables": str(var)}) self.histos.append(RootHistogram(params, optStat=0)) else: self.histo = RootHistogram(params, optStat=0) return True
def InternalConfigure(self, param_dict): ''' Configure ''' # Initialize Canvas: for some reason, the module or the class is # imported depending which script imports. try: self.rootcanvas = RootCanvas(param_dict, optStat=0) except: self.rootcanvas = RootCanvas.RootCanvas(param_dict, optStat=0) # Read other parameters self.nbins_x = int(reader.read_param(param_dict, 'n_bins_x', 100)) self.nbins_y = int(reader.read_param(param_dict, 'n_bins_y', 100)) self.namedata = reader.read_param(param_dict, 'variables', "required") self.draw_opt_2d = reader.read_param( param_dict, 'root_plot_option', "contz") return True
def InternalConfigure(self, config_dict): ''' Args: null_neutrino_mass (bool): set the neutrino mass to zero during fit ''' super().InternalConfigure(config_dict) self.null_m_nu = reader.read_param(config_dict, "null_neutrino_mass", False) return True
def InternalConfigure(self, params): """ Args: frequency_data: An list of frequencies to be converted to energies, in Hz B: Magnetic field used to convert frequency to energy in T m_electron: Electron mass in eV (Default=510998.910) omega_c: (Default=1.758820088e+11) Input: frequencies: list of frequencies to be converted Results: energies: list of the energies converted from frequencies in Hz """ self.params = params self.B = reader.read_param(params, "B", "required") self.m_electron = reader.read_param(params, "m_electron", 510998.910) self.omega_c = reader.read_param(params, "omega_c", 1.758820088e+11) self.frequencies = list() self.energies = list() return True
def InternalConfigure(self, params): ''' Configure ''' # Initialize Canvas self.rootcanvas = RootCanvas(params, optStat=0) self.histo = RootHistogram(params, optStat=0) logger.debug(params) # Read other parameters self.namedata = reader.read_param(params, 'variables', "required") return True
def InternalConfigure(self, param_dict): # Initialize Canvas: for some reason, the module or the class is # imported depending which script imports. try: self.rootcanvas = RootCanvas(param_dict, optStat=0) except: self.rootcanvas = RootCanvas.RootCanvas(param_dict, optStat=0) # Read other parameters self.namedata = reader.read_param(param_dict, 'variables', "required") return True
def InternalConfigure(self, config_dict): self.module_name = str(reader.read_param(config_dict, 'module_name', "required")) self.function_name = str(reader.read_param(config_dict, 'function_name', "required")) self.config_dict = config_dict # Test if the module exists try: import imp self.module = imp.load_source( self.module_name, self.module_name+'.py') except Exception as err: logger.critical(err) return 0 # Test if the function exists in the file if hasattr(self.module, self.function_name): logger.info("Found {} using {}".format( self.function_name, self.module_name)) else: logger.critical("Couldn't find {} using {}".format( self.function_name, self.module_name)) return False return True
def InternalConfigure(self, config_dict): self.varName = reader.read_param(config_dict, "varName", "required") self.mode = reader.read_param(config_dict, "mode", "generate") logger.debug("Mode {}".format(self.mode)) self.iter = int(reader.read_param(config_dict, "iter", "required")) if self.mode == "lsampling": self.binned = int(reader.read_param(config_dict, "binned", False)) self.nuisanceParametersNames = reader.read_param(config_dict, "nuisanceParams", "required") self.warmup = int(reader.read_param(config_dict, "warmup", self.iter/2.)) self.numCPU = int(reader.read_param(config_dict, "n_jobs", 1)) self.options = reader.read_param(config_dict, "options", dict()) if self.mode not in ['generate', 'lsampling', 'fit']: logger.error("Mode '{}' is not valid; choose between 'mode' and 'lsampling'".format(self.mode)) return False self.datasetName = "data_"+self.varName self.paramOfInterestNames = reader.read_param(config_dict, "interestParams", "required") self.fixedParameters = reader.read_param(config_dict, "fixedParams", dict) if not isinstance(self.fixedParameters, dict): logger.error("fixedParams should be a dictionary like {'varName': value}") return False return True
def __init__(self, input_dict, optStat='emr'): self.n_bins_x = reader.read_param(input_dict, "n_bins_x", 100) self.x_min, self.x_max = reader.read_param(input_dict, "range", [0., -1.]) self.dataName = reader.read_param(input_dict, "variables", "required") self.title = str(reader.read_param(input_dict, "title", 'hist_{}'.format(self.dataName))) self.xtitle = reader.read_param(input_dict, "x_title", self.dataName) self.ytitle = reader.read_param(input_dict, "y_title", "") self._createHisto()
def InternalConfigure(self, config_dict): ''' Args: null_neutrino_mass (bool): set the neutrino mass to zero during fit ''' super().InternalConfigure(config_dict) self.fixed_m_nu = reader.read_param(config_dict, "fixed_m_nu", False) self.neutrino_mass = reader.read_param( config_dict, "neutrino_mass", 0.) self.energy_resolution = reader.read_param( config_dict, "energy_resolution", 0.) # self.n_events = reader.read_param(config_dict, "n_events", 1200) # self.n_bkgd = reader.read_param(config_dict, "n_kbg", 100) self.background = reader.read_param(config_dict, "background", 1e-6) self.volume = reader.read_param(config_dict, "volume", 1e-6) self.density = reader.read_param(config_dict, "density", 1e18) self.duration = reader.read_param(config_dict, "duration", 1e18) self.KE_min, self.KE_max = reader.read_param( config_dict, "paramRange", "required")["KE"] self.numberDecays = reader.read_param(config_dict, "number_decays", -1) self.poisson_fluctuations = reader.read_param( config_dict, "poisson_fluctuations", False) return True
def __init__(self, input_dict, optStat='emr'): self.width = reader.read_param(input_dict, "width", 600) self.height = reader.read_param(input_dict, "height", 400) self.title = reader.read_param( input_dict, "title", 'can_{}_{}'.format(self.height, self.width)) if self.title != "": plots._set_style_options(0.04, 0.1, 0.07, 0.12, optStat) else: plots._set_style_options(0.04, 0.1, 0.03, 0.12, optStat) self.xtitle = reader.read_param(input_dict, "x_title", "") self.ytitle = reader.read_param(input_dict, "y_title", "") self.canvasoptions = reader.read_param(input_dict, "options", "") # Creating Canvas from ROOT import TCanvas self.canvas = TCanvas(self.title, self.title, self.width, self.height) if "logy" in self.canvasoptions: can.SetLogy() if "logx" in self.canvasoptions: can.SetLogx() # Output path self.path = reader.read_param(input_dict, "output_path", "./") self.output_format = reader.read_param( input_dict, "output_format", "pdf") if not self.path.endswith('/'): self.path = self.path + "/" if self.title != ' ': self.figurefullpath = self.path+self.title+'_' else: self.figurefullpath = self.path if isinstance(input_dict['variables'], str): self.figurefullpath += input_dict['variables'] elif isinstance(input_dict['variables'], list): for namedata in input_dict['variables']: self.figurefullpath += namedata + '_' if self.figurefullpath.endswith('_'): self.figurefullpath = self.figurefullpath[:-1] self.figurefullpath += "." + self.output_format
def InternalConfigure(self, params): ''' Args: object_type: class of the object to read in the file object_name: name of the tree followed by the name of the object use_katydid: retro-compatibility to Katydid namespace read_livetimes: read livetimes from root files channel_ids: key list that will be used for storing the file content, length determines how many files are read rf_roi_min_freqs: list of frequencies that is added to all frequencies read from ROOT file, has to match length of channel ids channel_transition_ranges: list of frequency ranges for each channel merged_frequency_variable: reutrn key for merged start frequencies ''' super().InternalConfigure(params) self.object_type = reader.read_param(params, "object_type", "TMultiTrackEventData") self.object_name = reader.read_param(params, "object_name", "multiTrackEvents:Event") self.use_katydid = reader.read_param(params, "use_katydid", False) self.read_livetimes = reader.read_param(params, "read_livetimes", False) self.channel_ids = reader.read_param(params, "channel_ids", ['a', 'b', 'c']) self.rf_roi_min_freqs = reader.read_param(params, "rf_roi_min_freqs", [0, 0, 0]) self.transition_freqs = reader.read_param(params, "channel_transition_freqs", [0, 0]) self.frequency_variable_name = reader.read_param( params, "merged_frequency_variable", "F") if len(self.channel_ids) > len(self.rf_roi_min_freqs): raise ValueError('More channel ids than min frequencies') if len(self.channel_ids) > len(self.transition_freqs): raise ValueError('More channel ids than frequency ranges') if len(self.channel_ids) > len(self.file_name): raise ValueError('More channel ids than root files') self.N_channels = len(self.channel_ids) return True
def InternalConfigure(self, params): super().InternalConfigure(params) self.tree_name = reader.read_param(params, "tree_name", "required") self.file_option = reader.read_param(params, "file_option", "Recreate") return True
def InternalConfigure(self, params): """ All parameters have defaults. Configurable parameters are: - Q [eV]: endpoint energy - neutrino_mass [eV]: true neutrino mass - minf [Hz]: low frequency cut-off (high cutoff is determined from efficiency dict) – Kmin [eV]: low energy cut-off – Kmax [eV]: high energy cut-off - n_steps: number of energy bins that data will be drawn from - B_field: used for energy-frequency conversion - sig_trans [eV]: width of thermal broadening - other_sig [eV]: width of other broadening - runtime [s]: used to calculate number of background events - S: number of signal events - A_b [1/eV/s]: background rate - poisson_stats (boolean): if True number of total events is random - err_from_B [eV]: energy uncertainty originating from B uncertainty - survival_prob: lineshape parameter - ratio of n+t/nth peak - scattering_sigma [eV]: lineshape parameter - 0-th peak gaussian broadening standard deviation - NScatters: lineshape parameter - number of scatters included in lineshape - simplified_scattering_path: path to simplified lineshape parameters #- detailed_scattering_path: path to H2 scattering files for detailed lineshape - efficiency_path: path to efficiency vs. frequency (and uncertainties) - use_lineshape (boolean): determines whether tritium spectrum is smeared by lineshape. If False, it will only be smeared with a Gaussian - detailed_or_simplified_lineshape: If use lineshape, this string determines which lineshape model is used. - apply_efficiency (boolean): determines whether tritium spectrum is multiplied by efficiency - return_frequency: data is always generated as energies. If this parameter is true a list of frequencies is added to the dictionary """ # Read other parameters self.Q = reader.read_param( params, 'Q', QT2) #Choose the atomic or molecular tritium endpoint self.m = reader.read_param(params, 'neutrino_mass', 0.2) #Neutrino mass (eV) self.Kmin = reader.read_param( params, 'Kmin', self.Q - self.m - 2300) #Energy corresponding to lower bound of frequency ROI (eV) self.Kmax = reader.read_param(params, 'Kmax', self.Q - self.m + 1000) #Same, for upper bound (eV) self.minf = reader.read_param(params, 'minf', 25.8e+9) #Minimum frequency if self.Kmax <= self.Kmin: logger.error("Kmax <= Kmin!") return False self.n_steps = reader.read_param(params, 'n_steps', 1e5) if self.n_steps <= 0: logger.error("Negative number of steps!") return False self.B_field = reader.read_param(params, 'B_field', 0.9578186017836624) #For a Phase IV gaussian smearing: self.sig_trans = reader.read_param( params, 'sig_trans', 0.020856 ) #Thermal translational Doppler broadening for atomic T (eV) self.other_sig = reader.read_param( params, 'other_sig', 0.05) #Kinetic energy broadening from other sources (eV) self.broadening = np.sqrt( self.sig_trans**2 + self.other_sig**2) #Total energy broadening (eV) # Phase II Spectrum parameters self.runtime = reader.read_param( params, 'runtime', 6.57e6) #In seconds. Default time is ~2.5 months. self.S = reader.read_param(params, 'S', 3300) self.B_1kev = reader.read_param( params, 'B_1keV', 0.1) #Background rate per keV for full runtime self.A_b = reader.read_param( params, 'A_b', self.B_1kev / float(self.runtime) / 1000.) #Flat background activity: events/s/eV self.B = self.A_b * self.runtime * (self.Kmax - self.Kmin ) #Background poisson rate self.poisson_stats = reader.read_param(params, 'poisson_stats', True) self.err_from_B = reader.read_param( params, 'err_from_B', 0.) #In eV, kinetic energy error from f_c --> K conversion #Simplified scattering model parameters self.survival_prob = reader.read_param(params, 'survival_prob', 0.77) self.scattering_sigma = reader.read_param(params, 'scattering_sigma', 18.6) self.NScatters = reader.read_param(params, 'NScatters', 20) #paths self.simplified_scattering_path = reader.read_param( params, 'simplified_scattering_path', '/host/input_data/simplified_scattering_params.txt') #self.detailed_scattering_path = reader.read_param(params, 'detailed_scattering_path', None) self.efficiency_path = reader.read_param(params, 'efficiency_path', '') #options self.use_lineshape = reader.read_param(params, 'use_lineshape', True) self.detailed_or_simplified_lineshape = reader.read_param( params, 'detailed_or_simplified_lineshape', 'detailed') self.apply_efficiency = reader.read_param(params, 'apply_efficiency', False) self.return_frequency = reader.read_param(params, 'return_frequency', True) # get file content if needed # get efficiency dictionary if self.apply_efficiency: self.efficiency_dict = self.load_efficiency_curve() np.random.seed() else: self.efficiency_dict = None # generate data with lineshape if self.use_lineshape: self.lineshape = self.detailed_or_simplified_lineshape if self.lineshape == 'simplified': self.SimpParams = self.load_simp_params( self.scattering_sigma, self.survival_prob, self.NScatters) elif self.lineshape == 'detailed': if not os.path.exists('./scatter_spectra_files'): raise IOError('./scatter_spectra_files does not exist') self.SimpParams = [ self.scattering_sigma * 2 * math.sqrt(2 * math.log(2)), self.survival_prob ] else: raise ValueError( "'detailed_or_simplified' is neither 'detailed' nor 'simplified'" ) else: self.lineshape = 'gaussian' self.SimpParams = [self.broadening] logger.info('Lineshape is Gaussian') return True
def InternalConfigure(self, params): ''' Configure ''' # Read other parameters self.bins_choice = reader.read_param(params, 'bins_choice', []) self.gases = reader.read_param(params, 'gases', ["H2", "Kr"]) self.max_scatters = reader.read_param(params, 'max_scatters', 20) self.max_comprehensive_scatters = reader.read_param( params, 'max_comprehensive_scatters', 20) self.fix_scatter_proportion = reader.read_param( params, 'fix_scatter_proportion', True) if self.fix_scatter_proportion == True: self.scatter_proportion = reader.read_param( params, 'gas1_scatter_proportion', 0.8) # This is an important parameter which determines how finely resolved # the scatter calculations are. 10000 seems to produce a stable fit, with minimal slowdown self.num_points_in_std_array = reader.read_param( params, 'num_points_in_std_array', 10000) self.RF_ROI_MIN = reader.read_param(params, 'RF_ROI_MIN', 25850000000.0) self.B_field = reader.read_param(params, 'B_field', 0.957810722501) self.shake_spectrum_parameters_json_path = reader.read_param( params, 'shake_spectrum_parameters_json_path', 'shake_spectrum_parameters.json') self.path_to_osc_strengths_files = reader.read_param( params, 'path_to_osc_strengths_files', '/host/') if not os.path.exists(self.shake_spectrum_parameters_json_path): raise IOError('Shake spectrum path does not exist') if not os.path.exists(self.path_to_osc_strengths_files): raise IOError('Path to osc strengths files does not exist')
def InternalConfigure(self, params): self.frequencies = list() self.results = list() self.frequency_shift = reader.read_param(params, "frequency_shift", 0) return True
def InternalConfigure(self, params): """Configures by reading in list of names of divergence plots to be created and dictionary containing fit object""" self.which_diag_plots = reader.read_param(params,"which_diag_plots") self.data = reader.read_param(params,"data",{})
def InternalConfigure(self,config_dict): ''' Args: - null_neutrino_mass (bool): set the neutrino mass to zero during fit - background: background rate in 1/eV/s - event_rate: tritium events in 1/s - duration: duration of data taking in s - options: Dicitonary (for example: {"snr_efficiency": True, "channel_efficiency":False, "smearing": False}) determines which efficiencies are multiplied and whether spectrum is smeared - energy_or_frequency: determines whether generated data is in energy or frequency domain - KEmin: minimum energy in eV. Only used if domain is energy. - KEmax: maximum energy in eV. Only used if domain is energy. - frequency_window: frequency range around central frequency in Hz. Only used if domain in frequency. - energy_resolution: width of Gaussian that will be used to smeare spectrum. Only used if domain is energy. - frequency_resolution: width of Gaussian that will be used to smeare spectrum. Only used if domain is frequency. - B_field_strength: used to translate energies to frequencies. Required for efficiency and frequency domain data. - snr_efficiency_coefficiency: polynomial coefficients for global (channel independent) efficiency. - channel_efficiency: coefficiency for filter function used to calcualte channel efficiency. function is: "c4 * TMath::Sqrt(1/(1 + 1*TMath::Power((@0*TMath::Power(10, -6)-cf)/c0, c1)))* TMath::Sqrt(1/(1 + TMath::Power((@0*TMath::Power(10, -6)-cf)/c2, c3))) cf is in MHz - channel_central_frequency: central frequency needed to calculate channel efficiency. Only used if channel efficiency is applied. - mixing_frequency: frequency to substract from global frequencies. ''' super().InternalConfigure(config_dict) self.null_m_nu = reader.read_param(config_dict,"null_neutrino_mass",False) self.background = reader.read_param(config_dict, "background", 1e-9) self.event_rate = reader.read_param(config_dict, "event_rate", 1.) self.duration = reader.read_param(config_dict, "duration", 24*3600) self.energy_or_frequency = reader.read_param(config_dict, "energy_or_frequency", "frequency") self.KEmin = reader.read_param(config_dict, "KEmin", 18.6e3-1e3) self.KEmax = reader.read_param(config_dict, "KEmax", 18.6e3+1e3) self.Fwindow = reader.read_param(config_dict, "frequency_window", [-50e6, 50e6]) self.energy_resolution = reader.read_param(config_dict, "energy_resolution", 0) self.frequency_resolution = reader.read_param(config_dict, "frequency_resolution", 0) self.B = reader.read_param(config_dict, "B_field_strength", 0.95777194923080811) self.snr_eff_coeff = reader.read_param(config_dict, "snr_efficiency_coefficients", [0.1, 0, 0, 0, 0, 0]) self.channel_eff_coeff = reader.read_param(config_dict, "channel_efficiency_coefficients", [24587.645303008387, 7645.8567999493698, 24507.145055859062, -11581.288750763715, 0.98587787287591955]) self.channel_cf = reader.read_param(config_dict, "channel_central_frequency", 1000e6) self.mix_frequency = reader.read_param(config_dict, "mixing_frequency", 24.5e9) self.Fmin, self.Fmax = [self.mix_frequency + self.channel_cf + self.Fwindow[0] , self.mix_frequency + self.channel_cf + self.Fwindow[1]] return True
def InternalConfigure(self, params): ''' Configure ''' # Read other parameters self.namedata = reader.read_param(params, 'variables', "required") self.N = reader.read_param(params, 'N', 'N') self.eff_eqn = reader.read_param(params, 'efficiency', '1') self.bins = reader.read_param(params, 'bins', []) self.asInteger = reader.read_param(params, 'asInteger', False) self.energy_or_frequency = reader.read_param( params, 'energy_or_frequency', 'energy') #Currently only set up to use frequency self.efficiency_filepath = reader.read_param(params, 'efficiency_filepath', '') self.fss_bins = reader.read_param(params, "fss_bins", False) # If self.fss_bins is True, self.bins is ignored and overwritten # initialize the histogram to store the corrected data if self.energy_or_frequency == 'energy': print(sys.getrefcount(self.corrected_data)) self.output_bin_variable = 'KE' elif self.energy_or_frequency == 'frequency': self.output_bin_variable = 'F' else: return False self.efficiency_file_content = self.GetEfficiencyFileContent() if not self.efficiency_file_content == self.GetEfficiencyFileContent(): logger.error("Failed reading efficiency file") return False if self.fss_bins == True: self.bin_centers = self.efficiency_file_content['frequencies'] self.bins = np.array(self.bin_centers) - (self.bin_centers[1] - self.bin_centers[0]) / 2 self.bins = np.append(self.bins, [ self.bin_centers[-1] + (self.bin_centers[1] - self.bin_centers[0]) / 2 ]) else: self.bin_centers = self.bins[0:-1] + 0.5 * (self.bins[1] - self.bins[0]) # check that frequency bins are withing good frequency region if self.bins[-1] > np.max( self.efficiency_file_content['frequencies']): logger.error( 'Bin edge above FSS frequency region. FSS region is {} - {} GHz' .format( np.min(self.efficiency_file_content['frequencies']) * 1e-9, np.max(self.efficiency_file_content['frequencies']) * 1e-9)) return False elif self.bins[0] < np.min( self.efficiency_file_content['frequencies']): logger.warning( 'Bin edge below FSS frequency region. As long as tritium endpoint is higher (in frequency) this is not a problem. FSS region is {} - {} GHz' .format( np.min(self.efficiency_file_content['frequencies']) * 1e-9, np.max(self.efficiency_file_content['frequencies']) * 1e-9)) return True