/* * GetJunoJediEnergy.hh * * Created on: Aug 25, 2017 * Author: AKKA */ #ifndef GetJunoJediEnergy_HH_ #define GetJunoJediEnergy_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 JunoJedi { namespace Base { /** * @class Base::GetJunoJediEnergy * @brief Compute Juno Jedi energy */ class GetJunoJediEnergy : public Operation { public: /** * @brief Default Constructor. */ GetJunoJediEnergy(Process& pProcess) : Operation(pProcess) {} /** * @brief Destructor. */ virtual ~GetJunoJediEnergy() {} /** * @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 GetJunoJediEnergy * @brief Compute Juno Jedi energy. */ template class GetJunoJediEnergy : public Base::GetJunoJediEnergy { public: /** * @brief Constructor. * @details Create the ParamData type of the input ParamData. */ GetJunoJediEnergy(Process& pProcess, TParamData& paramInput, const std::string& energy_band_name) : Base::GetJunoJediEnergy(pProcess), _paramInput(paramInput), _paramOutput(new ParamDataTab1DFloat()), _energy_band_name(energy_band_name), _look_dir(0) { _paramDataOutput=_paramOutput; } /** * * @overload Base::GetJunoJediEnergy::init() */ void init(Parameter& pInput, Process::AttributeList& pAttribute) { try { _look_dir = boost::lexical_cast( pAttribute[0] ); if (_look_dir > 7) { _look_dir = 0; } } catch( boost::bad_lexical_cast const& ) { _look_dir = 0; } Parameter::InfoList& lInfoList = pInput.getInfoList(); for (int mode = 0; mode < 2; ++mode) { for (int bin = 0; bin < 24; ++bin) { std::stringstream index_name; index_name << _energy_band_name; index_name << "_"; index_name << (mode * 6 + _look_dir); _energyList[mode].push_back((*lInfoList[index_name.str()].get())[bin]); } } } /** * @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. */ ParamDataTab1DFloat *_paramOutput; std::map > _energyList; std::string _energy_band_name; int _look_dir; }; } /* namespace JunoJedi */ } /* namespace AMDA */ #endif /* GetJunoJediEnergy_HH_ */