Analysis.EDM.DetectorChannelValues.GetChannelIndex C# (CSharp) Method

GetChannelIndex() public method

public GetChannelIndex ( string switches ) : uint
switches string
return uint
        public uint GetChannelIndex(string[] switches)
        {
            if (switches[0] == "SIG") return 0;
            else
            {
                uint index = 0;

                //foreach (string s in switches) index += SwitchMasks[s];
                foreach (string s in switches)
                {
                    uint val = 0;
                    if (SwitchMasks.TryGetValue(s, out val))
                    {
                        index += val;
                    }
                }
                return index;
            }
        }

Usage Example

コード例 #1
0
        // This is a convenience function that pulls out the mean and error of a channel,
        // specified by a set of switches for a given detector. This isn't the most efficient
        // way to do it if pulling out a lot of values, but it's not bad. And it is convenient.
        public double[] GetChannelValueAndError(string[] switches, string detector)
        {
            int detectorIndex;

            if (DetectorIndices.TryGetValue(detector, out detectorIndex))
            {
                DetectorChannelValues dcv = ChannelValues[detectorIndex];
                uint channelIndex         = dcv.GetChannelIndex(switches);
                return(new double[] { dcv.Values[channelIndex], dcv.Errors[channelIndex] });
            }
            else
            {
                return(new double[] { 0.0, 0.0 });
            }
        }