00001 #ifndef IMGPIXSPECTRA_CSPADPIXSPECTRA_H
00002 #define IMGPIXSPECTRA_CSPADPIXSPECTRA_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "psana/Module.h"
00021
00022
00023
00024
00025 #include "psddl_psana/cspad.ddl.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 namespace ImgPixSpectra {
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 class CSPadPixSpectra : public Module {
00087 public:
00088
00089 typedef Psana::CsPad::DataV2 CSPadDataType;
00090 typedef Psana::CsPad::ElementV2 CSPadElementType;
00091 typedef Psana::CsPad::ConfigV3 CSPadConfigType;
00092
00093
00094 CSPadPixSpectra (const std::string& name) ;
00095
00096
00097 virtual ~CSPadPixSpectra () ;
00098
00099
00100 virtual void beginJob(Event& evt, Env& env);
00101
00102
00103 virtual void beginRun(Event& evt, Env& env);
00104
00105
00106 virtual void beginCalibCycle(Event& evt, Env& env);
00107
00108
00109
00110 virtual void event(Event& evt, Env& env);
00111
00112
00113 virtual void endCalibCycle(Event& evt, Env& env);
00114
00115
00116 virtual void endRun(Event& evt, Env& env);
00117
00118
00119 virtual void endJob(Event& evt, Env& env);
00120
00121 protected:
00122
00123 void getQuadConfigPars(Env& env);
00124 void printQuadConfigPars();
00125 void printInputPars();
00126 void arrayInit();
00127 void arrayDelete();
00128 void loopOverQuads(shared_ptr<CSPadDataType> data);
00129 void arrayFill(int quad, const int16_t* data, uint32_t roiMask);
00130 void saveArrayInFile();
00131 void saveShapeInFile();
00132 int ampToIndex(double amp);
00133
00134 private:
00135
00136
00137
00138 Source m_src;
00139 Pds::Src m_actualSrc;
00140 std::string m_key;
00141 unsigned m_maxEvents;
00142 double m_amin;
00143 double m_amax;
00144 int m_nbins;
00145 std::string m_arr_fname;
00146 std::string m_arr_shape_fname;
00147 bool m_filter;
00148 long m_count;
00149
00150 int m_nbins1;
00151 double m_factor;
00152
00153 uint32_t m_roiMask [4];
00154 uint32_t m_numAsicsStored [4];
00155
00156 uint32_t m_nquads;
00157 uint32_t m_n2x1;
00158 uint32_t m_ncols2x1;
00159 uint32_t m_nrows2x1;
00160 uint32_t m_sizeOf2x1Arr;
00161 uint32_t m_sizeOfQuadArr;
00162 uint32_t m_sizeOfCSPadArr;
00163 uint32_t m_pixel_ind;
00164
00165
00166
00167 int* m_arr;
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 template <typename T>
00178 bool getQuadConfigParsForType(Env& env)
00179 {
00180 shared_ptr<T> config = env.configStore().get(m_src);
00181 if (config.get()) {
00182 for (uint32_t q = 0; q < 4; ++ q) {
00183 m_roiMask[q] = config->roiMask(q);
00184 m_numAsicsStored[q] = config->numAsicsStored(q);
00185 }
00186
00187 m_nquads = config->numQuads();
00188 m_n2x1 = Psana::CsPad::SectorsPerQuad;
00189 m_ncols2x1 = Psana::CsPad::ColumnsPerASIC;
00190 m_nrows2x1 = Psana::CsPad::MaxRowsPerASIC * 2;
00191 m_sizeOf2x1Arr = m_nrows2x1 * m_ncols2x1;
00192 m_sizeOfQuadArr = m_sizeOf2x1Arr * m_n2x1;
00193 m_sizeOfCSPadArr = m_sizeOfQuadArr * 4;
00194
00195 return true;
00196 }
00197 return false;
00198 }
00199
00200
00201
00202 };
00203
00204 }
00205
00206 #endif // IMGPIXSPECTRA_CSPADPIXSPECTRA_H