18 #include "pdsdata/xtc/Xtc.hh"
19 #include "pdsdata/xtc/TypeId.hh"
20 #include "pdsdata/xtc/DetInfo.hh"
21 #include "pdsdata/acqiris/ConfigV1.hh"
22 #include "pdsdata/acqiris/DataDescV1.hh"
23 #include "pdsdata/xtc/Src.hh"
48 _pdsTypeList.push_back(TypeId::Id_AcqConfig);
49 _pdsTypeList.push_back(TypeId::Id_AcqWaveform);
55 for (
int i = 0; i <
size; ++i)
58 string type(s.
value(
"TypeName",
"Invalid").toString().toStdString());
59 TypeId::Type typeID(TypeId::NumberOf);
60 for (
int i(0); i < TypeId::NumberOf; ++i)
61 if (TypeId::name(static_cast<TypeId::Type>(i)) == type)
63 typeID =
static_cast<TypeId::Type
>(i);
67 uint32_t detID(s.
value(
"DetectorID",0).toUInt());
68 string detname(s.
value(
"DetectorName",
"Invalid").toString().toStdString());
70 for (
int i(0); i < DetInfo::NumDetector; ++i)
71 if (DetInfo::name(static_cast<DetInfo::Detector>(i)) == detname)
77 uint32_t devID(s.
value(
"DeviceID",0).toUInt());
78 string devname(s.
value(
"DeviceName",
"Invalid").toString().toStdString());
79 DetInfo::Device devnameID(DetInfo::NumDevice);
80 for (
int i(0); i < DetInfo::NumDevice; ++i)
81 if (DetInfo::name(static_cast<DetInfo::Device>(i)) == devname)
83 devnameID =
static_cast<DetInfo::Device
>(i);
88 if (typeID == TypeId::NumberOf ||
89 detnameID == DetInfo::NumDetector ||
90 devnameID == DetInfo::NumDevice)
93 Key key(typeID, detnameID, detID, devnameID, devID);
94 _LCLSToCASSId[key] = s.
value(
"CASSID",0).toInt();
102 idmap_t::key_type lclskey(xtc->contains.id(), xtc->src.phy());
103 idmap_t::iterator lclsmapIt(_LCLSToCASSId.find(lclskey));
104 if (lclsmapIt == _LCLSToCASSId.end())
106 Log::add(
Log::DEBUG0,
string(
"Acqiris::Converter::operator(): There is no corresponding cass key for : '") +
107 TypeId::name(xtc->contains.id()) +
"'(" +
toString(xtc->contains.id()) +
108 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->detector()) +
109 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->detId()) +
110 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->device()) +
111 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->devId()) +
115 const idmap_t::mapped_type &casskey(lclsmapIt->second);
118 switch (xtc->contains.id())
121 case (Pds::TypeId::Id_AcqConfig) :
124 unsigned version = xtc->contains.version();
130 const Pds::Acqiris::ConfigV1 &config =
131 *
reinterpret_cast<const Pds::Acqiris::ConfigV1*
>(xtc->payload());
133 _configStore[casskey] = config.nbrChannels();
135 TypeId::name(xtc->contains.id()) +
"'(" +
toString(xtc->contains.id()) +
136 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->detector()) +
137 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->detId()) +
138 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->device()) +
139 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->devId()) +
140 "); SampleInterval '" +
toString(config.horiz().sampInterval()) +
141 "' NbrSamples '" +
toString(config.horiz().nbrSamples()) +
142 "' NbrSegments '" +
toString(config.horiz().nbrSegments()) +
143 "' DelayTime '" +
toString(config.horiz().delayTime()) +
144 "' TrigCoupling '" +
toString(config.trig().coupling()) +
145 "' TrigInput '" +
toString(config.trig().input()) +
146 "' TrigSlope '" +
toString(config.trig().slope()) +
147 "' TrigLevel '" +
toString(config.trig().level()) +
148 "' NbrChannels '" +
toString(config.nbrChannels()) +
150 for (
size_t i(0); i<_configStore[casskey]; ++i)
153 TypeId::name(xtc->contains.id()) +
"'(" +
toString(xtc->contains.id()) +
154 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->detector()) +
155 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->detId()) +
156 "), '" + DetInfo::name(reinterpret_cast<const DetInfo*>(&xtc->src)->device()) +
157 "'(" +
toString(reinterpret_cast<const DetInfo*>(&xtc->src)->devId()) +
159 "': Gain '" +
toString(config.vert(i).slope()) +
160 "' Offset '" +
toString(config.vert(i).offset()) +
161 "' FullScale '" +
toString(config.vert(i).fullScale()) +
162 "' Bandwidth '" +
toString(config.vert(i).bandwidth()) +
163 "' Coupling '" +
toString(config.vert(i).coupling()) +
169 throw runtime_error(
"Unsupported acqiris configuration version '" +
177 case (TypeId::Id_AcqWaveform):
180 const Acqiris::DataDescV1 *datadesc =
181 reinterpret_cast<const Acqiris::DataDescV1*
>(xtc->payload());
184 Instrument &instr(dev.instruments()[casskey]);
186 instr.
id() = evt->
id();
190 const size_t nChans(_configStore[casskey]);
191 channels.resize(nChans);
193 for (
size_t i(0); i < nChans; ++i)
196 const Acqiris::DataDescV1 &dd(*datadesc);
201 chan.
horpos() = dd.timestamp(0).horPos();
202 chan.
offset() = dd.offset();
203 chan.
gain() = dd.gain();
206 const short* wf = dd.waveform();
210 wf += dd.indexFirstPoint();
214 const size_t nSamples(dd.nbrSamplesInSeg());
215 waveform.resize(nSamples);
233 for (
size_t iWave=0;iWave<nSamples;++iWave)
234 waveform[iWave] = (wf[iWave]&0x00ff<<8) | (wf[iWave]&0xff00>>8);
237 datadesc = datadesc->nextChannel();
242 throw logic_error(
string(
"ACQIRIS::Converter(): xtc type '") +
243 Pds::TypeId::name(xtc->contains.id()) +
244 "' is not handled by Acqiris Converter");
std::vector< int16_t > waveform_t
define the waveform
definition of front detector[PixelDetectors] FrontPnCCD Detector
Event to store all LCLS Data.
static QMutex _mutex
singleton locker for mutithreaded requests
waveform_t & waveform()
setter
file contains declaration of the CASSEvent
double & sampleInterval()
setter
things written only at end of run H5Dump ProcessorSummary size
static void add(Level level, const std::string &line)
add a string to the log
beginReadArray(const QString &prefix)
devices_t & devices()
setters
std::string toString(const Type &t)
convert any type to a string
std::tr1::shared_ptr< ConversionBackend > shared_pointer
typedef
void operator()(const Pds::Xtc *, CASSEvent *)
takes the xtc and copies the data to cassevent
value(const QString &key, const QVariant &defaultValue=QVariant()
A Channel of an Acqiris Instrument.
std::vector< Channel > channels_t
a vector of Channels
file contains specialized class that do the settings for cass
file contains the declaration of the converter for the xtc containing acqiris data.
static ConversionBackend::shared_pointer _instance
the singleton container
size_t & channelNbr()
setter
contains a logger for cass
static ConversionBackend::shared_pointer instance()
create singleton if doesnt exist already
beginGroup(const QString &prefix)