Commit 4df4f7e9 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Move eventLength to Configuration instead of parameters

parent cc3b8f21
......@@ -124,7 +124,7 @@ StatusCode CLICpixEventLoader::run(Clipboard* clipboard) {
// Now set the event time so that the Timepix3 data is loaded correctly
parameters->currentTime = shutterStartTime;
parameters->eventLength = (shutterStopTime - shutterStartTime);
m_config.set<double>("eventLength", (shutterStopTime - shutterStartTime));
LOG(TRACE) << "Loaded " << npixels << " pixels";
// Put the data on the clipboard
......
......@@ -129,7 +129,7 @@ StatusCode Clicpix2EventLoader::run(Clipboard* clipboard) {
shutterStopTime = shutterStopTimeInt * 25. / 1000000000.;
parameters->currentTime = shutterStartTime;
parameters->eventLength = (shutterStopTime - shutterStartTime);
m_config.set<double>("eventLength", (shutterStopTime - shutterStartTime));
// Put the data on the clipboard
if(pixels->size() > 0)
......
......@@ -122,6 +122,9 @@ void Timepix3EventLoader::initialise(Parameters* par) {
}
}
}
// Read event length
eventLength = m_config.get<double>("eventLength", 0.0);
}
StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
......@@ -152,7 +155,6 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
SpidrSignals* spidrData = new SpidrSignals();
// Load the next chunk of data
LOG(DEBUG) << "Loading data from " << detectorID;
bool data = loadData(detectorID, deviceData, spidrData);
// If data was loaded then put it on the clipboard
......@@ -170,7 +172,7 @@ StatusCode Timepix3EventLoader::run(Clipboard* clipboard) {
}
// Increment the event time
parameters->currentTime += parameters->eventLength;
parameters->currentTime += eventLength;
// If all files are finished, tell the event loop to stop
if(endOfFiles == devices)
......@@ -354,7 +356,7 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
const uint64_t shutterClosed = ((controlbits & 0x1));
// Ignore packets if they arrive before the current event window
// if( parameters->eventLength != 0. && ((double)time/(4096. *
// if(eventLength != 0. && ((double)time/(4096. *
// 40000000.)) < (parameters->currentTime) ){
// continue;
// }
......@@ -362,8 +364,8 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
// Stop looking at data if the signal is after the current event window
// (and rewind the file
// reader so that we start with this signal next event)
if(parameters->eventLength != 0. &&
((double)time / (4096. * 40000000.)) > (parameters->currentTime + parameters->eventLength)) {
if(eventLength != 0. &&
((double)time / (4096. * 40000000.)) > (parameters->currentTime + eventLength)) {
fseek(m_currentFile[detectorID], -1 * sizeof(ULong64_t), SEEK_CUR);
fileNotFinished = true;
// LOG(DEBUG) <<"Signal has a time beyond the current event:
......@@ -480,7 +482,7 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
// time is within this window
// Ignore pixels if they arrive before the current event window
// if( parameters->eventLength != 0. && ((double)time/(4096. *
// if(eventLength != 0. && ((double)time/(4096. *
// 40000000.)) < (parameters->currentTime) ){
// continue;
// }
......@@ -488,8 +490,8 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
// Stop looking at data if the pixel is after the current event window
// (and rewind the file
// reader so that we start with this pixel next event)
if(parameters->eventLength != 0. &&
((double)time / (4096. * 40000000.)) > (parameters->currentTime + parameters->eventLength)) {
if(eventLength != 0. &&
((double)time / (4096. * 40000000.)) > (parameters->currentTime + eventLength)) {
fseek(m_currentFile[detectorID], -1 * sizeof(ULong64_t), SEEK_CUR);
fileNotFinished = true;
break;
......@@ -505,7 +507,7 @@ bool Timepix3EventLoader::loadData(string detectorID, Pixels* devicedata, SpidrS
// Stop when we reach some large number of pixels (if events not based on
// time)
if(parameters->eventLength == 0. && npixels == 2000) {
if(eventLength == 0. && npixels == 2000) {
fileNotFinished = true;
break;
}
......
......@@ -39,6 +39,8 @@ namespace corryvreckan {
bool m_shutterOpen;
std::map<std::string, Pixels*> bufferedData;
std::map<std::string, SpidrSignals*> bufferedSignals;
double eventLength{0};
};
}
#endif // TIMEPIX3EVENTLOADER_H
......@@ -16,7 +16,6 @@ Parameters::Parameters() {
dutMaskFile = "defaultMask.dat";
inputDirectory = "";
currentTime = 0.; // seconds
eventLength = 0.000; // seconds (0.1 ms)
}
// Sort function for detectors from low to high z
......@@ -62,10 +61,6 @@ void Parameters::readCommandLineOptions(int argc, char* argv[]) {
outputTupleFile = (string)temp;
LOG(INFO) << "Writing output tuples to: " << outputTupleFile;
break;
case 'p':
sscanf(optarg, "%lf", &eventLength);
LOG(INFO) << "Running with an event length of: " << eventLength << " s";
break;
case 's':
sscanf(optarg, "%s", &temp);
dutMaskFile = (string)temp;
......@@ -150,10 +145,12 @@ bool Parameters::readConditions() {
// Now check that all devices which are registered have parameters as well
bool unregisteredDetector = false;
LOG(WARNING) << "det: " << detectors.size() << " -- " << nDetectors;
// Loop over all registered detectors
for(int det = 0; det < nDetectors; det++) {
LOG(WARNING) << "det: " << detectors.size() << " ? " << det;
if(detector.count(detectors[det]) == 0) {
LOG(INFO) << "Detector " << detectors[det] << " has no conditions loaded";
//LOG(INFO) << "Detector " << detectors[det] << " has no conditions loaded";
unregisteredDetector = true;
}
}
......
......@@ -62,7 +62,6 @@ namespace corryvreckan {
std::string reference;
std::string dut;
double currentTime;
double eventLength;
std::string DUT;
std::map<std::string, bool> excludedFromTracking;
std::map<std::string, bool> masked;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment