36 template <
class containerType>
37 Detector::frame_t::value_type
getConstant(
const containerType& )
50 template <
class containerType>
51 Detector::frame_t::value_type
getZValue(
const containerType& container)
75 _detector = s.
value(
"Detector",
"UnamedPixeldetector").toString().toStdString();
79 DetectorHelper::instance(
_detector)->loadSettings();
83 (CommonData::instance(
_detector)->columns,
86 "' will display frame of detector '" +
_detector +
87 "'. It will use condition '" +
_condition->name() +
"'");
92 DetectorHelper::AdvDet_sptr det
96 if (result.
shape() != det->frame().shape())
98 throw invalid_argument(
"processor '" +
name() +
99 "' incomming frame '" +
toString(det->frame().columns) +
100 "x" +
toString(det->frame().rows) +
"'. Result '" +
104 copy(frame.begin(), frame.end(),result.
begin());
128 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
129 string mapType(s.
value(
"MapType",
"offset").toString().toStdString());
133 DetectorHelper::instance(
_detector)->loadSettings();
134 if (mapType ==
"offset")
136 else if (mapType ==
"noise")
138 else if (mapType ==
"gain_cte")
140 else if (mapType ==
"correction")
143 throw invalid_argument(
"p107::loadSettings(" +
name() +
"): MapType '"+ mapType +
149 (CommonData::instance(
_detector)->columns,
150 CommonData::instance(
_detector)->rows)));
152 "' map of detector '" +
_detector +
"'. It will use condition '" +
160 if (result.
shape().first != CommonData::instance(
_detector)->columns ||
163 throw invalid_argument(
"processor '" +
name() +
198 const int cols(s.
value(
"nCols",static_cast<int>(shape.first)).toUInt());
199 const int rows(s.
value(
"nRows",static_cast<int>(shape.second)).toUInt());
202 "' will display the raw frame of detector with CASSID '" +
209 CASSEvent::devices_t::const_iterator devIt(
211 if (devIt == evt.
devices().end())
212 throw logic_error(
"pp109::process(): Device " +
213 string(
"'PixelDetectors' does not exist in CASSEvent"));
214 const Device &dev (dynamic_cast<const Device&>(*(devIt->second)));
215 Device::detectors_t::const_iterator detIt(dev.dets().find(
_detector));
216 if (detIt == dev.dets().end())
219 "'PixelDetectors' within the CASSEvent");
221 if (det.id() != evt.
id())
222 throw InvalidData(
"pp109::process(): The dataId '" +
224 "' is inconsistent with the eventId '" +
toString(evt.
id()) +
"'");
227 if (result.
shape() != det.shape())
229 throw invalid_argument(
"processor '" +
name() +
230 "' incomming frame '" +
toString(det.shape().first) +
231 "x" +
toString(det.shape().second) +
"'. Result '" +
235 copy(det.frame().begin(), det.frame().end(),result.
begin());
260 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
265 _range = make_pair(s.
value(
"SpectralLowerLimit",0.).toFloat(),
266 s.
value(
"SpectralUpperLimit",0.).toFloat());
268 s.
value(
"SplitLevelUpperLimit",2).toUInt());
270 bool fillPixelvalueAsWeight(s.
value(
"PixelvalueAsWeight",
"true").toBool());
271 if(fillPixelvalueAsWeight)
272 _getZ = &getZValue<Hit>;
274 _getZ = &getConstant<Hit>;
276 DetectorHelper::instance(
_detector)->loadSettings();
278 "' will add all hits of detector '" +
_detector +
279 "' to an image only when the spectral component is between '" +
281 "', and the the split level is between '" +
toString(_splitLevelRange.first) +
282 "' and '" +
toString(_splitLevelRange.second) +
283 "'. It will fill the weight of the histograms with the " +
284 "pixels z value" +
toString(fillPixelvalueAsWeight) +
285 "'. Condition is '" +
_condition->name() +
"'");
290 DetectorHelper::AdvDet_sptr det
292 AdvancedDetector::hits_t::const_iterator
hit(det->hits().begin());
295 for (;
hit != det->hits().end(); ++
hit)
325 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
330 DetectorHelper::instance(
_detector)->loadSettings();
332 "' will retrieve the number of coalesced pixels (hits) of detector '"
338 DetectorHelper::AdvDet_sptr det
340 const AdvancedDetector::hits_t&
hits(det->hits());
365 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
370 DetectorHelper::instance(
_detector)->loadSettings();
372 "' will retrieve the number of coalesced photonhits of detector '"
378 DetectorHelper::AdvDet_sptr det
380 AdvancedDetector::hits_t::const_iterator
hit(det->hits().begin());
382 for (;
hit != det->hits().end(); ++
hit)
406 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
411 _range = make_pair(s.
value(
"SpectralLowerLimit",0.).toFloat(),
412 s.
value(
"SpectralUpperLimit",0.).toFloat());
414 bool fillPixelvalueAsWeight(s.
value(
"PixelvalueAsWeight",
"true").toBool());
415 if(fillPixelvalueAsWeight)
416 _getZ = &getZValue<Pixel>;
418 _getZ = &getConstant<Pixel>;
420 DetectorHelper::instance(
_detector)->loadSettings();
422 "' will add all hits of detector '" +
_detector +
423 "' to an image only when the spectral component is between '" +
425 "'. It will fill the weight of the histograms with the " +
426 "pixels z value" +
toString(fillPixelvalueAsWeight) +
427 "'. Condition is '" +
_condition->name() +
"'");
432 DetectorHelper::AdvDet_sptr det
434 AdvancedDetector::pixels_t::const_iterator
pixel(det->pixels().begin());
464 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
469 DetectorHelper::instance(
_detector)->loadSettings();
471 "' will retrieve the number of coalesced pixels (hits) of detector '" +
477 DetectorHelper::AdvDet_sptr det
506 if ( !(
_hist && ret) )
508 if (
_hist->result().dim() != 2)
509 throw std::runtime_error(
"PP type 241: Incomming is not a 2d histo");
516 _thresholdA = s.value(
"ThresholdQuadrantA",0).toFloat();
517 _thresholdB = s.value(
"ThresholdQuadrantA",0).toFloat();
518 _thresholdC = s.value(
"ThresholdQuadrantA",0).toFloat();
519 _thresholdD = s.value(
"ThresholdQuadrantA",0).toFloat();
525 _minRow = s.value(
"MinimumRow",0).toUInt();
526 _maxRow = s.value(
"MaximumRow",1024).toUInt();
529 "' corrects the distorted offset of image in '" +
_hist->name() +
530 ". Condition on Processor '" +
_condition->name() +
"'");
538 for(
size_t row=0; row < 512; ++row)
542 float averageOffsetA(0);
543 for (
size_t col=2; col<=6; ++col)
545 averageOffsetA += image[row*1024 + col];
547 if (row >= 2 && row < 510)
555 averageOffsetA = (row >= 2 && row < 510) ? averageOffsetA /
_weightSum : averageOffsetA / 5.f;
557 const float slopeA = ((
_minRow <= row) && (row <=
_maxRow) && (averageOffsetA <
_thresholdA)) ? (0.0055 * averageOffsetA - 0.0047) : 0.f;
559 for(
size_t col=0; col < 512; ++col)
561 result[row*1024 + col] = image[row*1024 + col] - (slopeA * col) - averageOffsetA;
566 float averageOffsetB(0);
567 for (
size_t col=1017; col<=1021; ++col)
569 averageOffsetB += image[row*1024 + col];
571 if (row >= 2 && row < 510)
579 averageOffsetB = (row >= 2 && row < 510) ? averageOffsetB /
_weightSum : averageOffsetB / 5.f;
581 const float slopeB = ((
_minRow <= row) && (row <=
_maxRow) && (averageOffsetB <
_thresholdB))? (0.0056 * averageOffsetB + 0.0007) : 0.f;
583 for(
size_t col=512; col < 1024; ++col)
585 result[row*1024 + col] = image[row*1024 + col] - (slopeB * (1023-col)) - averageOffsetB;
588 for(
size_t row = 512; row < 1024; ++row)
592 float averageOffsetC(0);
593 for (
size_t col=2; col<=6; ++col)
595 averageOffsetC += image[row*1024 + col];
597 if (row >= 514 && row < 1022)
605 averageOffsetC = (row >= 514 && row < 1022) ? averageOffsetC /
_weightSum : averageOffsetC / 5.f;
607 const float slopeC = ((
_minRow <= row) && (row <=
_maxRow) && (averageOffsetC <
_thresholdC)) ? (0.0050 * averageOffsetC + 0.0078) : 0.f;
609 for(
size_t col=0; col < 512; ++col)
611 result[row*1024 + col] = image[row*1024 + col] - (slopeC * col) - averageOffsetC;
616 float averageOffsetD(0);
617 for (
size_t col=1017; col<=1021; ++col)
619 averageOffsetD += image[row*1024 + col];
621 if (row >= 514 && row < 1022)
629 averageOffsetD = (row >= 514 && row < 1022) ? averageOffsetD /
_weightSum : averageOffsetD / 5.f;
631 const float slopeD = ((
_minRow <= row) && (row <=
_maxRow) && (averageOffsetD <
_thresholdD)) ? (0.0049 * averageOffsetD + 0.0043) : 0.f;
633 for(
size_t col=512; col < 1024; ++col)
635 result[row*1024 + col] = image[row*1024 + col] - (slopeD * (1023-col)) - averageOffsetD;
661 _detector = s.
value(
"Detector",
"UnnamedPixeldetector").toString().toStdString();
666 DetectorHelper::instance(
_detector)->loadSettings();
672 CommonData::instance(
_detector)->rows)));
680 DetectorHelper::AdvDet_sptr det
684 if (result.
shape() != det->frame().shape())
686 throw invalid_argument(
"processor '" +
name() +
687 "' incomming frame '" +
toString(det->frame().columns) +
688 "x" +
toString(det->frame().rows) +
"'. Result '" +
692 copy(frame.begin(), frame.end(), result.
begin());
695 pixeldetector::Detector::frame_t::const_iterator
mask(
_mask->begin());
731 _image->name() +
"' that are masked in '" +
_mask->name() +
"' to '"
746 for (; dest != result.
end(); ++dest, ++src, ++maskIt)
775 if (
_image->result().dim() != 2)
776 throw invalid_argument(
"pp244::loadSettings: '" +
name() +
"' input '" +
777 _image->name() +
"' is not a 2d histogram");
780 if (
_isPnCCD && (image.shape().first != 1024 || image.shape().second != 1024))
781 throw invalid_argument(
"pp244::loadSettings(): '" +
name() +
782 "' should be a pnCCD, but cols '" +
783 toString(image.shape().first) +
"' and rows '"
785 "' don't indicate a pnCCD");
786 const size_t nPixels =
787 _isPnCCD ? 512 + 2048 : image.shape().first * image.shape().second;
789 const size_t nbins(s.
value(
"XNbrBins",1).toUInt());
790 const float low(s.
value(
"XLow",0).toFloat());
791 const float up(s.
value(
"XUp",0).toFloat());
792 const string title(s.
value(
"XTitle",
"x-axis").toString().toStdString());
803 "' generates histogram nbr Bins '" +
toString(nbins) +
"', low '" +
805 "', for all pixels of '" +
_image->name() +
"'. Condition '" +
814 const size_t cols(image.
shape().first);
815 const size_t rows(image.
shape().second);
816 const size_t nPixels(cols*rows);
818 const float up(xaxis.up);
819 const float low(xaxis.low);
820 const size_t nBins(xaxis.nBins);
821 for (
size_t i=0; i<nPixels; ++i)
826 const float pixval(image[i]);
829 const size_t col(i % cols);
830 const size_t row(i / cols);
833 static_cast<size_t>(nBins * ((pixval - low) / (up - low))));
840 rowidx = (row < 512) ? col : col + cols;
847 size_t cterow = (row < 512) ? row : 1023 - row;
CachedList::item_type result_t
define the results
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
storage_t::const_iterator const_iterator
a const iterator on the storage
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
definition of front detector[PixelDetectors] FrontPnCCD Detector
shared_pointer _hist
pp containing 2d histogram to work on
Event to store all LCLS Data.
size_t _minRow
the minimum row
virtual void createHistList(result_t::shared_pointer result)
create result list.
pp146(const name_t &name)
constructor
std::pair< float, float > _range
gate on the z
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
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
virtual void process(const CASSEvent &, result_t &)
copy image from CASS event to histogram storage
virtual void loadSettings(size_t)
set the histogram size
float _baseValue
value of the image where no pixel is set
size_t _maxRow
the maximum row
bool _isPnCCD
flag to tell whether its an pnCCD
const name_t name() const
retrieve the name of this processor
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
pp244(const name_t &name)
constructor
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
Detector::frame_t::value_type getConstant(const containerType &)
get a constant 1
Processor::result_t::shared_pointer set2DHist(const Processor::name_t &name)
function to set the 2d histogram properties from the ini file.
pixeldetector::Device::detectors_t::key_type _detector
detector to work on
define which of the hitfinders defined above will be used as hit
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
Average out the iShit status to get the avererage hits
virtual void loadSettings(size_t)
load the settings for this pp
pp149(const name_t &name)
constructor
file contains custom exceptions used in cass
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
pp144(const name_t &name)
constructor
Exception thrown when there is a problem with the data.
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
pp105(const name_t &name)
constructor
static void add(Level level, const std::string &line)
add a string to the log
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
void setValue(const_reference value)
assign the result container to a value
float _weight
the weight to fill the histogram with
pp145(const name_t &name)
constructor
float _thresholdC
threshold for quadrant A
const_iterator begin() const
retrieve a iterator for read access to beginning
float _weightSecondRow
the weight of the row next over to the current one
fromStdString(const std::string &str)
std::pair< size_t, size_t > _splitLevelRange
gate on split level
base class for processors.
pixeldetector::Detector::frame_t * _mask
pointer to the mask
virtual void loadSettings(size_t)
set the histogram size
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
virtual void loadSettings(size_t)
set the histogram size
std::vector< hsize_t > shape_t
define the shape type
const axis_t & axis() const
read access to the axis
virtual void loadSettings(size_t)
load the settings for this pp
virtual void loadSettings(size_t)
set the histogram size
float _weightSum
the value by which one has to divide to get the right average value
devices_t & devices()
setters
pp242(const name_t &name)
constructor
pp148(const name_t &name)
constructor
pp109(const name_t &name)
constructor
std::vector< pixel_t > frame_t
a frame is a vector of pixels
file contains declaration of classes and functions that help other processors to do their job...
QReadWriteLock * _maskLock
the lock for locking the map
QReadWriteLock lock
lock for locking operations on the data of the container
pp241(const name_t &)
constructor
pp243(const name_t &name)
constructor
bool fuzzyIsNull(const T &val)
fuzzy compare a floating point number to 0
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
std::vector< Detector::pixel_t > pixels_t
Detector::frame_t::value_type getZValue(const containerType &container)
retrieve the z value of the container
std::string toString(const Type &t)
convert any type to a string
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
std::pair< float, float > _range
gate on the z
pixeldetector::Detector::frame_t * _map
pointer to the map
virtual void loadSettings(size_t)
set the histogram size
contains processor dealing with more advanced pixel detectors.
float _value
the value that the masked things should take
pp107(const name_t &name)
constructor
value(const QString &key, const QVariant &defaultValue=QVariant()
virtual void loadSettings(size_t)
set the histogram size
float _thresholdB
threshold for quadrant A
storage_t::iterator iterator
a iterator on the storage
float _thresholdA
threshold for quadrant A
noise and mask[Processor]
virtual void process(const CASSEvent &, result_t &)
process event
void setupGeneral()
general setup of the processor
virtual void loadSettings(size_t)
set the histogram size
contains the common data for one advanced pixeldetector
file contains specialized class that do the settings for cass
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
float _maskval
the value of masked pixels
iterator histogram(const value_t &pos, const value_t &weight=1)
add the weight at the right bin for the value in the 1d array
float _value
the value that the masked things should take
QReadWriteLock * _mapLock
the lock for locking the map
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
pixeldetector::DetectorHelper::instancesmap_t::key_type _detector
detector to work on
virtual void process(const CASSEvent &, result_t &)
copy image from CASS event to histogram storage
float _thresholdD
threshold for quadrant A
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
float _baseValue
value of the image where no pixel is set
shared_pointer _condition
pointer to the processor that will contain the condition
Processor::result_t::shared_pointer set1DHist(const Processor::name_t &name)
function to set the 1d histogram properties from the ini file.
virtual void loadSettings(size_t)
load the settings
shared_pointer _mask
pp containing the mask to apply
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
float _weightAdjectentRow
the weight of the row next to the current one
contains a logger for cass
int16_t pixel
define a pixel
std::tr1::function< pixeldetector::Detector::frame_t::value_type(const pixeldetector::Hit &)> _getZ
shared_pointer _image
pp containing image that will be masked
shared_pointer _image
pp containing image that will be masked
virtual void loadSettings(size_t)
set the histogram size
virtual void process(const CASSEvent &, result_t &)
copy pixels from CASS event to histogram storage
beginGroup(const QString &prefix)
virtual void process(const CASSEvent &, result_t &)
copy pixels from Map to histogram storage
virtual void loadSettings(size_t)
set the histogram size
std::tr1::function< pixeldetector::Detector::frame_t::value_type(const pixeldetector::Pixel &)> _getZ
function to retrieve the z value of the pixels