/**
  * make a form suitable to 1) reconstruct the original given access to starting conditions
  *
  * @param adder !null where to put the data
  */
 @Override
 public void serializeAsString(IXMLAppender adder) {
   String tag = TAG;
   adder.openTag(tag);
   adder.appendAttribute(
       "precursorIntensity", XTandemUtilities.formatDouble(getPrecursorIntensity(), 1));
   adder.appendAttribute("precursorCharge", Integer.toString(getPrecursorCharge()));
   FragmentationMethod method = getMethod();
   if (method == null) method = FragmentationMethod.CID;
   adder.appendAttribute("activationMethod", method);
   adder.endTag();
   adder.appendText(XTandemUtilities.formatDouble(getMassChargeRatio(), 3));
   adder.closeTag(tag);
 }
 @Override
 public double getPrecursorMass(int charge) {
   double chargeRatio = getMassChargeRatio();
   double protonMass = XTandemUtilities.getProtonMass();
   final double ret = ((chargeRatio - protonMass) * charge) + protonMass;
   return ret;
   // return getMassChargeRatio() * getPrecursorCharge();
 }
 /**
  * return true if a mass such as that of a throretical peak is within the range to scpre
  *
  * @param mass positive testMass
  * @return as above
  */
 @Override
 public boolean isMassWithinRange(double mass, int charge, IScoringAlgorithm alg) {
   if (m_PrecursorCharge == 0) {
     // try charge 2
     double test1 =
         (getMassChargeRatio() - XTandemUtilities.getProtonMass()) * 2
             + XTandemUtilities.getProtonMass();
     if (alg.isWithinLimits(test1, mass, 0)) return true;
     // try charge 3
     double test2 =
         (getMassChargeRatio() - XTandemUtilities.getProtonMass()) * 3
             + XTandemUtilities.getProtonMass();
     if (alg.isWithinLimits(test2, mass, 0)) return true;
     // try charge 1 -NOTE THIS IS NEW
     double test3 = getMassChargeRatio();
     if (alg.isWithinLimits(test3, mass, 0)) return true;
     return false; // give up
   } else {
     double test = getPrecursorMass();
     boolean withinLimits = alg.isWithinLimits(test, mass, m_PrecursorCharge);
     if (withinLimits) return true;
     return false; // give up
   }
 }
 public static double chargeRatioFromMass(double mass, int charge) {
   double protonMass = XTandemUtilities.getProtonMass();
   return ((mass - protonMass) / charge) + protonMass;
 }