Skip to content
4,384 changes: 4,384 additions & 0 deletions configs/standard_run_fiber_water_fill.json

Large diffs are not rendered by default.

4,384 changes: 4,384 additions & 0 deletions configs/standard_run_muons_water_fill.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Decode.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void *decode_thread(void *_data) {
Exception::dontPrint();

string fname = data->runtype->fname() + ".h5";
cout << "Saving data to " << fname << endl;

H5File file(fname, H5F_ACC_TRUNC);
data->runtype->write(file);
Expand Down
24 changes: 0 additions & 24 deletions src/Digitizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,6 @@ inline void writeall(const int fd, const void *ptr, int len) {
}
}

typedef struct DigitizerData {
typedef struct ChannelData {
uint32_t chID;
uint32_t offset;
uint32_t threshold;
float dynamic_range;
uint16_t samples[20][500];
uint16_t patterns[20];
} ChannelData;

uint16_t type;
uint16_t bits;
uint16_t samples;
uint16_t nEvents;
float ns_sample;
uint32_t counters[20];
uint32_t timetags[20];
uint16_t exttimetags[20];

ChannelData channels[16];
} DigitizerData;

class Decoder {

public:
Expand All @@ -110,8 +88,6 @@ class Decoder {
virtual void writeOut(H5::H5File &file, size_t nEvents) = 0;

virtual DigitizerSettings* getSettings() { return nullptr; }

virtual void pack(DigitizerData* data, size_t nEvents) {}
};

#endif
Expand Down
8 changes: 4 additions & 4 deletions src/Dispatch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void *dispatch_thread(void *_data) {

vector<size_t> evtsReady(data->buffers->size());
data->runtype->begin();
bool print = false;
try {
dispatch_running = true;
while (dispatch_running) {
Expand All @@ -56,15 +57,14 @@ void *dispatch_thread(void *_data) {
if (found) break;
pthread_cond_wait(data->newdata,data->iomutex);
}

size_t total = data->dispatcher->Digest(*data->buffers);
string path = data->dispatcher->NextPath();
if (stop && total == 0) {
dispatch_running = false;
} else if (stop || data->dispatcher->Ready()) {
} else if (stop || data->dispatcher->Ready(print, path)) {
Exception::dontPrint();

string path = data->dispatcher->NextPath();
cout << "Streaming data to " << path << endl;
data->dispatcher->Dispatch(*data->buffers);
dispatch_running = data->runtype->keepgoing();
}
Expand Down
22 changes: 13 additions & 9 deletions src/Dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ Dispatcher::~Dispatcher(){
/* */
}

bool Dispatcher::Ready(){
bool Dispatcher::Ready(bool &print, string path){
double rate = 0.0;
bool rv = this->nEvents > 0;
for (size_t i = 0; i < this->evtsReady.size(); i++) {
rate += this->evtsReady[i];
//if (this->evtsReady[i] < nEvents) rv = false;
std::cout << "evtsReady[" << i << "] " << evtsReady[i] << std::endl;
}
if (rate < nEvents) rv = false;
rate /= evtsReady.size();

cout << "Cycle " << curCycle+1 << endl;


clock_gettime(CLOCK_MONOTONIC,&cur_time);
double time_int = (cur_time.tv_sec - last_time.tv_sec)+1e-9*(cur_time.tv_nsec - last_time.tv_nsec);
rate /= time_int;
cout << "Avg rate " << rate << " Hz" << endl;

std::cout << "nEvents " << this->nEvents << ", rv " << rv << std::endl;

if(curCycle > 0){
print = true;
}
if(print && path != previous_path){
cout << "Cycle " << curCycle << ", Trig. Rate: " << rate << ", nEV: " << this->nEvents << endl;
print = false;
}

previous_path = path;

return rv;
}
3 changes: 2 additions & 1 deletion src/Dispatcher.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ class Dispatcher{
virtual string NextPath() = 0;
virtual size_t Digest(vector<Buffer*>& buffers) = 0;
virtual void Dispatch(vector<Buffer*>& buffers) = 0;
virtual bool Ready();
virtual bool Ready(bool &print, string path);
protected:
size_t curCycle;
size_t nEvents;
string previous_path;
vector<size_t> evtsReady;
struct timespec cur_time, last_time;
};
Expand Down
60 changes: 1 addition & 59 deletions src/LegacyHDF5Dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ size_t LegacyHDF5Dispatcher::Digest(vector<Buffer*>& buffers){

void LegacyHDF5Dispatcher::Dispatch(vector<Buffer*>& buffers){
string fname = this->NextPath();
cout << "Saving data to " << fname << endl;
// cout << "Saving data to " << fname << endl;

H5File file(fname, H5F_ACC_TRUNC);
this->Initialize(file);
Expand All @@ -58,64 +58,6 @@ void LegacyHDF5Dispatcher::Dispatch(vector<Buffer*>& buffers){

for (size_t i = 0; i < this->decoders.size(); i++) {
decoders[i]->writeOut(file, evtsReady[i]);
/*
this->decoders[i]->pack(&data, this->evtsReady[i]);

V1730Settings& settings = *((V1730Settings*)decoders[i]->getSettings()); // :(

Group cardgroup = file.createGroup("/"+settings.getIndex());

DataSpace scalar(0,NULL);

Attribute bits = cardgroup.createAttribute("bits",PredType::NATIVE_UINT32,scalar);
bits.write(PredType::NATIVE_INT32, &data.bits);

Attribute ns_sample = cardgroup.createAttribute("ns_sample",PredType::NATIVE_DOUBLE,scalar);
ns_sample.write(PredType::NATIVE_DOUBLE, &data.ns_sample);

Attribute samples = cardgroup.createAttribute("samples",PredType::NATIVE_UINT32,scalar);
samples.write(PredType::NATIVE_UINT32, &data.samples);

hsize_t dims[1];
dims[0] = nEvents;
DataSpace space(1, dims);
DataSet counters_ds = cardgroup.createDataSet("counters", PredType::NATIVE_UINT32, space);
counters_ds.write(&data.counters, PredType::NATIVE_UINT32);
DataSet timetags_ds = cardgroup.createDataSet("timetags", PredType::NATIVE_UINT32, space);
timetags_ds.write(&data.timetags, PredType::NATIVE_UINT32);

for (size_t i = 0; i < 16; i++) {
if (!settings.getEnabled(i)) continue;

DigitizerData::ChannelData& ch = data.channels[i];

string chname = "ch" + to_string(ch.chID);
Group group = cardgroup.createGroup(chname);
string groupname = "/"+settings.getIndex()+"/"+chname;

Attribute offset = group.createAttribute("offset",PredType::NATIVE_UINT32,scalar);
offset.write(PredType::NATIVE_UINT32, &ch.offset);

Attribute threshold = group.createAttribute("threshold",PredType::NATIVE_UINT32,scalar);
threshold.write(PredType::NATIVE_UINT32, &ch.threshold);

Attribute dynamic_range = group.createAttribute("dynamic_range",PredType::NATIVE_DOUBLE,scalar);
dynamic_range.write(PredType::NATIVE_DOUBLE, &ch.dynamic_range);

hsize_t dimensions[2];
dimensions[0] = data.nEvents;
dimensions[1] = settings.getRecordLength();

DataSpace samplespace(2, dimensions);
DataSpace metaspace(1, dimensions);

DataSet samples_ds = file.createDataSet(groupname+"/samples", PredType::NATIVE_UINT16, samplespace);
samples_ds.write(&ch.samples[i], PredType::NATIVE_UINT16);

DataSet patterns_ds = file.createDataSet(groupname+"/patterns", PredType::NATIVE_UINT16, metaspace);
patterns_ds.write(&ch.patterns[i], PredType::NATIVE_UINT16);
}
*/
}

this->curCycle++;
Expand Down
1 change: 0 additions & 1 deletion src/LegacyHDF5Dispatcher.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class LegacyHDF5Dispatcher: public Dispatcher{

string basename;
vector<Decoder*> decoders;
DigitizerData data;
};

#endif
30 changes: 17 additions & 13 deletions src/Readout.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <VMEBridge.hh>
#include <Dispatcher.hh>
#include <TCPDispatcher.hh>
#include <ZMQDispatcher.hh>
#include <LegacyHDF5Dispatcher.hh>
#include <SocketDispatcher.hh>
#include <SoftwareTrigger.hh>
Expand Down Expand Up @@ -274,15 +273,11 @@ void *readout(void *_data){
string path = run["outfile"].cast<string>();
dispatcher = new SocketDispatcher(nEvents, path, buffers.size());
}
else if (dispstr == "zmq"){
int nEvents = run["events"].cast<int>();
string address = run["address"].cast<string>();
dispatcher = new ZMQDispatcher(nEvents, address, decoders);
}
else if (dispstr == "tcp"){
int nEvents = run["events"].cast<int>();
int port = run["port"].cast<int>();
dispatcher = new TCPDispatcher(nEvents, port, decoders);
std::string address = disptbl["address"].cast<string>();
std::string port = disptbl["port"].cast<string>();
dispatcher = new TCPDispatcher(nEvents, address, port, decoders);
}
if (!dispatcher){
cerr << "error: dispatcher type "
Expand Down Expand Up @@ -421,14 +416,23 @@ void *readout(void *_data){
if (cur_time.tv_sec-last_temp_time.tv_sec > temptime) {
pthread_mutex_lock(&iomutex);
last_temp_time = cur_time;
cout << "Temperature check..." << endl;
cout << "Temperature check...";
bool overtemp = false;
for (size_t i = 0; i < digitizers.size() && !stop; i++) {
int warning_count = 0;
for (size_t i = 0; i < digitizers.size() && !stop; i++) {
overtemp |= digitizers[i]->checkTemps(temps,84);
cout << settings[i]->getIndex() << " temp: [ " << temps[0];
for (size_t t = 1; t < temps.size(); t++) cout << ", " << temps[t];
cout << " ]" << endl;
for (size_t t = 1; t < temps.size(); t++){
if(temps[t] > 65){
warning_count += 1;
}
}
}
if(warning_count > 0){
cout << "WARNING: " << warning_count << " temps above 65 deg." << endl;
}
else{
cout << "All below 65 deg." << endl;
}
if (overtemp) {
cout << "Overtemp! Aborting readout." << endl;
stop = true;
Expand Down
Loading