Class Summaries
source code
This class stores information about the foreground and background in a 
database for making calculation of uncombined fars and combined fars quick 
and efficient.
bkg_stats groups triggers by experiment_id, ifos, and param_group 
(param_group is an arbitrary integer representing the param bin, e.g., 
mchirp [3.48,7.4), to which a trigger belongs; if no binning is done, then
it is 0 for all triggers). It stores ALL the triggers in all the time 
slides (except zero-lag) within that group.
sngl_slide_stats groups triggers by experiment_id, experiment_summ_id, ifos, and 
param_group. It therefore groups all triggers within each time slide 
separately. It is used to subtract triggers within the same slide when calculating
uncombined fars for the background. Therefore, it only stores slide triggers;
for any zero-lag datatype sngl_slide_stats is just an empty list.
datatypes maps the list of datatypes for an experiment to the corresponding
experiment_summ_ids:
datatypes[experiment_id][datatype] = [esid1, esid2, etc.]
frg_durs stores the duration for each experiment_summ_id. Its keys are 
[experiment_id][experimen_summ_id].
bkg_durs stores the background duration for each time-slide and zero-lag, 
i.e., for each experiment_summ_id. This is the sum of all other slide
datatypes sharing the same experiment_id except for the given slide. 
max_bkg_fars stores the maximum background fars of all the categories 
within each time slide. It's keys are (experiment_summ_id, ifo_group). 
The maximum background far is just the total number of triggers within a 
category divided by the background duration for that time slide.
If opts.combine_fars is set to across_all a category is defined by the 
param bin in which a trigger exists and the ifos that took part in the 
trigger. So, if there are three param bins and we've excluded H2,L1 triggers 
in H1,H2,L1 time, then there are 6 categories for H1,H2,L1 time: three param
bins each for H1,L1 and H1,H2,L1 coincident triggrs. Thus, ifo_group will 
be set to "ALL_IFOS" and there will be 6 max_bkg_fars stored for each 
experiment_summ_id in triple time.
If opts.combine_fars is set to across_param_only, then a category is 
defined only by the param bins; ifo coincidences are treated as 
separate experiments. Thus, ifo_group will be set to whatever
coinc. trigger we are considering and there will only be 3 max_bkg_fars 
stored for that entry.
zero_lag_ids stores the esid of all zero-lag "slides" of an experiment.
    zero_lag_ids[ experiment_id ] = [experiment_summ_id1, experiment_summ_id2, etc.]
    | 
       
     | 
      
      
     | 
  
    | 
       
     | 
      
        
          add_to_bkg_stats(self,
        experiment_id,
        experiment_summ_id,
        ifos,
        param_group,
        stat) 
      Adds a stat to bkg_stats and sngl_slide_stats. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          sort_bkg_stats(self) 
      Sorts each list in bkg_stats and sngl_slide_stats from smallest to 
      largest value. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          store_datatypes(self,
        experiment_id,
        experiment_summ_id,
        datatype) 
      Stores the experiment_summ_id associated with each datatype. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          get_datatype(self,
        experiment_summ_id) 
      Retrieve the datatype for a given experiment_summ_id. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          append_zero_lag_id(self,
        experiment_id,
        zero_lag_esid) 
      Adds a zero_lag_id to the zero_lag_ids dictionary. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          append_duration(self,
        experiment_id,
        experiment_summ_id,
        duration) 
      Adds a duration to frg_durs. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          calc_bkg_durs(self) 
      Sums the background durs for each time-slide (experiment_summ_id). | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          append_max_bkg_far(self,
        experiment_summ_id,
        ifo_group,
        max_bkg_far) 
      Adds a max_bkg_far to the appropiate list; lists are grouped by 
      experiment_summ_id and ifo_group. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          sort_max_bkg_fars(self) 
      Sorts the max_bkg_fars lists from smallest to highest values. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          calc_ufar_by_max(self,
        eid,
        esid,
        ifos,
        param_group,
        stat) 
      Calculates the uncombined false alarm rate for a trigger by counting 
      the number of background triggers in the same category as it that 
      have a stat value greater than or equal to the trigger's stat value 
      and dividing by the background duration for that slide. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          calc_ufar_by_min(self,
        eid,
        esid,
        ifos,
        param_group,
        stat) 
      Same as calc_ufar_by_max, except that the uncombined far is 
      calculated by counting background triggers that have a stat value 
      less than or equal to the given stat. | 
          
            source code
            
           | 
         
       
      
     | 
  
    | 
       
     | 
      
        
          calc_cfar(self,
        esid,
        ifo_group,
        ufar) 
      Calculates the combined far for the given uncombined far (ufar). | 
          
            source code
            
           | 
         
       
      
     | 
  
  
  
  add_to_bkg_stats(self,
        experiment_id,
        experiment_summ_id,
        ifos,
        param_group,
        stat)
  
   | source code 
     | 
    
  
  Adds a stat to bkg_stats and sngl_slide_stats. What stat is added is 
  determined on the command line by the ranking-stat option. 
  
   
 | 
 
  
  
  append_max_bkg_far(self,
        experiment_summ_id,
        ifo_group,
        max_bkg_far)
  
   | source code 
     | 
    
  
  Adds a max_bkg_far to the appropiate list; lists are grouped by 
  experiment_summ_id and ifo_group. If one wants to combined fars across 
  param_bins and coincident_ifos (as was done in the low-mass S51yr and 
  12-18 month analyses), ifo_group should be set to 
  "ALL_IFOS". 
  
   
 | 
 
  
  
  calc_ufar_by_max(self,
        eid,
        esid,
        ifos,
        param_group,
        stat)
  
   | source code 
     | 
    
  
  Calculates the uncombined false alarm rate for a trigger by counting 
  the number of background triggers in the same category as it that have a 
  stat value greater than or equal to the trigger's stat value and dividing
  by the background duration for that slide. To do this quickly, 
  bisect.bisect_left is used (see python documentation for more info) on 
  the bkg_stats list. Since bkg_stats contains all the triggers in all the 
  slides for some experiment_id, this will result in counting the triggers 
  that are in the same slide (given by the esid) as the trigger we are 
  considering (except for zero-lag). To correct for this, the trigger's 
  place in it's sngl_slide_stats list is subtracted from this value. The 
  "background" considered for some trigger is therefore all the 
  triggers sharing the same experiment_id, excluding zero-lag triggers and 
  triggers in the same time-slide as the trigger. This means that 
  uncombined far for non-zero-lag triggers will use one less time slide 
  than zero-lag triggers. 
  
   
 | 
 
  
  
  calc_ufar_by_min(self,
        eid,
        esid,
        ifos,
        param_group,
        stat)
  
   | source code 
     | 
    
  
  Same as calc_ufar_by_max, except that the uncombined far is calculated
  by counting background triggers that have a stat value less than or equal
  to the given stat. (Done by using bisect.bisect_right as opposed to 
  len(list) - bisect.bisect_left). Note: if stat is 0, will just return 0. 
  This is because a 0 when caclulating FARs by minimum value is equivalent 
  to inf. when caclulating FARs by maximum value. 
  
   
 | 
 
| 
  
  
   Calculates the combined far for the given uncombined far (ufar). This 
  is defined as the ufar times the number of categories that are active at 
  that point plus the sum of the max_bkg_fars of all the categories that 
  are inactive. Whether or not a category is "active" is 
  determined by it's max_bkg_far. If the given ufar is greater than some 
  max_bkg_far, then the category which that max_bkg_far represents is 
  considered inactive. If the given ufar is less than some max_bkg_far, 
  then the category is considered active. 
  
   
 |