internal static unsafe run_rec MoveCycleToRunRec(Cycle c, Multiplicity mkey) { run_rec res = new run_rec(); res.run_number = (ushort)c.seq; byte[] b = StringSquish(c.DataSourceId.dt.ToString("yy.MM.dd"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, res.run_date); b = StringSquish(c.DataSourceId.dt.ToString("HH:mm:ss"), INCC.DATE_TIME_LENGTH); TransferUtils.Copy(b, res.run_time); QCStatus qc = c.QCStatus(mkey); b = StringSquish(QCTestStatusExtensions.INCCString(qc), INCC.MAX_RUN_TESTS_LENGTH); TransferUtils.Copy(b, res.run_tests); res.run_count_time = c.TS.TotalSeconds; res.run_singles = c.Totals; // raw counts MultiplicityCountingRes mcr = c.MultiplicityResults(mkey); res.run_scaler1 = mcr.Scaler1.v; res.run_scaler2 = mcr.Scaler2.v; res.run_reals_plus_acc = mcr.RASum; res.run_acc = mcr.ASum; TransferUtils.CopyULongsToDbls(mcr.RAMult, res.run_mult_reals_plus_acc); TransferUtils.CopyULongsToDbls(mcr.NormedAMult, res.run_mult_acc); res.run_singles_rate = mcr.DeadtimeCorrectedSinglesRate.v; // correct counts or not? res.run_doubles_rate = mcr.DeadtimeCorrectedDoublesRate.v; res.run_triples_rate = mcr.DeadtimeCorrectedTriplesRate.v; res.run_scaler1_rate = mcr.Scaler1Rate.v; res.run_scaler2_rate = mcr.Scaler2Rate.v; res.run_multiplicity_mult = mcr.multiplication; res.run_multiplicity_alpha = mcr.multiAlpha; res.run_multiplicity_efficiency = mcr.efficiency; res.run_mass = mcr.Mass; res.run_high_voltage = c.HighVoltage; return res; }
/// <summary> /// Create the cycle counting results, add it to the measurement and copy the data from the run to the equivalent fields on the cycle /// </summary> /// <param name="run"></param> /// <param name="cycle"></param> public static unsafe MultiplicityCountingRes RunToCycle(run_rec run, Cycle cycle, Multiplicity key) { cycle.seq = run.run_number; cycle.TS = new TimeSpan(0, 0, (int)run.run_count_time); // dev note: check if this is always only in seconds, or fractions of a second cycle.Totals = (ulong)run.run_singles; cycle.SinglesRate = run.run_singles / run.run_count_time; // use this value in the conditioning steps, it is not yet the DT corrected rate string s = TransferUtils.str(run.run_tests, INCC.MAX_RUN_TESTS_LENGTH); QCTestStatus qcts = QCTestStatusExtensions.FromString(s); cycle.SetQCStatus(key, qcts); // creates entry if not found MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq); cycle.CountingAnalysisResults.Add(key, mcr); mcr.Totals = cycle.Totals; mcr.TS = cycle.TS; mcr.DeadtimeCorrectedSinglesRate.v = run.run_singles_rate; // overridden later, not used mcr.DeadtimeCorrectedDoublesRate.v = run.run_doubles_rate; mcr.DeadtimeCorrectedTriplesRate.v = run.run_triples_rate; mcr.RASum = (ulong)run.run_reals_plus_acc; mcr.ASum = (ulong)run.run_acc; mcr.efficiency = run.run_multiplicity_efficiency; mcr.mass = run.run_mass; mcr.multiAlpha = run.run_multiplicity_alpha; mcr.multiplication = run.run_multiplicity_mult; cycle.HighVoltage = run.run_high_voltage; // assign the hits to a single channel (0) cycle.HitsPerChannel[0] = run.run_singles; mcr.RawSinglesRate.v = run.run_singles_rate; mcr.RawDoublesRate.v = run.run_doubles_rate; mcr.RawTriplesRate.v = run.run_triples_rate; mcr.Scaler1.v = run.run_scaler1; mcr.Scaler2.v = run.run_scaler2; mcr.Scaler1Rate.v = run.run_scaler1_rate; mcr.Scaler2Rate.v = run.run_scaler2_rate; mcr.RAMult = TransferUtils.multarrayxfer(run.run_mult_reals_plus_acc, INCC.MULTI_ARRAY_SIZE); mcr.NormedAMult = TransferUtils.multarrayxfer(run.run_mult_acc, INCC.MULTI_ARRAY_SIZE); mcr.MaxBins = (ulong)Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length); mcr.MinBins = (ulong)Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length); mcr.UnAMult = new ulong[mcr.MaxBins]; // todo: compute this return mcr; }
// cf index only for AAS positional cycles unsafe ulong AddToCycleList(run_rec run, Detector det, int cfindex = -1) { Cycle cycle = new Cycle(mlogger); ulong MaxBins = 0; try { cycle.UpdateDataSourceId(ConstructedSource.INCCTransferCopy, // becomes transfer if reanalysis occurs det.Id.SRType, INCC.DateTimeFrom(TransferUtils.str(run.run_date, INCC.DATE_TIME_LENGTH), TransferUtils.str(run.run_time, INCC.DATE_TIME_LENGTH)), det.Id.FileName); meas.Add(cycle, cfindex); // mcr is created and stored in the cycle's CountingAnalysisResults MultiplicityCountingRes mcr = RunToCycle(run, cycle, det.MultiplicityParams); // AB is calculated at runtime when conditioning a cycle AFAICT, so its gotta be worked here at least once if (det.AB.Unset) { ABKey abkey = new ABKey(det.MultiplicityParams, mcr); LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, det.AB); } mcr.AB.TransferIntermediates(det.AB); // copy alpha beta onto the cycle's results MaxBins = mcr.MaxBins; } catch (Exception e) { mlogger.TraceEvent(LogLevels.Warning, 33085, "Cycle processing error {0} {1}", run.run_number, e.Message); } return MaxBins; }