static void calibresult_validation( const adcontrols::MSCalibrateResult& res , const adcontrols::MassSpectrum& centroid , double threshold ) { const adcontrols::MSReferences& ref = res.references(); const adcontrols::MSAssignedMasses& assigned = res.assignedMasses(); std::ofstream of( "massassign.txt" ); of << "#\tm/z(observed)\ttof(us)\tintensity\t\tformula,\tm/z(exact)\tm/z(calibrated)\terror(mDa)" << std::endl; adcontrols::MSReferences::vector_type::const_iterator refIt = ref.begin(); for ( adcontrols::MSAssignedMasses::vector_type::const_iterator it = assigned.begin(); it != assigned.end(); ++it, ++refIt ) { const adcontrols::MSAssignedMass& a = *it; std::string formula = adportable::string::convert( a.formula() ); of << std::setprecision(8) << std::setw(4) << a.idMassSpectrum() << "\t" // id << std::setw(15) << std::fixed << centroid.getMass( a.idMassSpectrum() ) << "\t" // m/z(observed) << std::scientific << centroid.getTime( a.idMassSpectrum() ) << "\t" // tof << std::fixed << std::setprecision( 0 ) << centroid.getIntensity( a.idMassSpectrum() ) << "\t" // intensity << formula << "\t" << std::setprecision(8) << std::fixed << it->exactMass() << "\t" // mass(exact) << std::fixed << a.mass() << "\t" // m/z(calibrated) << std::setprecision(1) << ( a.mass() - it->exactMass() ) * 1000 << "\t" // error(mDa) << ( it->enable() ? "used" : "not used" ) << std::endl; } const std::vector<double>& coeffs = res.calibration().coeffs(); of << "#--------------------------- Calibration coefficients: " << std::endl; for ( size_t i = 0; i < coeffs.size(); ++i ) of << std::scientific << std::setprecision(14) << coeffs[i] << std::endl; of << "#--------------------------- centroid peak list (#,mass,intensity)--------------------------" << std::endl; adcontrols::MSReferences::vector_type::const_iterator it = res.references().begin(); for ( size_t i = 0; i < centroid.size(); ++i ) { if ( centroid.getIntensity( i ) > threshold ) { double mq = adcontrols::MSCalibration::compute( res.calibration().coeffs(), centroid.getTime( i ) ); double mass = mq * mq; double error = 0; if ( it != res.references().end() && std::abs( it->exactMass() - mass ) < 0.2 ) { error = ( it->exactMass() - mass ) * 1000; // mDa ++it; } of << i << "\t" << std::setprecision(8) << std::fixed << centroid.getMass( i ) << "\t" << std::setprecision(8) << mass << "\t" << std::setprecision(1) << centroid.getIntensityArray()[i] << std::endl; } } }