From 1a44d13635e480df4fdf7a27573c7eb63069ea91 Mon Sep 17 00:00:00 2001 From: "guillaume.grolleron" Date: Fri, 1 Dec 2023 12:19:25 +0100 Subject: [PATCH] -add classes to perform SPE fit directly at nominal voltage (config files) -change SPE fit plotting matplotlib -> pyqtgraph to speed up the plots generation --- .../calibration/gain/FlatFieldSPEMakers.py | 27 ++- .../makers/component/FlatFieldSPEComponent.py | 33 ++- src/nectarchain/makers/component/__init__.py | 2 + ...=> parameters_SPECombined_fromHHVFit.yaml} | 0 ...ers_signal.yaml => parameters_SPEHHV.yaml} | 0 ...gnalStd.yaml => parameters_SPEHHVStd.yaml} | 0 .../component/spe/parameters_SPEnominal.yaml | 32 +++ .../spe/parameters_SPEnominalStd.yaml | 32 +++ .../makers/component/spe/spe_algorithm.py | 202 ++++++++++++++---- .../gain_SPEfit_combined_computation.py | 5 +- .../ggrolleron/gain_SPEfit_computation.py | 29 ++- 11 files changed, 305 insertions(+), 57 deletions(-) rename src/nectarchain/makers/component/spe/{parameters_signal_fromHHVFit.yaml => parameters_SPECombined_fromHHVFit.yaml} (100%) rename src/nectarchain/makers/component/spe/{parameters_signal.yaml => parameters_SPEHHV.yaml} (100%) rename src/nectarchain/makers/component/spe/{parameters_signalStd.yaml => parameters_SPEHHVStd.yaml} (100%) create mode 100644 src/nectarchain/makers/component/spe/parameters_SPEnominal.yaml create mode 100644 src/nectarchain/makers/component/spe/parameters_SPEnominalStd.yaml diff --git a/src/nectarchain/makers/calibration/gain/FlatFieldSPEMakers.py b/src/nectarchain/makers/calibration/gain/FlatFieldSPEMakers.py index fe7d147c..79891a9f 100644 --- a/src/nectarchain/makers/calibration/gain/FlatFieldSPEMakers.py +++ b/src/nectarchain/makers/calibration/gain/FlatFieldSPEMakers.py @@ -23,12 +23,10 @@ from ....data.management import DataManagement +__all__ = ["FlatFieldSPENominalNectarCAMCalibrationTool","FlatFieldSPENominalStdNectarCAMCalibrationTool","FlatFieldSPEHHVNectarCAMCalibrationTool","FlatFieldSPEHHVStdNectarCAMCalibrationTool","FlatFieldSPECombinedStdNectarCAMCalibrationTool"] -__all__ = ["FlatFieldSPEHHVNectarCAMCalibrationTool","FlatFieldSPEHHVStdNectarCAMCalibrationTool","FlatFieldSPECombinedStdNectarCAMCalibrationTool"] - - -class FlatFieldSPEHHVNectarCAMCalibrationTool(GainNectarCAMCalibrationTool): +class FlatFieldSPENominalNectarCAMCalibrationTool(GainNectarCAMCalibrationTool): name = "FlatFieldSPEHHVNectarCAM" componentsList = ComponentNameList( NectarCAMComponent, @@ -113,9 +111,15 @@ def _write_container(self, container : Container,index_component : int = 0) -> N #else : super()._write_container(container = container,index_component= index_component) +class FlatFieldSPEHHVNectarCAMCalibrationTool(FlatFieldSPENominalNectarCAMCalibrationTool): + name = "FlatFieldSPEHHVNectarCAM" + componentsList = ComponentNameList( + NectarCAMComponent, + default_value = ["FlatFieldSingleHHVSPENectarCAMComponent"], + help="List of Component names to be apply, the order will be respected" + ).tag(config=True) - -class FlatFieldSPEHHVStdNectarCAMCalibrationTool(FlatFieldSPEHHVNectarCAMCalibrationTool): +class FlatFieldSPEHHVStdNectarCAMCalibrationTool(FlatFieldSPENominalNectarCAMCalibrationTool): name = "FlatFieldSPEHHVStdNectarCAM" componentsList = ComponentNameList( NectarCAMComponent, @@ -124,7 +128,16 @@ class FlatFieldSPEHHVStdNectarCAMCalibrationTool(FlatFieldSPEHHVNectarCAMCalibra ).tag(config=True) -class FlatFieldSPECombinedStdNectarCAMCalibrationTool(FlatFieldSPEHHVNectarCAMCalibrationTool): +class FlatFieldSPENominalStdNectarCAMCalibrationTool(FlatFieldSPENominalNectarCAMCalibrationTool): + name = "FlatFieldSPENominalStdNectarCAM" + componentsList = ComponentNameList( + NectarCAMComponent, + default_value = ["FlatFieldSingleNominalSPEStdNectarCAMComponent"], + help="List of Component names to be apply, the order will be respected" + ).tag(config=True) + + +class FlatFieldSPECombinedStdNectarCAMCalibrationTool(FlatFieldSPENominalNectarCAMCalibrationTool): name = "FlatFieldCombinedStddNectarCAM" componentsList = ComponentNameList( NectarCAMComponent, diff --git a/src/nectarchain/makers/component/FlatFieldSPEComponent.py b/src/nectarchain/makers/component/FlatFieldSPEComponent.py index 038e9f39..7a594bd9 100644 --- a/src/nectarchain/makers/component/FlatFieldSPEComponent.py +++ b/src/nectarchain/makers/component/FlatFieldSPEComponent.py @@ -21,13 +21,13 @@ from .chargesComponent import ChargesComponent from .gainComponent import GainNectarCAMComponent from .chargesComponent import ChargesComponent -from .spe import SPEHHVStdalgorithm,SPEHHValgorithm,SPECombinedalgorithm +from .spe import SPEHHVStdalgorithm,SPEHHValgorithm,SPECombinedalgorithm,SPEnominalStdalgorithm,SPEnominalalgorithm from ...utils import ComponentUtils -__all__ = ["FlatFieldSingleHHVSPENectarCAMComponent","FlatFieldSingleHHVSPEStdNectarCAMComponent","FlatFieldCombinedSPEStdNectarCAMComponent"] +__all__ = ["FlatFieldSingleNominalSPEStdNectarCAMComponent","FlatFieldSingleNominalSPENectarCAMComponent","FlatFieldSingleHHVSPENectarCAMComponent","FlatFieldSingleHHVSPEStdNectarCAMComponent","FlatFieldCombinedSPEStdNectarCAMComponent"] -class FlatFieldSingleHHVSPENectarCAMComponent(GainNectarCAMComponent): - SPEfitalgorithm = Unicode("SPEHHValgorithm", +class FlatFieldSingleNominalSPENectarCAMComponent(GainNectarCAMComponent): + SPEfitalgorithm = Unicode("SPEnominalalgorithm", help = "The Spe fit method to be use", read_only = True, ).tag(config = True) @@ -129,9 +129,27 @@ def finish(self,*args,**kwargs) : +class FlatFieldSingleNominalSPEStdNectarCAMComponent(FlatFieldSingleNominalSPENectarCAMComponent): + SPEfitalgorithm = Unicode("SPEnominalStdalgorithm", + help = "The Spe fit method to be use", + read_only = True, + ).tag(config = True) + + SubComponents = copy.deepcopy(GainNectarCAMComponent.SubComponents) + SubComponents.default_value = ["ChargesComponent",f"{SPEfitalgorithm.default_value}"] + SubComponents.read_only = True +class FlatFieldSingleHHVSPENectarCAMComponent(FlatFieldSingleNominalSPENectarCAMComponent): + SPEfitalgorithm = Unicode("SPEHHValgorithm", + help = "The Spe fit method to be use", + read_only = True, + ).tag(config = True) + + SubComponents = copy.deepcopy(GainNectarCAMComponent.SubComponents) + SubComponents.default_value = ["ChargesComponent",f"{SPEfitalgorithm.default_value}"] + SubComponents.read_only = True -class FlatFieldSingleHHVSPEStdNectarCAMComponent(FlatFieldSingleHHVSPENectarCAMComponent): +class FlatFieldSingleHHVSPEStdNectarCAMComponent(FlatFieldSingleNominalSPENectarCAMComponent): SPEfitalgorithm = Unicode("SPEHHVStdalgorithm", help = "The Spe fit method to be use", read_only = True, @@ -142,7 +160,10 @@ class FlatFieldSingleHHVSPEStdNectarCAMComponent(FlatFieldSingleHHVSPENectarCAMC SubComponents.read_only = True -class FlatFieldCombinedSPEStdNectarCAMComponent(FlatFieldSingleHHVSPEStdNectarCAMComponent) : + + + +class FlatFieldCombinedSPEStdNectarCAMComponent(FlatFieldSingleNominalSPENectarCAMComponent) : SPEfitalgorithm = Unicode("SPECombinedalgorithm", help = "The Spe fit method to be use", read_only = True, diff --git a/src/nectarchain/makers/component/__init__.py b/src/nectarchain/makers/component/__init__.py index fcf07804..9926ccef 100644 --- a/src/nectarchain/makers/component/__init__.py +++ b/src/nectarchain/makers/component/__init__.py @@ -15,6 +15,8 @@ "SPECombinedalgorithm", "FlatFieldSingleHHVSPENectarCAMComponent", "FlatFieldSingleHHVSPEStdNectarCAMComponent", + "FlatFieldSingleNominalSPENectarCAMComponent", + "FlatFieldSingleNominalSPEStdNectarCAMComponent", "FlatFieldCombinedSPEStdNectarCAMComponent", "ChargesComponent", "WaveformsComponent", diff --git a/src/nectarchain/makers/component/spe/parameters_signal_fromHHVFit.yaml b/src/nectarchain/makers/component/spe/parameters_SPECombined_fromHHVFit.yaml similarity index 100% rename from src/nectarchain/makers/component/spe/parameters_signal_fromHHVFit.yaml rename to src/nectarchain/makers/component/spe/parameters_SPECombined_fromHHVFit.yaml diff --git a/src/nectarchain/makers/component/spe/parameters_signal.yaml b/src/nectarchain/makers/component/spe/parameters_SPEHHV.yaml similarity index 100% rename from src/nectarchain/makers/component/spe/parameters_signal.yaml rename to src/nectarchain/makers/component/spe/parameters_SPEHHV.yaml diff --git a/src/nectarchain/makers/component/spe/parameters_signalStd.yaml b/src/nectarchain/makers/component/spe/parameters_SPEHHVStd.yaml similarity index 100% rename from src/nectarchain/makers/component/spe/parameters_signalStd.yaml rename to src/nectarchain/makers/component/spe/parameters_SPEHHVStd.yaml diff --git a/src/nectarchain/makers/component/spe/parameters_SPEnominal.yaml b/src/nectarchain/makers/component/spe/parameters_SPEnominal.yaml new file mode 100644 index 00000000..18b6ee31 --- /dev/null +++ b/src/nectarchain/makers/component/spe/parameters_SPEnominal.yaml @@ -0,0 +1,32 @@ +{ + pedestalWidth : { + value : 50, + min : 1, + max : 150 + }, + luminosity : { + value : 1, + min : 0.01, + max : 5.0 + }, + pp : { + value : 0.45, + min : 0.2, + max : 0.8 + }, + resolution : { + value : 0.5, + min : 0.3, + max : 0.7 + }, + n : { + value : 0.697, + min : 0.5, + max : 0.9 + }, + mean : { + value : 50, + min : 10, + max : 200 + } +} \ No newline at end of file diff --git a/src/nectarchain/makers/component/spe/parameters_SPEnominalStd.yaml b/src/nectarchain/makers/component/spe/parameters_SPEnominalStd.yaml new file mode 100644 index 00000000..3be2f77f --- /dev/null +++ b/src/nectarchain/makers/component/spe/parameters_SPEnominalStd.yaml @@ -0,0 +1,32 @@ +{ + pedestalWidth : { + value : 50, + min : 1, + max : 150 + }, + luminosity : { + value : 1, + min : 0.01, + max : 5.0 + }, + pp : { + value : 0.45, + min : .NAN, + max : .NAN + }, + resolution : { + value : 0.5, + min : 0.3, + max : 0.7 + }, + n : { + value : 0.697, + min : .NAN, + max : .NAN + }, + mean : { + value : 50, + min : 10, + max : 200 + } +} \ No newline at end of file diff --git a/src/nectarchain/makers/component/spe/spe_algorithm.py b/src/nectarchain/makers/component/spe/spe_algorithm.py index 6e255491..15074b5c 100644 --- a/src/nectarchain/makers/component/spe/spe_algorithm.py +++ b/src/nectarchain/makers/component/spe/spe_algorithm.py @@ -49,7 +49,7 @@ weight_gaussian, ) -__all__ = ["SPEHHValgorithm","SPEHHVStdalgorithm","SPECombinedalgorithm"] +__all__ = ["SPEHHValgorithm","SPEHHVStdalgorithm","SPEnominalStdalgorithm","SPEnominalalgorithm","SPECombinedalgorithm"] class SPEalgorithm(Component) : Windows_lenght = Integer(40, @@ -204,7 +204,7 @@ def _update_parameters( @staticmethod def _get_mean_gaussian_fit( - charge: np.ndarray, counts: np.ndarray, extension: str = "", **kwargs + charge: np.ndarray, counts: np.ndarray, pixel_id = None, **kwargs ) -> Tuple[np.ndarray, np.ndarray]: """ Perform a Gaussian fit on the data to determine the pedestal and mean values. @@ -212,7 +212,7 @@ def _get_mean_gaussian_fit( Args: charge (np.ndarray): An array of charge values. counts (np.ndarray): An array of corresponding counts. - extension (str, optional): An extension string. Defaults to "". + pixel_id (int): The id of the current pixel. Default to None **kwargs: Additional keyword arguments. Returns: @@ -278,7 +278,7 @@ def _get_mean_gaussian_fit( exist_ok=True, ) fig.savefig( - f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/initialization_pedestal_pixel{extension}_{os.getpid()}.pdf" + f"{os.environ.get('NECTARCHAIN_LOG')}/{os.getpid()}/figures/initialization_pedestal_pixel{pixel_id}_{os.getpid()}.pdf" ) fig.clf() plt.close(fig) @@ -339,7 +339,7 @@ def _get_mean_gaussian_fit( exist_ok=True, ) fig.savefig( - f"{os.environ.get('NECTARCHAIN_LOG','/tmp')}/{os.getpid()}/figures/initialization_mean_pixel{extension}_{os.getpid()}.pdf" + f"{os.environ.get('NECTARCHAIN_LOG','/tmp')}/{os.getpid()}/figures/initialization_mean_pixel{pixel_id}_{os.getpid()}.pdf" ) fig.clf() plt.close(fig) @@ -371,16 +371,16 @@ def _update_table_from_parameters(self) -> None: ) ''' -class SPEHHValgorithm(SPEalgorithm): +class SPEnominalalgorithm(SPEalgorithm): - parameters_file = Unicode("parameters_signal.yaml", + parameters_file = Unicode("parameters_SPEnominal.yaml", read_only = True, help = "The name of the SPE fit parameters file", ).tag(config = True) __fit_array = None - tol = Float(1e40, + tol = Float(1e-1, help="The tolerance used for minuit", read_only = True, ).tag(config=True) @@ -481,6 +481,7 @@ def _fill_results_table_from_dict(self, dico: dict, pixels_id: np.ndarray) -> No Returns: None """ + ########NEED TO BE OPTIMIZED!!!########### chi2_sig = signature(__class__.cost(self._charge, self._counts)) for i in range(len(pixels_id)): values = dico[i].get(f"values_{i}", None) @@ -742,11 +743,80 @@ def run( if display: self.log.info("plotting") + t = time.time() self.display(pixels_id, **kwargs) + log.info(f"time for plotting {len(pixels_id)} pixels : {time.time() - t:.2e} sec") return output - - def plot_single( + def plot_single_pyqtgraph( + pixel_id: int, + charge: np.ndarray, + counts: np.ndarray, + pp: float, + resolution: float, + gain: float, + gain_error: float, + n: float, + pedestal: float, + pedestalWidth: float, + luminosity: float, + likelihood: float, + ) -> tuple: + import pyqtgraph as pg + from pyqtgraph.Qt import QtGui, QtCore + #from pyqtgraph.Qt import QtGui + + app = pg.mkQApp(name = 'minimal') +# + ## Create a window + win = pg.GraphicsLayoutWidget(show=False) + win.setWindowTitle(f"SPE fit pixel id : {pixel_id}") + + # Add a plot to the window + plot = win.addPlot(title = f"SPE fit pixel id : {pixel_id}") + + plot.addLegend() + error = pg.ErrorBarItem( + x=charge, + y=counts, + top=np.sqrt(counts), + bottom=np.sqrt(counts), + beam=0.5) + plot.addItem(error) + plot.plot( + x=charge, + y=np.trapz(counts, charge) + * MPE2( + charge, + pp, + resolution, + gain, + n, + pedestal, + pedestalWidth, + luminosity, + ), + name = f"SPE model fit", + ) + legend = pg.TextItem( + f"SPE model fit gain : {gain - gain_error:.2f} < {gain:.2f} < {gain + gain_error:.2f} ADC/pe,\n likelihood : {likelihood:.2f}", + color=(200, 200, 200), + ) + legend.setPos(pedestal,np.max(counts)/2) + font = QtGui.QFont() + font.setPointSize(12) + legend.setFont(font) + legend.setTextWidth(500) + plot.addItem(legend) + + label_style = {"color": "#EEE", "font-size": "12pt"} + plot.setLabel("bottom", "Charge (ADC)", **label_style) + plot.setLabel("left", "Events",**label_style) + plot.setRange(xRange=[pedestal - 6 * pedestalWidth, np.quantile(charge.data[~charge.mask],0.84)]) + #ax.legend(fontsize=18) + return win + + def plot_single_matplotlib( pixel_id: int, charge: np.ndarray, counts: np.ndarray, @@ -802,48 +872,93 @@ def plot_single( ax.set_xlabel("Charge (ADC)", size=15) ax.set_ylabel("Events", size=15) ax.set_title(f"SPE fit pixel id : {pixel_id}") - ax.set_xlim([pedestal - 6 * pedestalWidth, None]) + ax.set_xlim([pedestal - 6 * pedestalWidth, np.max(charge)]) ax.legend(fontsize=18) return fig, ax - def display(self, pixels_id: np.ndarray, **kwargs) -> None: + def display(self, pixels_id: np.ndarray, package = "pyqtgraph", **kwargs) -> None: """ Display and save the plot for each specified pixel ID. Args: pixels_id (np.ndarray): An array of pixel IDs. + package (str): the package use to plot, can be matplotlib or pyqtgraph. Default to pyqtgraph **kwargs: Additional keyword arguments. figpath (str): The path to save the generated plot figures. Defaults to "/tmp/NectarGain_pid{os.getpid()}". """ - matplotlib.use('TkAgg') - figpath = kwargs.get("figpath", f"/tmp/NectarGain_pid{os.getpid()}") + figpath = kwargs.get("figpath", f"{os.environ.get('NECTARCHAIN_FIGURES','/tmp')}/NectarGain_pid{os.getpid()}") + self.log.debug(f"saving figures in {figpath}") os.makedirs(figpath, exist_ok=True) - for _id in pixels_id: - index = np.argmax(self._results.pixels_id == _id) - fig, ax = __class__.plot_single( - _id, - self._charge[index], - self._counts[index], - self._results.pp[index][0], - self._results.resolution[index][0], - self._results.high_gain[index][0], - self._results.high_gain[index][1:].mean(), - self._results.n[index][0], - self._results.pedestal[index][0], - self._results.pedestalWidth[index][0], - self._results.luminosity[index][0], - self._results.likelihood[index], - ) - fig.savefig(f"{figpath}/fit_SPE_pixel{_id}.pdf") - fig.clf() - plt.close(fig) - del fig, ax + if package == "matplotlib" : + matplotlib.use('TkAgg') + for _id in pixels_id: + index = np.argmax(self._results.pixels_id == _id) + fig, ax = __class__.plot_single_matplotlib( + _id, + self._charge[index], + self._counts[index], + self._results.pp[index][0], + self._results.resolution[index][0], + self._results.high_gain[index][0], + self._results.high_gain[index][1:].mean(), + self._results.n[index][0], + self._results.pedestal[index][0], + self._results.pedestalWidth[index][0], + self._results.luminosity[index][0], + self._results.likelihood[index], + ) + fig.savefig(f"{figpath}/fit_SPE_pixel{_id}.pdf") + fig.clf() + plt.close(fig) + del fig, ax + elif package =="pyqtgraph" : + import pyqtgraph as pg + import pyqtgraph.exporters + for _id in pixels_id: + index = np.argmax(self._results.pixels_id == _id) + try : + widget = None + widget = __class__.plot_single_pyqtgraph( + _id, + self._charge[index], + self._counts[index], + self._results.pp[index][0], + self._results.resolution[index][0], + self._results.high_gain[index][0], + self._results.high_gain[index][1:].mean(), + self._results.n[index][0], + self._results.pedestal[index][0], + self._results.pedestalWidth[index][0], + self._results.luminosity[index][0], + self._results.likelihood[index], + ) + exporter = pg.exporters.ImageExporter(widget.getItem(0,0)) + exporter.parameters()['width'] = 1000 + exporter.export(f"{figpath}/fit_SPE_pixel{_id}.png") + except Exception as e : + log.warning(e,exc_info = True) + finally : + del widget + + +class SPEHHValgorithm(SPEnominalalgorithm): + """class to perform fit of the SPE HHV signal with n and pp free""" -class SPEHHVStdalgorithm(SPEHHValgorithm): + parameters_file = Unicode("parameters_SPEHHV.yaml", + read_only = True, + help = "The name of the SPE fit parameters file", + ).tag(config = True) + tol = Float(1e40, + help="The tolerance used for minuit", + read_only = True, + ).tag(config=True) + + +class SPEnominalStdalgorithm(SPEnominalalgorithm): """class to perform fit of the SPE signal with n and pp fixed""" - parameters_file = Unicode("parameters_signalStd.yaml", + parameters_file = Unicode("parameters_SPEnominalStd.yaml", read_only = True, help = "The name of the SPE fit parameters file", ).tag(config = True) @@ -871,9 +986,20 @@ def __fix_parameters(self) -> None: n = self._parameters["n"] n.frozen = True +class SPEHHVStdalgorithm(SPEnominalStdalgorithm) : + parameters_file = Unicode( + "parameters_SPEHHVStd.yaml", + read_only = True, + help = "The name of the SPE fit parameters file", + ).tag(config = True) + tol = Float(1e40, + help="The tolerance used for minuit", + read_only = True, + ).tag(config=True) + -class SPECombinedalgorithm(SPEHHValgorithm): - parameters_file = Unicode("parameters_signal_fromHHVFit.yaml", +class SPECombinedalgorithm(SPEnominalalgorithm): + parameters_file = Unicode("parameters_SPECombined_fromHHVFit.yaml", read_only = True, help = "The name of the SPE fit parameters file", ).tag(config = True) diff --git a/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_combined_computation.py b/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_combined_computation.py index 17bb7283..7344b145 100644 --- a/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_combined_computation.py +++ b/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_combined_computation.py @@ -3,6 +3,7 @@ import sys from pathlib import Path import json +import time # to quiet numba os.makedirs(os.environ.get("NECTARCHAIN_LOG"), exist_ok=True) @@ -197,7 +198,7 @@ def main(log, if __name__ == "__main__": - + t = time.time() args = parser.parse_args() kwargs = copy.deepcopy(vars(args)) @@ -229,4 +230,6 @@ def main(log, log.info(f"arguments passed to main are : {kwargs}") main(log = log, **kwargs) + log.info(f"time for execution is {time.time() - t:.2e} sec") + diff --git a/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_computation.py b/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_computation.py index 55f935b4..7d74c6ec 100644 --- a/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_computation.py +++ b/src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_computation.py @@ -3,6 +3,7 @@ import sys from pathlib import Path import json +import time # to quiet numba os.makedirs(os.environ.get("NECTARCHAIN_LOG"), exist_ok=True) @@ -18,7 +19,9 @@ import argparse from nectarchain.makers.calibration import ( FlatFieldSPEHHVStdNectarCAMCalibrationTool, - FlatFieldSPEHHVNectarCAMCalibrationTool + FlatFieldSPEHHVNectarCAMCalibrationTool, + FlatFieldSPENominalNectarCAMCalibrationTool, + FlatFieldSPENominalStdNectarCAMCalibrationTool ) from nectarchain.makers.extractor.utils import CtapipeExtractor @@ -119,6 +122,14 @@ "--free_pp_n", action="store_true", default=False, help="to let free pp and n" ) +#to say if it is a run taken at HHV +parser.add_argument( + "--HHV", + action="store_true", + default=False, + help="to say that these runs are taken at HHV, it will change the configuration file used" +) + # multiprocessing args parser.add_argument( "--multiproc", @@ -152,11 +163,16 @@ def main(log, figpath = args.figpath - - if args.free_pp_n: - _class = FlatFieldSPEHHVNectarCAMCalibrationTool + if args.HHV : + if args.free_pp_n: + _class = FlatFieldSPEHHVNectarCAMCalibrationTool + else : + _class = FlatFieldSPEHHVStdNectarCAMCalibrationTool else : - _class = FlatFieldSPEHHVStdNectarCAMCalibrationTool + if args.free_pp_n: + _class = FlatFieldSPENominalNectarCAMCalibrationTool + else : + _class = FlatFieldSPENominalStdNectarCAMCalibrationTool for _run_number,_max_events in zip(run_number,max_events) : try : @@ -179,6 +195,7 @@ def main(log, if __name__ == "__main__": + t = time.time() args = parser.parse_args() kwargs = copy.deepcopy(vars(args)) @@ -207,6 +224,8 @@ def main(log, kwargs.pop("verbosity") kwargs.pop('figpath') kwargs.pop('display') + kwargs.pop('HHV') log.info(f"arguments passed to main are : {kwargs}") main(log = log, **kwargs) + log.info(f"time for execution is {time.time() - t:.2e} sec")