create view rich700_detector_setup_at_date
  ( pmt, backplane, active, geom_obj_name )
  as
  select s.pmt_id, m.backplane_id, s.active, m.geom_obj_name
    from rich700_detector_setup s, rich700_backplane_pmt m
    where hades_oper.run_query_2.get_date between s.valid_since and s.valid_until
      and hades_oper.run_query_2.get_history_date between s.date_create and s.invalid_since
      and hades_oper.run_query_2.get_location_id = s.exp_location_id
      and s.pmt_id = m.pmt_id;
 
comment on table rich700_detector_setup_at_date is 'Setup of RICH700 valid for a special run (use before package hades_oper.run_query to set a run)';
comment on column rich700_detector_setup_at_date.pmt is 'Globall identifier of the rich700 PMT';
comment on column rich700_detector_setup_at_date.backplane is 'Global identifier  of rich700 backplane';
comment on column rich700_detector_setup_at_date.active is 'Status of the PMT module (0= not active, 1= active)';
comment on column rich700_detector_setup_at_date.geom_obj_name is 'Name of PMT geometry object';
