public RateGateAnalysis(UInt64 gateWidthInTics) { this.gateWidth = gateWidthInTics; this.gateStack = new RateAccumulator(0); this.presentData = this.gateStack; this.presentDataZeroGateIndexOffset = 0; this.chnmask = new UInt32[RawAnalysisProperties.ChannelCount]; for (int i = 0; i < RawAnalysisProperties.ChannelCount; i++) { chnmask[i] = (uint)1 << i; } }
public RateAccumulator(UInt64 GateZeroStartTimeInTics) { int i, j; this.zeroOffsetInTics = GateZeroStartTimeInTics; this.neutronsPerGate = new UInt32[RawAnalysisProperties.rateGatesPerAccumulator]; this.neutronsPerGatePerChannel = new UInt32[RawAnalysisProperties.rateGatesPerAccumulator][]; for (i = 0; i < RawAnalysisProperties.rateGatesPerAccumulator; i++) { this.neutronsPerGate[i] = 0; this.neutronsPerGatePerChannel[i] = new UInt32[RawAnalysisProperties.ChannelCount]; for (j = 0; j < RawAnalysisProperties.ChannelCount; j++) { this.neutronsPerGatePerChannel[i][j] = 0; } } this.numCompletedGates = 0; this.next = null; }
public void HandleANeutronEvent(UInt64 eventTime, UInt32 eventNeutrons, UInt32 numNeutrons) { UInt32 whichGate; UInt32 relativeGateIndex; int j; whichGate = (UInt32)(eventTime / this.gateWidth); relativeGateIndex = whichGate - this.presentDataZeroGateIndexOffset; while (relativeGateIndex >= RawAnalysisProperties.rateGatesPerAccumulator) { UInt64 nextStartTime; //tell present data all its gates are filled this.presentData.numCompletedGates = RawAnalysisProperties.rateGatesPerAccumulator; //calculate the start time of the next block of gates nextStartTime = this.presentData.zeroOffsetInTics + (RawAnalysisProperties.rateGatesPerAccumulator * this.gateWidth); //create the next block of gates this.presentData.next = new RateAccumulator(nextStartTime); //point to the next block of gates this.presentData = this.presentData.next; if (this.presentData.next != null) { this.presentData.next = null; } //subtract block size from the relativeGateIndex relativeGateIndex -= RawAnalysisProperties.rateGatesPerAccumulator; //increment presentDataZeroGateIndexOffset by the block size this.presentDataZeroGateIndexOffset += RawAnalysisProperties.rateGatesPerAccumulator; } //store the neutron data in the appropriate gate of the present block this.presentData.neutronsPerGate[relativeGateIndex] += numNeutrons; this.presentData.numCompletedGates = relativeGateIndex; //having stored the total, now store totals by individual channels for all RawAnalysisProperties.ChannelCount possible channels for (j = 0; j < RawAnalysisProperties.ChannelCount; j++) { if ((eventNeutrons & this.chnmask[j]) != 0) { this.presentData.neutronsPerGatePerChannel[relativeGateIndex][j]++; } } }
/// <summary> /// ResetCompletely clears results and sets metadata for new data, /// such as running a new experiment or reading a new NCD file /// </summary> public void ResetCompletely(bool closeCounters) { this.gateStack = new RateAccumulator(0); this.presentData = this.gateStack; this.presentDataZeroGateIndexOffset = 0; }