// this function adds a new set of detector data to the block, constructed // by normalising the PMT data to the norm data. The normalisation is done // by dividing the PMT tofs through by the integrated norm data. The integration // is done according to the provided GatedDetectorExtractSpec. public void Normalise(GatedDetectorExtractSpec normGate) { GatedDetectorData normData = GatedDetectorData.ExtractFromBlock(this, normGate); double averageNorm = 0; foreach (double val in normData.PointValues) { averageNorm += val; } averageNorm /= normData.PointValues.Count; for (int i = 0; i < points.Count; i++) { Shot shot = ((EDMPoint)points[i]).Shot; TOF normedTOF = ((TOF)shot.TOFs[0]) / (normData.PointValues[i] * (1 / averageNorm)); shot.TOFs.Add(normedTOF); } // give these data a name detectors.Add("topNormed"); }
public static GatedDetectorData ExtractFromBlock(Block b, GatedDetectorExtractSpec gate) { GatedDetectorData gd = new GatedDetectorData(); GatedDetectorExtractFunction f; if (gate.Integrate) f = new GatedDetectorExtractFunction(b.GetTOFIntegralArray); else f = new GatedDetectorExtractFunction(b.GetTOFMeanArray); double[] rawData = f(gate.Index, gate.GateLow, gate.GateHigh); //if (gate.BackgroundSubtract) //{ //TOFFitResults results = (new TOFFitter()).FitTOF(b.GetAverageTOF(gate.Index)); //double bg = results.Background * (gate.GateHigh - gate.GateLow); //double[] bgSubData = new double[rawData.Length]; //for (int i = 0; i < rawData.Length; i++) bgSubData[i] = rawData[i] - bg; //gd.PointValues.AddRange(bgSubData); //gd.SubtractedBackground = bg; //} //else //{ gd.PointValues.AddRange(rawData); //} gd.Gate = gate; return gd; }
// this function adds a new set of detector data to the block, constructed // by normalising the PMT data to the norm data. The normalisation is done // by dividing the PMT tofs through by the integrated norm data. The integration // is done according to the provided GatedDetectorExtractSpec. public void Normalise(GatedDetectorExtractSpec normGate) { GatedDetectorData normData = GatedDetectorData.ExtractFromBlock(this, normGate); double averageNorm = 0; foreach (double val in normData.PointValues) averageNorm += val; averageNorm /= normData.PointValues.Count; for (int i = 0; i < points.Count; i++) { Shot shot = ((EDMPoint)points[i]).Shot; TOF normedTOF = ((TOF)shot.TOFs[0]) / (normData.PointValues[i] * (1 / averageNorm)); shot.TOFs.Add(normedTOF); } // give these data a name detectors.Add("topNormed"); }
//private static void AddSliceConfig(string name, double offset, double width) //{ // // the slow half of the fwhm // DemodulationConfigBuilder dcb = delegate(Block b) // { // DemodulationConfig dc; // GatedDetectorExtractSpec dg0, dg1, dg2, dg3, dg4; // dc = new DemodulationConfig(); // dc.AnalysisTag = name; // dg0 = GatedDetectorExtractSpec.MakeGateFWHM(b, 0, offset, width); // dg0.Name = "top"; // dg0.BackgroundSubtract = true; // dg1 = GatedDetectorExtractSpec.MakeGateFWHM(b, 1, offset, width); // dg1.Name = "norm"; // dg1.BackgroundSubtract = true; // dg2 = GatedDetectorExtractSpec.MakeWideGate(2); // dg2.Name = "mag1"; // dg2.Integrate = false; // dg3 = GatedDetectorExtractSpec.MakeWideGate(3); // dg3.Name = "short"; // dg3.Integrate = false; // dg4 = GatedDetectorExtractSpec.MakeWideGate(4); // dg4.Name = "battery"; // dc.GatedDetectorExtractSpecs.Add(dg0.Name, dg0); // dc.GatedDetectorExtractSpecs.Add(dg1.Name, dg1); // dc.GatedDetectorExtractSpecs.Add(dg2.Name, dg2); // dc.GatedDetectorExtractSpecs.Add(dg3.Name, dg3); // dc.GatedDetectorExtractSpecs.Add(dg4.Name, dg4); // dc.PointDetectorChannels.Add("MiniFlux1"); // dc.PointDetectorChannels.Add("MiniFlux2"); // dc.PointDetectorChannels.Add("MiniFlux3"); // dc.PointDetectorChannels.Add("NorthCurrent"); // dc.PointDetectorChannels.Add("SouthCurrent"); // dc.PointDetectorChannels.Add("PumpPD"); // dc.PointDetectorChannels.Add("ProbePD"); // return dc; // }; // standardConfigs.Add(name, dcb); //} private static void AddFixedSliceConfig(string name, double centre, double width) { // the slow half of the fwhm DemodulationConfigBuilder dcb = delegate(Block b) { DemodulationConfig dc; GatedDetectorExtractSpec dg0, dg1, dg2, dg3, dg4, dg5, dg6, dg7; //This dodgy bit of code is to make sure that the reflected rf power meters // only select a single point in the centre of the rf pulse. It won't work // if either of the rf pulses is centred at a time not divisible w/o rem. by 10us int rf1CT = (int)b.Config.Settings["rf1CentreTime"]; int rf2CT = (int)b.Config.Settings["rf2CentreTime"]; int clock = (int)b.Config.Settings["clockFrequency"]; int conFac = clock / 1000000; dc = new DemodulationConfig(); dc.AnalysisTag = name; dg0 = new GatedDetectorExtractSpec(); dg0.Index = 0; dg0.Name = "top"; dg0.BackgroundSubtract = false; dg0.GateLow = (int)(centre - width); dg0.GateHigh = (int)(centre + width); dg1 = new GatedDetectorExtractSpec(); dg1.Index = 1; dg1.Name = "norm"; dg1.BackgroundSubtract = false; dg1.GateLow = (int)((centre - width) / kDetectorDistanceRatio); dg1.GateHigh = (int)((centre + width) / kDetectorDistanceRatio); dg2 = GatedDetectorExtractSpec.MakeWideGate(2); dg2.Name = "magnetometer"; dg2.Integrate = false; dg3 = GatedDetectorExtractSpec.MakeWideGate(3); dg3.Name = "gnd"; dg3.Integrate = false; dg4 = GatedDetectorExtractSpec.MakeWideGate(4); dg4.Name = "battery"; dg4.Integrate = false; //Add this in to analyse By in 3 axis internal magnetometer tests dg5 = GatedDetectorExtractSpec.MakeWideGate(5); dg5.Name = "rfCurrent"; dg5.Integrate = false; dg6 = new GatedDetectorExtractSpec(); dg6.Index = 6; dg6.Name = "reflectedrf1Amplitude"; dg6.BackgroundSubtract = false; dg6.GateLow = 800; dg6.GateHigh = 1800; //dg6.GateLow = (rf1CT / conFac) - 1; //dg6.GateHigh = (rf1CT / conFac) + 1; dg7 = new GatedDetectorExtractSpec(); dg7.Index = 7 ; dg7.Name = "reflectedrf2Amplitude"; dg7.BackgroundSubtract = false; //dg7.GateLow = (rf2CT / conFac) - 1; //dg7.GateHigh = (rf2CT / conFac) + 1; dg7.GateLow = 800; dg7.GateHigh =1800; dc.GatedDetectorExtractSpecs.Add(dg0.Name, dg0); dc.GatedDetectorExtractSpecs.Add(dg1.Name, dg1); dc.GatedDetectorExtractSpecs.Add(dg2.Name, dg2); dc.GatedDetectorExtractSpecs.Add(dg3.Name, dg3); dc.GatedDetectorExtractSpecs.Add(dg4.Name, dg4); dc.GatedDetectorExtractSpecs.Add(dg5.Name, dg5); dc.GatedDetectorExtractSpecs.Add(dg6.Name, dg6); dc.GatedDetectorExtractSpecs.Add(dg7.Name, dg7); dc.PointDetectorChannels.Add("MiniFlux1"); dc.PointDetectorChannels.Add("MiniFlux2"); dc.PointDetectorChannels.Add("MiniFlux3"); dc.PointDetectorChannels.Add("NorthCurrent"); dc.PointDetectorChannels.Add("SouthCurrent"); dc.PointDetectorChannels.Add("PumpPD"); dc.PointDetectorChannels.Add("ProbePD"); dc.PointDetectorChannels.Add("PhaseLockFrequency"); //dc.PointDetectorChannels.Add("CplusV"); //dc.PointDetectorChannels.Add("CminusV"); return dc; }; standardConfigs.Add(name, dcb); }