/** @file GainAlgorithm.cpp @author Brian Magill @date 11/21/2006 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief A signal algorithm that does not alter the signal */ #include "GainAlgorithm.h" #include "SOFIE_namespace.h" #include #include using namespace std; GainAlgorithm const & GainAlgorithm::operator = (GainAlgorithm const &rhs) { if(&rhs == this) return *this; gainArray = rhs.gainArray; processName = rhs.processName; return *this; }; void GainAlgorithm::applyCorrection(valarray const &time, ChannelSignals const & inChannel, ChannelSignals & outChannel, string & comments) const { int gas_id = inChannel.getID(); double strong_atten = inChannel.getAttenuation(SOFIE::Strong); double weak_atten = inChannel.getAttenuation(SOFIE::Weak); valarray strongSig(inChannel.getSignal(SOFIE::Strong)); valarray weakSig(inChannel.getSignal(SOFIE::Weak)); valarray diffSig(inChannel.getSignal(SOFIE::Diff)); double gain; gain = gainArray.at(gas_id); if (gain == 0.0) throw invalid_argument("gain value is zero"); diffSig = diffSig/gain; comments = ""; outChannel = ChannelSignals(gas_id, strong_atten, weak_atten, strongSig, weakSig, diffSig); }; void GainAlgorithm::dump() const { cout << "Algorithm: " << processName << endl << endl; cout << "Gas ID\tGain"<< endl; for(unsigned long i = 0; i < gainArray.size(); i++) cout << i << "\t" << gainArray[i] << endl; cout << endl; }