View Javadoc

1   /*
2    * To change this template, choose Tools | Templates
3    * and open the template in the editor.
4    */
5   
6   package org.lcsim.recon.tracking.seedtracker.strategybuilder;
7   
8   /**
9    *The layer weighting scheme used by default by StrategyBuilder if no other is
10   * provided. It's loaded from a resource based on the name of the detector. 
11   * 
12   * After construction, the LayerWeight object may be accessed using getWeight(); 
13   * 
14   * @author cozzy
15   */
16  public class DefaultLayerWeight {
17  
18      private static final String prefix = "default_weights_";
19      private static final String suffix = ".xml"; 
20  
21      private LayerWeight weight;
22      public DefaultLayerWeight(String detectorName){
23          try { 
24  
25              // This is kind of screwy: if the detector name has a period in it,
26              // then loading the resource would normally throw an exception. 
27              // We can fix this by replacing "." with "%2E" (URL encoding).  
28              // It's probably best to avoid having periods in detector names
29              // though. 
30              
31              detectorName = detectorName.replace(".","%2E"); 
32              weight = LayerWeight.getLayerWeightFromResource(LayerWeight.getDefaultResourcePrefix()+prefix+detectorName+suffix);
33          } catch(Exception e) {
34              System.out.println("WARNING: could not find default layer weights for detector "+detectorName+". Falling back to empty layer weights with possibly insane default parameters.");
35              weight = new LayerWeight(); 
36          }
37      }   
38      /**
39       * Return the constructed weight for the detector. 
40       * @return The default weight for the detector name specified in the 
41       * constructor, or, if nothing is found, then an unmodified LayerWeight 
42       * object. 
43       */
44      public LayerWeight getWeight(){
45          return weight; 
46      }
47  
48  }