Blame view

src/ExternLib/GetJunoJediEnergy/GetJunoJediEnergy.hh 5.34 KB
be507aed   Benjamin Renard   Add pluggin to re...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * GetJunoJediEnergy.hh
 *
 *  Created on: Aug 25, 2017
 *      Author: AKKA
 */

#ifndef GetJunoJediEnergy_HH_
#define GetJunoJediEnergy_HH_

#include "vector"

#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>

#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 {
c0955cd4   Hacene SI HADJ MOHAND   ok for juno jedi
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
    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 TParamData>
        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<int>(pAttribute[0]);
                    if (_look_dir > 7) {
                        _look_dir = 0;
                    }
                } catch (boost::bad_lexical_cast const&) {
                    _look_dir = 0;
                }

                Parameter::InfoList& lInfoList = pInput.getInfoList();

                AMDA::Parameters::SemiVariableTable semiVariableTableElements;

                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]);
                        if (mode == 0){
                             std::string head = "Energy[" + std::to_string(bin) + "]";
79366e37   Hacene SI HADJ MOHAND   trying to add ful...
105
106
107
108
                             if(bin ==0){
                                  std::string lookdir = "LookingDir "+std::to_string(_look_dir);
                                  semiVariableTableElements.tabHeader.push_back(lookdir);
                             }
c0955cd4   Hacene SI HADJ MOHAND   ok for juno jedi
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
                             semiVariableTableElements.tabHeader.push_back(head);
                        }
                    }
                    std::vector<double> energyList(_energyList[mode].begin(), _energyList[mode].end());
                     std::stringstream index;
                     index << std::setw(3) << std::setfill('0') << mode;
                     index<<" "<<_energy_band_name;
                    semiVariableTableElements.tabValues[index.str()] = energyList;
                }
                semiVariableTableElements.calculateBounds = false;
                _process.setSemiVariableTable(semiVariableTableElements);
                if (!semiVariableTableElements.tabValues.empty())
                    pInput.setIsTableIndexParam(true);

            }

            /**
             * @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<unsigned int, std::vector<float> > _energyList;

            std::string _energy_band_name;

            int _look_dir;
        };

    } /* namespace JunoJedi */
be507aed   Benjamin Renard   Add pluggin to re...
155
156
} /* namespace AMDA */
#endif /* GetJunoJediEnergy_HH_ */