00001 package SctData;
00002
00003 import Sct.*;
00004 import java.util.*;
00005
00014 public class ModuleDefect implements Streamable, Cloneable {
00015
00016 private static HashMap defectMap = new HashMap(20);
00017
00019 public static ModuleDefect DEAD = new ModuleDefect(1, true, "DEAD", "Dead channel - output always <1%", 0.01);
00020 public static ModuleDefect STUCKON = new ModuleDefect(2, true, "STUCKON", "Dead channel - output always > 98% occupancy", 0.98);
00021 public static ModuleDefect OVER = new ModuleDefect(4, false, "OVER", "Occupancy greater than 100%", 1.);
00022 public static ModuleDefect UNDER = new ModuleDefect(3, true, "UNDER", "Occupancy never reaches 100%", 1.);
00023 public static ModuleDefect NOINIT = new ModuleDefect(18, true, "NOINIT", "Couldn't initialize fit", 0);
00024 public static ModuleDefect FIT_UNDER = new ModuleDefect(5, true, "FIT_UNDER", "Fitted mean out of bounds low", 0);
00025 public static ModuleDefect FIT_OVER = new ModuleDefect(6, true, "FIT_OVER", "Fitted mean out of bounds high", 0);
00026 public static ModuleDefect SIG_UNDER = new ModuleDefect(7, true, "SIG_UNDER", "Fitted sigma out of bounds low", 0);
00027 public static ModuleDefect SIG_OVER = new ModuleDefect(8, true, "SIG_OVER", "Fitted sigma out of bounds high", 0);
00029
00030 public static ModuleDefect LO_GAIN = new ModuleDefect(9, true, "LO_GAIN", "Gain is less than 0.75*chip average", 0.75);
00031 public static ModuleDefect HI_GAIN = new ModuleDefect(10, true, "HI_GAIN", "Gain is higher than 1.25*chip average", 1.25);
00032 public static ModuleDefect LO_OFFSET = new ModuleDefect(11, true, "LO_OFFSET", "Offset is less than -100", -100);
00033 public static ModuleDefect HI_OFFSET = new ModuleDefect(12, true, "HI_OFFSET", "Offset is higher than 12-", 120);
00034 public static ModuleDefect UNBONDED = new ModuleDefect(13, true, "UNBONDED", "Noise is less than 750", 750);
00035 public static ModuleDefect PARTBONDED = new ModuleDefect(14, false, "PARTBONDED", "Noise is less than 1100", 1100);
00036 public static ModuleDefect NOISY = new ModuleDefect(15, true, "NOISY", "Noise is > 1.15*chip average", 1.15);
00037
00038
00039 public static ModuleDefect TR_RANGE = new ModuleDefect(22, false, "TR_RANGE","Unusual chip trim step size",0.);
00040 public static ModuleDefect TR_STEP = new ModuleDefect(23, false, "TR_STEP","Channel trim step size different from chip",4.);
00041 public static ModuleDefect TR_OFFSET = new ModuleDefect(24, false, "TR_OFFSET","Channel trim range offset different from chip",4.);
00042 public static ModuleDefect TR_NOTRIM = new ModuleDefect(25, true, "TR_NOTRIM","Untrimmable channel",0.);
00043
00044
00045 public static ModuleDefect NO_HI = new ModuleDefect(19, true, "NO_HI", "High noise occupancy", 0.0005);
00046 public static ModuleDefect MEAN_ERROR = new ModuleDefect(16, true, "MEAN_ERROR", "Error in the mean", 0);
00047 public static ModuleDefect SIG_ERROR = new ModuleDefect(17, true, "SIG_ERROR", "Error in the sigma", 0);
00048 public static ModuleDefect STUCK_CELL = new ModuleDefect(21, false, "STUCK_CELL","Stuck cell in the pipeline",0.);
00049 public static ModuleDefect DEAD_CELL = new ModuleDefect(20, false, "DEAD_CELL","Dead cell in the pipeline",0.);
00050
00051
00053 public ModuleDefect(ModuleDefect prototype, ModuleElement element) {
00054 this.id = prototype.id;
00055 this.severe = prototype.severe;
00056 this.name = prototype.name;
00057 this.description = prototype.description;
00058 this.parameter = prototype.parameter;
00059 this.element = element;
00060 }
00061
00063 public boolean isSevere() {
00064 return severe;
00065 }
00066
00068 public ModuleElement getModuleElement() {
00069 return element;
00070 }
00071
00073 public boolean isPrototype() {
00074 return element == null;
00075 }
00076
00078 public boolean isUnfittable() {
00079 return isSameTypeAs(OVER) || isSameTypeAs(UNDER) || isSameTypeAs(STUCKON);
00080 }
00081
00083 public boolean isUnuseable() {
00084 return isSameTypeAs(DEAD) || isSameTypeAs(STUCKON);
00085 }
00086
00088 public boolean isDodgy() {
00089 return !(isSameTypeAs(DEAD) || isSameTypeAs(STUCKON));
00090 }
00091
00093 public String getName() {
00094 return name;
00095 }
00096
00098 public String getDescription() {
00099 return description;
00100 }
00101
00103 public double getParameter() {
00104 return parameter;
00105 }
00106
00112 public boolean isSameTypeAs(ModuleDefect defect) {
00113 return id == defect.id;
00114 }
00115
00121 public boolean equals(Object o) {
00122 if (o instanceof ModuleDefect) {
00123 ModuleDefect d = (ModuleDefect)o;
00124 if (d.isPrototype() || this.isPrototype()) return false;
00125 return id == d.id && element.equals(d.element);
00126 }
00127 return false;
00128 }
00129
00130 public String getClassName() {
00131 return "SctData.ModuleDefect";
00132 }
00133
00137 public static ModuleDefect read(IStream s, ObjectManager o) throws java.io.IOException {
00138 int id = s.readInt("Id");
00139 ModuleDefect proto = (ModuleDefect)defectMap.get(new Integer(id));
00140 if (proto == null) throw new java.io.StreamCorruptedException("Can't create a ModuleDefect for id: "+ id);
00141
00142 ModuleElement element = (ModuleElement)o.readObject(s, "Element", "SctData.ModuleElement");
00143 ModuleDefect d = new ModuleDefect(proto, element);
00144
00145 return d;
00146 }
00147
00148 public void write(OStream s, ObjectManager o) throws java.io.IOException {
00149 s.writeInt("Id", id, false);
00150 o.writeObject(s, "Element", element, false);
00151 }
00152
00154 private ModuleDefect(int id, boolean severe, String name, String d, double parameter) {
00155 this.id = id;
00156 this.severe = severe;
00157 this.name = name;
00158 this.description = description;
00159 this.parameter = parameter;
00160 defectMap.put(new Integer(id), this);
00161 }
00162
00163 private int id;
00164 private boolean severe;
00165 private String name;
00166 private String description;
00167 private double parameter;
00168 private ModuleElement element;
00169 }