CFEL - ASG Software Suite  2.5.0
CASS
sacla_converter.cpp
Go to the documentation of this file.
1 // Copyright (C) 2014, 2015 Lutz Foucar
2 
3 /**
4  * @file sacla_converter.cpp contains class to convert sacla data to cassevent
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include <algorithm>
10 
11 #include <QtCore/QRegExp>
12 
13 #ifdef _OPENMP
14 #include <omp.h>
15 #endif
16 
17 #include "sacla_converter.h"
18 
19 #include "cass_event.h"
20 #include "cass_settings.h"
21 #include "machine_device.hpp"
22 #include "cass.h"
23 #include "log.h"
24 #include "cass_exceptions.hpp"
25 
26 using namespace cass;
27 using namespace std;
28 
29 
31 {
32 #ifdef _OPENMP
33  Log::add(Log::INFO, "SACLAConverter: Running with up to '" +
34  toString(omp_get_max_threads()) + "' input threads");
35 #endif
36 }
37 
39 {
40  /** destroy the buffers */
41 // string bout(name+ " destroying buffer " + toString(size_t(readBuf)));
42 // cout << bout <<endl;
43  st_destroy_stbuf(&readBuf);
44 // string sout(name+ " destroying streamer " + toString(size_t(sreader)));
45 // cout << sout <<endl;
46  st_destroy_streader(&sreader);
47 }
48 
49 void SACLAConverter::detTileParams::init(int runNbr, int blNbr)
50 {
51  int funcstatus(0);
52  /** create stream reader object */
53  int r[] = {runNbr};
54  funcstatus = st_create_streader(&sreader, name.c_str(), blNbr, 1, r);
55  if (funcstatus)
56  throw SaclaPixDetError(string("dettile::init: couldn't create stream ") +
57  "reader object for tile '" + name + "' on beamline '" +
58  toString(blNbr) + "' with run '" + toString(runNbr) +
59  "' ErrorCode is '" + toString(funcstatus) + "'");
60  /** create the read buffer */
61  funcstatus = st_create_stbuf(&readBuf, sreader);
62  if (funcstatus)
63  throw SaclaPixDetError(string("dettile::init: couldn't create stream ") +
64  "reader object for tile '" + name + "' on beamline '" +
65  toString(blNbr) + "' with run '" + toString(runNbr) +
66  "' ErrorCode is '" + toString(funcstatus) + "'");
67 }
68 
70 {
71  int funcstatus(0);
72  /** collect the detector tile data */
73  funcstatus = st_collect_data(readBuf,sreader,&tag);
74  if (funcstatus)
75  throw SaclaPixDetError(string("readFromStreamer: could not collect ") +
76  "data for '" + name + "' for tag '" + toString(tag) +
77  "' ErrorCode is '" + toString(funcstatus) + "'");
78 }
79 
81 {
82  int funcstatus(0);
83  /** the number of columns */
84  funcstatus = st_read_det_xsize(&xsize, readBuf, 0);
85  if (funcstatus)
86  throw SaclaPixDetError(string("detTileParams::cache: error reading ") +
87  "xsize of '" + name + "' ErrorCode is '" +
88  toString(funcstatus) + "'");
89  else
90  Log::add(Log::INFO,"detTileParams::cache: Tile '" + name +
91  "' has xsize '" + toString(xsize) + "'");
92 
93  /** the number of rows */
94  funcstatus = st_read_det_ysize(&ysize, readBuf, 0);
95  if (funcstatus)
96  throw SaclaPixDetError(string("detTileParams::cache: error reading ") +
97  "ysize of '" + name + "' ErrorCode is '" +
98  toString(funcstatus) + "'");
99  else
100  Log::add(Log::INFO,"detTileParams::cache: Tile '" + name +
101  "' has ysize '" + toString(ysize) + "'");
102 
103  /** the x-size of the pixels of the tile */
104  funcstatus = mp_read_pixelsizex(&pixsizex_um, readBuf);
105  if (funcstatus)
106  throw SaclaPixDetError(string("detTileParams::cache: error reading ") +
107  "x pixelsize of '" + name + "' ErrorCode is '" +
108  toString(funcstatus) + "'");
109  else
110  Log::add(Log::INFO,"detTileParams::cache: Tile '" + name +
111  "' has x pixelsize '" + toString(pixsizex_um) + "' um");
112  /** the y-size of the pixels of the tile */
113  funcstatus = mp_read_pixelsizey(&pixsizey_um,readBuf);
114  if (funcstatus)
115  throw SaclaPixDetError(string("detTileParams::cache: error reading ")+
116  "y pixelsize of '" + name + "' ErrorCode is '" +
117  toString(funcstatus) + "'");
118  else
119  Log::add(Log::INFO,"detTileParams::cache: Tile '" + name +
120  "' has y-pixelsize '" + toString(pixsizey_um) + "' um");
121 
122  /** calc the total number of pixels form the x and y size */
123  nPixels = xsize * ysize;
124 }
125 
126 void SACLAConverter::detTileParams::copyTo(pixeldetector::Detector::frame_t::iterator pos)
127 {
128  bytes_retrieved = 0.;
129  int funcstatus(0);
130  /** prepare the buffer where the data should be loaded to and retrieve the
131  * detector data from the reader buffer
132  */
133  vector<float> buffer(nPixels);
134  funcstatus = st_read_det_data(&buffer.front(), readBuf, 0);
135  if (funcstatus)
136  throw SaclaPixDetError(string("detTileParams::copyTo: ") +
137  "could not retrieve data from buffer of '" + name +
138  "' ErrorCode is '" + toString(funcstatus) + "'");
139 
140  /** use transform to copy the data */
141  transform(buffer.begin(), buffer.end(), pos,
142  bind1st(multiplies<float>(),relativeGain));
143 
144  /** set the datasize of the retrieved data */
145  bytes_retrieved = nPixels * sizeof(uint16_t);
146 }
147 
149 {
150  CASSSettings s;
151  s.beginGroup("SACLAConverter");
152 
153  /** set the requested octal detectors */
154  int size = s.beginReadArray("OctalPixelDetectors");
155  for (int i = 0; i < size; ++i)
156  {
157  s.setArrayIndex(i);
158  string detID(s.value("DetectorIDName","Invalid").toString().toStdString());
159  /** skip if the detector name has not been set */
160  if (detID == "Invalid")
161  continue;
162  _octalDetectors.push_back(pixDets_t::value_type());
163  _octalDetectors.back().CASSID = s.value("CASSID",0).toInt();
164  _octalDetectors.back().normalize = s.value("NormalizeToAbsGain",true).toBool();
165  _octalDetectors.back().tiles.resize(8);
166  Log::add(Log::INFO,string("SACLAConverter::loadSettings(): Add ") +
167  "octal detector with CASSID '" +
168  toString(_octalDetectors.back().CASSID) + "'");
169  for (size_t i(0); i<_octalDetectors.back().tiles.size(); ++i)
170  _octalDetectors.back().tiles[i].name = (detID + "-" + toString(i+1));
171  }
172  s.endArray();
173 
174  /** set the requested pixel detectors */
175  size = s.beginReadArray("PixelDetectors");
176  for (int i = 0; i < size; ++i)
177  {
178  s.setArrayIndex(i);
179  string detID(s.value("DetectorIDName","Invalid").toString().toStdString());
180  /** skip if the detector name has not been set */
181  if (detID == "Invalid")
182  continue;
183  _pixelDetectors.push_back(pixDets_t::value_type());
184  _pixelDetectors.back().CASSID = s.value("CASSID",0).toInt();
185  _pixelDetectors.back().tiles.resize(1);
186  _pixelDetectors.back().tiles[0].name = detID;
187  Log::add(Log::INFO,string("SACLAConverter::loadSettings(): Add ") +
188  "detector with CASSID '" +
189  toString(_pixelDetectors.back().CASSID) + "'");
190  }
191  s.endArray();
192 
193  /** set the requested database values */
194  size = s.beginReadArray("DatabaseValues");
195  for (int i = 0; i < size; ++i)
196  {
197  s.setArrayIndex(i);
198  string machineValName(s.value("ValueName","Invalid").toString().toStdString());
199  /** skip if the value name has not been set */
200  if (machineValName == "Invalid")
201  continue;
202  /** retrieve the name that the value should have in the CASSEvent
203  * (in case non is given, default it to the machine value name
204  */
205  _machineVals.push_back(machineVals_t::value_type());
206  _machineVals.back().databaseName = machineValName;
207  _machineVals.back().cassName = s.value("CASSName",QString::fromStdString(machineValName)).toString().toStdString();
208  Log::add(Log::INFO,string("SACLAConverter::loadSettings(): Add ") +
209  "database value '" +
210  _machineVals.back().databaseName + "' with CASSName '" +
211  _machineVals.back().cassName + "'");
212  }
213  s.endArray();
214 
215  s.endGroup();
216 }
217 
218 void SACLAConverter::cacheParameters(vector<int>::const_iterator first,
219  vector<int>::const_iterator last,
220  int blNbr, int runNbr, int highTagNbr)
221 {
222  /** create the tag list from the iterators */
223  vector<int> tagList(first,last);
224 
225  int funcstatus(0);
226  /** for all requested beamline parameters retrieve the values for all tags in
227  * one go
228  */
229  machineVals_t::iterator machineValsIter(_machineVals.begin());
230  machineVals_t::const_iterator machineValsEnd(_machineVals.end());
231  for (; machineValsIter != machineValsEnd; ++machineValsIter)
232  {
233  MachineValue & mv(*machineValsIter);
234  /** create the sacla string buffer to retrieve the data */
235  struct da_string_array *machineValueStringList = NULL;
236  da_alloc_string_array(&machineValueStringList);
237  /** retrive the data */
238  funcstatus = sy_read_syncdatalist(machineValueStringList,
239  mv.databaseName.c_str(),
240  highTagNbr,
241  tagList.size(),
242  &(tagList.front()));
243  if (funcstatus)
244  {
245  Log::add(Log::ERROR,string("SACLAConverter::cacheParameters could not ") +
246  "cache values of '" + mv.databaseName + "' ErrorCode is '"
247  + toString(funcstatus) + "'");
248  da_destroy_string_array(&machineValueStringList);
249  continue;
250  }
251  /** check if as many parameters as tags given have been returned. In case
252  * this number is different, something bad happened
253  */
254  int machineValueStringListSize = 0;
255  da_getsize_string_array(&machineValueStringListSize, machineValueStringList);
256  if (machineValueStringListSize != static_cast<int>(tagList.size()))
257  {
258  Log::add(Log::ERROR,"SACLAConverter:cacheParameters caching '" +
259  mv.databaseName + "' did not return the right size");
260  da_destroy_string_array(&machineValueStringList);
261  continue;
262  }
263  /** convert the retrieved database values into double numbers
264  * and put them into the cache
265  */
266  vector<int>::const_iterator tag(tagList.begin());
267  vector<int>::const_iterator tagListEnd(tagList.end());
268  for (size_t i(0); tag != tagListEnd; ++tag, ++i)
269  {
270  /** check if retrieved value can be converted to double, and if so add it
271  * to the machine data, otherwise issue an error and add a 0 into the
272  * cache for that given tag.
273  * @note the retrieved values might contain the unit of the value in the
274  * string, therefore one has to remove all characters from the string
275  */
276  char * machineValueString(NULL);
277  da_getstring_string_array(&machineValueString,
278  machineValueStringList,
279  i);
280  QString machineValueQString(machineValueString);
281  machineValueQString.remove(QRegExp("V|C|pulse|a\\.u\\."));
282  bool isDouble(false);
283  double machineValue(machineValueQString.toDouble(&isDouble));
284  if (isDouble)
285  mv.values[*tag] = machineValue;
286  else
287  {
288  Log::add(Log::ERROR,"SACLAConverter::cacheParameters '" +
289  mv.databaseName + "' for tag '" + toString(*tag) +
290  "': String '" + machineValueString + "' which is altered to '" +
291  machineValueQString.toStdString() +
292  "' to remove units, cannot be converted to double. " +
293  "Setting it to 0");
294  mv.values[*tag] = 0.;
295  }
296  free(machineValueString);
297  }
298  /** destroy the sacla string list */
299  da_destroy_string_array(&machineValueStringList);
300  /** output which database value has been cached */
301  Log::add(Log::INFO,string("SACLAConverter::cacheParameters: ") +
302  "cached values of database '" + mv.databaseName +
303  "' into the CASS beamline value '" +
304  mv.cassName + "'");
305  }
306 
307  /** for all pixel dets, which consist of only 1 tile, retrieve the
308  * non-changing parameters from the first image
309  */
310  pixDets_t::iterator pixelDetsIter(_pixelDetectors.begin());
311  pixDets_t::const_iterator pixelDetsEnd(_pixelDetectors.end());
312  for (; pixelDetsIter != pixelDetsEnd; ++pixelDetsIter)
313  {
314  pixDets_t::value_type &pixdet(*pixelDetsIter);
315  detTileParams &tile(pixdet.tiles.front());
316  try
317  {
318  tile.init(runNbr,blNbr);
319  tile.readFromStreamer(*first);
320  tile.cache();
321  pixdet.notLoaded = false;
322  }//end try
323  catch (const SaclaPixDetError &err)
324  {
325  Log::add(Log::ERROR,err.what());
326  pixdet.notLoaded = true;
327  }
328  }//end pixdet loop
329 
330 
331  /** for all octal dets retrieve the non changing parameters from the first
332  * image
333  */
334  pixDets_t::iterator octalDetsIter(_octalDetectors.begin());
335  pixDets_t::const_iterator octalDetsEnd(_octalDetectors.end());
336  for (; octalDetsIter != octalDetsEnd; ++octalDetsIter)
337  {
338  pixDets_t::value_type &octdet(*octalDetsIter);
339  try
340  {
341  for (size_t i(0); i < octdet.tiles.size(); ++i)
342  {
343  /** get reference to the current tile */
344  detTileParams &tile(octdet.tiles[i]);
345  /** initialize the tiles streamer and buffer */
346  tile.init(runNbr,blNbr);
347  /** read data from the first tag into the buffer */
348  tile.readFromStreamer(*first);
349  /** cache the non-chaneging data */
350  tile.cache();
351  /** retrieve the additonal information of the tiles of an octal detector */
352  int funcstatus(0);
353  /** the position in x in the lab space in um */
354  funcstatus = mp_read_posx(&(tile.posx_um), tile.readBuf);
355  if (funcstatus)
356  throw SaclaPixDetError(string("SACLAConverter::cacheParameters: ") +
357  "pos X of '" + tile.name + "' ErrorCode is '" +
358  toString(funcstatus) + "'");
359  else
360  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
361  tile.name + "' has pos x '" + toString(tile.posx_um) + "' um");
362 
363  /** the position in y in the lab space in um */
364  funcstatus = mp_read_posx(&(tile.posy_um), tile.readBuf);
365  if (funcstatus)
366  throw SaclaPixDetError(string("SACLAConverter::cacheParameters: ") +
367  "pos Y of '" + tile.name + "' ErrorCode is '" +
368  toString(funcstatus) + "'");
369  else
370  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
371  tile.name + "' has pos y '" + toString(tile.posy_um) + "' um");
372 
373  /** the position in z in the lab space in um */
374  funcstatus = mp_read_posx(&(tile.posz_um), tile.readBuf);
375  if (funcstatus)
376  throw SaclaPixDetError(string("SACLAConverter::cacheParameter: ") +
377  "pos Z of '" + tile.name + "' ErrorCode is '" +
378  toString(funcstatus) + "'");
379  else
380  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
381  tile.name + "' has pos z '" + toString(tile.posz_um) + "' um");
382 
383  /** the angle in degrees in the lab space */
384  funcstatus = mp_read_rotationangle(&(tile.angle_deg), tile.readBuf);
385  if (funcstatus)
386  throw SaclaPixDetError(string("SACLAConverter::cacheParameter: ") +
387  "angle of '" + tile.name + "' ErrorCode is '" +
388  toString(funcstatus) + "'");
389  else
390  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
391  tile.name + "' has angle '" + toString(tile.angle_deg) +
392  "' degrees");
393 
394  /** the gain of the detector tile */
395  funcstatus = mp_read_absgain(&(tile.gain), tile.readBuf);
396  if (funcstatus)
397  throw SaclaPixDetError(string("SACLAConverter::cacheParameter: ") +
398  "absolute gain of '" + tile.name +
399  "' ErrorCode is '" + toString(funcstatus) + "'");
400  else
401  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
402  tile.name + "' has absolute gain '" + toString(tile.gain) +
403  "'");
404  }//end tile loop
405 
406  /** if the tiles of the octal detector should be normalized, calculate the
407  * relative gain of the individual tiles with respect to the first tile
408  * and store the relative gains within the tile
409  */
410  if (octdet.normalize)
411  {
412  detTileParams &firstTile(octdet.tiles.front());
413  firstTile.normalize = false;
414  for (size_t i(0); i < octdet.tiles.size(); ++i)
415  {
416  detTileParams &tile(octdet.tiles[i]);
417  tile.normalize = true;
418  tile.relativeGain = tile.gain / firstTile.gain;
419  Log::add(Log::INFO,"SACLAConverter::cacheParameters: Tile '" +
420  tile.name + "' will be normalized with relative gain of '" +
421  toString(tile.relativeGain) + "'");
422  }
423  }
424 
425  /** get the total size of the detector */
426  for (size_t i(0); i < octdet.tiles.size(); ++i)
427  {
428  detTileParams &tile(octdet.tiles[i]);
429  octdet.nCols = tile.xsize;
430  octdet.nRows += tile.ysize;
431  }
432  octdet.nPixels = octdet.nCols * octdet.nRows;
433  Log::add(Log::INFO,string("SACLAConverter::cacheParameters: octal det ") +
434  "has a shape of nCols '" + toString(octdet.nCols) + "', nRows '" +
435  toString(octdet.nRows) + "', thus nPixels '" +
436  toString(octdet.nPixels) + "'");
437  octdet.notLoaded = false;
438  }//end try
439  catch (const SaclaPixDetError &err)
440  {
441  Log::add(Log::ERROR,err.what());
442  octdet.notLoaded = true;
443  }
444  }//end octdet loop
445 
446 }
447 
448 uint64_t SACLAConverter::operator()(const int highTagNbr,
449  const int tagNbr,
450  CASSEvent& event)
451 {
452 
453  /** set the event id from the highTag and Tag number */
454  CASSEvent::id_t eId(highTagNbr);
455  eId = (eId << 32) + tagNbr;
456  event.id() = eId;
457  uint64_t datasize(0);
458 
459  /** get reference to the devices of the cassevent */
460  CASSEvent::devices_t &devices(event.devices());
461  CASSEvent::devices_t::iterator devIt;
462 
463  /** check if the event contains the machine data container, if so get a
464  * reference to it. Otherwise throw an error.
465  */
466  devIt = devices.find(CASSEvent::MachineData);
467  if (devIt == devices.end())
468  throw runtime_error(string("SACLAConverter():The CASSEvent does ") +
469  "not contain a Machine Data Device");
470  MachineData::Device &md(dynamic_cast<MachineData::Device&>(*(devIt->second)));
471 
472  /** go through all requested machine data events and retrieve the corresponding
473  * values for the tag
474  */
475  machineVals_t::const_iterator machineValsIter(_machineVals.begin());
476  machineVals_t::const_iterator machineValsEnd(_machineVals.end());
477  for (; machineValsIter != machineValsEnd; ++machineValsIter)
478  {
479  /** rerference to the machine value */
480  const MachineValue &mv(*machineValsIter);
481  /** check if the cache contains the machine value for the requested tag */
482  machineVals_t::value_type::values_t::const_iterator entry(mv.values.find(tagNbr));
483  if (entry == mv.values.end())
484  {
485  Log::add(Log::ERROR,"SACLAConverter: cannot find beamline value '" +
486  mv.databaseName + "' for tag '" + toString(tagNbr) +
487  "' in cache.");
488  continue;
489  }
490  md.BeamlineData()[mv.cassName] = entry->second;
491  datasize += sizeof(double);
492  }
493 
494  /** retrieve the container for pixel detectors */
495  devIt = devices.find(CASSEvent::PixelDetectors);
496  if(devIt == devices.end())
497  throw runtime_error(string("SACLAConverter: CASSEvent does not ") +
498  "contain a pixeldetector device");
499  pixeldetector::Device &dev(dynamic_cast<pixeldetector::Device&>(*(devIt->second)));
500 
501  /** read the requested pixel detector data */
502  pixDets_t::iterator pixelDetsIter(_pixelDetectors.begin());
503  pixDets_t::iterator pixelDetsEnd(_pixelDetectors.end());
504  for (; pixelDetsIter != pixelDetsEnd; ++pixelDetsIter)
505  {
506  detTileParams &tile(pixelDetsIter->tiles[0]);
507  /** skip if the detector data isn't loaded */
508  if (pixelDetsIter->notLoaded)
509  continue;
510 
511  /** retrieve the right detector from the cassevent and prepare the frame */
512  pixeldetector::Detector &det(dev.dets()[pixelDetsIter->CASSID]);
513  det.frame().clear();
514  det.columns() = tile.xsize;
515  det.rows() = tile.ysize;
516  det.frame().resize(det.rows()*det.columns());
517  det.id() = event.id();
518 
519  /** get information about the tile and the position with the frame */
520  md.BeamlineData()[tile.name + "_Width"] = det.columns();
521  md.BeamlineData()[tile.name + "_Height"] = det.rows();
522  md.BeamlineData()[tile.name + "_PixSizeX_um"] = tile.pixsizex_um;
523  md.BeamlineData()[tile.name + "_PixSizeY_um"] = tile.pixsizey_um;
524 
525  /** retrieve the data with the right type */
526  tile.readFromStreamer(tagNbr);
527  tile.copyTo(det.frame().begin());
528 
529  /** notice how much data has been retrieved */
530  datasize += tile.bytes_retrieved;
531  }
532 
533 
534  /** read the requested octal detectors */
535  pixDets_t::iterator octalDetsIter(_octalDetectors.begin());
536  pixDets_t::iterator octalDetsEnd(_octalDetectors.end());
537  for (; octalDetsIter != octalDetsEnd; ++octalDetsIter)
538  {
539  pixDets_t::value_type &octdet(*octalDetsIter);
540  /** skip if the data of the detector isn't loaded */
541  if (octdet.notLoaded)
542  continue;
543 
544  /** retrieve the right detector from the cassevent and reset it */
545  pixeldetector::Detector &det(dev.dets()[octdet.CASSID]);
546  det.frame().clear();
547  det.columns() = octdet.nCols;
548  det.rows() = octdet.nRows;
549  det.id() = event.id();
550  det.frame().resize(octdet.nPixels);
551 
552  /** copty the parameters of the tiles to the beamline data */
553  for (size_t i = 0; i<octdet.tiles.size(); ++i)
554  {
555  detTileParams &tile(octdet.tiles[i]);
556  md.BeamlineData()[tile.name+"_Width"] = tile.xsize;
557  md.BeamlineData()[tile.name+"_Height"] = tile.ysize;
558  md.BeamlineData()[tile.name+"_PixSizeX_um"]= tile.pixsizex_um;
559  md.BeamlineData()[tile.name+"_PixSizeY_um"]= tile.pixsizey_um;
560  md.BeamlineData()[tile.name+"_PosX_um"] = tile.posx_um;
561  md.BeamlineData()[tile.name+"_PosY_um"] = tile.posy_um;
562  md.BeamlineData()[tile.name+"_PosZ_um"] = tile.posz_um;
563  md.BeamlineData()[tile.name+"_Angle_deg"] = tile.angle_deg;
564  md.BeamlineData()[tile.name+"_AbsGain"] = tile.gain;
565  md.BeamlineData()[tile.name+"_RelGain"] = tile.relativeGain;
566  }
567 
568  /** retrive the data of the tiles
569  * Using openmp to parallelize the retrieval of the detector data. The
570  * 'pragma omp parallel for' statement says that the for loop should be
571  * parallelized. Within the loop all the declared variables are local to
572  * the thread and not shared. The 'num_threads' parameter allows to define
573  * how many threads should be used. Since the octal detector has 8 tiles,
574  * we only need 8 threads and not all that are available (which will be
575  * used if nothing is declared).
576  */
577 #ifdef _OPENMP
578  #pragma omp parallel for num_threads(octdet.tiles.size())
579 #endif
580  for (size_t i = 0; i<octdet.tiles.size(); ++i)
581  {
582  detTileParams &tile(octdet.tiles[i]);
583  /** retrieve the data with the right type */
584  tile.readFromStreamer(tagNbr);
585  tile.copyTo(det.frame().begin() + i*tile.nPixels);
586  }
587 
588  /** gather the size retrieved of all the tiles */
589  for (size_t i = 0; i<octdet.tiles.size(); ++i)
590  datasize += octdet.tiles[i].bytes_retrieved;
591  }
592 
593  return datasize;
594 }
uint64_t operator()(const int highTagNbr, const int tagNbr, CASSEvent &event)
read data from SaclaDataAccessUserAPI
setArrayIndex(int i)
Event to store all LCLS Data.
Definition: cass_event.h:32
uint32_t xsize
the number of columns of the tile
float gain
the absolute gain of the tile
file contains declaration of the CASSEvent
Settings for CASS.
Definition: cass_settings.h:30
detectors_t & dets()
instrument setter
void init(int runNbr, int blNbr)
init the tile reader
float posy_um
the position in y in lab space of the tile in um
SACLAConverter()
constructor
void cacheParameters(std::vector< int >::const_iterator first, std::vector< int >::const_iterator last, int blNbr, int runNbr, int highTagNbr)
retrieve requested beamline parameters in one go
std::string cassName
the name of the machine value within the cassevent
uint64_t id_t
define the id type
Definition: cass_event.h:52
STL namespace.
void cache()
cache the non-changing data
size_t bytes_retrieved
the number of bytes retrieved for this tile
things written only at end of run H5Dump ProcessorSummary size
remove(int position, int n)
toDouble(bool *ok=0)
void loadSettings()
load the settings of the reader
file contains custom exceptions used in cass
Exception thrown when there is an error with a SACLA Pixel Detector.
static void add(Level level, const std::string &line)
add a string to the log
Definition: log.cpp:31
fromStdString(const std::string &str)
float relativeGain
the realtive gain with respect to the tile that this tile should be normalized to ...
bool normalize
flag to tell whether the data of this tile should be normalized to another tile
float angle_deg
the angle in degree in lab space of the tile
beginReadArray(const QString &prefix)
Container for all Machine related Data.
values_t values
map that contains the tag as key and value for the value associated with the tag
devices_t & devices()
setters
Definition: cass_event.h:66
float posz_um
the position in z in lab space of the tile in um
float pixsizey_um
the y size of a pixel in um
uint32_t nPixels
the number of pixles of this tile
float pixsizex_um
the x size of a pixel in um
std::string databaseName
the name of the machine value within the database
file contains global definitions for project cass
~detTileParams()
destruct the tile parameter
void copyTo(pixeldetector::Detector::frame_t::iterator pos)
copy data to frame
std::string toString(const Type &t)
convert any type to a string
Definition: cass.h:63
value(const QString &key, const QVariant &defaultValue=QVariant()
float posx_um
the position in x in lab space of the tile in um
std::map< Device, DeviceBackend::shared_pointer > devices_t
mapping from device type to handler instance
Definition: cass_event.h:46
char * readBuf
a read buffer object for the tile
definitions of a machine device
file contains specialized class that do the settings for cass
the device containing pixel detector data
std::string name
the name of the tile
Detector containing a ccd camera image.
uint32_t ysize
the number of rows of the tile
non changeing parameters of a pixel detector tile
contains a logger for cass
contains class to convert sacla data to cassevent
container for the cached machine value
const bldMap_t & BeamlineData() const
getter
beginGroup(const QString &prefix)
void readFromStreamer(unsigned int tag)
retrieve data from streamer into buffer