CFEL - ASG Software Suite  2.5.0
CASS
processor_manager.h
Go to the documentation of this file.
1 // Copyright (C) 2010,2013 Lutz Foucar
2 // Copyright (C) 2010 Jochen Kuepper
3 
4 /**
5  * @file processor_manager.h contains the manager for the processors
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef __PROCESSOR_MANAGER_H__
11 #define __PROCESSOR_MANAGER_H__
12 
13 #include <list>
14 #include <string>
15 #include <map>
16 #include <sstream>
17 #include <stdexcept>
18 #include <iostream>
19 #include <tr1/memory>
20 
21 #include <QtCore/QMutex>
22 #include <QtCore/QReadWriteLock>
23 
24 #include "processor.h"
25 
26 namespace cass
27 {
28 //forward declarations
29 class CASSEvent;
30 class IdList;
31 
32 
33 
34 /** container and call handler for all registered processors.
35 
36 All currently registered processors are listed here, specifying their id and
37 a short description. The processor classes are named according to their
38 number and placed in the file for the most appropriate group according to their
39 content.
40 
41 @section pplist List of Processors
42 The Classes that implement the processor are pointed out in parenthesis. See
43 the Class description for information about what parameters are user settable.
44 (Keep in mind that cases matter)
45 @verbatim
46 ---Operations--
47 00001: Operation on 2 Result
48 00002: Operation on Result with value or 0D Result
49 00004: Apply boolean NOT to 0D Result
50 00014: Ternary Operation (output InputOne when condition is true, InputTwo otherwise)
51 
52 00009: Check whether Result is in a range
53 00012: Constant Value
54 
55 00013: Identity Operation (returns the input)
56 
57 00015: Check whether value of 0d Result has changed
58 
59 00040: Threshold result
60 00041: Set bin value in result to user value, when corresponding bin value of another result is in given range
61 
62 00050: Project 2D result onto a axis
63 00057: weighted Project 2D result onto a axis
64 00051: Integral of 1D result
65 
66 00055: rotate, transpose or invert axis on 2d result
67 
68 00056: Contains the result of the previous event
69 
70 00060: Histogram 0D, 1D or 2D values to a 1D histogram, optionally with
71  custom weights and remembering the counts per bin
72 00061: Average of a result
73 00062: Summing up of result
74 00063: Time Average of a result over given time-intervals
75 00064: 0D, 1D or 2D into 1D (append on right end, shifting old values to the left)
76 00065: Histogram two 0D values to a 2D histogram
77 00066: Create 2D result from two 1D results
78 00068: Create 2D result from 0D and 1D results, 0D defines the y-axis
79 00069: Use two 0D values for a scatter plot
80 
81 00070: Subset a Result
82 00071: retrieve a user choosable value of a Result
83 00081: retrieve user choosable bin of 1D Result
84 
85 00072: Returns a user choosable column from a table like 2D result
86 00073: Returns a subset of a table based on a condition on a chossable column
87 00074: Returns a specific value of a specific row of a table
88 00079: 2D Result from 2 Columns of a table with optional weight column
89 00500: Add a new column with content of another inputs index which is in table
90 
91 00075: Clear a Result
92 00076: Quit CASS when Condition is met
93 00077: Checks if eventid is on a user provided list
94 00078: Count how many times it has been called (Counter)
95 
96 00082: user choosable statistics value of all values of a result
97 
98 00085: full width at half maximum for a peak in given range of 1D result
99 00086: find step in a given range of 1D result
100 00087: find center of mass in given range of 1D result
101 
102 00088: retrieve an axis parameter of the result
103 
104 00089: high or low pass filter on 1D result
105 
106 00090: Q average of detector image
107 00091: Find local minima in a 1D result
108 
109 ---Data retrieval (Histogram contain only last shot)--
110 ## Data used with new pixeldetector device
111 00109: retrieve raw, untreated pixeldetector Image
112 
113 ## Processors below only work when one has set up the pixel detectors
114 00105: Pixeldetector Image
115 00107: Display the Map used for correction and pixel detection
116 
117 00148: 2d image from detected pixels
118 00149: Number of detected pixels
119 
120 00144: 2d image from coalesced detected pixels (hits)
121 00145: Number of coalesced detected pixels (hits)
122 00146: Split level of coalesced detected pixels (hits) (how many detected pixels within coalseced hit)
123 
124 
125 ## Beamline Data Retrieval
126 00120: Beamline data
127 00121: Eventcode check
128 00122: EventID retrival
129 00123: Beamline Spectrometer Data
130 00130: Epics data
131 
132 
133 ## Waveform and detectors recorded via waveform
134 00110: Acqiris Waveform
135 00111: CFD Trace from Acqiris Waveform
136 00112: CFD Analysis of Waveform
137 
138 00150: TofDetector number of signals in MCP waveform
139 00151: TofDetector all signals
140 00152: TofDetector signal height vs. fwhm
141 00153: TofDetector Deadtime between two consecutive MCP signals
142 
143 00160: Delayline wireend number of signals
144 00161: Delayline wireend signal height vs. fwhm
145 00162: Delayline timesum on anode
146 00163: Delayline timesum on anode vs. position
147 00164: Delayline image of first good hit
148 00165: Delayline reconstructed Number of detectorhits
149 00166: Delayline data of all reconstructed detectorhits
150 00167: Delayline Deadtime between two consecutive anode signals
151 
152 00170: Hex Delayline Calibrator (see Hexcalibrator for parameters)
153 
154 ---Data analysis--
155 00200: Scalar value of <cos^2\theta> from 2D Histogram
156 00201: Angular distribution from a 2D Histogram (interpolating)
157 00202: transform 2D Histogram kartesian coordinates to polar coordinates (interpolating)
158 00220: PIPICO Spectrum
159 00230: Photon energy of Shot
160 00250: Property of particle
161 00251: 2d hist with two properties of particle
162 00252: Number of found particle hits per shot
163 
164 00203: Local image background using median box
165 00204: Find Bragg peaks in image using signal to noise ratio
166 00208: Find Bragg peaks in image using signal to noise ratio without outliers
167 00210: Find Bragg peaks in image MAD
168 00209: Cluster connected pixels which are above a threshold in an image
169 00205: Display Peaks found in an image
170 00206: Find Pixels that might belong to a bragg peak by looking above threshold
171 
172 00300: single particle detection
173 00301: median over last values
174 00302: binary file 2DHistogram
175 00310: Autocorrelation of image in polar coordinates
176 00311: Autocorrelation of image in kartesian coordinates
177 00312: FFT of an histogram
178 00313: Convolute a histogram with a kernel
179 00240: Test Image
180 
181 00330: Generate Calibration data from raw images
182 00331: Generate Gain Calibration from images
183 00332: Generate Hot Pixel Map from images
184 00333: Generate common mode Background level
185 00334: Generate common mode Background level for CsPAD
186 
187 00241: fix distorted offset of pnCCD frames
188 00242: same as 105, but one can put a user defined value at the masked pixels
189 00243: apply a mask to an image set the masked values to a user defined value
190 00244: generate a histogram of the pixelvalues for each pixel in an image
191 
192 01600: convert cass cspad to cheetah cspad
193 01601: rearrange cspad to coarsly right orientation (looking from upstream)
194 01602: rearrange cspad using a geom file
195 
196 00400: ToF to Energy conversion
197 00404: ToF to Mass to Charge ratio conversion
198 00405: Pulse duration of shot
199 00406: ToF to Energy conversion from 0D histogram
200 00407: ToF to Energy conversion by linear interpolation
201 00408: ToF to Energy conversion by linear interpolation and correction from 0D histogram
202 00410: calculate covariance map
203 00412: calculate intensity correction
204 
205 ---Output--
206 01002: Put selectable histograms into HDF5-Files
207 01500: Put a selectable 2d histogram into CBF Files
208 02000: Dump all selected 0d, 1d and 2d cass histograms to root file
209 02001: Write Hits of selected Delayline Detectors to ROOT Tree
210 
211 ---Coltrims Analysis--
212 05000: Electron Energy from Recoil momenta
213 05001: Tripple Coincidence Spectra from same detector
214 
215 ---Removed Processors---
216 00003: removed use pp2 instead
217 00005: removed use pp1 instead
218 00006: removed use pp1 instead
219 00007: removed use pp1 instead
220 00008: removed use pp1 instead
221 00010: removed use pp12 instead
222 00011: removed use pp12 instead
223 00020: removed used pp1 instead
224 00021: removed used pp1 instead
225 00022: removed used pp1 instead
226 00023: removed used pp1 instead
227 00024: removed use pp2 instead
228 00025: removed use pp2 instead
229 00026: removed use pp2 instead
230 00027: removed use pp2 instead
231 00030: removed use pp2 instead
232 00031: removed use pp2 instead
233 00032: removed use pp2 instead
234 00033: removed use pp2 instead
235 00052: removed use pp202 and pp50 instead
236 00053: removed use pp202 and pp50 instead
237 00054: removed use pp202 instead
238 00067: removed use pp60 instead
239 00080: removed use pp78 instead
240 00083: removed use pp82 instead
241 00084: removed use pp82 instead
242 00100: removed use pp105 instead
243 00101: removed use pp105 and pp82 instead
244 00102: removed use pp105, pp40 and pp82 instead
245 00106: removed use pp60 instead
246 00108: removed use pp84 instead
247 00140: removed use pp105 and pp60 instead
248 00141: removed use pp148 instead
249 00142: removed use pp149 instead
250 00143: removed use pp60 instead
251 00147: removed use pp60 instead
252 00155: removed use pp84 instead
253 00156: removed use pp84 instead
254 00207: removed use pp79 instead
255 00212: removed use pp144 or pp148 instead
256 00401: removed use pp83 instead
257 00402: removed use pp61 instead
258 00403: removed use pp70 instead
259 00420: removed use pp80 instead
260 01000: removed use pp1002 instead
261 01001: removed use pp1002 instead
262 @endverbatim
263 */
265 {
266 public:
267 
268  /** List of all currently registered processors
269  *
270  * @todo instead of this list use strings as id
271  *
272  * Keep this fully list synchronized with the documentation in the class header!
273  */
274  enum id_t
275  {
290 
292 
301 
306 
309 
315 
318 
320 
331 
333 
338 
343 
345 
351 
353  step=86,
358  nodes=91,
359 
363 
368 
370 
374 
375  BlData=120,
376  EvrCode=121,
377  EventID=122,
380 
384 
389 
393 
398 
401 
410 
412 
416 
425 
427 
428  PIPICO=220,
429 
432 
437 
441 
447  fft=312,
449 
455 
460  TofToMTC=404,
468 
470 
471  PnccdHDF5=1000,
474  CBFOutput=1500,
478  ROOTDump=2000,
480 
483 
485  };
486 
487  /** a shared pointer of this class */
488  typedef std::tr1::shared_ptr<ProcessorManager> shared_pointer;
489 
490  /** type of proccessor accessor key */
492 
493  /** Container of all currently active processors */
494  typedef std::list<Processor::shared_pointer> processors_t;
495 
496  /** List of all processor keys */
498 
499  /** create the instance if not it does not exist already.
500  *
501  * @return poiner to this singelton class.
502  * @param outputfilename filename of the outputfile
503  */
504  static shared_pointer instance(std::string outputfilename);
505 
506  /** return the already created instance of this
507  *
508  * check whether static instance has been created and returns if so otherwise
509  * throws an exception.
510  *
511  * @return the instance
512  */
513  static shared_pointer instance();
514 
515  /** return a reference to this instance
516  *
517  * check whether static instance has been created and returns if so otherwise
518  * throws an exception.
519  *
520  * @return reference to the instance
521  */
522  static shared_pointer::element_type& reference();
523 
524  /** process event
525  *
526  * This function will call processors operators in the container
527  *
528  * @param event CASSEvent to process by all active processors
529  */
530  void operator()(const CASSEvent& event);
531 
532  /** retrieve all activated processors keys
533  *
534  * populate the serializable list of keys with the processors that are
535  * not hidden and return it
536  *
537  * @return shared pointer to the key list
538  */
539  std::tr1::shared_ptr<IdList> keys();
540 
541  /** retreive pp with key */
543 
544  /** retreive pp with name
545  *
546  * @param name The name of the Processor to retrive
547  */
549 
550  /** retrieve pp container */
551  processors_t& processors() {return _processors;}
552 
553  /** will be called when program will quit */
554  void aboutToQuit();
555 
556  /** retrieve the list of active processors */
557  const keyList_t &activeList() {return _active;}
558 
559  /** a read write lock
560  *
561  * read write for making sure that reload is not called when someone
562  * wants retrieve a list or retrieve a processor.
563  */
565 
566  /** Load active processors and histograms
567  *
568  * Reset set of active processors/histograms based on cass.ini
569  */
570  void loadSettings(size_t);
571 
572 protected:
573  /** factory to create new processor with the name key.
574  *
575  * The ID which processor should be used for the name is extracted from
576  * the settings and has the property ID.
577  *
578  * @return instance the newly created processor
579  * @param[in] key the key of the processor
580  */
581  Processor::shared_pointer create(const key_t &key);
582 
583 protected:
584  /** the list of keys.
585  *
586  * used to create the combobox in cassview
587  */
588  std::tr1::shared_ptr<IdList> _keys;
589 
590  /** container for user selected and registered processors */
591  processors_t _processors;
592 
593  /** filename of the output file */
594  std::string _outputfilename;
595 
596  /** list of active keys */
597  keyList_t _active;
598 
599 private:
600  /** Private constructor of singleton
601  *
602  * @param outputfilename filename of the file containing the results. Used
603  * by special processors.
604  */
605  ProcessorManager(std::string outputfilename);
606 
607  /** Prevent copy-construction of singleton */
609 
610  /** Prevent assignment (potentially resulting in a copy) of singleton */
612 
613  /** pointer to the singleton instance */
614  static shared_pointer _instance;
615 
616  /** Singleton operation locker */
617  static QMutex _mutex;
618 };
619 
620 } // namespace cass
621 
622 
623 #endif
id_t
List of all currently registered processors.
Event to store all LCLS Data.
Definition: cass_event.h:32
const keyList_t & activeList()
retrieve the list of active processors
Processor::shared_pointer getProcessorSPointer(const Processor::name_t &name)
retreive pp with name
Processor::name_t key_t
type of proccessor accessor key
void operator()(const CASSEvent &event)
process event
std::list< Processor::shared_pointer > processors_t
Container of all currently active processors.
void aboutToQuit()
will be called when program will quit
std::tr1::shared_ptr< IdList > keys()
retrieve all activated processors keys
std::tr1::shared_ptr< IdList > _keys
the list of keys.
container and call handler for all registered processors.
processors_t _processors
container for user selected and registered processors
void loadSettings(size_t)
Load active processors and histograms.
Processor::shared_pointer create(const key_t &key)
factory to create new processor with the name key.
std::string _outputfilename
filename of the output file
Processor::names_t keyList_t
List of all processor keys.
std::list< name_t > names_t
define the list of names
Definition: processor.h:49
base class for processors.
Definition: processor.h:39
static shared_pointer _instance
pointer to the singleton instance
static shared_pointer instance()
return the already created instance of this
ProcessorManager(std::string outputfilename)
Private constructor of singleton.
keyList_t _active
list of active keys
file contains processors baseclass declaration
binary function for averaging.
Processor & getProcessor(const Processor::name_t &name)
retreive pp with key
static QMutex _mutex
Singleton operation locker.
QReadWriteLock lock
a read write lock
std::tr1::shared_ptr< ProcessorManager > shared_pointer
a shared pointer of this class
ProcessorManager & operator=(const ProcessorManager &)
Prevent assignment (potentially resulting in a copy) of singleton.
static shared_pointer::element_type & reference()
return a reference to this instance
std::string name_t
define the name type
Definition: processor.h:46
std::tr1::shared_ptr< Processor > shared_pointer
a shared pointer of this
Definition: processor.h:43
processors_t & processors()
retrieve pp container