/* * GetMavenStaticEnergy.hh * * Created on: Sep 23, 2015 * Author: AKKA */ #ifndef GetMavenStaticEnergy_HH_ #define GetMavenStaticEnergy_HH_ #include "vector" #include #include #include "AMDA_exception.hh" #include "DicError.hh" #include "Parameter.hh" #include "ParamData.hh" #include "Operation.hh" using namespace std; using namespace boost; using namespace AMDA::Parameters; namespace AMDA { namespace MavenStatic { namespace Base { /** * @class Base::GetMavenStaticEnergy * @brief Compute Maven STATIC energy */ class GetMavenStaticEnergy : public Operation { public: /** * @brief Default Constructor. */ GetMavenStaticEnergy(Process& pProcess) : Operation(pProcess) {} /** * @brief Destructor. */ virtual ~GetMavenStaticEnergy() {} /** * @brief initialize the operation . * @detail initialize the operation with information stored in pInput.getInfoList() and pAttribute. */ virtual void init(Parameter& input, Process::AttributeList& pAttribute) = 0; protected: }; } /** * @class GetMavenStaticEnergy * @brief Compute Maven STATIC energy. */ template class GetMavenStaticEnergy : public Base::GetMavenStaticEnergy { public: /** * @brief Constructor. * @details Create the ParamData type of the input ParamData. */ GetMavenStaticEnergy(Process& pProcess, TParamData& paramInput) : Base::GetMavenStaticEnergy(pProcess), _paramInput(paramInput), _paramOutput(new ParamDataTab1DDouble()) { _paramDataOutput=_paramOutput; } /** * * @overload Base::GetMavenStaticEnergy::init() */ void init(Parameter& pInput, Process::AttributeList& pAttribute) { Parameter::InfoList& lInfoList = pInput.getInfoList(); int nbMass = (*lInfoList["nmass"].get())[0]; int nbSweep = (*lInfoList["nswp"].get())[0]; int nbEnergy = (*lInfoList["nenergy"].get())[0]; int massIndex = 0; try { massIndex = boost::lexical_cast( pAttribute[0] ); } catch( boost::bad_lexical_cast const& ) { massIndex = 0; } if (massIndex >= nbMass) nbMass = 0; for (int i = 0; i < nbSweep; ++i) { for (int k = 0; k < nbEnergy; ++k) { std::string infoKey = "energy_"; infoKey += std::to_string(massIndex * nbEnergy + k); _energyList[i].push_back((*lInfoList[infoKey].get())[i]); } } } /** * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo) */ void write(ParamDataIndexInfo &pParamDataIndexInfo) { unsigned int index = pParamDataIndexInfo._startIndex; for (; index< pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) { _paramOutput->pushTime(_paramInput.getTime(index)); _paramOutput->getDataList().push_back((_energyList[(int)floor(_paramInput.getDataList()[index])])); } } private: /** * @brief It is the channel of calibration. */ TParamData &_paramInput; /** * @brief It is the channel of the data shifted. */ ParamDataTab1DDouble *_paramOutput; /** * @brief map of calibrationInfo. * @detail for expression #getClbInfo($ETableN;0:ImaEner_0;1:ImaEner_1) * the key of map is 0 respectively 1 * the value of map is the value of attributes ImaEner[0] respectively and ImaEner[0] */ std::map> _energyList; }; } /* namespace MavenStatic */ } /* namespace AMDA */ #endif /* GetMavenStaticEnergy_HH_ */