CFEL - ASG Software Suite  2.5.0
CASS
tdc_extractor.cpp
Go to the documentation of this file.
1 //Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file tdc_extractor.cpp file contains class that extracts the right hits from
5  * the tdc data
6  *
7  * @author Lutz Foucar
8  */
9 
10 #include <sstream>
11 
12 #include "tdc_extractor.h"
13 
14 #include "cass_event.h"
15 #include "cass_settings.h"
16 #include "acqiristdc_device.hpp"
17 
18 using namespace std;
19 using namespace cass;
20 using namespace cass::ACQIRIS;
21 
23 {
24  const ACQIRISTDC::Channel::hits_t &hits(_chan->hits());
25  ACQIRISTDC::Channel::hits_t::const_iterator it(hits.begin());
26  for (; it != hits.end();++it)
27  {
28  bool add(false);
29  vector<pair<double,double> >::const_iterator tit(_timeranges.begin());
30  for (; tit != _timeranges.end();++tit)
31  {
32  if ((*tit).first < (*it) && (*it) < (*tit).second)
33  {
34  add = true;
35  break;
36  }
37  }
38  if (add)
39  {
41  signal[isUsed] = false;
42  signal[cass::ACQIRIS::time] = *it;
43  sig.push_back(signal);
44  }
45  }
46  return sig;
47 }
48 
50 {
51  s.beginGroup("TDCExtraction");
52  _instrument = s.value("TDCInstrument").toUInt();
53  _channelNumber= s.value("ChannelNumber",0).toUInt();
54  int size = s.beginReadArray("Timeranges");
55  for (int i = 0; i < size; ++i)
56  {
57  s.setArrayIndex(i);
58  _timeranges.push_back(make_pair(s.value("LowerLimit",0.).toDouble(),
59  s.value("UpperLimit",1000).toDouble()));
60  }
61  s.endArray();
62  s.endGroup();
63 }
64 
65 void ACQIRISTDC::TDCExtractor::associate(const CASSEvent &evt)
66 {
67  const Device &device
68  (dynamic_cast<const ACQIRISTDC::Device&>(*(evt.devices().find(CASSEvent::AcqirisTDC)->second)));
69  ACQIRISTDC::Device::instruments_t::const_iterator instrumentIt
70  (device.instruments().find(_instrument));
71  if (instrumentIt == device.instruments().end())
72  throw invalid_argument("TDCExtractor::associate(): The requested Instrument '" +
73  toString(_instrument) + "' is not in the datastream");
74  const ACQIRISTDC::Instrument::channels_t &tdcChannels
75  (instrumentIt->second.channels());
76  if ((_channelNumber >= tdcChannels.size()))
77  throw invalid_argument("TDCExtractor::associate(): The requested channel '" +
78  toString(_channelNumber) + "' does not exist in Instrument '"+
79  toString(_instrument) + "'");
80  _chan = &(tdcChannels[_channelNumber]);
81 }
setArrayIndex(int i)
file contains class that extracts the right hits from the tdc data
Event to store all LCLS Data.
Definition: cass_event.h:32
std::vector< signal_t > signals_t
file contains declaration of the CASSEvent
Settings for CASS.
Definition: cass_settings.h:30
STL namespace.
Average out the iShit status to get the avererage hits
things written only at end of run H5Dump ProcessorSummary size
std::vector< double > signal_t
beginReadArray(const QString &prefix)
file contains the declaration of the acqiristdc part of the CASSEvent
The Acqiris TDC device.
std::vector< Channel > channels_t
a vector of Channels
devices_t & devices()
setters
Definition: cass_event.h:66
std::string toString(const Type &t)
convert any type to a string
Definition: cass.h:63
value(const QString &key, const QVariant &defaultValue=QVariant()
void loadSettings(CASSSettings &s, CFDParameters &p, uint32_t &instrument, size_t &channelNbr)
implementation of loading settings for both CFD classes
Definition: cfd.cpp:210
file contains specialized class that do the settings for cass
std::vector< double > hits_t
define the hits
beginGroup(const QString &prefix)