Example #1
0
bool
MappedSpectrum::transform( adcontrols::MassSpectrum& ms ) const
{
    auto& prop = ms.getMSProperty();

    int32_t nDelay = int32_t( ( delay_ / sampInterval_ ) + 0.5 );
    auto si = SamplingInfo( sampInterval_, delay_, nDelay, nSamples_, num_average_, 0 /* mode */ );
    si.fSampInterval( sampInterval_ );
    prop.setSamplingInfo( si );
    prop.setNumAverage( num_average_ );
    prop.setTrigNumber( trig_number_, trig_number_origin_ );
    prop.setTimeSinceEpoch( timeSinceEpoch_.second );

    ms.resize( data_.size() );
    ms.setCentroid( adcontrols::CentroidNative );
    //auto scanlaw = prop.scanLaw();
    
    for ( size_t idx = 0; idx < data_.size(); ++idx ) {
        double tof = this->time( idx );
        ms.setTime( idx, tof );
        //if ( scanlaw )
        //    ms.setMass( idx, ms.compute_mass( data_[ idx ].first ) ); 
        ms.setIntensity( idx, data_[ idx ].second );
    }
    return true;
}
Example #2
0
bool
TimeDigitalHistogram::translate( adcontrols::MassSpectrum& sp
                                 , const TimeDigitalHistogram& hgrm )
{
    sp.setCentroid( adcontrols::CentroidNative );

    using namespace adcontrols::metric;

    // ext_trig_delay should be managed before came here.  (ex. histogram::move())

    double ext_trig_delay = hgrm.this_protocol_.delay_pulses().at( adcontrols::TofProtocol::EXT_ADC_TRIG ).first;
    
    adcontrols::MSProperty prop;
    adcontrols::SamplingInfo info( hgrm.xIncrement()
                                   , hgrm.initialXOffset() + ext_trig_delay
                                   , int32_t( ( hgrm.initialXOffset() + ext_trig_delay ) / hgrm.xIncrement() )  // delay
                                   , uint32_t( hgrm.actualPoints() ) // this is for acq. time range calculation
                                   , uint32_t( hgrm.trigger_count() )
                                   , hgrm.this_protocol_.mode() /* mode */);
    
    prop.setAcceleratorVoltage( 0 ); // empty

    prop.setSamplingInfo( info );
        
    prop.setTimeSinceInjection( hgrm.initialXTimeSeconds() );
    prop.setTimeSinceEpoch( hgrm.timeSinceEpoch().first );
    prop.setNumAverage( uint32_t( hgrm.trigger_count() ) );
    prop.setTrigNumber( uint32_t( hgrm.serialnumber().first ) );

    prop.setDataInterpreterClsid( "adcontrols::TimeDigitalHistogram" );

    TimeDigitalHistogram::device_data data( hgrm.this_protocol_ );
    std::string ar;
    adportable::binary::serialize<>()( data, ar );
    prop.setDeviceData( ar.data(), ar.size() );
        
    sp.setMSProperty( prop );

    size_t size = hgrm.size();

    sp.resize( size );
    size_t idx = 0;
    for ( auto it = hgrm.begin(); it != hgrm.end(); ++it, ++idx ) {
        sp.setTime( idx, it->first );
        sp.setIntensity( idx, it->second );
    }
    
    return true;
}