10 using
std::stringstream;
18 fQObjectCache =
new std::map<std::string, QObject*>;
31 fFile.open(filename.c_str(),ios::in);
35 err.SetDescription(filename);
52 std::map<std::string, QObject*>::iterator iter =
fQObjectCache->begin();
54 if(iter->second)
delete iter->second;
65 if(className ==
"QRunData") {
66 std::map<std::string, QObject*>::const_iterator
object =
fQObjectCache->find(name);
68 return object->second;
71 err.SetDescription(
GetName(),__LINE__,std::string(
"Could not find object \"")+name+
"\"");
76 err.SetDescription(
GetName(),__LINE__,std::string(
"Invalid type \"")+className+
"\"");
84 std::string suffix =
fName.substr(
fName.size()-9 ,5);
87 if(suffix.at(0) ==
'c') {
90 else if(suffix.at(0) ==
'q') {
93 string sRunNumber =
fName;
94 sRunNumber = sRunNumber.substr(sRunNumber.size()-8,4);
95 int runNumber = atoi(sRunNumber.c_str())+(int)detector*100000;
99 int numSamples,pulseDurationMs;
100 fFile>>minADC>>maxADC;
101 fFile>>numSamples>>pulseDurationMs;
102 float samplingFrequency = float(numSamples) / pulseDurationMs * 1000;
107 vector<int> channels;
110 if(line.size() > 0) line = line.substr(0,line.size()-1);
112 if(line.empty() || line[0] ==
' ' || line[0] ==
'\n' || line[0] ==
'\0') blank =
true;
115 std::stringstream str(line);
118 if(active) channels.push_back(chan);
126 std::stringstream str(line);
127 std::string word1,word2,word3;
129 if(word1 ==
"Start") {
132 if(word2 ==
"date") {
135 else if(word2 ==
"time") {
139 if(word1 ==
"Timer") {
142 if(!
fFile.good())
break;
146 int month=atoi(date.substr(0,2).c_str());
147 int day=atoi(date.substr(3,2).c_str());
148 int year=atoi(date.substr(6,4).c_str());
149 int hour=atoi(date.substr(11,2).c_str());
150 int min=atoi(date.substr(14,2).c_str());
151 int sec=atoi(date.substr(17,2).c_str());
153 int ADCScale = (int)
pow(2,16);
165 for(
size_t i = 0; i < channels.size(); i++) {
167 cr.
fADC2mV = (maxADC-minADC)*1000./ADCScale;
178 std::string name=
"DAQ@RunData_run";
180 sprintf(runss,
"%06d",runNumber);
183 (*fQObjectCache)[name] = runData;
global reader for hdr files (headers of runs acquired with old Milano DAQ)
Diana::QComplex pow(const Diana::QComplex &z, double a)
Raise a complex number to a real power.
#define REGISTER_GLOBAL_READER(clazz, ext)
double min(const Diana::QVector &v)
class wrapper to DetectorName_
QError Close()
Close file, called by QGlobalReaderDispatcher.
const Diana::QObject * GetQObject(const std::string &name, const std::string &className, QError &err) const
std::map< std::string, Diana::QObject * > * fQObjectCache
QError Open(const std::string &filename, const std::string &opt="")
Open file, called by QGlobalReaderDispatcher.
basic channel and run based info. Used in the QRunData object.
double fSamplingFrequency
sampling frequency in Hz
int fADCMin
ADC minimum in ADC units.
bool fIsThermometer
is thermometer
int fNumberOfSamples
number of samples in ADC window
int fADCMax
ADC maximum in ADC units.
double fADC2mV
conversion: mV = ADC * fADC2mV
bool fIsBolometer
is bolometer
error class with error type and description
Abstract class for global readers.
const std::string & GetName() const
time_t fStartDate
StartTime.
std::vector< int > fThermalDetectorChannels
Thermal detector channels: union of fBolometerChannels and fThermometerChannels.
time_t fStopDate
StopTime.
time_t fDuration
Duration.
std::vector< int > fBolometerChannels
Bolometers channels (thermistors glued to a crystal)
DetectorName fDetector
Source Run Number.
void SetChannelRunData(const int channel, const QChannelRunData &chanRunData)
set channel based run data quantities
void SetStartRunUnix(unsigned int time)
set time of start of run in seconds from 1/1/1970
time_t GetStartRunUnix() const
retrieve time of start of run in seconds from 1/1/1970
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...