11 #include <tr1/functional>
13 #include <QtCore/QString>
24 using tr1::placeholders::_1;
25 using tr1::placeholders::_2;
26 using tr1::placeholders::_3;
27 using tr1::placeholders::_4;
28 using tr1::placeholders::_5;
41 return (nCols*row + col);
58 const size_t nDestCols(size.first);
59 const size_t nSrcCols(size.second);
60 const size_t srcCol(destRow);
61 const size_t srcRow(nDestCols - destCol - 1);
79 const size_t nDestCols(size.first);
80 const size_t nDestRows(size.second);
81 const size_t nSrcCols(size.first);
82 const size_t srcCol(nDestCols - destCol - 1);
83 const size_t srcRow(nDestRows - destRow - 1);
101 const size_t nDestRows(size.second);
102 const size_t nSrcCols(size.first);
103 const size_t srcCol(nDestRows - destRow - 1);
104 const size_t srcRow(destCol);
122 const size_t nSrcCols(size.second);
123 const size_t srcCol(destRow);
124 const size_t srcRow(destCol);
142 const size_t nSrcCols(size.first);
143 const size_t nDestRows(size.second);
144 const size_t srcCol(destCol);
145 const size_t srcRow(nDestRows - destRow - 1);
163 const size_t nSrcCols(size.first);
164 const size_t nDestCols(size.first);
165 const size_t srcCol(nDestCols - destCol -1);
166 const size_t srcRow(destRow);
208 const int destColStart,
const int destRowStart,
209 const Rotor &rot)
const
211 int destRow = destRowStart;
212 int destCol = destColStart;
214 const int srcRowStart(segment*_srcRows);
215 const int srcRowStop((segment+1)*_srcRows);
216 for (
int srcRow = srcRowStart; srcRow < srcRowStop; ++srcRow)
218 destCol = (((destCol - destColStart)) % _srcCols) + destColStart;
219 destRow = (((destRow - destRowStart)) % _srcCols) + destRowStart;
220 for (
int srcCol = 0; srcCol < _srcCols; ++srcCol)
222 dest[destRow*_destCols + destCol] = src[srcRow*_srcCols + srcCol];
269 if (!(
_one && ret))
return;
272 throw invalid_argument(
"pp55 (" +
name() +
"): Operation '" +
_operation +
273 "' is not supported.");
279 _size = make_pair(
_one->result().shape().second,
280 _one->result().shape().first);
290 "' on Histogram in Processor '" +
_one->name() +
291 "'. Condition is '" +
_condition->name() +
"'");
301 for (
size_t row(0); row <
_size.second; ++row)
302 for (
size_t col(0); col <
_size.first; ++col)
329 if (!(
_one && ret))
return;
336 "Processor '" +
_one->name() +
" into the format that cheetah is using."
337 ". Condition is '" +
_condition->name() +
"'");
346 const size_t pix_per_quad(8*
_ny*2*
_nx);
347 for(
size_t quadrant=0; quadrant<4; quadrant++)
349 for(
size_t k=0; k < pix_per_quad; k++)
351 const size_t i = k % (2*
_nx) + quadrant*(2*_nx);
352 const size_t j = k / (2*
_nx);
353 const size_t ii = i+(
_na*
_nx)*j;
354 dest[ii] = src[quadrant * pix_per_quad + k];
387 if (!(
_one && ret))
return;
394 std::tr1::shared_ptr<SegmentCopier>
398 "Processor '" +
_one->name() +
" into a condensed real layout, " +
399 " looking from upstream."
400 ". Condition is '" +
_condition->name() +
"'");
487 _filename = s.
value(
"GeometryFilename",
"cspad.geom").toString().toStdString();
500 srcImageHist.
shape().first,
509 "Processor '" +
_imagePP->name() +
" into lab frame" +
510 ". Geometry Filename '" +
_filename +
"'"
513 ". Condition is '" +
_condition->name() +
"'");
533 for (; srcpixel != srcImageEnd; ++srcpixel, ++idx)
534 destImage[*idx] = *srcpixel;
565 string method(s.
value(
"Output",
"Q").toString().toStdString());
568 else if (
method ==
"Resolution")
570 else if (
method ==
"Radius")
573 throw invalid_argument(
"pp90::loadSettings() " +
name() +
574 ": requested output type '" +
method +
"' unknown.");
576 _filename = s.
value(
"GeometryFilename",
"cspad.geom").toString().toStdString();
578 _np_m = s.
value(
"PixelSize_m",110.e-6).toDouble();
581 string output(
"Processor '" +
name() +
"' will generate an average " +
582 "using Output '" +
method +
583 ". Geometry Filename '" +
_filename +
"'" +
584 ", Convert from cheetah to cass '" +
593 bool wlIsDouble(
false);
596 double wlval(wlparam.toDouble(&wlIsDouble));
608 output += (
", Wavelength in Angstroem '" + wlparam.toStdString() +
"'");
613 bool ddIsDouble(
false);
614 QString ddkey(
"DetectorDistance_m");
616 double ddval(ddparam.toDouble(&ddIsDouble));
628 output += (
", Detector Distance in m '" + ddparam.toStdString() +
"'");
645 throw invalid_argument(
"pp208:loadSettings '" +
name() +
646 "': input image '" +
_imagePP->name() +
647 "' is not a 2d result");
651 throw invalid_argument(
"pp208:loadSettings '" +
name() +
653 "' is not a 0d result");
655 throw invalid_argument(
"pp208:loadSettings '" +
name() +
656 "': detector distance processor '" +
_detdistPP->name() +
657 "' is not a 0d result");
660 output += (
". The operation will be done on output from Processor '" +
668 srcImage.shape().first,
670 for (
size_t i(0); i < _pixPositions_m.size(); ++i)
672 _pixPositions_m[i].x *=
_np_m;
673 _pixPositions_m[i].y *=
_np_m;
680 output += (
". Condition is '" +
_condition->name() +
"'");
688 return wavelength.getValue();
695 return detdist.getValue();
773 if (!std::isfinite(retval))
794 const size_t imageSize(srcImage.
datasize());
796 transform(srcImage.
begin(),srcImage.
begin()+imageSize,
799 std::tr1::bind(
_getBin,lambda,D,_1,_2));
805 for (
size_t i(0); i<imageSize; ++i)
807 result[temparr[i].bin] += temparr[i].weight;
808 normfactors[temparr[i].bin] += temparr[i].fill;
double _np_m
the size of one pixel in m
size_t FlipVertical(size_t destCol, size_t destRow, pair< size_t, size_t > size)
flip matrix vertically
double operator()(const double x, const double y) const
CachedList::item_type result_t
define the results
storage_t::const_iterator const_iterator
a const iterator on the storage
const int _srcCols
the number of colums in the src matrix
GeometryInfo::lookupTable_t _lookupTable
the lookup table
std::string _filename
filename of the geometry file
const size_t _nx
nbr bins in x of asic
std::pair< size_t, size_t > _size
the size of the original histogram
Event to store all LCLS Data.
virtual void createHistList(result_t::shared_pointer result)
create result list.
bool fuzzycompare(const T &first, const T &second)
fuzzy compare two floating point variables
const_iterator end() const
retrieve iterator to the end of storage
pp1600(const name_t &)
constructor
virtual void process(const CASSEvent &evt, result_t &)
process event
pp55(const name_t &)
constructor
size_t Rotate270DegCCW(size_t destCol, size_t destRow, pair< size_t, size_t > size)
calculate the corresponding indezes for 270 deg ccw (90 cw) rotation
shared_pointer _one
pp containing 2d histogram
virtual void process(const CASSEvent &evt, result_t &)
process event
const name_t name() const
retrieve the name of this processor
float value_t
the values of this container
result_t::axe_t _axis
the axis of the result
virtual void loadSettings(size_t unused)
load the settings of this pp
const Rotor _TBRL
the rotation matrix if x of src goes from (T)op to (B)ottom in dest and y of the src goes from (R)igh...
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
double _wavelength
the wavelength in case its fixed
float _badPixVal
value of the bad pixels
std::map< std::string, std::pair< func_t, bool > > _functions
container for all functions
std::string _operation
the user chosen operation
file contains processors that will manipulate 2d histograms
size_type size() const
return the raw size of the storage
uint64_t id_t
define the id type
func_t _pixIdx
function that will calc the corresponding bin
size_t FlipHorizontal(size_t destCol, size_t destRow, pair< size_t, size_t > size)
flip matrix horizontally
size_t Rotate180Deg(size_t destCol, size_t destRow, pair< size_t, size_t > size)
calculate the corresponding indezes for 180 deg rotation
an axis of a more than 0 dimensional container
size_t bin(const Axis< AxisPrecessionType > &xaxis, const ResultValueType &value)
calculate the index of the lineared array
things written only at end of run H5Dump ProcessorSummary size
std::tr1::function< temp_t(const double, const double, const result_t::value_t &, const GeometryInfo::pos_t &)> _getBin
function to map the pixel to histogram bin, value and fill flag
double _detdist
the detector distance in case its fixed
const Rotor _LRTB
the rotation matrix if x of src goes from (L)eft to (R)ight in dest and y of the src goes from (T)op ...
SegmentCopier(const int srcCols, const int srcRows, const int destCols)
contructor
conversion_t generateConversionMap(const std::string &filename, const size_t sizeOfSrc, const size_t nSrcCols, const bool convertFromCheetahToCASS)
parse the geom file and generate a lookup table
combine the position in the lab into a struct
static void add(Level level, const std::string &line)
add a string to the log
const_iterator begin() const
retrieve a iterator for read access to beginning
std::tr1::function< double(const CASSEvent::id_t &)> _getDetectorDistance
function that gets the detectordistance
const size_t _nx
nbr bins in x of asic
fromStdString(const std::string &str)
char incDestRowPerSrcCol
steps to increase in the dest row when src column is increased by one
float _backgroundValue
the value with wich the background should be filled
temp_t Rad(const double lambda, const double D, const result_t::value_t &pixval, const GeometryInfo::pos_t &pixpos)
get the bin when the radius of the pixel is asked
bool _convertCheetahToCASSLayout
flag whether to convert the positions in the src from cheetah to cass layout
virtual void loadSettings(size_t unused)
load the settings of this pp
shared_pointer _imagePP
pp containing 2d histogram
base class for processors.
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
virtual void process(const CASSEvent &evt, result_t &)
process event
temp_t R(const double lambda, const double D, const result_t::value_t &pixval, const GeometryInfo::pos_t &pixpos)
get the bin when the resolution value of the pixel is asked
const axis_t & axis() const
read access to the axis
virtual void loadSettings(size_t unused)
load the settings of this pp
define the table row of a single output
file contains declaration of classes and functions that help other processors to do their job...
size_t Rotate90DegCCW(size_t destCol, size_t destRow, pair< size_t, size_t > size)
calculate the corresponding indezes for 90 deg ccw rotation
pp90(const name_t &)
constructor
pp1602(const name_t &)
constructor
const size_t _ny
nbr bins in y of asic
QReadWriteLock lock
lock for locking operations on the data of the container
pp1601(const name_t &)
constructor
char incDestColPerSrcRow
steps to increase in the dest columns when src row is increased by one
std::vector< temp_t > tempArray_t
define the matrix
bool fuzzyIsNull(const T &val)
fuzzy compare a floating point number to 0
GeometryInfo::conversion_t _pixPositions_m
the pixel positions
size_t toLinearized(size_t col, size_t row, size_t nCols)
convert the index for rows and cols into the index of linareized array
std::string toString(const Type &t)
convert any type to a string
const int _srcRows
the number of rows that one segement in the src matrix consists of
char incDestRowPerSrcRow
steps to increase in the dest row when src row is increased by one
std::vector< result_t::value_t > normfactors_t
define the normalization factors
value(const QString &key, const QVariant &defaultValue=QVariant()
std::string _filename
filename of the geometry file
double wlFromConstant(const CASSEvent::id_t &)
retrieve the constant wavelength
void setup(const result_t &srcImageHist)
generate the lookup table by parsing the geom file
storage_t::iterator iterator
a iterator on the storage
virtual void process(const CASSEvent &evt, result_t &)
process event
void setupGeneral()
general setup of the processor
const Rotor _RLBT
the rotation matrix if x of src goes from (R)ight to (L)eft in dest and y of the src goes from (B)ott...
std::tr1::shared_ptr< SegmentCopier > _copyMatrixSegment
void operator()(Processor::result_t::const_iterator src, Processor::result_t::iterator dest, const int segment, const int destColStart, const int destRowStart, const Rotor &rot) const
copy the selected segment of the src matrix to the destination matrix
copy from a source matrix to a destination matrix in user wanted way
virtual void loadSettings(size_t unused)
load the settings of this pp
file contains specialized class that do the settings for cass
bool _convertCheetahToCASSLayout
flag whether to convert the positions in the src from cheetah to cass layout
shared_pointer _one
pp containing 2d histogram
char incDestColPerSrcCol
steps to increase in the dest columns when src column is increased by one
const size_t _na
magic cheetah number
virtual void loadSettings(size_t)
load the settings of this pp
const int _destCols
the number of columns in the dest matrix
virtual void process(const CASSEvent &evt, result_t &)
process event
double ddFromProcessor(const CASSEvent::id_t &id)
retrieve the detector distance from the processor
shared_pointer _imagePP
pp containing 2d histogram
shared_pointer _condition
pointer to the processor that will contain the condition
shared_pointer _wavelengthPP
pp containing wavelength in case its not fixed
Processor::result_t::shared_pointer set1DHist(const Processor::name_t &name)
function to set the 1d histogram properties from the ini file.
shape_t shape() const
return the shape of the result
bool setupCondition(bool defaultConditionType=true)
setup the condition.
std::string name_t
define the name type
shared_pointer _one
pp containing 2d histogram
contains a logger for cass
temp_t Q(const double lambda, const double D, const result_t::value_t &pixval, const GeometryInfo::pos_t &pixpos)
get the bin when the q-value of the pixel is asked
shared_pointer _detdistPP
pp containing detector distance in case its not fixed
std::tr1::function< double(const CASSEvent::id_t &)> _getWavelength
function that gets the wavelength
size_type datasize() const
return the size of the data as determined by the axis
double wlFromProcessor(const CASSEvent::id_t &id)
retrieve the wavelength from the processor
size_t Transpose(size_t destCol, size_t destRow, pair< size_t, size_t > size)
transpose the indizes
const size_t _ny
nbr bins in y of asic
beginGroup(const QString &prefix)
double ddFromConstant(const CASSEvent::id_t &)
retrieve the constant detector distance
std::vector< size_t > lut
lookupTable_t generateLookupTable(const std::string &filename, const size_t sizeOfSrc, const size_t nSrcCols, const bool convertFromCheetahToCASS)
generate a lookup table for a new image
virtual const result_t & result(const CASSEvent::id_t eventid=0)
retrieve a result for a given id.
const Rotor _BTLR
the rotation matrix if x of src goes from (B)ottom to (T)op in dest and y of the src goes from (L)eft...