CFEL - ASG Software Suite  2.5.0
CASS
advanced_pixeldetector.h
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file advanced_pixeldetector.h advanced pixeldetectors
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _PIXELDETECTORNEW_H_
10 #define _PIXELDETECTORNEW_H_
11 
12 #include <tr1/memory>
13 #include <stdint.h>
14 #include <string>
15 
16 #include "pixeldetector.hpp"
17 #include "pixel_finder_base.h"
18 
19 namespace cass
20 {
21 //forward declaration
22 class CASSSettings;
23 class CASSEvent;
24 
25 namespace pixeldetector
26 {
27 //forward declaration
28 class CommonData;
29 class FrameProcessorBase;
30 class PixelFinderBase;
31 class CoalescingBase;
32 
33 
34 /** A Frame of an advance Pixel Detector
35  *
36  * the frame consists of the data and columns and rows
37  *
38  * @author Lutz Foucar
39  */
40 struct Frame
41 {
42  /** how many columns */
43  uint16_t columns;
44 
45  /** how many rows */
46  uint16_t rows;
47 
48  /** the frame data */
50 
51  /** return the shape of the frame */
53  {
54  return std::make_pair(columns,rows);
55  }
56 
57  /** try to retrive the right shape of the detector from the name
58  *
59  * in case the shape cannot be deduced from the name, 0,0 will be returned
60  *
61  * @return the shape of the detector
62  * @param name the name of the detector
63  */
64  static Detector::shape_t shapeFromName(const std::string &name)
65  {
66  using namespace std;
67  Detector::shape_t shape(make_pair(0,0));
68  if (name.find("PnCCD") != string::npos)
69  shape = make_pair(1024,1024);
70  else if (name.find("CsPad2x2") != string::npos)
71  shape = make_pair(2*194,2*185);
72  else if (name.find("CsPad") != string::npos)
73  shape = make_pair(2*194,4*8*185);
74  else if (name.find("Opal1k") != string::npos)
75  shape = make_pair(1024,1024);
76  else if (name.find("Opal2k") != string::npos)
77  shape = make_pair(1920,1080);
78  else if (name.find("Opal4k") != string::npos)
79  shape = make_pair(2048,2048);
80  return shape;
81  }
82 };
83 
84 /** A Hit on a pixel detector.
85  *
86  * This class defines a hit on a pixel detector that might consist of more
87  * one pixel.
88  *
89  * @author Lutz Foucar
90  */
91 struct Hit
92 {
93  /** default constructor.*/
94  Hit()
95  :x(0),y(0),z(0),nbrPixels(0)
96  {}
97 
98  /** the x coordinate of hit */
99  float x;
100 
101  /** the x coordinate of hit */
102  float y;
103 
104  /** the value of the hit */
105  uint64_t z;
106 
107  /** number of pixels that this hit consists of */
108  size_t nbrPixels;
109 };
110 
111 /** An Advanced Pixel Detector
112  *
113  * This class describes a pixel detector which has all the opertors to analyse
114  * and extract the additional information internally.
115  *
116  * @cassttng PixelDetectors/\%name\%/{Detector}\n
117  * The detector that contains the ccd image. Default is 0. Options are:
118  * - 0: Front pnCCD
119  * - 1: Rear pnCCD
120  * - 2: 1st commercial CCD in AMO
121  * - 3: 2nd commercial CCD in AMO
122  * - 4: 3rd commercial CCD in AMO
123  * - 6: 4th commercial CCD in AMO
124  * - 5: 1st commercial CCD in XPP
125  * - 7: Front CsPad in CXI
126  * - 8: Rear CsPad in CXI
127  * @cassttng PixelDetectors/\%name\%/{FrameProcessorType}\n
128  * Functor for processing the frame. Default is "none". Options are:
129  * - "none": No processing is done to the frame, just the raw frame
130  * will be returned
131  * - "hll": The type of processing that the semiconductor lab applies
132  * to their frame data. see cass::pixeldetector::HLLProcessor
133  * @cassttng PixelDetectors/\%name\%/{PixelFinderType}\n
134  * Functor for finding pixels of interest in the frame. The pixels
135  * will be found after the frame processor has processed the frame.
136  * Default is "aboveNoise". Options are:
137  * - "aboveNoise": uses the noise map
138  * (see cass::pixeldetector::CommonData) to check
139  * whether a pixel is of interest. See
140  * cass::pixeldetector::AboveNoiseFinder
141  * - "simple": checks whether a pixel value is higher than the
142  * pixelvalues of the neighbours.
143  * See cass::pixeldetector::PixelFinderSimple
144  * - "simpleMoreOptions": checks whether a pixel value is higher than the
145  * pixelvalues of the neighbours defining a box
146  * See cass::pixeldetector::PixelFinderSimpleMoreOptions
147  * - "range": checks whether the pixel value is a user set range. See
148  * cass::pixeldetector::WithinRange
149  * @cassttng PixelDetectors/\%name\%/{CoalescingFunctionType}\n
150  * Functor to coalesce the pixels into hits. Default is "simple".
151  * Options are:
152  * - "simple": simple coalescing with basic checks.
153  * See cass::pixeldetector::SimpleCoalesce.
154  * @cassttng there are more settings for the common data. Please see
155  * cass::pixeldetector::CommonData for details on what to set.
156  *
157  * @author Lutz Foucar
158  */
160 {
161 public:
162  /** define the list of coalesced pixels */
163  typedef std::vector<Hit> hits_t;
164 
165  typedef std::vector<Pixel> pixels_t;
166 
167  /** constructor
168  *
169  * @param name the name of this detector
170  */
171  AdvancedDetector(const std::string &name);
172 
173  /** associate the detector with a simple Pixel Detector within a CASSEvent
174  *
175  * resets the flags indicating whether the frame, the pixel list and the hit
176  * list have been created. Copies the Frame data the info about the columns
177  * and rows to the _frame object of this class. The _frame object is then
178  * passed to the _common object. This should then build up the necessary
179  * Maps for correcting. See CommonData for details
180  *
181  * @param evt The CASSEvent that contains the PixelDetector that this
182  * container is responsible for.
183  */
184  void associate(const CASSEvent &evt);
185 
186  /** load the settings of this
187  *
188  * loads which FrameProcessorBase functor should be used, get an instance of
189  * the right type and load its settings.
190  * loads which PixelFinderBase functor should be used, get an instance of
191  * the right type and load its settings.
192  * loads which CoalescingBase functor should be used, get an instance of
193  * the right type and load its settings.
194  * the loads the seetings for the common data. See CommonData for details.
195  *
196  * @param s the CASSSettings object to read the information from
197  */
198  void loadSettings(CASSSettings &s);
199 
200  /** retrieve the frame
201  *
202  * the frame from the cass event is treated with the frame processor _process
203  * before it is returned, but only when it has not yet been treated. For
204  * all available options see this classes cass settings information.
205  */
206  const Frame& frame();
207 
208  /** retrieve the pixellist
209  *
210  * the pixels list contains all pixels that fullfill a certain criteria. They
211  * are found in the processed frame using different finding functions. For a
212  * list of all available finding procedures please refer to the description
213  * of this class.
214  */
215  const pixels_t& pixels();
216 
217  /** retrieve the hits/
218  *
219  * Hits are defined as particles or photons that hit the detector. Those hits
220  * can potentially not only be detected by just one pixel. Therefore one has
221  * to find the pixels that belong to one hit on the detector. This is done
222  * by the coalsecing functions available to this class (for a complete
223  * list of all available finding procedures please refer to the description
224  * of this class). The coalsecing functions work on the pixellist that is
225  * created from the processed frame.
226  */
227  const hits_t& hits();
228 
229 private:
230  /** container for data common for all detectors with this name */
231  std::tr1::shared_ptr<CommonData> _common;
232 
233  /** the frame of the detector */
235 
236  /** flag to tell whether the frame has been extracted already */
238 
239  /** functor to extract the frame from the CASSEvent */
240  std::tr1::shared_ptr<FrameProcessorBase> _process;
241 
242  /** the list of pixels */
243  pixels_t _pixels;
244 
245  /** flag to tell whether the pixel list has been created */
247 
248  /** functor to extract the pixel list */
249  std::tr1::shared_ptr<PixelFinderBase> _find;
250 
251  /** hits on the detector */
252  hits_t _hits;
253 
254  /** flag whether hit list has been created already */
256 
257  /** functor that will do the coalescing */
258  std::tr1::shared_ptr<CoalescingBase> _coalesce;
259 
260  /** the name of this detector */
261  std::string _name;
262 
263  /** the detector within the device */
264  int32_t _detector;
265 };
266 
267 }
268 }
269 #endif
std::vector< Hit > hits_t
define the list of coalesced pixels
Event to store all LCLS Data.
Definition: cass_event.h:32
float x
the x coordinate of hit
std::tr1::shared_ptr< CommonData > _common
container for data common for all detectors with this name
int32_t _detector
the detector within the device
Settings for CASS.
Definition: cass_settings.h:30
std::tr1::shared_ptr< PixelFinderBase > _find
functor to extract the pixel list
Frame _frame
the frame of the detector
STL namespace.
std::pair< size_t, size_t > shape_t
define a shape of an image columnsxrows
Average out the iShit status to get the avererage hits
bool _hitListCreated
flag whether hit list has been created already
std::string _name
the name of this detector
Detector::shape_t shape() const
return the shape of the frame
std::tr1::shared_ptr< CoalescingBase > _coalesce
functor that will do the coalescing
std::vector< pixel_t > frame_t
a frame is a vector of pixels
uint16_t columns
how many columns
contains base class for all pixel finders.
A Hit on a pixel detector.
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
float y
the x coordinate of hit
A Frame of an advance Pixel Detector.
size_t nbrPixels
number of pixels that this hit consists of
Detector::frame_t data
the frame data
contains container for simple pixel detector data
bool _pixellistCreated
flag to tell whether the pixel list has been created
void loadSettings(CASSSettings &s, CFDParameters &p, uint32_t &instrument, size_t &channelNbr)
implementation of loading settings for both CFD classes
Definition: cfd.cpp:210
uint64_t z
the value of the hit
Hit()
default constructor.
static Detector::shape_t shapeFromName(const std::string &name)
try to retrive the right shape of the detector from the name