Ejemplo n.º 1
0
def xenonnt_online(output_folder='./strax_data',
                   we_are_the_daq=False,
                   **kwargs):
    """XENONnT online processing and analysis"""
    context_options = {**straxen.contexts.common_opts, **kwargs}

    st = strax.Context(storage=[
        straxen.RunDB(readonly=not we_are_the_daq,
                      runid_field='number',
                      new_data_path=output_folder),
    ],
                       config=straxen.contexts.xnt_common_config,
                       **context_options)
    st.register([straxen.DAQReader, straxen.LEDCalibration])

    if not we_are_the_daq:
        st.storage += [
            strax.DataDirectory('/dali/lgrandi/xenonnt/raw',
                                readonly=True,
                                take_only=straxen.DAQReader.provides),
            strax.DataDirectory('/dali/lgrandi/xenonnt/processed',
                                readonly=True)
        ]
        if output_folder:
            st.storage.append(strax.DataDirectory(output_folder))

        st.context_config['forbid_creation_of'] = ('raw_records', 'records')

    return st
Ejemplo n.º 2
0
    def setUpClass(cls) -> None:
        # Just to make sure we are running some mongo server, see test-class docstring
        cls.test_run_ids = ['0', '1']
        cls.all_targets = ('peaks', 'records')

        uri = os.environ.get('TEST_MONGO_URI')
        db_name = 'test_rundb'
        cls.collection_name = 'test_rundb_coll'
        client = pymongo.MongoClient(uri)
        cls.database = client[db_name]
        collection = cls.database[cls.collection_name]
        cls.path = os.path.join(tempfile.gettempdir(), 'strax_data')
        # assert cls.collection_name not in cls.database.list_collection_names()

        if not straxen.utilix_is_configured():
            # Bit of an ugly hack but there is no way to get around this
            # function even though we don't need it
            straxen.rundb.utilix.rundb.xent_collection = lambda *args, **kwargs: collection

        cls.rundb_sf = straxen.RunDB(readonly=False,
                                     runid_field='number',
                                     new_data_path=cls.path,
                                     minimum_run_number=-1,
                                     rucio_path='./strax_test_data',
                                     )
        cls.rundb_sf.client = client
        cls.rundb_sf.collection = collection

        cls.st = strax.Context(register=[Records, Peaks],
                               storage=[cls.rundb_sf],
                               use_per_run_defaults=False,
                               config=dict(bonus_area=0),
                               )
Ejemplo n.º 3
0
 def test_invalids(self):
     """Test a couble of invalid ways of passing arguments to the RunDB"""
     with self.assertRaises(ValueError):
         straxen.RunDB(runid_field='numbersdfgsd', )
     with self.assertRaises(ValueError):
         r = self.test_run_ids[0]
         keys = [self.st.key_for(r, t) for t in self.all_targets]
         self.rundb_sf.find_several(keys, fuzzy_for=self.all_targets)
     with self.assertRaises(strax.DataNotAvailable):
         self.rundb_sf.find(self.st.key_for('_super-run', self.all_targets[0]))
Ejemplo n.º 4
0
def nt_daq_test_analysis(local_data_dir='./strax_data'):
    """Return strax test for analysis of the nT DAQ test data"""
    return strax.Context(
        storage = [
            straxen.RunDB(
                mongo_url='mongodb://{username}:{password}@gw:27019/xenonnt',
                mongo_collname='run',
                runid_field='number',
                mongo_dbname='xenonnt'),
            # TODO: can we avoid having to declare this as another frontend?
            strax.DataDirectory('./strax_data_jelle')],
        **common_opts)
Ejemplo n.º 5
0
def xenonnt_online(output_folder='./strax_data',
                   we_are_the_daq=False,
                   _minimum_run_number=7157,
                   _database_init=True,
                   **kwargs):
    """XENONnT online processing and analysis"""
    context_options = {**straxen.contexts.common_opts, **kwargs}

    st = strax.Context(config=straxen.contexts.xnt_common_config,
                       **context_options)
    st.register_all(have_nT_plugins)
    st.register([straxen.DAQReader, straxen.LEDCalibration])

    st.storage = [
        straxen.RunDB(readonly=not we_are_the_daq,
                      minimum_run_number=_minimum_run_number,
                      runid_field='number',
                      new_data_path=output_folder,
                      rucio_path='/dali/lgrandi/rucio/')
    ] if _database_init else []
    if not we_are_the_daq:
        st.storage += [
            strax.DataDirectory('/dali/lgrandi/xenonnt/raw',
                                readonly=True,
                                take_only=straxen.DAQReader.provides),
            strax.DataDirectory('/dali/lgrandi/xenonnt/processed',
                                readonly=True)
        ]
        if output_folder:
            st.storage.append(strax.DataDirectory(output_folder))

        st.context_config[
            'forbid_creation_of'] = straxen.daqreader.DAQReader.provides + (
                'records', )
    # Only the online monitor backend for the DAQ
    elif _database_init:
        st.storage += [
            straxen.OnlineMonitor(readonly=not we_are_the_daq,
                                  take_only=(
                                      'veto_intervals',
                                      'online_peak_monitor',
                                      'online_veto_monitor',
                                  ))
        ]

    # Remap the data if it is before channel swap (because of wrongly cabled
    # signal cable connectors) These are runs older than run 8797. Runs
    # newer than 8796 are not affected. See:
    # https://github.com/XENONnT/straxen/pull/166 and
    # https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenonnt:dsg:daq:sector_swap
    st.set_context_config(
        {'apply_data_function': (straxen.common.remap_old, )})
    return st
Ejemplo n.º 6
0
def xenon1t_analysis(local_only=False):
    """Return strax context used for XENON1T re-analysis with
    the latest strax version
    """
    return straxen.XENONContext(
        storage=[
            straxen.RunDB(local_only=local_only),
            strax.DataDirectory('./strax_data'),
        ],
        register=straxen.plugins.pax_interface.RecordsFromPax,
        register_all=straxen.plugins.plugins,
        # When asking for runs that don't exist, throw an error rather than
        # starting the pax converter
        forbid_creation_of=('raw_records', ),
    )
Ejemplo n.º 7
0
def xenon1t_analysis(local_only=False):
    """Return strax context used for XENON1T re-analysis with
    the latest strax version
    """
    return strax.Context(
        storage=[
            straxen.RunDB(local_only=local_only),
            strax.DataDirectory(
                '/dali/lgrandi/aalbers/strax_data_raw',
                take_only='raw_records',
                deep_scan=False,
                readonly=True),
            strax.DataDirectory('./strax_data'),
        ],
        register=straxen.plugins.pax_interface.RecordsFromPax,
        # When asking for runs that don't exist, throw an error rather than
        # starting the pax converter
        forbid_creation_of=('raw_records',),
        **common_opts)
Ejemplo n.º 8
0
def xenonnt_online(output_folder='./strax_data',
                   we_are_the_daq=False,
                   _minimum_run_number=7157,
                   _maximum_run_number=None,
                   _database_init=True,
                   _forbid_creation_of=None,
                   _rucio_path='/dali/lgrandi/rucio/',
                   _raw_path='/dali/lgrandi/xenonnt/raw',
                   _processed_path='/dali/lgrandi/xenonnt/processed',
                   _add_online_monitor_frontend=False,
                   _context_config_overwrite=None,
                   **kwargs):
    """
    XENONnT online processing and analysis

    :param output_folder: str, Path of the strax.DataDirectory where new
        data can be stored
    :param we_are_the_daq: bool, if we have admin access to upload data
    :param _minimum_run_number: int, lowest number to consider
    :param _maximum_run_number: Highest number to consider. When None
        (the default) consider all runs that are higher than the
        minimum_run_number.
    :param _database_init: bool, start the database (for testing)
    :param _forbid_creation_of: str/tuple, of datatypes to prevent form
        being written (raw_records* is always forbidden).
    :param _rucio_path: str, path of rucio
    :param _raw_path: str, common path of the raw-data
    :param _processed_path: str. common path of output data
    :param _context_config_overwrite: dict, overwrite config
    :param _add_online_monitor_frontend: bool, should we add the online
        monitor storage frontend.
    :param kwargs: dict, context options
    :return: strax.Context
    """
    context_options = {
        **straxen.contexts.xnt_common_opts,
        **kwargs}

    st = strax.Context(
        config=straxen.contexts.xnt_common_config,
        **context_options)
    st.register([straxen.DAQReader, straxen.LEDCalibration])

    st.storage = [
        straxen.RunDB(
            readonly=not we_are_the_daq,
            minimum_run_number=_minimum_run_number,
            maximum_run_number=_maximum_run_number,
            runid_field='number',
            new_data_path=output_folder,
            rucio_path=_rucio_path,
        )] if _database_init else []
    if not we_are_the_daq:
        st.storage += [
            strax.DataDirectory(
                _raw_path,
                readonly=True,
                take_only=straxen.DAQReader.provides),
            strax.DataDirectory(
                _processed_path,
                readonly=True,
            )]
        if output_folder:
            st.storage.append(
                strax.DataDirectory(output_folder))

        st.context_config['forbid_creation_of'] = straxen.daqreader.DAQReader.provides
        if _forbid_creation_of is not None:
            st.context_config['forbid_creation_of'] += strax.to_str_tuple(_forbid_creation_of)
    # Only the online monitor backend for the DAQ
    if _database_init and (_add_online_monitor_frontend or we_are_the_daq):
        st.storage += [straxen.OnlineMonitor(
            readonly=not we_are_the_daq,
            take_only=('veto_intervals',
                       'online_peak_monitor',
                       'event_basics',))]

    # Remap the data if it is before channel swap (because of wrongly cabled
    # signal cable connectors) These are runs older than run 8797. Runs
    # newer than 8796 are not affected. See:
    # https://github.com/XENONnT/straxen/pull/166 and
    # https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenonnt:dsg:daq:sector_swap
    st.set_context_config({'apply_data_function': (straxen.remap_old,)})
    if _context_config_overwrite is not None:
        st.set_context_config(_context_config_overwrite)
    return st
Ejemplo n.º 9
0
 def test_find_local(self):
     """Make sure that we don't find the non existing data"""
     run_db = straxen.RunDB(rucio_path='./rucio_test')
     with self.assertRaises(strax.DataNotAvailable):
         run_db.find(self.test_keys[0])