11 #include <QtCore/QRegExp>
34 toString(omp_get_max_threads()) +
"' input threads");
43 st_destroy_stbuf(&readBuf);
46 st_destroy_streader(&sreader);
54 funcstatus = st_create_streader(&sreader, name.c_str(), blNbr, 1, r);
57 "reader object for tile '" + name +
"' on beamline '" +
59 "' ErrorCode is '" +
toString(funcstatus) +
"'");
61 funcstatus = st_create_stbuf(&readBuf, sreader);
64 "reader object for tile '" + name +
"' on beamline '" +
66 "' ErrorCode is '" +
toString(funcstatus) +
"'");
73 funcstatus = st_collect_data(readBuf,sreader,&tag);
76 "data for '" + name +
"' for tag '" +
toString(tag) +
77 "' ErrorCode is '" +
toString(funcstatus) +
"'");
84 funcstatus = st_read_det_xsize(&xsize, readBuf, 0);
87 "xsize of '" + name +
"' ErrorCode is '" +
91 "' has xsize '" +
toString(xsize) +
"'");
94 funcstatus = st_read_det_ysize(&ysize, readBuf, 0);
97 "ysize of '" + name +
"' ErrorCode is '" +
101 "' has ysize '" +
toString(ysize) +
"'");
104 funcstatus = mp_read_pixelsizex(&pixsizex_um, readBuf);
107 "x pixelsize of '" + name +
"' ErrorCode is '" +
111 "' has x pixelsize '" +
toString(pixsizex_um) +
"' um");
113 funcstatus = mp_read_pixelsizey(&pixsizey_um,readBuf);
116 "y pixelsize of '" + name +
"' ErrorCode is '" +
120 "' has y-pixelsize '" +
toString(pixsizey_um) +
"' um");
123 nPixels = xsize * ysize;
128 bytes_retrieved = 0.;
133 vector<float> buffer(nPixels);
134 funcstatus = st_read_det_data(&buffer.front(), readBuf, 0);
137 "could not retrieve data from buffer of '" + name +
138 "' ErrorCode is '" +
toString(funcstatus) +
"'");
141 transform(buffer.begin(), buffer.end(), pos,
142 bind1st(multiplies<float>(),relativeGain));
145 bytes_retrieved = nPixels *
sizeof(uint16_t);
155 for (
int i = 0; i <
size; ++i)
158 string detID(s.
value(
"DetectorIDName",
"Invalid").toString().toStdString());
160 if (detID ==
"Invalid")
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);
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));
176 for (
int i = 0; i <
size; ++i)
179 string detID(s.
value(
"DetectorIDName",
"Invalid").toString().toStdString());
181 if (detID ==
"Invalid")
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;
188 "detector with CASSID '" +
189 toString(_pixelDetectors.back().CASSID) +
"'");
195 for (
int i = 0; i <
size; ++i)
198 string machineValName(s.
value(
"ValueName",
"Invalid").toString().toStdString());
200 if (machineValName ==
"Invalid")
205 _machineVals.push_back(machineVals_t::value_type());
206 _machineVals.back().databaseName = machineValName;
210 _machineVals.back().databaseName +
"' with CASSName '" +
211 _machineVals.back().cassName +
"'");
219 vector<int>::const_iterator last,
220 int blNbr,
int runNbr,
int highTagNbr)
223 vector<int> tagList(first,last);
229 machineVals_t::iterator machineValsIter(_machineVals.begin());
230 machineVals_t::const_iterator machineValsEnd(_machineVals.end());
231 for (; machineValsIter != machineValsEnd; ++machineValsIter)
235 struct da_string_array *machineValueStringList = NULL;
236 da_alloc_string_array(&machineValueStringList);
238 funcstatus = sy_read_syncdatalist(machineValueStringList,
246 "cache values of '" + mv.
databaseName +
"' ErrorCode is '"
248 da_destroy_string_array(&machineValueStringList);
254 int machineValueStringListSize = 0;
255 da_getsize_string_array(&machineValueStringListSize, machineValueStringList);
256 if (machineValueStringListSize != static_cast<int>(tagList.size()))
260 da_destroy_string_array(&machineValueStringList);
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)
276 char * machineValueString(NULL);
277 da_getstring_string_array(&machineValueString,
278 machineValueStringList,
280 QString machineValueQString(machineValueString);
282 bool isDouble(
false);
283 double machineValue(machineValueQString.
toDouble(&isDouble));
285 mv.
values[*tag] = machineValue;
290 "': String '" + machineValueString +
"' which is altered to '" +
291 machineValueQString.toStdString() +
292 "' to remove units, cannot be converted to double. " +
296 free(machineValueString);
299 da_destroy_string_array(&machineValueStringList);
303 "' into the CASS beamline value '" +
310 pixDets_t::iterator pixelDetsIter(_pixelDetectors.begin());
311 pixDets_t::const_iterator pixelDetsEnd(_pixelDetectors.end());
312 for (; pixelDetsIter != pixelDetsEnd; ++pixelDetsIter)
314 pixDets_t::value_type &pixdet(*pixelDetsIter);
318 tile.
init(runNbr,blNbr);
319 tile.readFromStreamer(*first);
321 pixdet.notLoaded =
false;
326 pixdet.notLoaded =
true;
334 pixDets_t::iterator octalDetsIter(_octalDetectors.begin());
335 pixDets_t::const_iterator octalDetsEnd(_octalDetectors.end());
336 for (; octalDetsIter != octalDetsEnd; ++octalDetsIter)
338 pixDets_t::value_type &octdet(*octalDetsIter);
341 for (
size_t i(0); i < octdet.tiles.size(); ++i)
346 tile.
init(runNbr,blNbr);
357 "pos X of '" + tile.
name +
"' ErrorCode is '" +
367 "pos Y of '" + tile.
name +
"' ErrorCode is '" +
377 "pos Z of '" + tile.
name +
"' ErrorCode is '" +
387 "angle of '" + tile.
name +
"' ErrorCode is '" +
395 funcstatus = mp_read_absgain(&(tile.
gain), tile.
readBuf);
398 "absolute gain of '" + tile.
name +
399 "' ErrorCode is '" +
toString(funcstatus) +
"'");
410 if (octdet.normalize)
414 for (
size_t i(0); i < octdet.tiles.size(); ++i)
420 tile.
name +
"' will be normalized with relative gain of '" +
426 for (
size_t i(0); i < octdet.tiles.size(); ++i)
429 octdet.nCols = tile.
xsize;
430 octdet.nRows += tile.
ysize;
432 octdet.nPixels = octdet.nCols * octdet.nRows;
434 "has a shape of nCols '" +
toString(octdet.nCols) +
"', nRows '" +
435 toString(octdet.nRows) +
"', thus nPixels '" +
437 octdet.notLoaded =
false;
442 octdet.notLoaded =
true;
455 eId = (eId << 32) + tagNbr;
457 uint64_t datasize(0);
461 CASSEvent::devices_t::iterator devIt;
467 if (devIt == devices.end())
468 throw runtime_error(
string(
"SACLAConverter():The CASSEvent does ") +
469 "not contain a Machine Data Device");
475 machineVals_t::const_iterator machineValsIter(_machineVals.begin());
476 machineVals_t::const_iterator machineValsEnd(_machineVals.end());
477 for (; machineValsIter != machineValsEnd; ++machineValsIter)
482 machineVals_t::value_type::values_t::const_iterator entry(mv.
values.find(tagNbr));
483 if (entry == mv.
values.end())
491 datasize +=
sizeof(double);
496 if(devIt == devices.end())
497 throw runtime_error(
string(
"SACLAConverter: CASSEvent does not ") +
498 "contain a pixeldetector device");
502 pixDets_t::iterator pixelDetsIter(_pixelDetectors.begin());
503 pixDets_t::iterator pixelDetsEnd(_pixelDetectors.end());
504 for (; pixelDetsIter != pixelDetsEnd; ++pixelDetsIter)
508 if (pixelDetsIter->notLoaded)
514 det.columns() = tile.
xsize;
515 det.rows() = tile.
ysize;
516 det.frame().resize(det.rows()*det.columns());
517 det.id() =
event.id();
527 tile.
copyTo(det.frame().begin());
535 pixDets_t::iterator octalDetsIter(_octalDetectors.begin());
536 pixDets_t::iterator octalDetsEnd(_octalDetectors.end());
537 for (; octalDetsIter != octalDetsEnd; ++octalDetsIter)
539 pixDets_t::value_type &octdet(*octalDetsIter);
541 if (octdet.notLoaded)
547 det.columns() = octdet.nCols;
548 det.rows() = octdet.nRows;
549 det.id() =
event.id();
550 det.frame().resize(octdet.nPixels);
553 for (
size_t i = 0; i<octdet.tiles.size(); ++i)
578 #pragma omp parallel for num_threads(octdet.tiles.size())
580 for (
size_t i = 0; i<octdet.tiles.size(); ++i)
589 for (
size_t i = 0; i<octdet.tiles.size(); ++i)
590 datasize += octdet.tiles[i].bytes_retrieved;
uint64_t operator()(const int highTagNbr, const int tagNbr, CASSEvent &event)
read data from SaclaDataAccessUserAPI
Event to store all LCLS Data.
uint32_t xsize
the number of columns of the tile
float gain
the absolute gain of the tile
file contains declaration of the CASSEvent
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
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)
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
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
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
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
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