00001 #ifndef CSPADPIXCOORDS_CSPADINTERPOLIMAGEPRODUCER_H
00002 #define CSPADPIXCOORDS_CSPADINTERPOLIMAGEPRODUCER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <ostream>
00017
00018
00019
00020
00021 #include "psana/Module.h"
00022
00023
00024
00025
00026 #include "PSCalib/CSPadCalibPars.h"
00027
00028 #include "CSPadPixCoords/QuadParameters.h"
00029 #include "CSPadPixCoords/PixCoords2x1.h"
00030 #include "CSPadPixCoords/PixCoordsQuad.h"
00031 #include "CSPadPixCoords/PixCoordsCSPad.h"
00032
00033
00034
00035
00036
00037 #include "PSEvt/Source.h"
00038
00039
00040
00041
00042
00043
00044 namespace CSPadPixCoords {
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 struct ArrAddr {
00081 int quad;
00082 int sect;
00083 int row;
00084 int col;
00085 };
00086
00087 std::ostream& operator<< (std::ostream& s, const ArrAddr& a) ;
00088 bool areEqual( const ArrAddr& a1, const ArrAddr& a2 ) ;
00089
00090 class CSPadInterpolImageProducer : public Module {
00091 public:
00092
00093 enum { NQuadsMax = Psana::CsPad::MaxQuadsPerSensor };
00094 enum { N2x1 = Psana::CsPad::SectorsPerQuad };
00095 enum { NCols2x1 = Psana::CsPad::ColumnsPerASIC };
00096 enum { NRows2x1 = Psana::CsPad::MaxRowsPerASIC * 2 };
00097 enum { SizeOf2x1Arr = NRows2x1 * NCols2x1 };
00098
00099
00100 CSPadInterpolImageProducer (const std::string& name) ;
00101
00102
00103 virtual ~CSPadInterpolImageProducer () ;
00104
00105
00106 virtual void beginJob(Event& evt, Env& env);
00107
00108
00109 virtual void beginRun(Event& evt, Env& env);
00110
00111
00112 virtual void beginCalibCycle(Event& evt, Env& env);
00113
00114
00115
00116 virtual void event(Event& evt, Env& env);
00117
00118
00119 virtual void endCalibCycle(Event& evt, Env& env);
00120
00121
00122 virtual void endRun(Event& evt, Env& env);
00123
00124
00125 virtual void endJob(Event& evt, Env& env);
00126
00127 protected:
00128
00129 void init_address_table_1();
00130 void fill_address_table_1();
00131 void init_address_and_weights_of_4_neighbors();
00132 void fill_address_and_weights_of_4_neighbors();
00133 void get_address_of_4_neighbors(unsigned ix, unsigned iy);
00134 void get_weight_of_4_neighbors(unsigned ix, unsigned iy);
00135
00136 void getConfigPars(Env& env);
00137 void cspad_image_init();
00138 void cspad_image_save_in_file(const std::string &filename = "cspad_image.txt");
00139 void cspad_image_add_in_event(Event& evt);
00140
00141 void cspad_image_interpolated_fill (ndarray<const int16_t, 3> data[], QuadParameters* quadpars[], bool quadIsAvailable[]);
00142
00143 private:
00144
00145
00146
00147 std::string m_calibDir;
00148 std::string m_typeGroupName;
00149 std::string m_source;
00150
00151 Source m_src;
00152 Pds::Src m_actualSrc;
00153 std::string m_inkey;
00154 std::string m_imgkey;
00155 unsigned m_maxEvents;
00156 bool m_filter;
00157 bool m_tiltIsApplied;
00158 unsigned m_print_bits;
00159 long m_count;
00160
00161 uint32_t m_roiMask [4];
00162 uint32_t m_numAsicsStored [4];
00163
00164 CSPadPixCoords::PixCoords2x1::COORDINATE XCOOR;
00165 CSPadPixCoords::PixCoords2x1::COORDINATE YCOOR;
00166 CSPadPixCoords::PixCoords2x1::COORDINATE ZCOOR;
00167
00168 PSCalib::CSPadCalibPars *m_cspad_calibpar;
00169 CSPadPixCoords::PixCoords2x1 *m_pix_coords_2x1;
00170 CSPadPixCoords::PixCoordsQuad *m_pix_coords_quad;
00171 CSPadPixCoords::PixCoordsCSPad *m_pix_coords_cspad;
00172
00173 uint32_t m_cspad_ind;
00174 double *m_coor_x_pix;
00175 double *m_coor_y_pix;
00176 uint32_t *m_coor_x_int;
00177 uint32_t *m_coor_y_int;
00178
00179 enum{ NX_QUAD=850,
00180 NY_QUAD=850 };
00181
00182 enum{ NX_CSPAD=1750,
00183 NY_CSPAD=1750 };
00184 double m_arr_cspad_image [NX_CSPAD][NY_CSPAD];
00185
00186 ArrAddr m_addr_empty;
00187 ArrAddr m_address_table_1[NX_CSPAD][NY_CSPAD];
00188 ArrAddr m_address [NX_CSPAD][NY_CSPAD][4];
00189 double m_weight [NX_CSPAD][NY_CSPAD][4];
00190
00191 };
00192
00193 }
00194
00195 #endif // CSPADPIXCOORDS_CSPADINTERPOLIMAGEPRODUCER_H