CFEL - ASG Software Suite  2.5.0
CASS
advanced_pixeldetector.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file advanced_pixeldetector.cpp file more advanced pixeldetectors
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include <sstream>
10 #include <stdexcept>
11 
12 #include "advanced_pixeldetector.h"
13 
14 #include "coalescing_base.h"
15 #include "cass_settings.h"
16 #include "cass_event.h"
17 #include "common_data.h"
18 #include "frame_processor_base.h"
19 #include "pixel_finder_base.h"
20 #include "cass_exceptions.hpp"
21 
22 using namespace cass;
23 using namespace pixeldetector;
24 using namespace std;
25 
26 
27 AdvancedDetector::AdvancedDetector(const std::string &name)
28  : _common(CommonData::instance(name)),
29  _frameExtracted(false),
30  _pixellistCreated(false),
31  _hitListCreated(false),
32  _name(name)
33 {}
34 
36 {
37  if(!_frameExtracted)
38  {
39  FrameProcessorBase &process(*_process);
40  process(_frame);
41  _frameExtracted = true;
42  }
43  return _frame;
44 }
45 
47 {
49  {
50  frame();
51  PixelFinderBase &find(*_find);
52  find(_frame,_pixels);
53  _pixellistCreated = true;
54  }
55  return _pixels;
56 }
57 
59 {
60  if (!_hitListCreated)
61  {
62  pixels();
65  _hitListCreated = true;
66  }
67  return _hits;
68 }
69 
71 {
72  /** validate the detector data */
73  CASSEvent::devices_t::const_iterator devIt(
75  if (devIt == evt.devices().end())
76  throw logic_error("AdvancedDetector::associate(): Device " +
77  string("'PixelDetectors' isn't existing in CASSEvent"));
78  const Device &dev (dynamic_cast<const Device&>(*(devIt->second)));
79  Device::detectors_t::const_iterator detIt(dev.dets().find(_detector));
80  if (detIt == dev.dets().end())
81  throw InvalidData("AdvancedDetector::associate(): Detector '" +
82  toString(_detector) + "' isn't present in Device " +
83  "'PixelDetectors' within the CASSEvent");
84  const Detector &det(detIt->second);
85  if (det.id() != evt.id())
86  throw InvalidData("AdvancedDetector::associate(): The dataId '" +
87  toString(det.id()) + "' of detector '" + toString(_detector)+
88  "' is inconsistent with the eventId '" + toString(evt.id()) + "'");
89 
90  _frame.columns = det.columns();
91  _frame.rows = det.rows();
92  _frame.data = det.frame();
93  _common->generateMaps(_frame);
94  _frameExtracted = false;
95  _pixels.clear();
96  _pixellistCreated = false;
97  _hits.clear();
98  _hitListCreated = false;
99 }
100 
102 {
104  _detector = s.value("Detector",0).toUInt();
105  string frameprocesstype(s.value("FrameProcessorType","none").toString().toStdString());
106  _process = FrameProcessorBase::instance(frameprocesstype);
107  _process->loadSettings(s);
108  string pixfindtype(s.value("PixelFinderType","simple").toString().toStdString());
109  _find = PixelFinderBase::instance(pixfindtype);
110  _find->loadSettings(s);
111  string coalescetype(s.value("CoalescingFunctionType","simple").toString().toStdString());
112  _coalesce = CoalescingBase::instance(coalescetype);
113  _coalesce->loadSettings(s);
115  _common->detectorId = _detector;
116  _common->loadSettings(s);
117  s.endGroup();
118 }
std::vector< Hit > hits_t
define the list of coalesced pixels
const hits_t & hits()
retrieve the hits/
Event to store all LCLS Data.
Definition: cass_event.h:32
std::tr1::shared_ptr< CommonData > _common
container for data common for all detectors with this name
int32_t _detector
the detector within the device
void associate(const CASSEvent &evt)
associate the detector with a simple Pixel Detector within a CASSEvent
contains base class for all frame processors.
file contains declaration of the CASSEvent
Settings for CASS.
Definition: cass_settings.h:30
std::tr1::shared_ptr< PixelFinderBase > _find
functor to extract the pixel list
detectors_t & dets()
instrument setter
Frame _frame
the frame of the detector
STL namespace.
void loadSettings(CASSSettings &s)
load the settings of this
bool _hitListCreated
flag whether hit list has been created already
std::string _name
the name of this detector
file contains custom exceptions used in cass
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
Exception thrown when there is a problem with the data.
fromStdString(const std::string &str)
file contains base class for all coalescing functors.
base class for all frame processors
devices_t & devices()
setters
Definition: cass_event.h:66
std::tr1::shared_ptr< CoalescingBase > _coalesce
functor that will do the coalescing
uint16_t columns
how many columns
AdvancedDetector(const std::string &name)
constructor
base class for all coalescing functors
id_t & id()
setters
Definition: cass_event.h:64
contains base class for all pixel finders.
std::string toString(const Type &t)
convert any type to a string
Definition: cass.h:63
Data used commonly for one AdvancedDetector.
Definition: common_data.h:136
std::tr1::shared_ptr< FrameProcessorBase > _process
functor to extract the frame from the CASSEvent
bool _frameExtracted
flag to tell whether the frame has been extracted already
value(const QString &key, const QVariant &defaultValue=QVariant()
A Frame of an advance Pixel Detector.
Detector::frame_t data
the frame data
const Frame & frame()
retrieve the frame
contains the common data for one advanced pixeldetector
base class for pixel finders
bool _pixellistCreated
flag to tell whether the pixel list has been created
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
file contains specialized class that do the settings for cass
the device containing pixel detector data
Detector containing a ccd camera image.
static shared_pointer instance(const instancesmap_t::key_type &detector)
static function creating instance of this.
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
Hit coalesce(const CoalescingBase::pixels_t &splitpixelslist)
coalesce the pixels
advanced pixeldetectors
beginGroup(const QString &prefix)
const pixels_t & pixels()
retrieve the pixellist